1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15 ///////////////////////////////////////////////////////////////////////////
16 // Implementation of AliDecayer using EvtGen package. //
18 // Giuseppe E. Bruno & Fiorella Fionda //
19 // (Giuseppe.Bruno@ba.infn.it) (Fiorella.Fionda@ba.infn.it) //
20 ///////////////////////////////////////////////////////////////////////////
23 #include <TDatabasePDG.h>
24 #include <TParticle.h>
25 #include <TClonesArray.h>
26 #include <TLorentzVector.h>
28 #include "EvtGenBase/EvtStdHep.hh"
29 #include "EvtGenBase/EvtRandomEngine.hh"
30 #include "EvtGen/EvtGen.hh"
31 #include "EvtGenBase/EvtParticle.hh"
32 #include "EvtGenBase/EvtPDL.hh"
33 #include "EvtGenBase/EvtParticleFactory.hh"
34 #include "AliDecayerEvtGen.h"
37 ClassImp(AliDecayerEvtGen)
38 //____________________________________________________________
39 AliDecayerEvtGen::AliDecayerEvtGen():
44 fParticleTablePath(0x0),
47 // Default constructor
48 fEvtstdhep = new EvtStdHep();
49 fDecayTablePath = gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DECAY.DEC"); //default decay table
50 fParticleTablePath = gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/evt.pdl"); //particle table
52 //_________________________________________________________________
53 AliDecayerEvtGen::AliDecayerEvtGen(const AliDecayerEvtGen &decayer):
55 fRandomEngine(decayer.fRandomEngine),
56 fGenerator(decayer.fGenerator),
57 fEvtstdhep(decayer.fEvtstdhep),
58 fDecayTablePath(decayer.fDecayTablePath),
59 fParticleTablePath(decayer.fParticleTablePath),
60 fDecay(decayer.fDecay)
65 //____________________________________________________________
66 AliDecayerEvtGen::~AliDecayerEvtGen()
69 if(fRandomEngine) {delete fRandomEngine;}
71 if(fGenerator) {delete fGenerator;}
73 if(fEvtstdhep) {delete fEvtstdhep;}
75 if(fDecayTablePath) {delete fDecayTablePath;}
77 if(fParticleTablePath) {delete fParticleTablePath;}
78 fParticleTablePath = 0;
81 //___________________________________________________________
82 void AliDecayerEvtGen::Init()
84 //Standard AliDecayerEvtGen initializer:
85 //initialize EvtGen with default decay table (DECAY.DEC), particle table (evt.pdl)
86 //and fRandomEngine for generation of random numbers
89 AliWarning(" AliDecayerEvtGen already initialized!!!!\n");
92 fRandomEngine=new EvtNUMRandomEngine();
93 fGenerator=new EvtGen(fDecayTablePath,fParticleTablePath,fRandomEngine);
95 //____________________________________________________________
96 void AliDecayerEvtGen::Decay(Int_t ipart, TLorentzVector *p)
100 //input: pdg code and momentum of the particle to be decayed
101 //all informations about decay products are stored in fEvtstdhep
103 EvtId IPART=EvtPDL::evtIdFromStdHep(ipart);
104 EvtVector4R p_init(p->E(),p->Px(),p->Py(),p->Pz());
105 EvtParticle *froot_part=EvtParticleFactory::particleFactory(IPART,p_init);
106 fGenerator->generateDecay(froot_part);
108 froot_part->makeStdHep(*fEvtstdhep);
109 //froot_part->printTree(); //to print the decay chain
110 froot_part->deleteTree();
113 //____________________________________________________________
114 Int_t AliDecayerEvtGen::ImportParticles(TClonesArray *particles)
117 //Input: pointer to a TClonesArray - Output(Int_t): number of decay products
118 //Put all the informations about the decay products in the
119 //TClonesArray particles
121 if (particles == 0) return 0;
122 TClonesArray &clonesParticles = *particles;
123 clonesParticles.Clear();
132 Int_t npart=fEvtstdhep->getNPart();
133 for(int i=0;i<fEvtstdhep->getNPart();i++){
135 int jmotherfirst=fEvtstdhep->getFirstMother(i)+1;
136 int jmotherlast=fEvtstdhep->getLastMother(i)+1;
137 int jdaugfirst=fEvtstdhep->getFirstDaughter(i)+1;
138 int jdauglast=fEvtstdhep->getLastDaughter(i)+1;
140 partnum=fEvtstdhep->getStdHepID(i);
142 //verify if all particles of decay chain are in the TDatabasePDG
143 TParticlePDG *partPDG = TDatabasePDG::Instance()->GetParticle(partnum);
146 AliWarning("Particle code non known in TDatabasePDG - set pdg = 89");
147 partnum=89; //internal use for unspecified resonance data
150 istat=fEvtstdhep->getIStat(i);
152 if(istat!=1 && istat!=2) Info("ImportParticles","Attention: unknown status code!");
153 if(istat == 2) istat = 11; //status decayed
155 p4=fEvtstdhep->getP4(i);
156 x4=fEvtstdhep->getX4(i);
161 const Float_t kconvT=0.001/2.999792458e8; // mm/c to seconds conversion
162 const Float_t kconvL=1./10; // mm to cm conversion
163 x=x4.get(1)*kconvL;//[cm]
164 y=x4.get(2)*kconvL;//[cm]
165 z=x4.get(3)*kconvL;//[cm]
166 t=x4.get(0)*kconvT;//[s]
168 AliDebug(1,Form("partnum = %d istat = %d primaMadre = %d ultimaMadre = %d primaF = %d ultimaF=%d x=%f y=%f z=%f t=%f e=%f px=%f \n",partnum,istat,jmotherfirst,jmotherlast,jdaugfirst,jdauglast,x,y,z,t,e,px));
170 new(clonesParticles[i]) TParticle(partnum,istat,jmotherfirst,-1,jdaugfirst,jdauglast,px,py,pz,e,x,y,z,t);
172 //set polarization!!!
179 void AliDecayerEvtGen::Copy(TObject &) const
182 // Copy *this onto AliDecayerEvtGen -- not implemented
184 Fatal("Copy","Not implemented!\n");
187 void AliDecayerEvtGen::ForceDecay()
190 // Intupt: none - Output: none
191 // Set the decay mode to decay particles: for each case is read a
192 // different decay table. case kAll read the default decay table only
194 Decay_t decay = fDecay;
199 case kBJpsiDiElectron:
200 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/BTOJPSITOELE.DEC"));
203 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/BTOJPSI.DEC"));
206 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/BTOJPSITOMU.DEC"));
208 case kBSemiElectronic:
209 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/BTOELE.DEC"));
212 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/BTOD.DEC"));
215 case kChiToJpsiGammaToMuonMuon:
216 case kChiToJpsiGammaToElectronElectron:
220 case kSemiElectronic:
222 case kBPsiPrimeDiMuon:
228 case kWToCharmToMuon:
231 case kHadronicDWithout4Bodies:
238 case kBPsiPrimeDiElectron:
240 case kBJpsiUndecayed:
246 case kPsiPrimeJpsiDiElectron:
247 AliWarning(Form("Warning: case %d not implemented for this class!",(int)decay));
253 Float_t AliDecayerEvtGen::GetPartialBranchingRatio(Int_t)
255 // This method is dummy
259 Float_t AliDecayerEvtGen::GetLifetime(Int_t kf)
262 //Input: pdg code of a particle
263 //return lifetime in sec for a particle with particle code kf
265 EvtId IdPart=EvtPDL::evtIdFromStdHep(kf);
266 Double_t lifetime = EvtPDL::getctau(IdPart); //c*tau (mm)
267 AliDebug(1,Form("lifetime is %f (mum) , particle id= %d",lifetime*1000,kf));
268 return lifetime*kconv; //tau (sec)
271 void AliDecayerEvtGen::ReadDecayTable()
273 //Input none - Output none
274 //Read the decay table that correspond to the path
277 TString temp = fDecayTablePath;
278 if(!temp.EndsWith("DECAY.DEC"))
279 fGenerator->readUDecay(fDecayTablePath);
281 ////////////////////////////////////////////////////////////
282 Bool_t AliDecayerEvtGen::SetDecayTablePath(Char_t *path)
285 //Set the path of the decay table read to force particle decays
287 if(gSystem->AccessPathName(path))
289 AliWarning("Attention: This path not exist!\n");
292 fDecayTablePath = path;