Warning, file /estarlight/utils/eTTreemaker.C was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006 #include <TFile.h>
0007 #include <TNtuple.h>
0008 #include <TMath.h>
0009 #include <cmath>
0010 #include <cassert>
0011 #include <string>
0012 #include <iostream>
0013 #include <fstream>
0014 #include <sstream>
0015
0016 using namespace std;
0017
0018 void eTTreemaker(TString slightname="slight.out")
0019 {
0020 double me=0.000511;
0021 double mfinal;
0022
0023
0024 double fspx,fspy,fspz,fse,fsrap,fspt,fsmass,p1x,p1y,p1z,p1e,p1prap;
0025 double p2x,p2y,p2z,p2e,p2prap,p1pt,p2pt;
0026 double targx, targy, targz, targE;
0027 double sx, sy, sz, sE;
0028
0029
0030 double kphoton,kperp,qsquared,xbj,ttransfer;
0031 double eTheta;
0032
0033
0034
0035 TNtuple *esNTuple = new TNtuple("esNT","eslightNtuple","fspt:fspz:fsrap:fsmass:p1pt:p1z:p1prap:p2pt:p2z:p2prap:kg:qsq:xbj");
0036
0037
0038
0039
0040 cout <<" Opening slight.out"<< endl;
0041
0042 ifstream inFile;
0043 cout << "FileName=" << slightname << endl;
0044 inFile.open( slightname.Data());
0045 cout << "slight.out open"<<endl;
0046 int countLines=0;
0047
0048
0049 int ntrk,nvtx;
0050 int i1,i2,i3,i4;
0051
0052 string line;
0053 stringstream lineStream;
0054
0055
0056 string label;
0057 int eventNmb,nmbTracks, pcode;
0058 int nev,ntr,stopv,pdgpid1,pdgpid2;
0059
0060
0061
0062 double gamma_e,gamma_ion,junk1;
0063
0064 if (!getline(inFile,line)) {cout <<" Error reading CONFIG_OPT line"<<endl;}
0065 countLines++;
0066 lineStream=stringstream(line);
0067
0068 lineStream>>label;
0069
0070 if (!getline(inFile,line)) {cout <<" Error reading BEAM_1 line"<<endl;}
0071 countLines++;
0072 lineStream=stringstream(line);
0073 lineStream>>label>>gamma_e;
0074 cout<<"Electron Lorentz boost is "<<gamma_e<<endl;
0075
0076 if (!getline(inFile,line)) {cout <<" Error reading BEAM_2 line"<<endl;}
0077 countLines++;
0078 lineStream=stringstream(line);
0079 lineStream>>label>>i1>>i2>>gamma_ion;
0080 cout << "Check... " << label << " " << i1 << " " << i2 << " " << gamma_ion << endl;
0081
0082 cout<<"Ion Lorentz boost is "<<gamma_ion<<endl;
0083
0084 if (!getline(inFile,line)) {cout <<" Error reading PHOTON line"<<endl;}
0085 countLines++;
0086 lineStream=stringstream(line);
0087
0088
0089
0090
0091
0092 while (inFile.good())
0093 {
0094
0095 if (!getline(inFile,line)) {break;}
0096 countLines++;
0097 lineStream=stringstream(line);
0098 lineStream>>label>>eventNmb>>nmbTracks;
0099 if (!(label =="EVENT:")) continue;
0100 if (eventNmb < 5) {cout <<"Reached Event "<<eventNmb<<endl;}
0101
0102
0103 if (!getline(inFile,line)) {break;}
0104 countLines++;
0105
0106 lineStream=stringstream(line);
0107 lineStream>>label;
0108
0109 if (!getline(inFile,line)) {break;}
0110 lineStream=stringstream(line);
0111 lineStream>>label>>kphoton>>qsquared;
0112
0113 if (!getline(inFile,line)) {break;}
0114 lineStream=stringstream(line);
0115 lineStream>>label>>ttransfer;
0116
0117 if (!getline(inFile,line)) {break;}
0118 lineStream=stringstream(line);
0119 lineStream>>label >> targx >> targy >> targz >> targE;
0120
0121 if (!getline(inFile,line)) {break;}
0122 lineStream=stringstream(line);
0123 lineStream>>label >> sx >> sy >> sz >> sE;
0124
0125
0126 if (!getline(inFile,line)) {break;}
0127 countLines++;
0128
0129 lineStream=stringstream(line);
0130 lineStream>>label>>pcode>>p1x>>p1y>>p1z>>i1>>i2>>i3>>pdgpid1;
0131
0132 if (!getline(inFile,line)) {break;}
0133 countLines++;
0134 lineStream=stringstream(line);
0135
0136 lineStream>>label>>pcode>>p2x>>p2y>>p2z>>i1>>i2>>i3>>pdgpid2;
0137
0138
0139 if(abs(pdgpid1)==22 && (pdgpid1 != pdgpid2)){
0140 cout<<"Error pdgpid codes don't match "<<pdgpid1<<" "<<pdgpid2<<endl;
0141 exit(-1);
0142 }
0143 else if (abs(pdgpid1)!=22 && pdgpid1 != -pdgpid2)
0144 { cout<<"Error pdgpid codes don't match "<<pdgpid1<<" "<<pdgpid2<<endl;
0145 exit(-1);
0146 }
0147
0148 double pdgabs=abs(pdgpid1);
0149 mfinal=0.;
0150 if (pdgabs == 211) mfinal=0.139;
0151 if (pdgabs == 11) mfinal=0.000511;
0152 if (pdgabs == 13) mfinal=0.105;
0153 if (pdgabs == 321) mfinal=0.494;
0154 if (pdgabs == 22) mfinal=0;
0155 else if (mfinal ==0)
0156 {cout<<" Error final mass=0. pdgabs="<<pdgabs<<endl;
0157 exit(-1);
0158 }
0159
0160
0161 double p1=sqrt(p1x*p1x+p1y*p1y+p1z*p1z);
0162 double e1=sqrt(p1*p1+mfinal*mfinal);
0163 p1prap=0.5*log((p1+p1z)/(p1-p1z));
0164 p1pt=sqrt(p1x*p1x+p1y*p1y);
0165
0166 double p2=sqrt(p2x*p2x+p2y*p2y+p2z*p2z);
0167 double e2=sqrt(p2*p2+mfinal*mfinal);
0168 p2prap=0.5*log((p2+p2z)/(p2-p2z));
0169 p2pt=sqrt(p2x*p2x+p2y*p2y);
0170
0171 eTheta = TMath::ATan(TMath::Sqrt(sx*sx+sy*sy)/sz);
0172
0173
0174 fspx=p1x+p2x;
0175 fspy=p1y+p2y;
0176 fspz=p1z+p2z;
0177 double fse=e1+e2;
0178
0179
0180 fspt=sqrt(fspx*fspx+fspy*fspy);
0181 fsmass=sqrt(fse*fse-(fspx*fspx+fspy*fspy+fspz*fspz));
0182 fsrap= 0.5*log((fse+fspz)/(fse-fspz));
0183
0184
0185
0186 double kphotontargetframe=kphoton*gamma_ion;
0187 double mass = sqrt(fsmass*fsmass+qsquared*qsquared);
0188 double xbjorken=mass/(2.*gamma_ion*0.939)*exp(fsrap);
0189
0190
0191 esNTuple->Fill(fspt,fspz,fsrap,fsmass,p1pt,p1z,p1prap,p2pt,p2z,p2prap,kphoton,qsquared,xbjorken);
0192
0193 if (eventNmb < 5)
0194 {
0195 cout<<fspx<<fspy<<fspz<<fse<<fsrap<<fspt<<fsmass<<fsrap<<endl;
0196 cout<<p1x<<p1y<<p1z<<p1prap<<" "<<p1<<" pt1="<<p1pt<<endl;
0197 cout<<p2x<<p2y<<p2z<<p2prap<<" "<<p2<<" pt2="<<p2pt<<endl;
0198 }
0199
0200 }
0201
0202
0203 TString baseName = slightname.ReplaceAll(".out",".root");
0204 TFile *NTfile = new TFile(TString::Format("ntuple_%s",baseName.Data()),"recreate");
0205
0206 esNTuple->Write();
0207 NTfile->Close();
0208
0209 }