8 #include "TClonesArray.h"
10 #include "TLorentzVector.h"
14 #include "TParticle.h"
18 #include "FairPrimaryGenerator.h"
22 #include "EvtGen/EvtGen.hh"
24 #include "EvtGenBase/EvtPatches.hh"
25 #include "EvtGenBase/EvtParticleFactory.hh"
26 #include "EvtGenBase/EvtStdHep.hh"
27 #include "EvtGenBase/EvtParticle.hh"
28 #include "EvtGenBase/EvtRandom.hh"
29 #include "EvtGenBase/EvtRandomEngine.hh"
30 #include "EvtGenBase/EvtReport.hh"
31 #include "EvtGenBase/EvtHepMCEvent.hh"
35 #include "EvtGenExternal/EvtExternalGenList.hh"
36 #include "EvtGenBase/EvtAbsRadCorr.hh"
37 #include "EvtGenBase/EvtDecayBase.hh"
59 static TRandom3 randengine(
seed);
60 return randengine.Rndm();
76 cout <<
"<I> PndEvtGenDirect"<<endl;
77 cout <<
"<I> Particle: "<<particle<<endl;
78 cout <<
"<I> decfile: "<<decfile<<endl;
79 if(Mom>0) cout <<
"<I> pbar-Momentum: "<<Mom<<endl;
80 if(Mom==0) cout <<
"<I> Momentum: "<<Mom<<endl;
81 if(Mom<0) cout <<
"<I> CMS energy: "<<Mom<<endl;
82 cout <<
"<I> Rnd Seed: "<<Seed<<endl;
83 TString work = getenv(
"VMCWORKDIR");
84 if (defaultDECAY==
"") defaultDECAY = work +
"/pgenerators/EvtGen/EvtGen/Private/DECAY.DEC";
85 if (defaultPDL==
"") defaultPDL = work +
"/pgenerators/EvtGen/EvtGen/Private/evt.pdl";
87 if (particle.Contains(
"pbarASystem") && (ATarg<3.||ATarg>238.))
89 cerr <<
"****** FATAL ERROR: nuclear target mass number MUST be between 3 and 238! ******"<<endl;
97 EvtRandomEngine* myRandomEngine=0;
102 Seed = gRandom->GetSeed();
103 cout <<
"<I> Rnd Seed changed to " << Seed << endl;
110 EvtExternalGenList genList;
111 EvtAbsRadCorr* radCorrEngine = genList.getPhotosModel();
112 std::list<EvtDecayBase*> extraModels = genList.getListOfModels();
115 myGenerator=
new EvtGen(defaultDECAY,defaultPDL,myRandomEngine,
116 radCorrEngine, &extraModels);
119 myGenerator=
new EvtGen(defaultDECAY,defaultPDL,myRandomEngine);
123 if(decfile!=
"") myGenerator->readUDecay(decfile.Data());
125 PART=EvtPDL::getId(std::string(particle.Data()));
127 if ( (particle.Contains(
"pbarp") || particle.Contains(
"pbard") || particle.Contains(
"pbarA")) && Mom==0)
129 cerr <<
"\033[5m\033[31m -E ****** FATAL ERROR: <particle> is '" << particle.Data() <<
"'; MUST give pbar momentum or cms energy!\033[0m"<<endl;
141 if ( (particle.Contains(
"pbarp") || particle.Contains(
"pbard") || particle.Contains(
"pbarA") ) && Mom!=0){
144 if(PART.getId()==-1){
145 cerr <<
"Particle \""<<particle<<
"\" is unknown!!!"<<endl<<
"Check your Macro for spelling mistake."<<endl;
148 val=-EvtPDL::getMass(PART);
154 if ( particle.Contains(
"pbarpSystem") ) fEnergy = mp+
sqrt(fMomentum*fMomentum+mp*mp);
155 if ( particle.Contains(
"pbardSystem") ) fEnergy = md+
sqrt(fMomentum*fMomentum+mp*mp);
156 if ( particle.Contains(
"pbarASystem") ) fEnergy = mA+
sqrt(fMomentum*fMomentum+mp*mp);
161 fEnergy = val*val/(2*
mp);
162 fMomentum =
sqrt(fEnergy*fEnergy-val*val);
165 cout <<
"\n############# Generating with following conditions:\n\n";
166 cout <<
"incident 4-mom : ("<<fEnergy<<
", 0, 0, "<<fMomentum<<
"), m = "<<
sqrt(fEnergy*fEnergy-fMomentum*fMomentum)<<endl;
167 cout <<
"\n######################\n\n"<<endl;
180 static Int_t evtnr=0;
185 EvtVector4R pInit(fEnergy, 0.0000, -0.0000, fMomentum);
186 parent=EvtParticleFactory::particleFactory(PART,pInit);
187 parent->setDiagonalSpinDensity();
191 myGenerator->generateDecay(parent);
196 parent->makeStdHep(evtstdhep);
201 if (
verbose>1 ||(
verbose==1 && (evtnr<10 || ((evtnr+1)%100)==0))){
202 cout <<
"PndEvtGenDirect::ReadEvent "<<evtnr <<
" "<<fEnergy<<
" "<<fMomentum << endl;
203 parent->printParticle();
205 EvtHepMCEvent theEvent;
206 theEvent.constructEvent(parent);
207 HepMC::GenEvent* genEvent = theEvent.getEvent();
208 genEvent->print(std::cout);
214 cout <<
"==== now compare ==="<<endl;
224 npart=evtstdhep.getNPart();
225 EvtVector4R vxyz,pxyz;
227 for(Int_t
i=0;
i<npart;
i++){
230 nFD=evtstdhep.getFirstDaughter(
i);
231 nLD=evtstdhep.getLastDaughter(
i);
232 if(fStoreTree ||(nFD==-1 && nLD==-1))
234 Id=evtstdhep.getStdHepID(
i);
235 vxyz=evtstdhep.getX4(
i);
236 pxyz=evtstdhep.getP4(
i);
245 if(plotflag)
printf(
"- I -: new particle %d at: %f, %f, %f (%f)-> %f %f %f (%f) ID %d ##Daughters %d %d Mothers %d %d\n",
i,
246 fX, fY, fZ, fT,Px, Py, Pz, fE, Id, nFD, nLD,evtstdhep.getFirstMother(
i),evtstdhep.getLastMother(
i));
248 primGen->AddTrack(Id, Px, Py, Pz, fX, fY, fZ, evtstdhep.getFirstMother(
i),(nFD==-1 && nLD==-1),fE,fT);
250 primGen->AddTrack(Id, Px, Py, Pz, fX, fY, fZ,-1,
true,fE,fT);
254 if(plotflag) cout <<
"==== compare end ==="<<endl;
256 parent->deleteTree();
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
virtual ~PndEvtGenDirect()
cout<< "-----------------------------------------------> Quarter VOLUME<<endl;name="QuarterShape";QuarterShape=newTGeoArb8(name,dz,vertQuar);name="Quarter4Vol";TStringmedium="air";QuarterVol=newTGeoVolumeAssembly(name);name="SubunitShape";SubunitShape=newTGeoArb8(name,dz,vertSub);TStringmedium="air";name="SubunitVol";name1="SubunitVol1";name2="SubunitVol2";name3="SubunitVol3";name4="SubunitVol4";name5="SubunitVol5";name6="SubunitVol6";name7="SubunitVol7";name8="SubunitVol8";name9="SubunitVol9";SubunitVol=newTGeoVolumeAssembly(name);SubunitVol1=newTGeoVolumeAssembly(name1);SubunitVol2=newTGeoVolumeAssembly(name2);SubunitVol3=newTGeoVolumeAssembly(name3);SubunitVol4=newTGeoVolumeAssembly(name4);SubunitVol5=newTGeoVolumeAssembly(name5);SubunitVol6=newTGeoVolumeAssembly(name6);SubunitVol7=newTGeoVolumeAssembly(name7);SubunitVol8=newTGeoVolumeAssembly(name8);SubunitVol9=newTGeoVolumeAssembly(name9);name="BoxShape";BoxShape=newTGeoArb8(name,dz,vertBox);TStringmedium="air";name="BoxVol";BoxVol=newTGeoVolumeAssembly(name);name1="BoxVol1";name2="BoxVol2";name3="BoxVol3";name4="BoxVol4";BoxVol1=newTGeoVolumeAssembly(name1);BoxVol2=newTGeoVolumeAssembly(name2);BoxVol3=newTGeoVolumeAssembly(name3);BoxVol4=newTGeoVolumeAssembly(name4);for(Int_tb=0;b<kNumOfBoxes;b++){cout<<""<<endl;cout<<"---------------->BOXnumber:"<<b<<endl;if(b==0){trBox=newTGeoTranslation(tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,0.);rotBox=newTGeoRotation();rotBox.RotateX(0.465518);rotBox.RotateY(-0.465518);}if(b==1){trBox=newTGeoTranslation(-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,0.);rotBox=newTGeoRotation();rotBox.RotateX(-0.465518);rotBox.RotateY(0.465518);}if(b==2){trBox=newTGeoTranslation(tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,0.);rotBox=newTGeoRotation();rotBox.RotateX(-0.465518);rotBox.RotateY(-0.465518);}if(b==3){trBox=newTGeoTranslation(-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,0.);rotBox=newTGeoRotation();rotBox.RotateX(0.465518);rotBox.RotateY(0.465518);}TGeoCombiTrans*trrotBox=newTGeoCombiTrans(trBox,rotBox);name="BoxVol";name+=b;trrotBox->SetName(name);trrotBox->RegisterYourself();SubunitVol->AddNode(BoxVol,b,trrotBox);if(b==1){name+=b;trrotBox->SetName(name);trrotBox->RegisterYourself();SubunitVol1->AddNode(BoxVol,b,trrotBox);}if(b==2){name+=b;trrotBox->SetName(name);trrotBox->RegisterYourself();SubunitVol2->AddNode(BoxVol1,b,trrotBox);}if(b==0){name+=b;trrotBox-> SetName(name)
friend F32vec4 sqrt(const F32vec4 &a)
Double_t val[nBoxes][nFEBox]
FairPrimaryGenerator * primGen
EvtRootRandomEngine(int s=0)
virtual Bool_t ReadEvent(FairPrimaryGenerator *primGen)