27 #include <TDatabasePDG.h>
62 int main(
int argc,
char* argv[]){
79 cerr <<
"Detector sepcified as " << qapars.
detstring
81 <<
" not recognized or empty." << endl;
87 if ( gSystem->AccessPathName( rootname ) ){
88 cout <<
" ======================= " << endl;
89 cout <<
" Transforming input file " << endl
91 <<
" into root file " << endl
94 if ( buildresult !=0 ){
95 cerr <<
"Failed to build a tree from " << qapars.
txtfilename << endl;
99 cout <<
" ======================= " << endl;
100 cout <<
" Reusing existing root file " << rootname << endl;
105 TString smearedname = rootname;
106 smearedname.ReplaceAll (
".root",
".smeared.root" );
111 SmearTree( detector, rootname.Data(), smearedname.Data());
116 TChain* inTree =
new TChain(
"EICTree");
117 inTree->Add(rootname);
118 inTree->AddFriend(
"Smeared",smearedname);
123 inTree->SetBranchAddress(
"event",&inEvent);
124 inTree->SetBranchAddress(
"eventS",&inEventS);
137 map<int,pidqacollection> qabook;
139 if ( qapars.
pids.size() == 0 ) qapars.
pids = { 2212, 2112 };
146 for(
long iEvent=0; iEvent<inTree->GetEntries(); iEvent++){
149 if(inTree->GetEntry(iEvent) <=0)
break;
150 if(iEvent%10000 == 0) cout <<
"Event " << iEvent << endl;
162 for(
int j=0; j<inEventS->GetNTracks(); j++){
167 const Particle* inParticle = inEvent->GetTrack(j);
170 if ( inParticle->
GetStatus() != 1 )
continue;
173 if(inParticleS == NULL)
continue;
188 qapars.usedevents = inTree->GetEntries();
189 PlotQA( qapars, eventqa, qabook );
229 for (
auto& pidcoll : qabook ){
230 auto&
pid = pidcoll.first;
231 auto& coll = pidcoll.second;
236 auto P = inParticle->
GetP();
237 coll.P_th->Fill(th, P);
239 auto Pt = inParticle->
GetPt();
240 coll.Pt_th->Fill(th, Pt);
243 coll.xL_th->Fill(th, xL);
245 coll.Phi_theta->Fill(th, inParticle->
GetPhi());
253 vector<string> arguments(argv + 1, argv + argc);
257 for (
auto parg = arguments.begin() ; parg!=arguments.end() ; ++parg){
262 }
else if ( arg ==
"-o" ){
263 if (++parg == arguments.end() ){ argsokay=
false;
break; }
265 }
else if ( arg ==
"-i" ){
266 if (++parg ==arguments.end() ){ argsokay=
false;
break; }
268 }
else if ( arg ==
"-N" ){
269 if (++parg==arguments.end() ){ argsokay=
false;
break; }
270 qapars.
nevents=std::stoi(parg->data());
271 }
else if ( arg ==
"-addpid" ){
272 if ( ++parg == arguments.end() ){ argsokay=
false;
break; }
273 qapars.
pids.push_back(std::stoi(parg->data()));
274 }
else if ( arg ==
"-det" ){
275 if (++parg == arguments.end() ){ argsokay=
false;
break; }
278 if ( TString(qapars.
detstring).Contains(
"MATRIX") && TString(qapars.
detstring).Contains(
"FF")){
279 if (++parg == arguments.end() ){ argsokay=
false;
break; }
287 }
catch (
const std::exception&
e){
288 cerr <<
"Caught exception during argument parsing: "
294 cerr <<
"usage: " << argv[0] << endl
295 <<
" [-i txtfilename] (Lund-style file)" << endl
296 <<
" [-o OutFileBase] (extension will be added)" << endl
297 <<
" [-N Nevents] (<0 for all)" << endl
298 <<
" [-addpid pid] (can be called multiple times)" << endl
299 <<
" [-det detstring] matrix, matrixff [beam_mom_nn], handbook, perfect, beast, ephenix, zeus, jleic (capitalization does not matter.)" << endl
301 throw std::runtime_error(
"Not a valid list of options");
315 if ( rootname.EndsWith(
".gz", TString::kIgnoreCase) ||
316 rootname.EndsWith(
".zip", TString::kIgnoreCase) )
317 rootname.Replace(rootname.Last(
'.'), rootname.Length(),
"");
320 if (rootname.Last(
'.') > -1) {
321 rootname.Replace(rootname.Last(
'.'), rootname.Length(),
"");
331 rootname = gSystem->BaseName( rootname );
332 rootname.Prepend( qapars.
outpath );
337 gStyle->SetHistLineColor(kRed);
340 auto pdgdb=TDatabasePDG::Instance() ;
362 float phimax = TMath::TwoPi();
365 for (
auto pid : qapars.
pids ){
367 TString pdgname = pdgdb->GetParticle(
pid)->GetName();
371 qabook[
pid].P_th =
new TH2D( s,t+
" P vs. #theta;#theta;P", thbins, thmin, thmax, pbins, pmin, pmax);
374 qabook[
pid].Pt_th =
new TH2D( s,t+
" p_{T} vs. #theta;#theta;Pt", thbins, thmin, thmax, ptbins, ptmin, ptmax);
377 qabook[
pid].xL_th =
new TH2D( s,t+
" x_{L} vs. #theta;#theta;xL", thbins, thmin, thmax, xLbins, xLmin, xLmax);
380 qabook[
pid].Phi_theta =
new TH2D( s,t+
" #phi vs. #theta;#theta;#phi", thbins, thmin, thmax, phibins, phimin, phimax );
431 gStyle->SetStatX(0.25);
432 gStyle->SetStatW(0.15);
433 gStyle->SetStatY(0.9);
434 gStyle->SetStatH(0.15);
445 gErrorIgnoreLevel = kWarning;
450 gPad->SaveAs( pdfname +
"[" );
490 gStyle->SetStatX(0.89);
491 gStyle->SetStatW(0.15);
492 gStyle->SetStatY(0.89);
493 gStyle->SetStatH(0.15);
501 for (
auto&
pid : qapars.
pids ){
502 auto& coll = qabook[
pid];
504 coll.Phi_theta->Draw(
"colz");
505 gPad->SaveAs( pdfname );
507 coll.P_th->Draw(
"colz");
508 gPad->SaveAs( pdfname );
510 coll.Pt_th->Draw(
"colz");
511 gPad->SaveAs( pdfname );
513 coll.xL_th->Draw(
"colz");
514 gPad->SaveAs( pdfname );
519 gErrorIgnoreLevel = kInfo;
522 gPad->SaveAs( pdfname +
"]" );