Pluto v6.3.0
Loading...
Searching...
No Matches
PParticle.h
Go to the documentation of this file.
1// Author: Marios A. Kagarlis
2// Written: 15.11.98
3// Revised: 20.07.99
4// Revised: 30.08.00 R. Holzmann
5// Revised: 07.09.00 J. Ritman (added parent-,siblings-,daughter- index
6// and decayTime)
7// Revised: 15.12.00 R. Holzmann (creation time added)
8// Revised: 22.03.05 R. Holzmann (get/setParent() added)
9// Revised: 23.07.07 IF (new framework)
10
11// PParticle Class Header
12
13#ifndef _PPARTICLE_H_
14#define _PPARTICLE_H_
15
16#include "TLorentzVector.h"
17#include "PData.h"
18#include "PValues.h"
19#include "PUtils.h"
20
21#include "TMath.h"
22
23
24
25class PParticle: public TLorentzVector {
26
27 public:
28 PParticle(Int_t id=0, Double_t T=0., Double_t w=1.);
29 // id, lab kinetic energy (GeV), weight
30
31 PParticle(const char *, Double_t T=0., Double_t w=1.);
32 // name, lab kinetic energy (GeV), weight
33
34 PParticle(Int_t, Double_t, Double_t, Double_t, Double_t m=0., Double_t w=1.);
35 // id, Px, Py, Pz (GeV/c), mass (GeV/c**2) overrides default, weight
36
37 PParticle(const char *, Double_t, Double_t, Double_t,Double_t m=0., Double_t w=1.);
38 // name, Px, Py, Pz (GeV/c), mass (GeV/c**2) overrides default, weight
39
40 PParticle(Int_t, const TVector3 &, Double_t m=0., Double_t w=1.);
41 // id, 3-momentum vector (GeV/c), mass (GeV/c**2) overrides default, weight
42
43 PParticle(Int_t, Double_t *, Double_t w=1.);
44 // id, pointer to 4-dim array (Px, Py, Pz, E) (GeV/c, GeV), weight
45
46 PParticle(Int_t, float *, Double_t w=1.);
47 // id, pointer to 4-dim array (Px, Py, Pz, E) (GeV/c, GeV), weight
48
50 // copy constructor
51
53 // copy constructor
54
55 virtual ~PParticle() {
56 if (qParticle1) delete qParticle1;
57 if (qParticle2) delete qParticle2;
58 if (values) delete values;
59 }
60
61 Int_t Is(const char * id) {
62 return (pid==makeStaticData()->GetParticleID(id));
63 }
64 Int_t is(const char * id) {
65 //kept for compatibility only
66 return Is(id);
67 }
68 Int_t HasID(const Int_t id) {
69 return (pid==id);
70 }
71 Int_t HasNotID(const Int_t id) {
72 return (pid!=id);
73 }
74
75 Int_t size() { return (pid<1000)?1:2; }
76 Int_t IsNucleon() { return (Is("p") || Is("n")); }
77 Int_t IsDelta() { return (Is("D0") || Is("D-") || Is("D+") || Is("D++")); }
78 Int_t IsPi() { return (Is("pi0") || Is("pi+") || Is("pi-")); }
79 Int_t IsRho() { return (Is("rho0") || Is("rho+") || Is("rho-")); }
80 Int_t ID() const { return pid; }
81
82 const char *Name() {
84 }
85
86 void SetSpectator(Int_t s) {spectator=s;};
87 //=0 don't care; =-1 never; =1 force
88
89 Int_t IsSpectator() {return spectator;};
90
91 void SetID(const Int_t id) { pid=id; }
92 Double_t W() const { return wt; }
93 void SetW(Double_t w=1.) { wt=w; }
94 void SetMultiplicity(Double_t w=1.) { mult=w; }
95 Double_t GetMultiplicity() {return mult;};
96 Double_t GenW() const { return genwt; }
97 void SetGenW(Double_t w=1.) { genwt=w; }
98 Double_t InvGenW() const { return invgenwt; }
99 void SetInvGenW(Double_t w=1.) { invgenwt=w; }
100
101
102 virtual Double_t KE() const { return E()-M(); } // kinetic energy
103 void SetKE(Double_t T=0.); // reset by kinetic energy
104 void SetM(Double_t m=0.); // reset by mass
105 void SetMom(Double_t mom=0.); // reset by momentum
106
107 void ResetE() { // reset E to be consistent with mass(ID)
108 if (makeStaticData()->GetParticleTotalWidth(pid) > 1.e-3)
109 return; // broad particle
110 Double_t m = makeStaticData()->GetParticleMass(pid); // get tabulated mass
111 Double_t px = Px(), py = Py(), pz = Pz();
112 Double_t lE = sqrt(m*m + px*px + py*py + pz*pz);
113 SetPxPyPzE(px, py, pz, lE);
114 }
115
116 Double_t Life(Double_t m=0., Int_t idx=-1); // lifetime in lab frame
117 TLorentzVector Vect4() const { return TLorentzVector(Vect(),E()); }
118 void SetVect4(const TLorentzVector & v) { SetPxPyPzE(v[0],v[1],v[2],v[3]); }
119 Int_t IsMeson() const { return makeStaticData()->IsParticleMeson(pid); }
120 Int_t IsHadron() const { return makeStaticData()->IsParticleHadron(pid); }
121 Int_t BaryonN() const { return makeStaticData()->GetParticleBaryon(pid); }
122 Int_t LeptonN() const { return makeStaticData()->GetParticleLepton(pid); }
123 Int_t Charge() const { return makeStaticData()->GetParticleCharge(pid); }
124 Int_t Key() const { return makeStaticData()->GetParticleKey(pid); }
125 void Reset(const Int_t id, const TLorentzVector & v, const Double_t w=1.) {
126 pid = id;
127 wt = w;
128 SetVect4(v);
129 }
130 virtual Int_t IsFireball() { return 0; }
131 virtual Int_t IsDilepton() { return 0; }
132 virtual Int_t IsFileInput() { return 0; }
133 void Reset(const Int_t id=0, const Double_t px=0., const Double_t py=0.,
134 const Double_t pz=0., const Double_t e=0., const Double_t w=1.) {
135 SetPxPyPzE(px,py,pz,e);
136 pid = id;
137 wt = w;
138 };
139 void Reset(const PParticle & p) {
140 *this = p;
141 };
142
143 PParticle* Clone(const char*delme = NULL) const;
144
145 bool SetValue(Int_t id , Double_t val) {
146 if (!values) values=new PValues();
147 return values->SetValue(id, val);
148 };
149
150 bool SetValue(Int_t id) {
151 return SetValue(id, 1.);
152 };
153
154 bool GetValue(Int_t id, Double_t *val) {
155 if (!values) return kFALSE;
156 return values->GetValue(id, val);
157 };
158
159
160 Int_t GetDBInt(char *name) {
161 Int_t param = makeDataBase()->GetParamInt(name);
162 if (param < 0) return -1;
163 Int_t pkey = makeStaticData()->GetParticleKey(pid);
164 if (pkey < 0) return -1;
165 Int_t *result;
166 if (!makeDataBase()->GetParamInt(pkey, param, &result)) return -1;
167 return *result;
168 };
169 Double_t GetDBDouble(char *name) {
170 Int_t param = makeDataBase()->GetParamDouble(name);
171 if (param < 0) return -1;
172 Int_t pkey = makeStaticData()->GetParticleKey(pid);
173 if (pkey < 0) return -1;
174 Double_t *result;
175 if (!makeDataBase()->GetParamDouble(pkey, param, &result)) return -1;
176 return *result;
177 };
178 char GetDBString(char *name) const {
179 Int_t param = makeDataBase()->GetParamString(name);
180 if (param < 0) return -1;
181 Int_t pkey = makeStaticData()->GetParticleKey(pid);
182 if (pkey < 0) return -1;
183 const char *result;
184 if (!makeDataBase()->GetParamString(pkey, param, &result)) return -1;
185 return *result;
186 };
187
188 void SetStatus(Int_t st){
189 status=st;
190 };
191
192 Int_t GetStatus(){
193 return status;
194 };
195
196 Double_t InvariantT(Double_t m3, Double_t m4, Double_t cos_th_cm);
197 // The Mandelstam invariant t in 1 + 2 --> 3 + 4 scattering
198
199 PParticle operator + (const PParticle & b) const {
200 // "addition" for composite quasi-particles
201 PParticle v( *this );
202 return v += b;
203 }
205
206 PParticle operator - (const PParticle & b) const {
207 // "addition" for composite quasi-particles
208 PParticle v( *this );
209 return v -= b;
210 }
211 void Reconstruct(void);
212
216 PParticle & operator *= ( const TRotation & );
217 PParticle & operator *= ( const TLorentzRotation & );
218 PParticle & Transform( const TRotation & );
219 PParticle & Transform( const TLorentzRotation & );
220
223
224 void Print(const Option_t* delme= NULL) const;
225
226
227 inline void SetParentId(Int_t pId) {parentId = pId;}
228 inline void SetSourceId(Int_t sId) {sourceId = sId;}
229 inline Int_t GetParentId() const {return parentId;}
230 inline Int_t GetSourceId() const {return sourceId;}
231
232 inline Int_t getSourceId() const {return sourceId;} //kept for backw. comp.
233
234 inline void SetParentIndex(Int_t pInd) {parentIndex = pInd;}
235 inline Int_t GetParentIndex() const {return parentIndex;}
236 inline void SetDecayModeIndex(Int_t pInd, Int_t i=0) {
237 if (i) {
238 decayModeIndex = -1;
240 } else {
241 decayModeIndex = pInd;
243 }
244 }
245
246 //Internal models should use opt=1, they will not get the "wrong" getDecayModeIndex
247 inline Int_t GetDecayModeIndex(Int_t opt=0) const {
248 if ((opt ==0) && (decayModeIndex<0) && (destroyDecayModeIndex>0))
250 return decayModeIndex;
251 }
252 inline void SetDaughterIndex(Int_t dInd) {daughterIndex = dInd;}
253 inline Int_t GetDaughterIndex() const {return daughterIndex;}
254 inline void SetSiblingIndex(Int_t sInd) {siblingIndex = sInd;}
255 inline Int_t GetSiblingIndex() const {return siblingIndex;}
256 inline void SetIndex(Int_t Ind) {index = Ind;}
257 inline Int_t GetIndex() const {return index;}
258
259 inline Bool_t IsActive() const {return active;}
260 inline void SetActive() {active = kTRUE;}
261 inline void SetInActive() {active = kFALSE;}
262
263 void SetProperTime(); // sample time until decay in proper time (sec)
264 void SetProperTime(Double_t t) {decayTime = t;}
265 inline Double_t GetProperTime() const {return decayTime;}
266
267 void SetVertex(Double_t x, Double_t y, Double_t z, Double_t t) {
268 fV.SetXYZ(x, y, z);
269 fT = t;
270 }
271 void SetVertex(Double_t x, Double_t y, Double_t z) {
272 fV.SetXYZ(x, y, z);
273 }
274 inline void SetVertex(TVector3& v, Double_t t) {fV = v; fT=t;}
275 inline TVector3& GetVertex() {return fV;}
276 inline TVector3& getVertex() {return fV;}
277 inline Double_t X() const {return fV.X();}
278 inline Double_t Y() const {return fV.Y();}
279 inline Double_t Z() const {return fV.Z();}
280 inline Double_t R() const {return fV.Mag();}
281 inline Double_t T() const {return fT;}
282 inline void SetT(Double_t time) {fT = time;}
283 inline void SetInput(PParticle *p) {pParticle = p;}
284 inline PParticle* GetInput() {return pParticle;}
285 inline void SetParent(PParticle *p) {pParticle = p;}
286 inline PParticle* GetParent() {return pParticle;}
287 inline void SetSibling(PParticle *p) {sParticle = p;}
289 if (sParticle)
290 return sParticle;
291 else
292 return this;
293 };
294
295 inline void ResetDaughters(void) {
296 for (int i=0; i<(MAX_DAUGHTERS+1); i++)
297 daughters[i] = NULL;
298 };
299
300 inline void SetDaughter(PParticle *d) {
301 for (int i=0; i<MAX_DAUGHTERS; i++) {
302 if (daughters[i] == NULL) {
303 daughters[i] = d;
304 return;
305 }
306 }
307 Error("SetDaughter","MAX_DAUGHTERS reached");
308 };
309
310 inline PParticle *GetDaughter(int i) {
311 return daughters[i];
312 }
313
314 inline PParticle *GetScattering(Int_t i) {
315 if (i == 0)
316 return qParticle1;
317 else
318 return qParticle2;
319 };
320
321 inline PParticle *GetBeam(void){
322 return qParticle1;
323 };
324 inline PParticle *GetTarget(void){
325 return qParticle2;
326 };
327
328 void addDebugString(char * s) {
329 debug.Append(s);
330 debug.Append(":");
331 }
333 debug = ""; //BUGBUG memory leak?
334 }
335 TString *GetDebugString(){
336 return &debug;
337 }
338
339 Int_t GetScatterClone(void) {return make_new_qParticle;};
341
342 Double_t weight_divisor;
343
344 //Something for PBatch:
345 Double_t Sample() {return PUtils::sampleFlat();};
346
347 protected:
348
349 void defaults(void);
350
351 Int_t pid; // particle code (partially conforms with Geant 3)
352 Int_t sourceId; // Source ID
353 Int_t parentId; // parent ID
354 Int_t parentIndex; // parent index in particle array
355 Int_t decayModeIndex;// decay Mode index (for decayAll option)
356 Int_t destroyDecayModeIndex;// save only for data file
357 Int_t daughterIndex; // daughter index
358 Int_t siblingIndex; // sibling index
359 Int_t spectator;
360
361 Double_t decayTime; // proper time until decay (in mm/c)
362 Double_t wt; // weight
363 Double_t genwt;
364 Double_t invgenwt;
365 Double_t mult;
366
367 TVector3 fV; // creation vertex (in mm)
368 Double_t fT; // creation time (in mm/c)
369 Bool_t active;
370 Int_t index;
376 TString debug;
377
379 Int_t status;
380
382
383 ClassDef(PParticle,4) // Pluto Particle Class
384 };
385#endif // _PPARTICLE_H_
386
387
388
389
390
391
392
393
394
395
396
397
398
PDataBase * makeDataBase()
#define MAX_DAUGHTERS
Definition PStaticData.h:17
PStaticData * makeStaticData()
PParticle * d
double pz
double px
double py
Int_t GetParamDouble(const char *paramname)
Int_t GetParamString(const char *paramname)
Int_t GetParamInt(const char *paramname, Int_t length=-1)
Bool_t IsActive() const
Definition PParticle.h:259
void SetProperTime(Double_t t)
Definition PParticle.h:264
void SetDaughterIndex(Int_t dInd)
Definition PParticle.h:252
void SetParentIndex(Int_t pInd)
Definition PParticle.h:234
Int_t LeptonN() const
Definition PParticle.h:122
PParticle & Transform(const TLorentzRotation &)
void SetDaughter(PParticle *d)
Definition PParticle.h:300
Int_t IsHadron() const
Definition PParticle.h:120
TVector3 fV
multiplicity
Definition PParticle.h:367
PParticle(const PParticle *)
TVector3 & GetVertex()
Definition PParticle.h:275
PParticle & operator-=(const PParticle &)
PParticle * GetTarget(void)
Definition PParticle.h:324
Int_t GetParentIndex() const
Definition PParticle.h:235
void ResetDaughters(void)
Definition PParticle.h:295
const char * Name()
Definition PParticle.h:82
Int_t index
internal activity flag
Definition PParticle.h:370
Int_t IsMeson() const
Definition PParticle.h:119
Double_t mult
inverted generator weight
Definition PParticle.h:365
void SetDecayModeIndex(Int_t pInd, Int_t i=0)
Definition PParticle.h:236
void SetVertex(TVector3 &v, Double_t t)
Definition PParticle.h:274
Int_t GetSourceId() const
Definition PParticle.h:230
Int_t ID() const
Definition PParticle.h:80
Double_t InvariantT(Double_t m3, Double_t m4, Double_t cos_th_cm)
Double_t Y() const
Definition PParticle.h:278
PParticle * qParticle2
Definition PParticle.h:373
Int_t parentId
Definition PParticle.h:353
void addDebugString(char *s)
Definition PParticle.h:328
Int_t pid
Definition PParticle.h:351
Double_t GetProperTime() const
Definition PParticle.h:265
Int_t getSourceId() const
Definition PParticle.h:232
Int_t Key() const
Definition PParticle.h:124
Double_t Z() const
Definition PParticle.h:279
Double_t GetMultiplicity()
Definition PParticle.h:95
Int_t GetIndex() const
Definition PParticle.h:257
bool SetValue(Int_t id)
Definition PParticle.h:150
void SetKE(Double_t T=0.)
Int_t HasID(const Int_t id)
Definition PParticle.h:68
Double_t GetDBDouble(char *name)
Definition PParticle.h:169
void SetInput(PParticle *p)
Definition PParticle.h:283
Double_t GenW() const
Definition PParticle.h:96
PParticle(Int_t, float *, Double_t w=1.)
void SetScatterClone(Int_t t)
Definition PParticle.h:340
Int_t BaryonN() const
Definition PParticle.h:121
TVector3 & getVertex()
Definition PParticle.h:276
PParticle(Int_t, Double_t, Double_t, Double_t, Double_t m=0., Double_t w=1.)
Int_t GetStatus()
Definition PParticle.h:192
PParticle & operator=(const PParticle &)
PParticle * GetInput()
Definition PParticle.h:284
Bool_t active
Definition PParticle.h:369
PParticle operator-(const PParticle &b) const
Definition PParticle.h:206
PParticle * sParticle
Definition PParticle.h:374
void Print(const Option_t *delme=NULL) const
Double_t InvGenW() const
Definition PParticle.h:98
bool SetValue(Int_t id, Double_t val)
Definition PParticle.h:145
Int_t GetSiblingIndex() const
Definition PParticle.h:255
Double_t invgenwt
generator weight
Definition PParticle.h:364
void SetParent(PParticle *p)
Definition PParticle.h:285
void SetSibling(PParticle *p)
Definition PParticle.h:287
void SetProperTime()
virtual Int_t IsFireball()
Definition PParticle.h:130
void SetVertex(Double_t x, Double_t y, Double_t z)
Definition PParticle.h:271
Int_t siblingIndex
Definition PParticle.h:358
void SetActive()
Definition PParticle.h:260
PParticle(Int_t, const TVector3 &, Double_t m=0., Double_t w=1.)
void SetM(Double_t m=0.)
Int_t sourceId
Definition PParticle.h:352
void SetInActive()
Definition PParticle.h:261
PParticle & SubTmp(const PParticle &p)
Double_t Life(Double_t m=0., Int_t idx=-1)
PParticle * GetBeam(void)
Definition PParticle.h:321
Int_t daughterIndex
Definition PParticle.h:357
void Scatter(PParticle *p1, PParticle *p2)
Int_t is(const char *id)
Definition PParticle.h:64
Int_t GetScatterClone(void)
Definition PParticle.h:339
PParticle * daughters[MAX_DAUGHTERS+1]
pointer to particle object
Definition PParticle.h:375
void SetID(const Int_t id)
Definition PParticle.h:91
void SetInvGenW(Double_t w=1.)
Definition PParticle.h:99
Int_t GetDaughterIndex() const
Definition PParticle.h:253
virtual ~PParticle()
Definition PParticle.h:55
void Reset(const Int_t id, const TLorentzVector &v, const Double_t w=1.)
Definition PParticle.h:125
Int_t HasNotID(const Int_t id)
Definition PParticle.h:71
PParticle * GetSibling()
Definition PParticle.h:288
PParticle & AddTmp(const PParticle &p)
Int_t GetDecayModeIndex(Int_t opt=0) const
Definition PParticle.h:247
Int_t IsDelta()
Definition PParticle.h:77
char GetDBString(char *name) const
Definition PParticle.h:178
void SetT(Double_t time)
Definition PParticle.h:282
PParticle * Clone(const char *delme=NULL) const
Int_t IsSpectator()
Definition PParticle.h:89
Double_t fT
Definition PParticle.h:368
void SetMom(Double_t mom=0.)
PParticle * qParticle1
pointer to particle object
Definition PParticle.h:372
void SetVect4(const TLorentzVector &v)
Definition PParticle.h:118
PParticle(const char *, Double_t, Double_t, Double_t, Double_t m=0., Double_t w=1.)
Double_t X() const
Definition PParticle.h:277
PParticle * pParticle
index in particle array
Definition PParticle.h:371
PParticle(Int_t id=0, Double_t T=0., Double_t w=1.)
virtual Int_t IsFileInput()
Definition PParticle.h:132
PParticle(const PParticle &)
PParticle operator+(const PParticle &b) const
Definition PParticle.h:199
PParticle * GetParent()
Definition PParticle.h:286
TString debug
pointer to daughter array
Definition PParticle.h:376
Int_t IsRho()
Definition PParticle.h:79
Double_t T() const
Definition PParticle.h:281
PParticle * GetDaughter(int i)
Definition PParticle.h:310
PParticle(const char *, Double_t T=0., Double_t w=1.)
void Reset(const Int_t id=0, const Double_t px=0., const Double_t py=0., const Double_t pz=0., const Double_t e=0., const Double_t w=1.)
Definition PParticle.h:133
Double_t Sample()
Helper for PReaction.
Definition PParticle.h:345
Double_t decayTime
flag that forces particle to be treated as spectator
Definition PParticle.h:361
virtual Double_t KE() const
Definition PParticle.h:102
Bool_t make_new_qParticle
status of parent particle in PChannel::Decay
Definition PParticle.h:381
void Reset(const PParticle &p)
Definition PParticle.h:139
Int_t GetDBInt(char *name)
Definition PParticle.h:160
TLorentzVector Vect4() const
Definition PParticle.h:117
Int_t size()
Definition PParticle.h:75
TString * GetDebugString()
Definition PParticle.h:335
void ResetE()
Definition PParticle.h:107
Double_t W() const
Definition PParticle.h:92
Int_t decayModeIndex
Definition PParticle.h:355
Int_t parentIndex
Definition PParticle.h:354
PValues * values
debug string
Definition PParticle.h:378
PParticle(Int_t, Double_t *, Double_t w=1.)
Double_t genwt
Definition PParticle.h:363
Int_t GetParentId() const
Definition PParticle.h:229
void clearDebugString()
Definition PParticle.h:332
virtual Int_t IsDilepton()
Definition PParticle.h:131
Int_t IsNucleon()
Definition PParticle.h:76
PParticle & Transform(const TRotation &)
Double_t R() const
Definition PParticle.h:280
void SetW(Double_t w=1.)
Definition PParticle.h:93
void Reconstruct(void)
bool GetValue(Int_t id, Double_t *val)
Definition PParticle.h:154
void SetGenW(Double_t w=1.)
Definition PParticle.h:97
PParticle * GetScattering(Int_t i)
Definition PParticle.h:314
Int_t destroyDecayModeIndex
Definition PParticle.h:356
Double_t weight_divisor
Definition PParticle.h:342
PParticle & operator+=(const PParticle &)
Int_t IsPi()
Definition PParticle.h:78
void SetMultiplicity(Double_t w=1.)
Definition PParticle.h:94
void SetSiblingIndex(Int_t sInd)
Definition PParticle.h:254
void SetStatus(Int_t st)
Definition PParticle.h:188
void SetVertex(Double_t x, Double_t y, Double_t z, Double_t t)
Definition PParticle.h:267
void defaults(void)
PParticle & operator*=(const TRotation &)
Int_t Is(const char *id)
Definition PParticle.h:61
void SetSpectator(Int_t s)
Definition PParticle.h:86
void SetParentId(Int_t pId)
Definition PParticle.h:227
Double_t wt
Definition PParticle.h:362
Int_t Charge() const
Definition PParticle.h:123
void SetSourceId(Int_t sId)
Definition PParticle.h:228
void SetIndex(Int_t Ind)
Definition PParticle.h:256
Int_t status
pointer to value container
Definition PParticle.h:379
Int_t spectator
Definition PParticle.h:359
int GetParticleCharge(const int &id)
const char * GetParticleName(const int &id)
double GetParticleMass(const int &id)
int IsParticleMeson(const int &id)
int GetParticleLepton(const int &id)
int GetParticleKey(const int &id)
int GetParticleBaryon(const int &id)
int IsParticleHadron(const int &id)
static Double_t sampleFlat()
Definition PUtils.h:121
PParticle p2("p")
PParticle p1("p", beam_energy)
PParticle * p
Definition dp_mult.C:24
PParticle * s
Definition dp_mult.C:25
PParticle * w