BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtParticle.hh
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3// Environment:
4// This software is part of the EvtGen package developed jointly
5// for the BaBar and CLEO collaborations. If you use all or part
6// of it, please give an appropriate acknowledgement.
7//
8// Copyright Information: See EvtGen/COPYRIGHT
9// Copyright (C) 1998 Caltech, UCSB
10//
11// Module: EvtGen/EvtParticle.hh
12//
13// Description:Class to describe all particles
14//
15// Modification history:
16//
17// DJL/RYD Sept. 25, 1996 Module created
18//
19//------------------------------------------------------------------------
20
21#ifndef EVTPARTICLE_HH
22#define EVTPARTICLE_HH
23
24// #include <iostream.h>
25#include "EvtGlobalSet.hh"
26#include "EvtId.hh"
27#include "EvtSpinDensity.hh"
28#include "EvtSpinType.hh"
29#include "EvtVector4R.hh"
30#include <assert.h>
31#include <string>
32class EvtDiracSpinor;
33class EvtVector4C;
34class EvtTensor4C;
35class EvtStdHep;
36class EvtSecondary;
37
38const int MAX_DAUG = 100;
39const int MAX_LEVEL = 10;
40const int MAX_TRIES = 10000;
41
43
44public:
45 /**
46 * Default constructor.
47 */
49
50 /**
51 * Destructor.
52 */
53 virtual ~EvtParticle();
54
55 /**
56 * Returns polarization vector in the parents restframe.
57 */
58 virtual EvtVector4C epsParent( int i ) const;
59
60 /**
61 * Returns polarization vector in the particles own restframe.
62 */
63 virtual EvtVector4C eps( int i ) const;
64
65 /**
66 * Returns polarization vector in the parents restframe for a photon.
67 */
68 virtual EvtVector4C epsParentPhoton( int i );
69
70 /**
71 * Returns polarization vector in the particles own restframe for a photon.
72 */
73 virtual EvtVector4C epsPhoton( int i );
74
75 /**
76 * Returns Dirac spinor in the parents restframe for a Dirac particle.
77 */
78 virtual EvtDiracSpinor spParent( int ) const;
79
80 /**
81 * Returns Dirac spinor in the particles own restframe for a Dirac particle.
82 */
83 virtual EvtDiracSpinor sp( int ) const;
84
85 /**
86 * Returns Dirac spinor in the parents restframe for a Neutrino particle.
87 */
88 virtual EvtDiracSpinor spParentNeutrino() const;
89
90 /**
91 * Returns Dirac spinor in the particles own restframe for a
92 * Neutrino particle.
93 */
94 virtual EvtDiracSpinor spNeutrino() const;
95
96 /**
97 * Returns tensor in the parents restframe for a spin 2 particle.
98 */
99 virtual EvtTensor4C epsTensorParent( int i ) const;
100
101 /**
102 * Returns tensor in the particles own restframe for a spin 2 particle.
103 */
104 virtual EvtTensor4C epsTensor( int i ) const;
105
106 /**
107 * Initialiaze particle with id and 4momentum.
108 */
109 virtual void init( EvtId part_n, const EvtVector4R& p4 ) = 0;
110
111 /**
112 * Add another daughter to the particle
113 */
114 void addDaug( EvtParticle* node );
115
116 /**
117 * Decay particle
118 */
119 void decay();
120
121 /**
122 * Delete a decay chain
123 */
124 void deleteTree();
125 void deleteDaughters( bool keepChannel = false );
126
127 /**
128 * Should only be used internally.
129 */
130 void setChannel( int i );
131
132 /**
133 * set generator information; pingrg-2011-1-6
134 */
135 void setGeneratorFlag( int flag ) { _generatorFlag = flag; }
136
137 /**
138 * get generator information; pingrg-2011-1-6
139 */
140 int getGeneratorFlag() { return _generatorFlag; }
141
142 //////////////////////NEW ADDATION/////////////////////////////////////
143 static int _NextLevelDauNum; ///////
144 static EvtId _NextLevelId[20]; ///////
145 static EvtVector4R _NextLevelP4[20]; ///////
146 ///////////////////////////////////////////////////////////////////////
147 /**
148 * set int flag for ConExc: pingrg-2015-2-7
149 **/
150 void setIntFlag( std::vector<int> vi ) { _intFlag = vi; }
151
152 /**
153 * get int flag for ConExc: pingrg-2015-2-7
154 **/
155 std::vector<int> getIntFlag() { return _intFlag; }
156
157 /**
158 * Creates the daughters in the list of ids and
159 * adds them to the parent. Note that momentum
160 * is left uninitialized, this is _only_ creation.
161 */
162 void makeDaughters( int ndaug, EvtId* id );
163
164 /**
165 * Similar to the routine above except that here
166 * momentum is generated according to phase space
167 * daughters are filled with this momentum.
168 */
169 double initializePhaseSpace( int numdaughter, EvtId* daughters, double poleSize = -1.,
170 int whichTwo1 = 0, int whichTwo2 = 1 );
171
172 /**
173 * Get pointer the the i:th daugther.
174 */
175 EvtParticle* getDaug( int i );
176
177 /**
178 * Iterates over the particles in a decay chain.
179 */
180 EvtParticle* nextIter( EvtParticle* rootOfTree = 0 );
181
182 /**
183 * Makes stdhep list
184 */
185 void makeStdHep( EvtStdHep& stdhep, EvtSecondary& secondary, EvtId* stable_parent_ihep );
186 void makeStdHep( EvtStdHep& stdhep );
187
188 /**
189 * Gets 4vector in the labframe, i.e., the frame in which the root
190 * particles momentum is measured.
191 */
193
194 /**
195 * Gets 4vector in the particles restframe, i.e. this functiont will
196 * return (m,0,0,0)
197 */
199
200 /**
201 * Returns the 4position of the particle in the lab frame.
202 */
204
205 /**
206 * Returns pointer to parent particle.
207 */
209
210 /**
211 * Makes partptr the idaug:th daugther.
212 */
213 void insertDaugPtr( int idaug, EvtParticle* partptr ) {
214 _daug[idaug] = partptr;
215 partptr->_parent = this;
216 }
217 /**
218 * Returns mass of particle.
219 */
220 double mass() const;
221
222 /**
223 * Used internally to decide if first time particle is decayed.
224 */
225 int firstornot() const;
226 void setFirstOrNot();
227 void resetFirstOrNot();
228
229 /**
230 * Returns Id of particle.
231 */
232 EvtId getId() const;
233
234 /**
235 * Returns particle type.
236 */
237
239
240 /**
241 * Returns number of spin states of the particle.
242 */
243 int getSpinStates() const;
244
245 /**
246 * Returns 4momentum in parents restframe.
247 */
248 const EvtVector4R& getP4() const;
249
250 /**
251 * Sets the 4momentum in the parents restframe.
252 */
253 void setP4( const EvtVector4R& p4 ) { _p = p4; }
254
255 /**
256 * Retunrs the decay channel.
257 */
258 int getChannel() const;
259
260 /**
261 * Returns number of daugthers.
262 */
263 int getNDaug() const;
264 void resetNDaug() {
265 _ndaug = 0;
266 return;
267 }
268
269 /**
270 * Prints out the particle "tree" of a given particle. The
271 * tree consists of all daughters (and their daughters, etc)
272 * and their properties.
273 */
274 void printTree() const;
275
276 void printTreeRec( int level ) const;
277 std::string writeTreeRec( std::string ) const;
278
279 void dumpTree() const;
280 void dumpTreeRec( int level, int dj ) const;
281
282 std::string treeStr() const;
283 std::string treeStrRec( int level ) const;
284
285 /**
286 * Prints information for the particle.
287 */
288 void printParticle() const;
289
290 /**
291 * Set lifetime of the particle in parents restframe.
292 */
293 void setLifetime( double tau );
294
295 /**
296 * Generate lifetime according to pure exponential.
297 */
298 void setLifetime();
299
300 /**
301 * Returns the lifetime.
302 */
303 double getLifetime();
304
305 /**
306 * Set diagonal spindensity matrix.
307 */
309
310 /**
311 * Set spindensity matrix for e+e- -> V
312 */
314
315 void setPolarizedSpinDensity( double r00, double r11,
316 double r22 ); // pingrg for polarized charmonium production
317 /**
318 * Set forward spin density matrix.
319 */
320 void setSpinDensityForward( const EvtSpinDensity& rho ) { _rhoForward = rho; }
321
322 /**
323 * Set forward spin density matrix according to the density matrix
324 * rho in the helicity amplitude basis.
325 */
328 double beta, double gamma );
329
330 /**
331 * Returns a rotation matrix need to rotate the basis state
332 * to the helicity basis. The EvtSpinDensity matrix is just use
333 * as a matrix here. This function is to be implemented in each
334 * derived class.
335 */
337 virtual EvtSpinDensity rotateToHelicityBasis( double alpha, double beta,
338 double gamma ) const = 0;
339
340 /**
341 * Get forward spin density matrix.
342 */
343 EvtSpinDensity getSpinDensityForward() { return _rhoForward; }
344
345 /**
346 * Set backward spin density matrix.
347 */
348 void setSpinDensityBackward( const EvtSpinDensity& rho ) { _rhoBackward = rho; }
349
350 /**
351 * Get backward spin density matrix.
352 */
353 EvtSpinDensity getSpinDensityBackward() { return _rhoBackward; }
354
355 // Hacks will be removed when better solutions are thought of!
356 // This is used to suppress use of random numbers when doing initialization
357 // of some models.
358 void noLifeTime() { _genlifetime = 0; }
359
360 // lange - April 29, 2002
361 void setId( EvtId id ) { _id = id; }
362 void initDecay( bool useMinMass = false );
363 void generateMassTree();
364
365 double compMassProb();
366
367 // setMass will blow away any existing 4vector
368 void setMass( double m ) { _p = EvtVector4R( m, 0.0, 0.0, 0.0 ); }
369
370 // void setMixed() {_mix=true;}
371 // void setUnMixed() {_mix=false;}
372 // bool getMixed() {return _mix;}
373
374 // void takeCConj() {report(INFO,"EvtGen") << "should take conj\n";}
375
376 // this means that the particle has gone through initDecay
377 // and thus has a mass
378 bool isInitialized() { return _isInit; }
379 bool hasValidP4() { return _validP4; }
380 bool isDecayed() { return _isDecayed; }
381
382 // decay prob - only relevent if already decayed
383 // and is a scalar particle
384 // returned is a double* that should be prob/probMax
385 double* decayProb() { return _decayProb; }
386 void setDecayProb( double p );
387
388 void setInclusiveMode( int im ) { _inclusiveMode = im; }
389 int getInclusiveMode() { return _inclusiveMode; }
390
391protected:
392 void setp( double e, double px, double py, double pz ) { _p.set( e, px, py, pz ); }
393 void setp( const EvtVector4R& p4 ) { _p = p4; }
394 void setpart_num( EvtId particle_number ) {
395 assert( _channel == -10 || _id.getId() == particle_number.getId() || _id.getId() == -1 );
396 _id = particle_number;
397 }
399
400private:
401 EvtParticle* _daug[MAX_DAUG];
402 int _ndaug;
403 EvtParticle* _parent;
404 int _channel;
405 int _first;
406 EvtId _id;
407 EvtVector4R _p;
408 double _t;
409 bool _isInit;
410 bool _isDecayed;
411 int _generatorFlag;
412 // bool _mix;
413
414 EvtSpinDensity _rhoForward;
415 EvtSpinDensity _rhoBackward;
416
417 void makeStdHepRec( int firstparent, int lastparent, EvtStdHep& stdhep,
418 EvtSecondary& secondary, EvtId* stable_parent_ihep );
419 void makeStdHepRec( int firstparent, int lastparent, EvtStdHep& stdhep );
420
421 // This is a hack until things gets straightened out. (Ryd)
422 int _genlifetime;
423
424 // should never be used, therefor is private.
425 // these does _not_ have an implementation
426 EvtParticle& operator=( const EvtParticle& p );
427 EvtParticle( const EvtParticle& p );
428
429 double* _decayProb;
430
431 // Access the inclusive mode for OPENCHARM
432 int _inclusiveMode;
433 // Set mode index for ConExc
434 std::vector<int> _intFlag;
435};
436
437std::string IntToStr( int a ); // pingrg, 2008-03-24
438#endif
const int MAX_LEVEL
std::string IntToStr(int a)
const int MAX_DAUG
const int MAX_TRIES
double alpha
Definition EvtId.hh:27
int getId() const
Definition EvtId.hh:40
void noLifeTime()
virtual EvtVector4C epsPhoton(int i)
void setMass(double m)
void setSpinDensityBackward(const EvtSpinDensity &rho)
void setSpinDensityForwardHelicityBasis(const EvtSpinDensity &rho)
void setSpinDensityForward(const EvtSpinDensity &rho)
void setDecayProb(double p)
void makeDaughters(int ndaug, EvtId *id)
virtual ~EvtParticle()
virtual EvtVector4C epsParent(int i) const
void initDecay(bool useMinMass=false)
virtual void init(EvtId part_n, const EvtVector4R &p4)=0
void resetNDaug()
void insertDaugPtr(int idaug, EvtParticle *partptr)
EvtVector4R getP4Lab()
virtual EvtTensor4C epsTensorParent(int i) const
virtual EvtVector4C epsParentPhoton(int i)
void printTreeRec(int level) const
EvtId getId() const
EvtParticle * getParent()
virtual EvtDiracSpinor spParentNeutrino() const
static EvtId _NextLevelId[20]
void setGeneratorFlag(int flag)
virtual EvtDiracSpinor spParent(int) const
void setVectorSpinDensity()
bool hasValidP4()
bool isDecayed()
void printParticle() const
virtual EvtDiracSpinor spNeutrino() const
static int _NextLevelDauNum
virtual EvtSpinDensity rotateToHelicityBasis(double alpha, double beta, double gamma) const =0
int getSpinStates() const
EvtVector4R getP4Restframe()
void setLifetime()
void setPolarizedSpinDensity(double r00, double r11, double r22)
void setIntFlag(std::vector< int > vi)
double getLifetime()
void setDiagonalSpinDensity()
double compMassProb()
EvtSpinType::spintype getSpinType() const
void setChannel(int i)
const EvtVector4R & getP4() const
void setp(double e, double px, double py, double pz)
void printTree() const
virtual EvtSpinDensity rotateToHelicityBasis() const =0
int getGeneratorFlag()
void setP4(const EvtVector4R &p4)
void resetFirstOrNot()
int getNDaug() const
EvtParticle * getDaug(int i)
void dumpTreeRec(int level, int dj) const
double * decayProb()
bool isInitialized()
std::vector< int > getIntFlag()
void deleteDaughters(bool keepChannel=false)
static EvtVector4R _NextLevelP4[20]
double mass() const
virtual EvtDiracSpinor sp(int) const
void setp(const EvtVector4R &p4)
void makeStdHep(EvtStdHep &stdhep, EvtSecondary &secondary, EvtId *stable_parent_ihep)
int firstornot() const
EvtSpinDensity getSpinDensityBackward()
void setInclusiveMode(int im)
EvtVector4R get4Pos()
virtual EvtVector4C eps(int i) const
void addDaug(EvtParticle *node)
void dumpTree() const
std::string treeStr() const
std::string treeStrRec(int level) const
void setpart_num(EvtId particle_number)
int getChannel() const
virtual EvtTensor4C epsTensor(int i) const
void setId(EvtId id)
std::string writeTreeRec(std::string) const
void setFirstOrNot()
double initializePhaseSpace(int numdaughter, EvtId *daughters, double poleSize=-1., int whichTwo1=0, int whichTwo2=1)
EvtSpinDensity getSpinDensityForward()
int getInclusiveMode()
EvtParticle * nextIter(EvtParticle *rootOfTree=0)
void generateMassTree()
void deleteTree()