EvtGen 2.2.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
Loading...
Searching...
No Matches
EvtParticle.hh
Go to the documentation of this file.
1
2/***********************************************************************
3* Copyright 1998-2020 CERN for the benefit of the EvtGen authors *
4* *
5* This file is part of EvtGen. *
6* *
7* EvtGen is free software: you can redistribute it and/or modify *
8* it under the terms of the GNU General Public License as published by *
9* the Free Software Foundation, either version 3 of the License, or *
10* (at your option) any later version. *
11* *
12* EvtGen is distributed in the hope that it will be useful, *
13* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15* GNU General Public License for more details. *
16* *
17* You should have received a copy of the GNU General Public License *
18* along with EvtGen. If not, see <https://www.gnu.org/licenses/>. *
19***********************************************************************/
20
21#ifndef EVTPARTICLE_HH
22#define EVTPARTICLE_HH
23
24#include "EvtGenBase/EvtId.hh"
28
29#include <assert.h>
30#include <map>
31#include <string>
32#include <vector>
33
34class EvtDiracSpinor;
35class EvtVector4C;
36class EvtTensor4C;
37class EvtStdHep;
38class EvtSecondary;
40
41const int MAX_DAUG = 100;
42const int MAX_LEVEL = 10;
43const int MAX_TRIES = 10000;
44
46 public:
51
55 virtual ~EvtParticle();
56
60 virtual EvtVector4C epsParent( int i ) const;
61
65 virtual EvtVector4C eps( int i ) const;
66
70 virtual EvtVector4C epsParentPhoton( int i ) const;
71
75 virtual EvtVector4C epsPhoton( int i ) const;
76
80 virtual EvtDiracSpinor spParent( int ) const;
81
85 virtual EvtDiracSpinor sp( int ) const;
86
90 virtual EvtDiracSpinor spParentNeutrino() const;
91
96 virtual EvtDiracSpinor spNeutrino() const;
97
101 virtual EvtTensor4C epsTensorParent( int i ) const;
102
106 virtual EvtTensor4C epsTensor( int i ) const;
107
112 virtual EvtRaritaSchwinger spRSParent( int ) const;
113
118 virtual EvtRaritaSchwinger spRS( int ) const;
119
123 virtual void init( EvtId part_n, const EvtVector4R& p4 ) = 0;
124
128 void addDaug( EvtParticle* node );
129
133 void decay();
134
138 void deleteTree();
139 void deleteDaughters( bool keepChannel = false );
140
144 void setChannel( int i );
145
151 void makeDaughters( size_t ndaug, const EvtId* id );
152
158 void makeDaughters( size_t ndaug, const std::vector<EvtId> idVector );
159
165 double initializePhaseSpace( size_t numdaughter, const EvtId* daughters,
166 bool forceResetMasses = false,
167 double poleSize = -1., int whichTwo1 = 0,
168 int whichTwo2 = 1 );
169
173 EvtParticle* getDaug( const int i ) { return m_daug[i]; }
174
178 const EvtParticle* getDaug( const int i ) const { return m_daug[i]; }
179
183 EvtParticle* nextIter( EvtParticle* rootOfTree = nullptr );
184
188 void makeStdHep( EvtStdHep& stdhep, EvtSecondary& secondary,
189 EvtId* stable_parent_ihep );
190 void makeStdHep( EvtStdHep& stdhep );
191
196 EvtVector4R getP4Lab() const;
197
204
210
214 EvtVector4R get4Pos() const;
215
219 EvtParticle* getParent() const;
220
224 void insertDaugPtr( int idaug, EvtParticle* partptr )
225 {
226 m_daug[idaug] = partptr;
227 partptr->m_parent = this;
228 }
229
232 double mass() const;
233
237 int firstornot() const;
238 void setFirstOrNot();
239 void resetFirstOrNot();
240
244 EvtId getId() const;
245
249
250 int getPDGId() const;
251
255
257
261 int getSpinStates() const;
262
266 const EvtVector4R& getP4() const;
267
271 void setP4( const EvtVector4R& p4 )
272 {
273 m_p = p4;
274 m_pBeforeFSR = p4;
275 }
276
277 void setP4WithFSR( const EvtVector4R& p4 ) { m_p = p4; }
278
279 void setFSRP4toZero() { m_pBeforeFSR.set( 0.0, 0.0, 0.0, 0.0 ); }
280
284 int getChannel() const;
285
289 size_t getNDaug() const;
291 {
292 m_ndaug = 0;
293 return;
294 }
295
301 void printTree() const;
302
303 void printTreeRec( unsigned int level ) const;
304
305 std::string treeStr() const;
306 std::string treeStrRec( unsigned int level ) const;
307
311 void printParticle() const;
312
316 void setLifetime( double tau );
317
321 void setLifetime();
322
326 double getLifetime() const;
327
332
337
342 {
343 m_rhoForward = rho;
344 }
345
352 double alpha, double beta,
353 double gamma );
354
362 virtual EvtSpinDensity rotateToHelicityBasis( double alpha, double beta,
363 double gamma ) const = 0;
364
369
374 {
375 m_rhoBackward = rho;
376 }
377
382
383 //Hacks will be removed when better solutions are thought of!
384 //This is used to suppress use of random numbers when doing initialization
385 //of some models.
386 void noLifeTime() { m_genlifetime = 0; }
387
388 //lange - April 29, 2002
389 void setId( EvtId id ) { m_id = id; }
390 void initDecay( bool useMinMass = false );
391 bool generateMassTree();
392
393 double compMassProb();
394
395 //setMass will blow away any existing 4vector
396 void setMass( double m ) { m_p = EvtVector4R( m, 0.0, 0.0, 0.0 ); }
397
398 //void setMixed() {m_mix=true;}
399 //void setUnMixed() {m_mix=false;}
400 //bool getMixed() {return m_mix;}
401
402 //void takeCConj() {EvtGenReport(EVTGEN_INFO,"EvtGen") << "should take conj\n";}
403
404 //this means that the particle has gone through initDecay
405 // and thus has a mass
406 bool isInitialized() { return m_isInit; }
407 bool hasValidP4() { return m_validP4; }
408 bool isDecayed() { return m_isDecayed; }
409
410 // decay prob - only relevent if already decayed
411 // and is a scalar particle
412 // returned is a double* that should be prob/probMax
413 // FIXME - this should probably be changed to std::optional
414 const double* decayProb() const { return m_decayProb; }
415 void setDecayProb( double p );
416
417 // Return the name of the particle (from the EvtId number)
418 std::string getName() const;
419
420 // Specify whether the particle has a special named attribute with
421 // a set value. By default, nothing is set, but derived classes
422 // can set this to mean something specific, e.g. if a photon is FSR
423 void setAttribute( std::string attName, int attValue )
424 {
425 m_intAttributes[attName] = attValue;
426 }
427
428 // Retrieve the integer value for the given attribute name
429 int getAttribute( std::string attName ) const;
430
431 // Specify if the particle has a double attribute value, e.g. amplitude weight.
432 // By default, nothing is set, but derived classes can set this to mean something specific
433 void setAttributeDouble( std::string attName, double attValue )
434 {
435 m_dblAttributes[attName] = attValue;
436 }
437
438 // Retrieve the double value for the given attribute name
439 double getAttributeDouble( std::string attName ) const;
440
441 protected:
442 void setp( double e, double px, double py, double pz )
443 {
444 m_p.set( e, px, py, pz );
446 }
447
448 void setp( const EvtVector4R& p4 )
449 {
450 m_p = p4;
452 }
453
454 void setpart_num( EvtId particle_number )
455 {
456 assert( m_channel == -10 || m_id.getId() == particle_number.getId() ||
457 m_id.getId() == -1 );
458 m_id = particle_number;
459 }
461
462 // A typedef to define the attribute (name, integer) map
463 typedef std::map<std::string, int> EvtAttIntMap;
465
466 // A typedef to define the attribute (name, double) map
467 typedef std::map<std::string, double> EvtAttDblMap;
469
470 private:
472 size_t m_ndaug;
479 double m_t;
482
483 //bool m_mix;
484
487
488 void makeStdHepRec( int firstparent, int lastparent, EvtStdHep& stdhep,
489 EvtSecondary& secondary, EvtId* stable_parent_ihep );
490 void makeStdHepRec( int firstparent, int lastparent, EvtStdHep& stdhep );
491
492 //This is a hack until things gets straightened out. (Ryd)
494
495 //should never be used, therefor is private.
496 //these does _not_ have an implementation
499
500 double* m_decayProb;
501};
502
503#endif
const int MAX_LEVEL
const int MAX_DAUG
const int MAX_TRIES
Definition EvtId.hh:27
int getId() const
Definition EvtId.hh:41
void noLifeTime()
void setMass(double m)
void setSpinDensityBackward(const EvtSpinDensity &rho)
void setSpinDensityForwardHelicityBasis(const EvtSpinDensity &rho)
void setSpinDensityForward(const EvtSpinDensity &rho)
std::map< std::string, int > EvtAttIntMap
void setDecayProb(double p)
virtual ~EvtParticle()
virtual EvtVector4C epsParent(int i) const
EvtAttIntMap m_intAttributes
double getAttributeDouble(std::string attName) const
void initDecay(bool useMinMass=false)
virtual void init(EvtId part_n, const EvtVector4R &p4)=0
void resetNDaug()
void insertDaugPtr(int idaug, EvtParticle *partptr)
virtual EvtTensor4C epsTensorParent(int i) const
double initializePhaseSpace(size_t numdaughter, const EvtId *daughters, bool forceResetMasses=false, double poleSize=-1., int whichTwo1=0, int whichTwo2=1)
EvtVector4R m_p
std::string treeStrRec(unsigned int level) const
EvtId getId() const
virtual EvtRaritaSchwinger spRSParent(int) const
EvtVector4R getP4Restframe() const
void printTreeRec(unsigned int level) const
void setAttribute(std::string attName, int attValue)
virtual EvtDiracSpinor spParentNeutrino() const
virtual EvtDiracSpinor spParent(int) const
void setVectorSpinDensity()
bool hasValidP4()
bool isDecayed()
EvtVector4R getP4LabBeforeFSR() const
void printParticle() const
virtual EvtDiracSpinor spNeutrino() const
EvtVector4R m_pBeforeFSR
EvtParticle & operator=(const EvtParticle &p)
virtual EvtSpinDensity rotateToHelicityBasis(double alpha, double beta, double gamma) const =0
virtual EvtRaritaSchwinger spRS(int) const
int getSpinStates() const
int getPDGId() const
void setLifetime()
const EvtParticle * getDaug(const int i) const
void setDiagonalSpinDensity()
double compMassProb()
EvtSpinType::spintype getSpinType() const
void setChannel(int i)
const EvtVector4R & getP4() const
EvtParticle * nextIter(EvtParticle *rootOfTree=nullptr)
void setp(double e, double px, double py, double pz)
void printTree() const
virtual EvtSpinDensity rotateToHelicityBasis() const =0
std::map< std::string, double > EvtAttDblMap
EvtAttDblMap m_dblAttributes
void setP4(const EvtVector4R &p4)
void resetFirstOrNot()
std::string getName() const
EvtParticle * getDaug(const int i)
bool isInitialized()
void deleteDaughters(bool keepChannel=false)
double getLifetime() const
double * m_decayProb
double mass() const
void setP4WithFSR(const EvtVector4R &p4)
virtual EvtDiracSpinor sp(int) const
void setAttributeDouble(std::string attName, double attValue)
virtual EvtVector4C epsPhoton(int i) const
virtual EvtVector4C epsParentPhoton(int i) const
EvtParticle * m_daug[MAX_DAUG]
void setp(const EvtVector4R &p4)
void makeStdHep(EvtStdHep &stdhep, EvtSecondary &secondary, EvtId *stable_parent_ihep)
size_t getNDaug() const
EvtSpinDensity m_rhoForward
int firstornot() const
EvtSpinDensity getSpinDensityBackward()
EvtSpinDensity m_rhoBackward
EvtVector4R getP4Lab() const
EvtParticle * m_parent
virtual EvtVector4C eps(int i) const
void addDaug(EvtParticle *node)
EvtParticle(const EvtParticle &p)
std::string treeStr() const
bool generateMassTree()
void setpart_num(EvtId particle_number)
int getChannel() const
void setFSRP4toZero()
virtual EvtTensor4C epsTensor(int i) const
void setId(EvtId id)
EvtVector4R get4Pos() const
void makeStdHepRec(int firstparent, int lastparent, EvtStdHep &stdhep, EvtSecondary &secondary, EvtId *stable_parent_ihep)
EvtParticle * getParent() const
void setFirstOrNot()
void makeDaughters(size_t ndaug, const EvtId *id)
const double * decayProb() const
EvtSpinDensity getSpinDensityForward()
int getAttribute(std::string attName) const
void deleteTree()