22 #include "TLorentzVector.h"
23 #include "TClonesArray.h"
36 void set(
float px,
float py,
float pz,
float E,
float Q2){
37 p =
new TLorentzVector(px,py,pz,E);
44 {cout <<
"Considering the electron mass." <<endl;
45 mass = 0.000510998928;
49 cout <<
"Considering the proton mass."<<endl; }
50 double E = lorentz*
mass;
51 double pz = std::sqrt(E*E-mass*mass);
52 cout<<
"Mass = "<<mass<<endl;
53 TLorentzVector* to_ret =
new TLorentzVector(0,0,dir*pz, E);
64 TFile* outFile =
new TFile(
outFileName,
"RECREATE");
66 cerr <<
" error: could not create output file '" <<
outFileName <<
"'" << endl;
69 TTree* outTree =
new TTree(
"starlightTree",
"starlightTree");
70 TLorentzVector* parentParticle =
new TLorentzVector();
71 TClonesArray* daughterParticles =
new TClonesArray(
"TLorentzVector");
72 TLorentzVector* source =
new TLorentzVector();
73 TLorentzVector*
target =
new TLorentzVector();
75 TLorentzVector* beam1 =
new TLorentzVector();
76 TLorentzVector* beam2 =
new TLorentzVector();
77 std::map<string, int> set_up;
78 double photon_setup[5];
80 Float_t q2, W, Egamma, vertex_t;
81 outTree->Branch(
"beam1",
"TLorentzVector", &beam1, 32000, -1);
82 outTree->Branch(
"beam2",
"TLorentzVector", &beam2, 32000, -1);
84 outTree->Branch(
"Egamma", &Egamma,
"Egamma/F");
85 outTree->Branch(
"Q2", &q2,
"q2/F");
86 outTree->Branch(
"W", &W,
"W/F");
87 outTree->Branch(
"t", &vertex_t,
"vertex_t/F");
88 outTree->Branch(
"Target",
"TLorentzVector", &target, 32000, -1);
89 outTree->Branch(
"source",
"TLorentzVector", &source, 32000, -1);
90 outTree->Branch(
"parent",
"TLorentzVector", &parentParticle, 32000, -1);
91 outTree->Branch(
"daughters",
"TClonesArray", &daughterParticles, 32000, -1);
95 unsigned int countLines = 0;
97 bool loaded_head =
false;
98 while (inFile.good()) {
101 stringstream lineStream;
103 if( loaded_head ==
false){
107 lineStream.str(line);
108 cout<<lineStream.str()<<endl;
109 R__ASSERT( lineStream >> label >> set_up[
"prod_id"] >> set_up[
"part_id"] >> set_up[
"nevents"]
110 >> set_up[
"qc"] >> set_up[
"impulse"] >> set_up[
"rnd_seed"] );
111 R__ASSERT(label ==
"CONFIG_OPT:");
113 cout <<
" -------------------- Simulation set up -------------------- "<<endl;
114 cout <<
"prod_id: " << set_up[
"prod_id"] <<
"\t part_id: " << set_up[
"part_id"] <<
"\t nevents: " << set_up[
"nevents"] << endl;
115 cout <<
"q_glauber: "<< set_up[
"qc"] <<
"\t impulse: "<< set_up[
"impulse"] <<
"\t rnd_seed: "<< set_up[
"rnd_seed"] << endl;
116 cout <<
" ___________________________________________________________ "<<endl;
125 lineStream.str(line);
126 R__ASSERT( lineStream >> label >> lorentz );
127 R__ASSERT(label ==
"ELECTRON_BEAM:" );
135 lineStream.str(line);
136 R__ASSERT( lineStream >> label >> Z >> A >> lorentz );
137 R__ASSERT(label ==
"TARGET_BEAM:" );
145 lineStream.str(line);
146 int g_bins, q_bins, fixed_q;
147 double q2_min, q2_max;
148 R__ASSERT( lineStream >> label >> g_bins >> fixed_q>> q_bins
150 R__ASSERT(label ==
"PHOTON:");
155 int eventNmb, nmbTracks;
160 lineStream.str(line);
161 R__ASSERT(lineStream >> label >> eventNmb >> nmbTracks);
162 if (!(label ==
"EVENT:"))
171 lineStream.str(line);
172 R__ASSERT(lineStream >> label);
173 R__ASSERT(label ==
"VERTEX:");
175 *parentParticle = TLorentzVector(0, 0, 0, 0);
182 lineStream.str(line);
184 R__ASSERT(lineStream >> label >> Egamma >> q2 );
185 R__ASSERT(label ==
"GAMMA:");
190 lineStream.str(line);
192 R__ASSERT(lineStream >> label >> vertex_t );
193 R__ASSERT(label ==
"t:");
199 lineStream.str(line);
201 float tpx=0., tpy=0., tpz=0., tE=0.;
202 R__ASSERT(lineStream >> label >> tpx >> tpy >> tpz >> tE) ;
203 R__ASSERT(label ==
"TARGET:");
204 *target = TLorentzVector(tpx, tpy, tpz, tE);
211 lineStream.str(line);
213 float px=0., py=0., pz=0., E=0.;
214 R__ASSERT(lineStream >> label >> px >> py >> pz >> E) ;
215 R__ASSERT(label ==
"SOURCE:");
216 *source = TLorentzVector(px, py, pz, E);
224 for (
int i = 0; i < nmbTracks; ++i) {
231 lineStream.str(line);
232 R__ASSERT(lineStream >> label >> particleCode >> momentum[0] >> momentum[1] >> momentum[2]);
233 R__ASSERT(label ==
"TRACK:");
234 Double_t daughterMass =
IDtoMass(particleCode);
235 if (daughterMass < 0) {
break;}
237 const double E = sqrt( momentum[0] * momentum[0] + momentum[1] * momentum[1]
238 + momentum[2] * momentum[2] + daughterMass * daughterMass);
239 new ( (*daughterParticles)[i] ) TLorentzVector(momentum[0], momentum[1], momentum[2], E);
240 *parentParticle += *(
static_cast<TLorentzVector*
>(daughterParticles->At(i)));
242 pxtot += momentum[0];
243 pytot += momentum[1];
244 pztot += momentum[2];
248 W = sqrt(Etot * Etot - pxtot * pxtot - pytot * pytot - pztot * pztot);
250 daughterParticles->Compress();
258 cout<<
"Processed "<<tot_events<<
" events"<<endl;
263 if (particleCode == 2 || particleCode==3) {mass = 0.00051099907;}
264 else if (particleCode == 5 || particleCode==6) {mass = 0.105658389;}
265 else if (particleCode == 8 || particleCode==9) {mass = 0.13956995;}
266 else if (particleCode == 7) {mass = 0.1345766;}
267 else if (particleCode == 11|| particleCode==12) {mass = 0.493677;}
268 else if (particleCode == 10 || particleCode == 16) {mass = 0.497614;}
269 else if (particleCode == 14) {mass = 0.93827231;}
270 else if (particleCode == 1) {mass = 0;}
272 cout <<
"unknown daughter particle (ID = " << particleCode <<
"), please modify code to accomodate" << endl;