Fix bug in building local list of valid files.
[u/mrichter/AliRoot.git] / TEvtGen / AliDecayerEvtGen.cxx
CommitLineData
da0e9ce3 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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. //
17// //
18// Giuseppe E. Bruno & Fiorella Fionda //
19// (Giuseppe.Bruno@ba.infn.it) (Fiorella.Fionda@ba.infn.it) //
20///////////////////////////////////////////////////////////////////////////
21
22#include <TSystem.h>
23#include <TDatabasePDG.h>
24#include <TParticle.h>
25#include <TClonesArray.h>
26#include <TLorentzVector.h>
27
28#include "EvtGenBase/EvtStdHep.hh"
29#include "EvtGenBase/EvtRandomEngine.hh"
0ca57c2f 30#include "EvtGenBase/EvtStdlibRandomEngine.hh"
da0e9ce3 31#include "EvtGen/EvtGen.hh"
32#include "EvtGenBase/EvtParticle.hh"
33#include "EvtGenBase/EvtPDL.hh"
34#include "EvtGenBase/EvtParticleFactory.hh"
35#include "AliDecayerEvtGen.h"
0ca57c2f 36#include "EvtGenExternal/EvtExternalGenList.hh"
37#include "EvtGenBase/EvtAbsRadCorr.hh"
da0e9ce3 38#include "AliLog.h"
39
40ClassImp(AliDecayerEvtGen)
41//____________________________________________________________
42AliDecayerEvtGen::AliDecayerEvtGen():
43 fRandomEngine(0x0),
0ca57c2f 44 fRadCorrEngine(0x0),
da0e9ce3 45 fGenerator(0x0),
46 fEvtstdhep(0x0),
47 fDecayTablePath(0x0),
48 fParticleTablePath(0x0),
49 fDecay(kAll)
50 {
51 // Default constructor
52 fEvtstdhep = new EvtStdHep();
53 fDecayTablePath = gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DECAY.DEC"); //default decay table
54 fParticleTablePath = gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/evt.pdl"); //particle table
55 }
56//_________________________________________________________________
57AliDecayerEvtGen::AliDecayerEvtGen(const AliDecayerEvtGen &decayer):
58 AliDecayer(decayer),
59 fRandomEngine(decayer.fRandomEngine),
60 fGenerator(decayer.fGenerator),
61 fEvtstdhep(decayer.fEvtstdhep),
62 fDecayTablePath(decayer.fDecayTablePath),
63 fParticleTablePath(decayer.fParticleTablePath),
64 fDecay(decayer.fDecay)
65 {
66 // Copy Constructor
67 decayer.Copy(*this);
68 }
69//____________________________________________________________
70AliDecayerEvtGen::~AliDecayerEvtGen()
71 {
72 // Destructor
73 if(fRandomEngine) {delete fRandomEngine;}
74 fRandomEngine = 0;
0ca57c2f 75 if(fRadCorrEngine) {delete fRadCorrEngine;}
76 fRadCorrEngine = 0;
da0e9ce3 77 if(fGenerator) {delete fGenerator;}
78 fGenerator = 0;
79 if(fEvtstdhep) {delete fEvtstdhep;}
80 fEvtstdhep = 0;
81 if(fDecayTablePath) {delete fDecayTablePath;}
82 fDecayTablePath = 0;
83 if(fParticleTablePath) {delete fParticleTablePath;}
84 fParticleTablePath = 0;
85 }
86
87//___________________________________________________________
88void AliDecayerEvtGen::Init()
89 {
90 //Standard AliDecayerEvtGen initializer:
91 //initialize EvtGen with default decay table (DECAY.DEC), particle table (evt.pdl)
92 //and fRandomEngine for generation of random numbers
93 //
94 if(fGenerator){
95 AliWarning(" AliDecayerEvtGen already initialized!!!!\n");
96 return;
97 }
0ca57c2f 98 fRandomEngine = new EvtStdlibRandomEngine();
99 std::list<EvtDecayBase*> extraModels;
100
101 EvtExternalGenList genList;
102 fRadCorrEngine = genList.getPhotosModel();
103 extraModels = genList.getListOfModels();
104
105 fGenerator=new EvtGen(fDecayTablePath,fParticleTablePath,fRandomEngine,fRadCorrEngine,&extraModels);
da0e9ce3 106 }
107//____________________________________________________________
108void AliDecayerEvtGen::Decay(Int_t ipart, TLorentzVector *p)
109 {
110 //
111 //Decay a particle
112 //input: pdg code and momentum of the particle to be decayed
113 //all informations about decay products are stored in fEvtstdhep
114 //
115 EvtId IPART=EvtPDL::evtIdFromStdHep(ipart);
34dbffe9 116 EvtVector4R p_init(p->E(),p->Px(),p->Py(),p->Pz());
da0e9ce3 117 EvtParticle *froot_part=EvtParticleFactory::particleFactory(IPART,p_init);
118 fGenerator->generateDecay(froot_part);
119 fEvtstdhep->init();
120 froot_part->makeStdHep(*fEvtstdhep);
0ca57c2f 121 froot_part->printTree(); //to print the decay chain
da0e9ce3 122 froot_part->deleteTree();
123 }
124
125//____________________________________________________________
126Int_t AliDecayerEvtGen::ImportParticles(TClonesArray *particles)
127 {
128 //
129 //Input: pointer to a TClonesArray - Output(Int_t): number of decay products
130 //Put all the informations about the decay products in the
131 //TClonesArray particles
132 //
133 if (particles == 0) return 0;
134 TClonesArray &clonesParticles = *particles;
135 clonesParticles.Clear();
136
137 int j;
138 int istat;
139 int partnum;
140 double px,py,pz,e;
141 double x,y,z,t;
142 EvtVector4R p4,x4;
143
144 Int_t npart=fEvtstdhep->getNPart();
145 for(int i=0;i<fEvtstdhep->getNPart();i++){
146 j=i+1;
147 int jmotherfirst=fEvtstdhep->getFirstMother(i)+1;
148 int jmotherlast=fEvtstdhep->getLastMother(i)+1;
149 int jdaugfirst=fEvtstdhep->getFirstDaughter(i)+1;
150 int jdauglast=fEvtstdhep->getLastDaughter(i)+1;
151
152 partnum=fEvtstdhep->getStdHepID(i);
153
154 //verify if all particles of decay chain are in the TDatabasePDG
155 TParticlePDG *partPDG = TDatabasePDG::Instance()->GetParticle(partnum);
156 if(!partPDG)
157 {
158 AliWarning("Particle code non known in TDatabasePDG - set pdg = 89");
159 partnum=89; //internal use for unspecified resonance data
160 }
161
162 istat=fEvtstdhep->getIStat(i);
163
164 if(istat!=1 && istat!=2) Info("ImportParticles","Attention: unknown status code!");
165 if(istat == 2) istat = 11; //status decayed
166
167 p4=fEvtstdhep->getP4(i);
168 x4=fEvtstdhep->getX4(i);
169 px=p4.get(1);
170 py=p4.get(2);
171 pz=p4.get(3);
172 e=p4.get(0);
774ceaaf 173 const Float_t kconvT=0.001/2.999792458e8; // mm/c to seconds conversion
174 const Float_t kconvL=1./10; // mm to cm conversion
175 x=x4.get(1)*kconvL;//[cm]
176 y=x4.get(2)*kconvL;//[cm]
177 z=x4.get(3)*kconvL;//[cm]
178 t=x4.get(0)*kconvT;//[s]
da0e9ce3 179
180 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));
181
182 new(clonesParticles[i]) TParticle(partnum,istat,jmotherfirst,-1,jdaugfirst,jdauglast,px,py,pz,e,x,y,z,t);
183
184 //set polarization!!!
185 }
186
187 return npart;
188
189 }
190
191void AliDecayerEvtGen::Copy(TObject &) const
192 {
193 //
194 // Copy *this onto AliDecayerEvtGen -- not implemented
195 //
196 Fatal("Copy","Not implemented!\n");
197 }
198
199void AliDecayerEvtGen::ForceDecay()
200 {
201 //
202 // Intupt: none - Output: none
203 // Set the decay mode to decay particles: for each case is read a
204 // different decay table. case kAll read the default decay table only
205 //
206 Decay_t decay = fDecay;
207 switch(decay)
208 {
0ca57c2f 209 case kAll: // particles decayed "naturally" according to $ALICE_ROOT/TEvtGen/EvtGen/DECAY.DEC
3a6cdcc8 210 break;
da0e9ce3 211 case kBJpsiDiElectron:
3a6cdcc8 212 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/BTOJPSITOELE.DEC"));
213 break;
da0e9ce3 214 case kBJpsi:
3a6cdcc8 215 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/BTOJPSI.DEC"));
216 break;
da0e9ce3 217 case kBJpsiDiMuon:
3a6cdcc8 218 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/BTOJPSITOMU.DEC"));
219 break;
da0e9ce3 220 case kBSemiElectronic:
3a6cdcc8 221 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/BTOELE.DEC"));
222 break;
941c36b4 223 case kHadronicD:
de323cb7 224 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/HADRONICD.DEC"));
941c36b4 225 break;
de323cb7 226 case kHadronicDWithout4Bodies:
227 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/HADRONICDWITHOUT4BODIES.DEC"));
228 break;
229 case kChiToJpsiGammaToElectronElectron:
3a6cdcc8 230 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/CHICTOJPSITOELE.DEC"));
231 break;
da0e9ce3 232 case kChiToJpsiGammaToMuonMuon:
3a6cdcc8 233 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/CHICTOJPSITOMUON.DEC"));
234 break;
235 case kSemiElectronic:
236 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/BANDCTOELE.DEC"));
237 break;
da0e9ce3 238 case kBSemiMuonic:
3a6cdcc8 239 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/BTOMU.DEC"));
240 break;
da0e9ce3 241 case kSemiMuonic:
3a6cdcc8 242 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/BANDCTOMU.DEC"));
243 break;
da0e9ce3 244 case kDiElectron:
3a6cdcc8 245 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/DIELECTRON.DEC"));
246 break;
247 case kDiMuon:
248 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/DIMUON.DEC"));
249 break;
da0e9ce3 250 case kBPsiPrimeDiMuon:
3a6cdcc8 251 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/BTOPSIPRIMETODIMUON.DEC"));
252 break;
253 case kBPsiPrimeDiElectron:
254 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/BTOPSIPRIMETODIELECTRON.DEC"));
255 break;
256 case kJpsiDiMuon:
257 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/JPSIDIMUON.DEC"));
258 break;
de323cb7 259 case kPsiPrimeJpsiDiElectron:
260 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/PSIPRIMETOJPSITOMU.DEC"));
261 break;
262 case kPhiKK:
263 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/PHITOK.DEC"));
264 break;
265 case kOmega:
266 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/OMEGATOLAMBDAK.DEC"));
267 break;
268 case kLambda:
269 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/LAMBDATOPROTPI.DEC"));
270 break;
3a6cdcc8 271 case kHardMuons:
de323cb7 272 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/HARDMUONS.DEC"));
273 break;
274 case kElectronEM:
275 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/ELECTRONEM.DEC"));
276 break;
277 case kDiElectronEM:
278 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/DIELECTRONEM.DEC"));
279 break;
280 case kGammaEM:
281 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/GAMMAEM.DEC"));
282 break;
283 case kBeautyUpgrade:
284 SetDecayTablePath(gSystem->ExpandPathName("$ALICE_ROOT/TEvtGen/EvtGen/DecayTable/BEAUTYUPGRADE.DEC"));
285 break;
da0e9ce3 286 case kPiToMu:
287 case kKaToMu:
288 case kAllMuonic:
289 case kWToMuon:
290 case kWToCharm:
291 case kWToCharmToMuon:
292 case kZDiMuon:
293 case kZDiElectron:
da0e9ce3 294 case kNoDecay:
295 case kNoDecayHeavy:
296 case kNeutralPion:
f2f8bbb9 297 case kBJpsiUndecayed:
49686315 298 case kNoDecayBeauty:
f2f8bbb9 299 AliWarning(Form("Warning: case %d not implemented for this class!",(int)decay));
da0e9ce3 300 break;
301 }
302 ReadDecayTable();
303 }
304
305Float_t AliDecayerEvtGen::GetPartialBranchingRatio(Int_t)
306 {
307 // This method is dummy
308 return 1.;
309 }
310
311Float_t AliDecayerEvtGen::GetLifetime(Int_t kf)
312 {
313 //
314 //Input: pdg code of a particle
315 //return lifetime in sec for a particle with particle code kf
316 //
317 EvtId IdPart=EvtPDL::evtIdFromStdHep(kf);
318 Double_t lifetime = EvtPDL::getctau(IdPart); //c*tau (mm)
319 AliDebug(1,Form("lifetime is %f (mum) , particle id= %d",lifetime*1000,kf));
320 return lifetime*kconv; //tau (sec)
321 }
322
323void AliDecayerEvtGen::ReadDecayTable()
324 {
325 //Input none - Output none
326 //Read the decay table that correspond to the path
327 //fDecayTablePath
328 //
329 TString temp = fDecayTablePath;
330 if(!temp.EndsWith("DECAY.DEC"))
331 fGenerator->readUDecay(fDecayTablePath);
332 }
333////////////////////////////////////////////////////////////
334Bool_t AliDecayerEvtGen::SetDecayTablePath(Char_t *path)
335 {
336 //
337 //Set the path of the decay table read to force particle decays
338 //
339 if(gSystem->AccessPathName(path))
340 {
341 AliWarning("Attention: This path not exist!\n");
342 return kFALSE;
343 }
344 fDecayTablePath = path;
345 return kTRUE;
346 }
347
348
349