Index: trunk/utils/eTTreemaker.C =================================================================== --- trunk/utils/eTTreemaker.C (revision 11) +++ trunk/utils/eTTreemaker.C (revision 12) @@ -1,206 +1,206 @@ -// this very simple macro takes as input an Ascii eSTARlight output file, slight.out, and creates a standard TTree named ntuple.root +// this macro takes as input an Ascii eSTARlight output +// file, slight.out, and creates a standard TTREE // S. Klein, June, 2018 -// Fixed Bjorken-x calc Jan. 2020 + #include #include #include #include #include #include #include #include #include -void eTTreemaker(void) -{ using namespace std; - using namespace std; + +void eTTreemaker(TString slightname="slight.out") +{ double me=0.000511; double mfinal; -// create output TTree here + // create output TTree here double fspx,fspy,fspz,fse,fsrap,fspt,fsmass,p1x,p1y,p1z,p1e,p1prap; double p2x,p2y,p2z,p2e,p2prap,p1pt,p2pt; + double targx, targy, targz, targE; + double sx, sy, sz, sE; -// new variables for eSTARlight + // new variables for eSTARlight double kphoton,kperp,qsquared,xbj,ttransfer; - -// ttransfer will be imlemented later - + double eTheta; //Scattered electron polar angle + + // ttransfer will be imlemented later + TNtuple *esNTuple = new TNtuple("esNT","eslightNtuple","fspt:fspz:fsrap:fsmass:p1pt:p1z:p1prap:p2pt:p2z:p2prap:kg:qsq:xbj"); -// This is the electron, photon, final state (particle combination), particle 1 and particle 2 -// These are pseudorapidities, except for the final state, where it is rapidity -// For the photon there is the photon energy, Q^2 the bjorken x of the target (calculated with x = Q^2/(2km_p) and t, the momentum transfer from the target - - cout <<" Opening slight.out"<< endl; - - ifstream inFile; - inFile.open("slight.out"); - cout << "slight.out open"<>label); - //assert(label == "VERTEX:"); - - - if (!getline(inFile,line)) {cout <<" Error reading CONFIG_OPT line"<>label);// CONFIG_OPT - - if (!getline(inFile,line)) {cout <<" Error reading BEAM_1 line"<>label>>i1>>i2>>gamma_e); // BEAM_1 is the electron - cout<<"Electron Lorentz boost is "<>label>>i1>>i2>>gamma_ion); // BEAM_2 is the ion - cout<<"Ion Lorentz boost is "<>label;// CONFIG_OPT + + if (!getline(inFile,line)) {cout <<" Error reading BEAM_1 line"<>label>>i1>>i2>>gamma_e; // BEAM_1 is the electron + cout<<"Electron Lorentz boost is "<>label>>i1>>i2>>gamma_ion; // BEAM_2 is the ion + cout << "Check... " << label << " " << i1 << " " << i2 << " " << gamma_ion << endl; + + cout<<"Ion Lorentz boost is "<>label>>eventNmb>>nmbTracks); + lineStream>>label>>eventNmb>>nmbTracks; if (!(label =="EVENT:")) continue; if (eventNmb < 5) {cout <<"Reached Event "<>label); - assert(label == "VERTEX:"); - + lineStream>>label; + if (!getline(inFile,line)) {break;} lineStream=stringstream(line); - assert(lineStream>>label>>kphoton>>qsquared); - assert(label == "GAMMA:"); - + lineStream>>label>>kphoton>>qsquared; + if (!getline(inFile,line)) {break;} lineStream=stringstream(line); - assert(lineStream>>label>>ttransfer); - assert(label == "t:"); - + lineStream>>label>>ttransfer; + if (!getline(inFile,line)) {break;} lineStream=stringstream(line); - assert(lineStream>>label); - assert(label == "TARGET:"); - + lineStream>>label >> targx >> targy >> targz >> targE; + if (!getline(inFile,line)) {break;} lineStream=stringstream(line); - assert(lineStream>>label); - assert(label == "SOURCE:"); - -// two track cards + lineStream>>label >> sx >> sy >> sz >> sE; + + // two track cards if (!getline(inFile,line)) {break;} countLines++; - //lineStream.str(line); + lineStream=stringstream(line); - assert(lineStream>>label>>pcode>>p1x>>p1y>>p1z>>i1>>i2>>i3>>pdgpid1); - assert(label == "TRACK:"); - + lineStream>>label>>pcode>>p1x>>p1y>>p1z>>i1>>i2>>i3>>pdgpid1; if (!getline(inFile,line)) {break;} countLines++; lineStream=stringstream(line); - //lineStream.str(line); - assert(lineStream>>label>>pcode>>p2x>>p2y>>p2z>>i1>>i2>>i3>>pdgpid2); - assert(label == "TRACK:"); + + lineStream>>label>>pcode>>p2x>>p2y>>p2z>>i1>>i2>>i3>>pdgpid2; // get the final state masses should be particle anti-particle, so pdgcodes should be opposite if (pdgpid1 != -pdgpid2) { cout<<"Error pdgpid codes don't match"<Write(); + NTfile->Close(); - TFile *NTfile = new TFile("ntuple.root","recreate"); - esNTuple->Write(); - NTfile->Close(); }