//################################################################ //# Macros for DPM output check //# author: Anastasia Karavdina //# date: September, 2012 //# //# to compile it add in "# install #" part of CMakeLists.txt lines: //# add_executable(dpm_out_check GenInfoDPMgen.C) //# target_link_libraries(dpm_out_check ${ROOT_LIBRARIES}) //# //# to run it (and see options): //# ${PANDAROOT}/build/bin/./dpm_out_check --help //################################################################ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "TStopwatch.h" #include "TString.h" #include "TChain.h" #include "TClonesArray.h" #include "TH1.h" #include "TH2.h" #include "TLorentzVector.h" #include "TDatabasePDG.h" #include "TParticlePDG.h" #include "TVector3.h" #include "TCanvas.h" #include "TFile.h" //#include "PndMCTrack.h" using namespace std; // void GenInfoDPMgen(const int nEvents=2, const double beamMom = 1.5, const int startEvent=0, TString storePath="tmpOutputDPM", const int verboseLevel=3) // { int main(int __argc,char *__argv[]) { TString storePath="/data/FAIRsorf/pandaroot/trunk/macro/lmd/tmpOutputBkg"; double beamMom = 1.5; int startEvent=0; int nEvents=100; std::string pathStr="", beamMomStr="", startStr="", nEvStr=""; // decode arguments if( __argc>1 && ( strcmp( __argv[1], "-help" ) == 0 || strcmp( __argv[1], "--help" ) == 0 ) ){ std::cout << "This is script for checking DPM output with parameters\n" <<"-path path to the file(s) \n" <<"-s start event \n" <<"-n number of events \n" <<"-p beam momentum \n" <<"Have fun! \n" << std::endl; return 0; } while ((optind < (__argc-1) ) && (__argv[optind][0]=='-')) { bool found=false; std::string sw = __argv[optind]; if (sw=="-path"){ optind++; pathStr = __argv[optind]; found=true; } if (sw=="-s"){ optind++; startStr = __argv[optind]; found=true; } if (sw=="-n"){ optind++; nEvStr = __argv[optind]; found=true; } if (sw=="-p"){ optind++; beamMomStr = __argv[optind]; found=true; } if (!found){ std::cout<< "Unknown switch: " << __argv[optind] <> storePath; beamSStr >> beamMom; startSStr >> startEvent; nEvSStr >> nEvents; // ---- Load libraries ------------------------------------------------- gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C"); gSystem->Load("libLmdTrk"); gSystem->Load("libLmdTrk"); gSystem->Load("libPIPIGEN"); // ------------------------------------------------------------------------ // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); // ------------------------------------------------------------------------ // ---- Input files -------------------------------------------------------- TString simMC=storePath+"/Lumi_MC_"; simMC += startEvent; simMC += ".root"; TChain tMC("cbmsim"); tMC.Add(simMC); // --------------------------------------------------------------------------------- //--- MC info ----------------------------------------------------------------- TClonesArray* true_tracks=new TClonesArray("PndMCTrack"); tMC.SetBranchAddress("MCTrack",&true_tracks); //True Track to compare TClonesArray* true_points=new TClonesArray("PndSdsMCPoint"); tMC.SetBranchAddress("LMDPoint",&true_points); //True Points to compare //---------------------------------------------------------------------------------- // ---- Output file ---------------------------------------------------------------- TString out=storePath+"/GenInfo_out_DPM_all_beamMom_"; out += beamMom; // out += "_inel.root"; out += "_inel_and_el.root"; TFile *f = new TFile(out,"RECREATE"); // --------------------------------------------------------------------------------- //--- Output histogram ----------------------------------------------------- TH1 *hMCparticles = new TH1F("hMCparticles","Number of simulated particles;N;",5e1,0,5e1); TH1 *hMCpx = new TH1F("hMCpx","Px*;Px, GeV/c;",1e3,-1e1,1e1); TH1 *hMCpy = new TH1F("hMCpy","Py*;Py, GeV/c;",1e3,-1e1,1e1); TH1 *hMCpz = new TH1F("hMCpz","Pz*;Pz, GeV/c;",1e3,-1e1,1e1); TH1 *hMCphi = new TH1F("hMCphi","#phi*;#phi, rad;",1e2,-3.15,3.15); TH1 *hMCLabtheta = new TH1F("hMLabtheta","#theta (LAB);#theta, rad;",1e2,0,3.15); TH2 *hMCLABtheta_vs_ID = new TH2F("hMCLABtheta_vs_ID"," ;ID_{PDG};#theta(LAB), rad",6e3,-3e3,3e3,1e4,0,3.15); TH2 *hMCsmallLABtheta_vs_ID = new TH2F("hMCsmallLABtheta_vs_ID"," ;ID_{PDG};#theta(LAB), rad",6e3,-3e3,3e3,1e2,0,1.5e-2); TH2 *hMCsmallLABtheta_vs_Mass = new TH2F("hMCsmallLABtheta_vs_Mass"," ;Mass_{PDG};#theta(LAB), rad",1e3,-1,1,1e2,0,1.5e-2); TH1 *hSumIDs = new TH1F("hSumIDs","sum of PDG IDs;",1e4,0,1e4); TH2 *hSumIDs_numPar = new TH2F("hSumIDs_numPar",";sum of PDG IDs;number of particles",1e4,0,1e4,20,0,20); TH2 *hSumIDs_numPar_smallTheta = new TH2F("hSumIDs_numPar_smallTheta",";sum of PDG IDs;number of particles",1e4,0,1e4,20,0,20); //int countPDGid[15]; /// [0]=22 photon, [1]=111 pi0, [2]=130 K0_L, [3]=211 pi+, [4]=310 K0_S, [5]=321 K+ /// [6]=333 phi, [7]=2112 n, [8]=2212 p, [9]=3122 lyambda, [10]=-211 pi-, [11]=-321 K- /// [12]= -2112 anti_n, [13]=-2212 anti_p, [14]=-3122 anti_lyambda // TLorentzVector PbarBeam, PTarget, particle; // PbarBeam.SetPxPyPzE(0.,0.,beamMom,TMath::Sqrt(cProtonMass*cProtonMass + beamMom*beamMom)); // PTarget.SetPxPyPzE(0.,0.,0.,cProtonMass); vector countPDGid(6246); //number of each possible particle, [i]= PDGid + countPDGid.size()/2.; vector process(10000);// process[i]= name of process with PGDis sum=i; bool fsumID[100][10000]; for(int in=0;in<20;in++){ for(int isum=0;isum<10000;isum++){ fsumID[in][isum]=false; } } for (Int_t j=0; j vecPDGid; vector smallTheta; // for(int pid=0;pid<3123;pid++){ for(int pid=0;pid<6246;pid++){ //cout<<"countPDGid["<Fill(nParticles); double TotCharge=0; for(int nk=0;nkAt(nk); Int_t mcID = mctrk->GetPdgCode(); if(fabs(mcID)>3122) cout<<"!!!!!!!! PDGid = "<3122) countPDGid[0] +=1; if(fabs(mcID)>3122) continue; vecPDGid.push_back(mcID); // cout<<"#"<Fill(sumIDnum); hSumIDs_numPar->Fill(sumIDnum,nParticles); fsumID[nParticles][sumIDnum]=true; for(int ks=0;ksFill(sumIDnum,nParticles); } // cout<<"sumIDnum="<GetXaxis()->GetXmin(); double sumMax = hSumIDs_numPar->GetXaxis()->GetXmax(); double nparMin = hSumIDs_numPar->GetYaxis()->GetXmin(); double nparMax = hSumIDs_numPar->GetYaxis()->GetXmax(); double sumStep = (sumMax-sumMin)/(hSumIDs_numPar->GetNbinsX()); double nparStep = (nparMax-nparMin)/(hSumIDs_numPar->GetNbinsY()); int xpbarp = (4424+1)/sumStep; int numpbarpTot = hSumIDs_numPar->GetBinContent(xpbarp,2); int numpbarpSmall = hSumIDs_numPar_smallTheta->GetBinContent(xpbarp,2); if(numpbarpTot==0) numpbarpTot=1; if(numpbarpSmall==0) numpbarpSmall=1; if((hSumIDs_numPar->GetBinContent(xpbarp,2))) for(int xi=0;xiGetNbinsX();xi++){ for(int yi=0;yiGetNbinsY();yi++){ double numEv = hSumIDs_numPar->GetBinContent(xi,yi); // cout<<"xi = "<GetBinContent(xi,yi); if(numEvAtt!=0){ if(numpbarpTot!=1) cout<Divide(3,2); c1->cd(1); hMCpx->Draw(); c1->cd(2); hMCpy->Draw(); c1->cd(3); hMCpz->Draw(); c1->cd(4); hMCphi->Draw(); c1->cd(5); hMCLabtheta->Draw(); c1->cd(6); // hMCparticles->Draw(); c1->Write(); c1->Close(); TCanvas *c3 = new TCanvas("theta_vs_ID"); c3->Divide(2,2); c3->cd(1); hMCLABtheta_vs_ID->Draw(); c3->cd(2); hMCsmallLABtheta_vs_ID->Draw(); c3->cd(3); hMCsmallLABtheta_vs_Mass->Draw(); c3->Write(); c3->Close(); hMCLABtheta_vs_ID->Write(); hMCsmallLABtheta_vs_ID->Write(); hMCsmallLABtheta_vs_Mass->Write(); hSumIDs->Write(); hSumIDs_numPar->Write(); hSumIDs_numPar_smallTheta->Write(); hMCpx->Write(); hMCpy->Write(); hMCpz->Write(); hMCphi->Write(); hMCLabtheta->Write(); f->Close(); }