FairRoot/PandaRoot
PndPythia6Direct.cxx
Go to the documentation of this file.
1 #include <math.h>
2 #include "TROOT.h"
3 #include "FairPrimaryGenerator.h"
4 //#include "FairGenerator.h"
5 #include "TClonesArray.h"
6 #include "TDatabasePDG.h"
7 
8 #include "PndPythia6Direct.h"
9 
10 
11 // ----- Default constructor -------------------------------------------
13 {
14  fMom = 15.;
15  fStoreTree=false;
16  fPythia=TPythia6::Instance();
18 }
19 // -------------------------------------------------------------------------
20 
21 // -------------------------------------------------------------------------
23  std::cout<<"PndPythia6Direct::SetPandaDefaults()"<<std::endl;
24  // Those are the FORTRAN settings. Let's access them via TPythia6
25  //c---------- Choice of the nessesary process --------------------
26  fPythia->SetMSEL(0); // full User Access
27  fPythia->SetMSUB(1,1); // qQ-->A*/Z0*
28  //c------------------- Nessesary limits for PANDA ENERGY region ---------
29  fPythia->SetPARP(2,0.5); // Lowest inv. Mass (D=10.GeV)
30  fPythia->SetPARP(111,0.1); // Minimum invar. mass of the remnant hadronic system (D=2.GeV)
31  fPythia->SetCKIN(1,1.); // limits for shat
32  //fPythia->SetCKIN(2,-1.); // no upper limit for S-HAT
33  fPythia->SetCKIN(5,0.1); // low cut limits for PT_-range
34  fPythia->SetCKIN(6,0.1); // low cut limits for intermediate mass
35 }
36 
37 // ----- Default constructor -------------------------------------------
39 {
40  std::cout<<"PndPythia6Direct::Init(): Beam Momentum "<<fMom<<std::endl;
41 
42  fPythia->Initialize("FIXT", "pbar", "p", fMom);
43  fParticleList = (TClonesArray*)fPythia->GetListOfParticles();
44 
45  return kTRUE;
46 }
47 // -------------------------------------------------------------------------
48 
49 
50 // ----- Destructor ----------------------------------------------------
52 {
53  if(fPythia!=NULL) delete fPythia;
54 }
55 // -------------------------------------------------------------------------
56 
57 // ----- Passing the event ---------------------------------------------
59 {
60  static int evtn=0;
61  if(fVerbose>0) std::cout<<"PndPythia6Direct::ReadEvent() No. "<<evtn<<std::endl;
62  fPythia->GenerateEvent();
63  if(fVerbose>2) std::cout<<"PndPythia6Direct::ReadEvent() Generation done."<<std::endl;
64  double fX, fY, fZ, fT;
65  double Px,Py,Pz, fE; // ,Pm[1000],Wh[1000];
66  int Id,nFD,nLD,nMO,status;
67  bool dotracking;
68  //fParticleList=(TClonesArray*)fPythia->ImportParticles();
69  int npart=fParticleList->GetEntriesFast();
70  if(fVerbose>0) std::cout<<"PndPythia6Direct::ReadEvent() We have "<<npart<<" tracks."<<std::endl;
71  for(int i=0; i<npart; ++i)
72  {
73  if(fVerbose>4) std::cout<<"PndPythia6Direct::ReadEvent() particle No. "<<i<<std::endl;
74  fParticle=(TMCParticle*)fParticleList->At(i);
75  if(fVerbose>4) std::cout<<"PndPythia6Direct::ReadEvent() particle pointer "<<fParticle<<std::endl;
76  if(fParticle==NULL) continue;
77  // add track
78  nFD=fParticle->GetFirstChild();
79  nLD=fParticle->GetLastChild();
80  nMO=fParticle->GetParent();
81  status=fParticle->GetKS();
82  //Id=TDatabasePDG::Instance()->GetParticle(fParticle->GetName())->PdgCode();
83  Id=fParticle->GetKF(); // "Flavour code" is pdg code
84  if(fVerbose>4) {
85  std::cout<<"PndPythia6Direct::ReadEvent() Particle:"
86  //<<" pdg="<<TDatabasePDG::Instance()->GetParticle(fParticle->GetName())->PdgCode()
87  <<" name=\""<<fParticle->GetName()<<"\""
88  <<" nFD= "<<nFD
89  <<" nLD= "<<nLD
90  <<" nMO= "<<nMO
91  <<" pdg= "<<Id
92  <<" status= "<<status
93  <<"\n "
94  <<" Time()*1000="<<fParticle->GetTime()*1000
95  <<" Vx()*0.1= "<<fParticle->GetVx()*0.1
96  <<" Vy()*0.1= "<<fParticle->GetVy()*0.1
97  <<" Vz()*0.1= "<<fParticle->GetVz()*0.1
98  <<"\n "
99  <<" Energy()= "<<fParticle->GetEnergy()
100  <<" Px()= "<<fParticle->GetPx()
101  <<" Py()= "<<fParticle->GetPy()
102  <<" Pz()= "<<fParticle->GetPz()
103  <<std::endl;
104  }
105 
106  if(status==1 || fStoreTree ) //fStoreTree && status==11 && nFD!=nLD)
107  {
108  fT=fParticle->GetTime()*1000; //[mm/c]->s with c in [m/s] // /(1000*TMath::C()); //mm - > s conversion
109  fX=fParticle->GetVx()*0.1; // mm -> cm conversion
110  fY=fParticle->GetVy()*0.1; // mm -> cm conversion
111  fZ=fParticle->GetVz()*0.1; // mm -> cm conversion
112  fE=fParticle->GetEnergy();
113  Px=fParticle->GetPx();
114  Py=fParticle->GetPy();
115  Pz=fParticle->GetPz();
116  if(fVerbose>0&&(evtn<10||(evtn%100)==0)) printf("- I -: new particle %d at: %f, %f, %f (%f)-> %f %f %f (%f) ID %d ##Daughters %d %d Mother %d\n",
117  i,fX, fY, fZ, fT,Px, Py, Pz, fE, Id, nFD, nLD, nMO);
118  if(fStoreTree) {
119  // here we write all particles to the stack, but do processing only for final state particles
120  dotracking = (status==1);
121  primGen->AddTrack(Id, Px, Py, Pz, fX, fY, fZ, nMO,dotracking,fE,fT);
122  } else {
123  primGen->AddTrack(Id, Px, Py, Pz, fX, fY, fZ,-1,true,fE,fT);// set mother id to default: -1, do tracking: true
124  }
125  }
126  }
127  evtn++;
128  return kTRUE;
129 }
130 
131 // -------------------------------------------------------------------------
133  //fPythia.settings.listAll();
134 }
135 // -------------------------------------------------------------------------
136 
138 
Bool_t ReadEvent(FairPrimaryGenerator *)
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
virtual Bool_t Init()
Int_t i
Definition: run_full.C:25
TClonesArray * fT
Definition: drawGLTracks.C:13
Double_t fX
Definition: PndCaloDraw.cxx:34
Double_t fZ
Definition: PndCaloDraw.cxx:34
TMCParticle * fParticle
FairPrimaryGenerator * primGen
Definition: sim_emc_apd.C:81
virtual ~PndPythia6Direct()
Double_t fY
Definition: PndCaloDraw.cxx:34
ClassImp(PndAnaContFact)
TClonesArray * fParticleList
int status[10]
Definition: f_Init.h:28