//################################################################ //# 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; TString beamMom =""; 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_"; // int beamMomint= int(1000*beamMom); // double beamMomnew = beamMomint/1000; // cout<<"beamMom = "< 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[1000][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); TVector3 MomMCv = mctrk->GetMomentum(); TVector3 PosMCv = mctrk->GetStartVertex(); Int_t mcID = mctrk->GetPdgCode(); if(fabs(mcID)>3122) cout<<"!!!!!!!! PDGid = "<3122) countPDGid[0] +=1; if(fabs(mcID)>3122) continue; ntupMCTrk->Fill(mcID,PosMCv.X(),PosMCv.Y(),PosMCv.Z(),MomMCv.Mag(),MomMCv.Theta(),MomMCv.Phi()); vecPDGid.push_back(mcID); // cout<<"#"<Fill(MomMC.Theta()); double Px = MomMC.Px(); double Py = MomMC.Py(); double Pz = MomMC.Pz(); hMCpx->Fill(Px); hMCpy->Fill(Py); hMCpz->Fill(Pz); hMCphi->Fill(MomMC.Phi()); hMCLABtheta_vs_ID->Fill(mcID,MomMC.Theta()); if(MomMC.Theta()<1.5e-2 && mcID<0){ // if(MomMC.Theta()>1.5e-2 && mcID<0){ //!!!TEST hMCsmallLABtheta_vs_ID->Fill(mcID,MomMC.Theta()); hMCsmallLABtheta_vs_Mass->Fill(mcMass ,MomMC.Theta()); smallTheta.push_back(1); } else smallTheta.push_back(0); } if(nParticles!=vecPDGid.size()) continue; if(TotCharge!=0) continue; /// sort vecPDGid --------- Int_t k, x; bool ch=false; //Was element changed? Int_t nch = 0; //How many times? for(Int_t n=0; nFill(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(); ntupMCTrk->Write(); ntupMCHit->Write(); f->Close(); }