//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Plot pad occupancy // This macro plots the pads occupancy in a 2d histogram resembeling the IROC padplane // load macro with .L .C+ to compile it and then enter ExecuteplotOccupancy and press to see the arguments // runnumber: which run? datanumber: which reconstruction of this run? nevents: process how many events? dirname: output directory // poolfile and padplanefilename: where can the macro find information on the padshape and padplane? // // Environment: // GEM ALICE IROC prototype data analysis in fopiroot // // Author List: // Philipp Gadow (philipp.gadow@mytum.de) // // //----------------------------------------------------------- #include #include "TCanvas.h" #include "TAxis.h" #include "TFrame.h" #include "TFile.h" #include "TTree.h" #include "TString.h" #include "TH2F.h" #include "TH1I.h" #include "TROOT.h" #include #include #include #include #include #include #include #include #include #include //--------------------------------------------- //Helper functions //--------------------------------------------- string inttostring(Int_t input) { string s; stringstream out; out << input; s = out.str(); return s; } //--------------------------------------------- void ExecuteplotOccupancy(bool verbose, int runnumber, int datanumber, int nevents, bool pretty = false, string dirname = "../plots/", TString poolfile = "/nfs/hicran/project/panda/SIM/pgadow/fopiROOT_trunk/tpc/ALICE/par/padshape_iroc.dat", TString padplanefilename = "/nfs/hicran/project/panda/SIM/pgadow/fopiROOT_trunk/tpc/ALICE/par/padplane_iroc.dat"){ if (pretty){ gROOT->ProcessLine(".x ~/rootlogon_Bernhard.C"); gROOT->SetStyle("col"); gROOT->ForceStyle(); } TString indirname = "/nfs/mds/data/tpc/alice/ps_test_beam/RecoOut/"; TString infilename = "merge_" + inttostring(runnumber) + "_" + inttostring(datanumber) + "_corrected_hough_smoothed.reco.root"; TString inpathname = indirname + infilename; // open file TFile *reco = new TFile(inpathname); // create canvas TCanvas *c1 = new TCanvas("c1","Occupancy Map",1000,700); c1->SetFillColor(00); c1->SetGrid(); TCanvas *c2 = new TCanvas("c2","Number of signals per pad",1000,700); c2->SetFillColor(00); c2->SetGrid(); // create histogram TH2F *histoccupancy = new TH2F ("histoccupancy","Occupancy Map", 63,85.225,131.725,108,-21.4,21.8); TH1I *histpadoccupancy = new TH1I ("histpadoccupancy","Signals per pad", 5504,0,5504); // create Tree TTree *tpcTree = (TTree*)reco->Get("cbmsim"); // create arrays TClonesArray *samples = new TClonesArray("TpcSample"); //save time and load only necessary branches tpcTree->SetBranchStatus("*",0); tpcTree->SetBranchStatus("TpcSample.*",1); // set branches tpcTree->SetBranchAddress("TpcSample",&samples); // create padplane TpcPadShapePool *pool = new TpcPadShapePool(poolfile); TpcPadPlane* padplane = new TpcPadPlane(padplanefilename,pool); //events if (nevents == 0){ nevents = tpcTree->GetEntries(); } for( Int_t ev = 0; ev < nevents; ev++){ if(ev%1000==0){ cout<<"#################### Event done: "<GetEvent(ev); unsigned int nsamples = samples->GetEntriesFast(); for (unsigned int isample = 0; isample < nsamples; isample++){ TpcSample* sample = (TpcSample*) samples->At(isample); double padx = 0.; double pady = 0.; padplane->GetPadXY(sample->padId(),padx, pady); histoccupancy->Fill(padx,pady, 1); histpadoccupancy->Fill(sample->padId()); } } unsigned int maxtimebin = 317; //max time bin of samples in the analyzed data histoccupancy->Scale(1./long(nevents*maxtimebin)); //define output filename string filename = "merge_" + inttostring(runnumber) +"_"+ inttostring(datanumber) + "_occupancymap_"+ inttostring(nevents) + "_events"; string pathname1 = dirname + filename+".pdf"; string pathname2 = dirname + filename+".root"; string pathname3 = dirname + filename+"_PADIDs.pdf"; string pathname4 = dirname + filename+"_PADIDs.root"; // Draw the histograms and save plot c1->cd(); histoccupancy->GetXaxis()->SetTitle("x (cm)"); histoccupancy->GetYaxis()->SetTitle("y (cm)"); histoccupancy->Draw("colz"); c2->cd(); histpadoccupancy->GetXaxis()->SetTitle("padID"); histpadoccupancy->GetYaxis()->SetTitle("# entries"); histpadoccupancy->Draw(); c1->SaveAs(pathname1.data()); c1->SaveAs(pathname2.data()); c2->SaveAs(pathname3.data()); c2->SaveAs(pathname4.data()); }