//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Plot clusters per event // This macro plots the # of clusters found by the clustering task per event and the # of clusters in a single track event. // load macro with .L .C+ to compile it and then enter ExecuteEventAnalysis and press to see the arguments // runnumber: which run? datanumber: which reconstruction of this run? nevents: process how many events? dirname: output directory // // 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 "TLatex.h" #include "TFile.h" #include "TTree.h" #include "TString.h" #include "TH1F.h" #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 ExecuteEventAnalysis(bool verbose, int runnumber, int datanumber, int nevents, string dirname = "../plots/evanalysis/"){ 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","clusters per event",1000,700); c1->Divide(2,1); c1->SetFillColor(00); c1->SetGrid(); // create histogram TH1F *hist1 = new TH1F("hist1", "number of clusters per event", 100,0,100); TH1F *hist2 = new TH1F("hist2", "number of clusters per single track event", 100,0,100); // create Tree TTree *tpcTree = (TTree*)reco->Get("cbmsim"); //save time and load only necessary branches tpcTree->SetBranchStatus("*",0); tpcTree->SetBranchStatus("TpcCluster.*",1); tpcTree->SetBranchStatus("TrackPostFit.*",1); // create arrays TClonesArray *clusters = new TClonesArray("TpcCluster"); TClonesArray *tracks = new TClonesArray("GFTrack"); // set branches tpcTree->SetBranchAddress("TpcCluster",&clusters); tpcTree->SetBranchAddress("TrackPostFit",&tracks); // loop over events if (nevents == 0){ nevents = tpcTree->GetEntries(); } for( Int_t ev = 0; ev < nevents; ev++){ if(ev%1000==0){ cout<< "#################### Event done: "<Delete(); tracks->Delete(); tpcTree->GetEvent(ev); int numberoftracks = tracks->GetEntries(); if(verbose){ cout << std::endl; std::cout << "number of tracks per event:" << numberoftracks << std::endl; } Int_t NumTpcClusters = clusters->GetEntries(); //Fill histograms hist1->Fill(NumTpcClusters); if (numberoftracks==1){ hist2->Fill(NumTpcClusters); } } //define output filename string filename = "merge_" + inttostring(runnumber) + "_"+ inttostring(datanumber) + "_clusterperevent"; string pathname1 = dirname + filename +".root"; string pathname2 = dirname + filename +".pdf"; // Draw the histogram c1->cd(1); hist1->GetXaxis()->SetTitle("# of clusters per event"); hist1->GetXaxis()->CenterTitle(); hist1->GetYaxis()->SetTitle("# of entries"); hist1->Draw(); c1->cd(2); hist2->GetXaxis()->SetTitle("# of clusters per single track event"); hist2->GetYaxis()->SetTitle("# of entries"); hist2->Draw(); c1->SaveAs(pathname1.data()); c1->SaveAs(pathname2.data()); }