Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaBeamEloss.cxx
Go to the documentation of this file.
1//*-- Author : Ole Hansen 11-May-04
2
4//
5// THaBeamEloss
6//
7// Correct energy loss of the beam by a constant. This is basically trivial,
8// but useful to have to provide input for kinematics modules.
9// More advanced corrections can be implemented by inheritance from
10// this module.
11//
13
14#include "THaBeamEloss.h"
15#include "THaBeam.h"
16#include "THaVertexModule.h"
17#include "TMath.h"
18
19using namespace std;
20
21//_____________________________________________________________________________
22THaBeamEloss::THaBeamEloss( const char* name, const char* description,
23 const char* input_beam ) :
24 THaElossCorrection(name,description,input_beam), fBeamModule(nullptr)
25{
26 // Normal constructor.
27
28 Clear();
29}
30
31//_____________________________________________________________________________
33{
34 // Destructor
35
37}
38
39//_____________________________________________________________________________
41{
42 // Compute the mean energy loss for the beam given in beamifo.
43 //
44 // Currently, we use a very simple algorithm that computes
45 // the energy loss based on a fixed material thickness.
46 // Only the beta dependence of the energy loss is used,
47 // but there are no corrections for angle, pathlength etc.
48 //
49 // May be overridden by derived classes as necessary.
50
51 Double_t p0 = beamifo->GetP();
52 Double_t beta = p0 / TMath::Sqrt(p0*p0 + fM*fM);
53 if( fElectronMode ) {
56 } else {
59 }
60}
61
62//_____________________________________________________________________________
64{
65 // Clear all event-by-event variables.
66
69}
70
71//_____________________________________________________________________________
73{
74 // Initialize the module.
75 // Locate the input beam module named in fInputName and save pointer to it.
76 // Extract mass and charge of the beam particles from the input.
77
78 static const char* const here = "Init()";
79
80 // Find the input beam module
81 fBeamModule = dynamic_cast<THaBeamModule*>
82 ( FindModule( fInputName.Data(), "THaBeamModule"));
83 if( !fBeamModule )
84 return fStatus;
85
86 // Get the parent beam apparatus from the input module
87 // NB: FindModule() above already checked initialization
89 THaBeam* beam = beamifo->GetBeam();
90 if( !beam ) {
91 Error( Here(here), "Oops. Input beam module has no pointer to "
92 "a beam apparatus?!?" );
93 return fStatus = kInitError;
94 }
95 // Needed for initialization of dependent modules in a chain
96 fBeamIfo.SetBeam(beam);
97
98 // Get beam particle properties from the input module.
99 // Overrides anything set by SetMass()
100 SetMass( beamifo->GetM() );
101 fZ = TMath::Abs(beamifo->GetQ());
102
103 // Standard initialization. Calls this object's DefineVariables().
104 // Reads material parameters from the run database
105 THaElossCorrection::Init( run_time );
106
107 return fStatus;
108}
109
110//_____________________________________________________________________________
112{
113 // Define/delete global variables.
114
116 if( ret )
117 return ret;
118
119 // Define the variables for the beam info subobject
121}
122
123//_____________________________________________________________________________
125{
126 // Calculate corrections and adjust the track parameters.
127
128 if( !IsOK() ) return -1;
129
130 THaBeamInfo* beamifo = fBeamModule->GetBeamInfo();
131 if( !beamifo->IsOK() ) return 2;
132
133 // Copy the input track info
134 fBeamIfo = *beamifo;
135
136 // Compute the correction. Remember that we want to compute the
137 // beam energy at the reaction vertex, so we need to subtract the
138 // energy loss from the input energy.
139 Double_t p_in = fBeamIfo.GetP();
140 if( p_in <= 0.0 ) return 4; //oops
141 Double_t E_in = TMath::Sqrt(p_in*p_in + fM*fM);
142 if( !fTestMode ) {
143 // calculate pathlength for this event if we have a vertex module
144 if( fExtPathMode ) {
145 if( !fVertexModule->HasVertex() )
146 return 1;
147 fPathlength =
149 }
150 //update fEloss
151 CalcEloss(beamifo);
152 }
153 Double_t p_out = TMath::Sqrt(p_in*p_in + fEloss*fEloss - 2.0*E_in*fEloss);
154
155 // Apply the corrected momentum to our beam info
156 fBeamIfo.SetP(p_out);
157
158 fDataValid = true;
159 return 0;
160}
161
162//_____________________________________________________________________________
164
int Int_t
double Double_t
const char Option_t
Option_t Option_t TPoint TPoint const char mode
char name[80]
static const char *const here
Definition THaVar.cxx:64
static Int_t DefineVarsFromList(const void *list, EType type, EMode mode, const char *def_prefix, const TObject *obj, const char *prefix, const char *here, const char *comment_subst="")
virtual const char * Here(const char *) const
THaAnalysisObject * FindModule(const char *name, const char *classname, bool do_error=true)
Bool_t IsOK() const
THaBeamEloss(const char *name, const char *description, const char *input_beam="")
virtual void Clear(Option_t *opt="")
THaBeamModule * fBeamModule
virtual ~THaBeamEloss()
virtual Int_t DefineVariables(EMode mode=kDefine)
virtual Int_t Process(const THaEvData &)
virtual void CalcEloss(THaBeamInfo *beamifo)
THaBeam * GetBeam() const
Definition THaBeamInfo.h:59
void SetBeam(THaBeam *obj)
Definition THaBeamInfo.h:71
Double_t GetP() const
Definition THaBeamInfo.h:45
Double_t GetM() const
void SetP(Double_t p)
Definition THaBeamInfo.h:61
Bool_t IsOK() const
Definition THaBeamInfo.h:41
Int_t GetQ() const
THaBeamInfo * GetBeamInfo()
static const RVarDef * GetRVarDef()
THaBeamInfo fBeamIfo
void BeamIfoClear()
virtual Int_t DefineVariables(EMode mode=kDefine)
virtual void Clear(Option_t *opt="")
static Double_t ElossHadron(Int_t Z_hadron, Double_t beta, Double_t z_med, Double_t a_med, Double_t d_med, Double_t pathlength)
static Double_t ElossElectron(Double_t beta, Double_t z_med, Double_t a_med, Double_t d_med, Double_t pathlength)
THaVertexModule * fVertexModule
virtual Bool_t HasVertex() const
virtual const TVector3 & GetVertex() const
virtual void Error(const char *method, const char *msgfmt,...) const
const char * Data() const
Double_t Z() const
double beta(double x, double y)
Double_t Sqrt(Double_t x)
Double_t Abs(Double_t d)
STL namespace.
ClassImp(TPyArg)