BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtTrackGen.cc
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3// Modification history:
4//
5// pingrg January 22, 2014 Module created
6//
7// -------- input file must take the form like:
8// [number of final state particles in this event]
9// [PDG ID of particle 1] [P_x] [P_y] [P_z] [E]
10// [PDG ID of particle 2] [P_x] [P_y] [P_z] [E]
11// and so on
12//------------------------------------------------------------------------
13//
15#include <stdlib.h>
18#include "EvtGenBase/EvtPDL.hh"
21#include "EvtTrackGen.hh"
22#include "EvtGlobalSet.hh"
23#include <string>
24
26
27void EvtTrackGen::getName(std::string& model_name){
28
29 model_name="TrackGen";
30
31}
32
34
35 return new EvtTrackGen;
36
37}
38
39
41
42 // check that there are 0 arguments
43 checkNArg(1);
44 int idx=getArg(0);
45 if(EvtGlobalSet::SV.size()==0){
46 std::cout<<"No track data file is available! "<<std::endl;abort();
47 }else{m_inputFileName=EvtGlobalSet::SV[idx];}
48
49 m_inputFile.open(m_inputFileName.c_str());
50 if (!m_inputFile){
51 cout << "EvtTrackGen: PROBLEMS OPENING FILE "
52 << m_inputFileName << endl;
53 exit(0);
54 }
55 //load the event P4
56 Evt.clear();
57 while(!m_inputFile.eof()){
58 m_inputFile >> nParticles;
59 std::vector<EvtVector4R> vp4;
60 for (int i = 0; i < nParticles; i++){
61 EvtVector4R p4;
62 m_inputFile >> idParticles[i];
63 m_inputFile >> pxParticle; p4.set(1,pxParticle);
64 m_inputFile >> pyParticle; p4.set(2,pyParticle);
65 m_inputFile >> pzParticle; p4.set(3,pzParticle);
66 m_inputFile >> eParticle; p4.set(0,eParticle);
67 vp4.push_back(p4);
68 }
69 Evt.push_back(vp4);
70 }
71 Evt.pop_back();
72 //check daughters id
73 if(nParticles!=getNDaug()){std::cout<<"The number of daughters are not cosistent with that the data file"<<std::endl;abort();}
74 for(int i=0;i<nParticles;i++){
75 EvtId pid = EvtPDL::evtIdFromStdHep(idParticles[i] );
76 if(pid!=getDaug(i) ){std::cout<<"The daughter particle pdg in your data file is not consistent with you decay card."<<std::endl;abort();}
77 }
78 //debugging
79 /*
80 for(int i=0;i<Evt.size();i++){
81 std::cout<<"Event "<<i<<std::endl;
82 for(int j=0;j<nParticles;j++){
83 std::cout<<Evt[i][j].get(0)<<" "<<Evt[i][j].get(1)<<" "<<Evt[i][j].get(2)<<" "<<Evt[i][j].get(3)<<std::endl;
84 }
85 }
86 */
87//---------
88}
89
91
92 noProbMax();
93
94}
95
97
99 int rdm= (int)Evt.size()*EvtRandom::Flat(0.0,1.0);
100 if(Evt.size()==0) {std::cout<<"EvtTrackGen: out of stored file record"<<std::endl;abort();}
101 EvtVector4R ptot(0,0,0,0);
102 for(int i=0;i<nParticles;i++){
103 EvtParticle* daug=p->getDaug(i);
104 ptot += Evt[rdm][i];
105 daug->init(daug->getId(),Evt[rdm][i]);
106 }
107 //p->init(p->getId(),ptot);
108
109 //debugging
110 // std::cout<<p->getDaug(getNDaug()-1)->getP4()<<" =? "<<eParticle<<" "<<pxParticle<<" "<<pyParticle<<" "<<pzParticle<<std::endl;
111
112 return ;
113}
114
115
116
*********Class see also m_nmax DOUBLE PRECISION m_MasPhot DOUBLE PRECISION m_phsu DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_r2 DOUBLE PRECISION m_WtMass INTEGER m_nmax INTEGER m_Nevgen INTEGER m_IsFSR INTEGER m_MarTot *COMMON c_KarFin $ !Output file $ !Event serial number $ !alpha QED at Thomson limit $ !minimum energy at CMS for remooval $ !infrared dimensionless $ !dummy photon IR regulator $ !crude photon multiplicity enhancement factor *EVENT $ !MC crude volume of PhhSpace *Sfactors $ !YFS formfactor IR part only $ !YFS formfactor non IR finite part $ !mass weight
Definition: KarFin.h:34
double getArg(int j)
void noProbMax()
EvtId * getDaugs()
Definition: EvtDecayBase.hh:65
void checkNArg(int a1, int a2=-1, int a3=-1, int a4=-1)
EvtId getDaug(int i)
Definition: EvtDecayBase.hh:66
static std::vector< std::string > SV
Definition: EvtGlobalSet.hh:19
Definition: EvtId.hh:27
static EvtId evtIdFromStdHep(int stdhep)
Definition: EvtPDL.cc:244
virtual void init(EvtId part_n, const EvtVector4R &p4)=0
EvtId getId() const
Definition: EvtParticle.cc:113
EvtParticle * getDaug(int i)
Definition: EvtParticle.cc:85
double initializePhaseSpace(int numdaughter, EvtId *daughters, double poleSize=-1., int whichTwo1=0, int whichTwo2=1)
static double Flat()
Definition: EvtRandom.cc:73
void initProbMax()
Definition: EvtTrackGen.cc:90
virtual ~EvtTrackGen()
Definition: EvtTrackGen.cc:25
void init()
Definition: EvtTrackGen.cc:40
EvtDecayBase * clone()
Definition: EvtTrackGen.cc:33
void decay(EvtParticle *p)
Definition: EvtTrackGen.cc:96
void getName(std::string &name)
Definition: EvtTrackGen.cc:27
void set(int i, double d)
Definition: EvtVector4R.hh:183