evtgen is hosted by Hepforge, IPPP Durham
EvtGen  2.0.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
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 <iostream.h>
25 #include "EvtGenBase/EvtId.hh"
29 
30 #include <assert.h>
31 #include <map>
32 #include <string>
33 #include <vector>
34 
35 class EvtDiracSpinor;
36 class EvtVector4C;
37 class EvtTensor4C;
38 class EvtStdHep;
39 class EvtSecondary;
40 class EvtRaritaSchwinger;
41 
42 const int MAX_DAUG = 100;
43 const int MAX_LEVEL = 10;
44 const int MAX_TRIES = 10000;
45 
46 class EvtParticle {
47  public:
51  EvtParticle();
52 
56  virtual ~EvtParticle();
57 
61  virtual EvtVector4C epsParent( int i ) const;
62 
66  virtual EvtVector4C eps( int i ) const;
67 
71  virtual EvtVector4C epsParentPhoton( int i );
72 
76  virtual EvtVector4C epsPhoton( int i );
77 
81  virtual EvtDiracSpinor spParent( int ) const;
82 
86  virtual EvtDiracSpinor sp( int ) const;
87 
91  virtual EvtDiracSpinor spParentNeutrino() const;
92 
97  virtual EvtDiracSpinor spNeutrino() const;
98 
102  virtual EvtTensor4C epsTensorParent( int i ) const;
103 
107  virtual EvtTensor4C epsTensor( int i ) const;
108 
113  virtual EvtRaritaSchwinger spRSParent( int ) const;
114 
119  virtual EvtRaritaSchwinger spRS( int ) const;
120 
124  virtual void init( EvtId part_n, const EvtVector4R& p4 ) = 0;
125 
129  void addDaug( EvtParticle* node );
130 
134  void decay();
135 
139  void deleteTree();
140  void deleteDaughters( bool keepChannel = false );
141 
145  void setChannel( int i );
146 
152  void makeDaughters( unsigned int ndaug, EvtId* id );
153 
159  void makeDaughters( unsigned int ndaug, std::vector<EvtId> idVector );
160 
166  double initializePhaseSpace( unsigned int numdaughter, EvtId* daughters,
167  bool forceResetMasses = false,
168  double poleSize = -1., int whichTwo1 = 0,
169  int whichTwo2 = 1 );
170 
174  EvtParticle* getDaug( int i );
175 
179  EvtParticle* nextIter( EvtParticle* rootOfTree = 0 );
180 
184  void makeStdHep( EvtStdHep& stdhep, EvtSecondary& secondary,
185  EvtId* stable_parent_ihep );
186  void makeStdHep( EvtStdHep& stdhep );
187 
192  EvtVector4R getP4Lab() const;
193 
200 
205  EvtVector4R getP4Restframe() const;
206 
210  EvtVector4R get4Pos() const;
211 
215  EvtParticle* getParent() const;
216 
220  void insertDaugPtr( int idaug, EvtParticle* partptr )
221  {
222  _daug[idaug] = partptr;
223  partptr->_parent = this;
224  }
228  double mass() const;
229 
233  int firstornot() const;
234  void setFirstOrNot();
235  void resetFirstOrNot();
236 
240  EvtId getId() const;
241 
246  int getPDGId() const;
247 
253 
257  int getSpinStates() const;
258 
262  const EvtVector4R& getP4() const;
263 
267  void setP4( const EvtVector4R& p4 )
268  {
269  _p = p4;
270  _pBeforeFSR = p4;
271  }
272 
273  void setP4WithFSR( const EvtVector4R& p4 ) { _p = p4; }
274 
275  void setFSRP4toZero() { _pBeforeFSR.set( 0.0, 0.0, 0.0, 0.0 ); }
276 
280  int getChannel() const;
281 
285  size_t getNDaug() const;
286  void resetNDaug()
287  {
288  _ndaug = 0;
289  return;
290  }
291 
297  void printTree() const;
298 
299  void printTreeRec( unsigned int level ) const;
300 
301  std::string treeStr() const;
302  std::string treeStrRec( unsigned int level ) const;
303 
307  void printParticle() const;
308 
312  void setLifetime( double tau );
313 
317  void setLifetime();
318 
322  double getLifetime();
323 
327  void setDiagonalSpinDensity();
328 
332  void setVectorSpinDensity();
333 
338  {
339  _rhoForward = rho;
340  }
341 
348  double alpha, double beta,
349  double gamma );
350 
357  virtual EvtSpinDensity rotateToHelicityBasis() const = 0;
358  virtual EvtSpinDensity rotateToHelicityBasis( double alpha, double beta,
359  double gamma ) const = 0;
360 
365 
370  {
371  _rhoBackward = rho;
372  }
373 
378 
379  //Hacks will be removed when better solutions are thought of!
380  //This is used to suppress use of random numbers when doing initialization
381  //of some models.
382  void noLifeTime() { _genlifetime = 0; }
383 
384  //lange - April 29, 2002
385  void setId( EvtId id ) { _id = id; }
386  void initDecay( bool useMinMass = false );
387  bool generateMassTree();
388 
389  double compMassProb();
390 
391  //setMass will blow away any existing 4vector
392  void setMass( double m ) { _p = EvtVector4R( m, 0.0, 0.0, 0.0 ); }
393 
394  //void setMixed() {_mix=true;}
395  //void setUnMixed() {_mix=false;}
396  //bool getMixed() {return _mix;}
397 
398  //void takeCConj() {EvtGenReport(EVTGEN_INFO,"EvtGen") << "should take conj\n";}
399 
400  //this means that the particle has gone through initDecay
401  // and thus has a mass
402  bool isInitialized() { return _isInit; }
403  bool hasValidP4() { return _validP4; }
404  bool isDecayed() { return _isDecayed; }
405 
406  // decay prob - only relevent if already decayed
407  // and is a scalar particle
408  // returned is a double* that should be prob/probMax
409  double* decayProb() { return _decayProb; }
410  void setDecayProb( double p );
411 
412  // Return the name of the particle (from the EvtId number)
413  std::string getName();
414 
415  // Specify whether the particle has a special named attribute with
416  // a set value. By default, nothing is set, but derived classes
417  // can set this to mean something specific, e.g. if a photon is FSR
418  void setAttribute( std::string attName, int attValue )
419  {
420  _intAttributes[attName] = attValue;
421  }
422 
423  // Retrieve the integer value for the given attribute name
424  int getAttribute( std::string attName );
425 
426  // Specify if the particle has a double attribute value, e.g. amplitude weight.
427  // By default, nothing is set, but derived classes can set this to mean something specific
428  void setAttributeDouble( std::string attName, double attValue )
429  {
430  _dblAttributes[attName] = attValue;
431  }
432 
433  // Retrieve the double value for the given attribute name
434  double getAttributeDouble( std::string attName );
435 
436  protected:
437  void setp( double e, double px, double py, double pz )
438  {
439  _p.set( e, px, py, pz );
440  _pBeforeFSR = _p;
441  }
442 
443  void setp( const EvtVector4R& p4 )
444  {
445  _p = p4;
446  _pBeforeFSR = _p;
447  }
448 
449  void setpart_num( EvtId particle_number )
450  {
451  assert( _channel == -10 || _id.getId() == particle_number.getId() ||
452  _id.getId() == -1 );
453  _id = particle_number;
454  }
455  bool _validP4;
456 
457  // A typedef to define the attribute (name, integer) map
458  typedef std::map<std::string, int> EvtAttIntMap;
460 
461  // A typedef to define the attribute (name, double) map
462  typedef std::map<std::string, double> EvtAttDblMap;
464 
465  private:
467  size_t _ndaug;
469  int _channel;
470  int _first;
474  double _t;
475  bool _isInit;
477 
478  //bool _mix;
479 
482 
483  void makeStdHepRec( int firstparent, int lastparent, EvtStdHep& stdhep,
484  EvtSecondary& secondary, EvtId* stable_parent_ihep );
485  void makeStdHepRec( int firstparent, int lastparent, EvtStdHep& stdhep );
486 
487  //This is a hack until things gets straightened out. (Ryd)
489 
490  //should never be used, therefor is private.
491  //these does _not_ have an implementation
492  EvtParticle& operator=( const EvtParticle& p );
493  EvtParticle( const EvtParticle& p );
494 
495  double* _decayProb;
496 };
497 
498 #endif
virtual EvtTensor4C epsTensorParent(int i) const
virtual EvtVector4C epsPhoton(int i)
void setMass(double m)
Definition: EvtParticle.hh:392
const int MAX_LEVEL
Definition: EvtParticle.hh:43
double compMassProb()
void setChannel(int i)
Definition: EvtParticle.cpp:86
EvtSpinDensity _rhoForward
Definition: EvtParticle.hh:480
size_t _ndaug
Definition: EvtParticle.hh:467
void setAttribute(std::string attName, int attValue)
Definition: EvtParticle.hh:418
bool isInitialized()
Definition: EvtParticle.hh:402
EvtSpinDensity getSpinDensityForward()
Definition: EvtParticle.hh:364
void printTreeRec(unsigned int level) const
void setFSRP4toZero()
Definition: EvtParticle.hh:275
void resetFirstOrNot()
Definition: EvtParticle.cpp:81
virtual EvtRaritaSchwinger spRSParent(int) const
void printParticle() const
void setSpinDensityForward(const EvtSpinDensity &rho)
Definition: EvtParticle.hh:337
void setDecayProb(double p)
virtual EvtVector4C eps(int i) const
std::string treeStr() const
virtual EvtDiracSpinor sp(int) const
EvtParticle * getParent() const
Definition: EvtParticle.cpp:96
void setSpinDensityBackward(const EvtSpinDensity &rho)
Definition: EvtParticle.hh:369
std::string getName()
EvtSpinType::spintype getSpinType() const
void setAttributeDouble(std::string attName, double attValue)
Definition: EvtParticle.hh:428
void makeStdHepRec(int firstparent, int lastparent, EvtStdHep &stdhep, EvtSecondary &secondary, EvtId *stable_parent_ihep)
EvtVector4R getP4Lab() const
std::string treeStrRec(unsigned int level) const
virtual EvtRaritaSchwinger spRS(int) const
virtual void init(EvtId part_n, const EvtVector4R &p4)=0
EvtAttIntMap _intAttributes
Definition: EvtParticle.hh:459
void initDecay(bool useMinMass=false)
void insertDaugPtr(int idaug, EvtParticle *partptr)
Definition: EvtParticle.hh:220
std::map< std::string, double > EvtAttDblMap
Definition: EvtParticle.hh:462
EvtAttDblMap _dblAttributes
Definition: EvtParticle.hh:463
double * _decayProb
Definition: EvtParticle.hh:495
EvtSpinDensity getSpinDensityBackward()
Definition: EvtParticle.hh:377
int getSpinStates() const
virtual EvtVector4C epsParentPhoton(int i)
EvtId getId() const
void makeDaughters(unsigned int ndaug, EvtId *id)
EvtVector4R get4Pos() const
void set(int i, double d)
Definition: EvtVector4R.hh:167
const int MAX_TRIES
Definition: EvtParticle.hh:44
void resetNDaug()
Definition: EvtParticle.hh:286
virtual EvtDiracSpinor spParent(int) const
bool hasValidP4()
Definition: EvtParticle.hh:403
EvtParticle * _parent
Definition: EvtParticle.hh:468
Definition: EvtId.hh:27
size_t getNDaug() const
EvtVector4R _p
Definition: EvtParticle.hh:472
EvtVector4R getP4LabBeforeFSR()
bool generateMassTree()
void printTree() const
void setp(double e, double px, double py, double pz)
Definition: EvtParticle.hh:437
int getAttribute(std::string attName)
void setId(EvtId id)
Definition: EvtParticle.hh:385
EvtVector4R _pBeforeFSR
Definition: EvtParticle.hh:473
double initializePhaseSpace(unsigned int numdaughter, EvtId *daughters, bool forceResetMasses=false, double poleSize=-1., int whichTwo1=0, int whichTwo2=1)
void deleteTree()
virtual EvtVector4C epsParent(int i) const
virtual EvtSpinDensity rotateToHelicityBasis() const =0
void deleteDaughters(bool keepChannel=false)
bool isDecayed()
Definition: EvtParticle.hh:404
EvtParticle * nextIter(EvtParticle *rootOfTree=0)
void setLifetime()
void addDaug(EvtParticle *node)
void setP4(const EvtVector4R &p4)
Definition: EvtParticle.hh:267
void setp(const EvtVector4R &p4)
Definition: EvtParticle.hh:443
void setP4WithFSR(const EvtVector4R &p4)
Definition: EvtParticle.hh:273
const EvtVector4R & getP4() const
int getChannel() const
double mass() const
virtual EvtTensor4C epsTensor(int i) const
int getId() const
Definition: EvtId.hh:42
void setSpinDensityForwardHelicityBasis(const EvtSpinDensity &rho)
virtual EvtDiracSpinor spParentNeutrino() const
int firstornot() const
virtual EvtDiracSpinor spNeutrino() const
int getPDGId() const
const int MAX_DAUG
Definition: EvtParticle.hh:42
std::map< std::string, int > EvtAttIntMap
Definition: EvtParticle.hh:458
EvtSpinDensity _rhoBackward
Definition: EvtParticle.hh:481
double getLifetime()
double getAttributeDouble(std::string attName)
void setDiagonalSpinDensity()
EvtParticle * getDaug(int i)
Definition: EvtParticle.cpp:91
EvtParticle & operator=(const EvtParticle &p)
void noLifeTime()
Definition: EvtParticle.hh:382
double * decayProb()
Definition: EvtParticle.hh:409
void makeStdHep(EvtStdHep &stdhep, EvtSecondary &secondary, EvtId *stable_parent_ihep)
EvtParticle * _daug[MAX_DAUG]
Definition: EvtParticle.hh:466
EvtVector4R getP4Restframe() const
void setFirstOrNot()
Definition: EvtParticle.cpp:77
void setpart_num(EvtId particle_number)
Definition: EvtParticle.hh:449
void setVectorSpinDensity()
virtual ~EvtParticle()
Definition: EvtParticle.cpp:55