//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Plot sample amplitude distribution of a single pad // This macro plots the amplitude distribution of a single pad, useful to identify broken pads // load macro with .L .C+ to compile it and then enter ExecuteMacroSinglePadAnalysisAmp and press to see the arguments // runnumber: which run? datanumber: which reconstruction of this run? padnumber: which pad? 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 "TGraphErrors.h" #include "TAxis.h" #include "TFrame.h" #include "TH1F.h" #include "TLegend.h" #include "TArrow.h" #include "TLatex.h" #include "TFile.h" #include "TTree.h" #include "TString.h" #include "TROOT.h" #include "TPad.h" #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 ExecuteMacroSinglePadAnalysisAmp(bool verbose, int runnumber, int datanumber, int padnumber, int numevents, bool pretty = false, string dirname = "../plots/"){ 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","samples on pad: amplitude distribution",1000,700); c1->SetFillColor(00); c1->SetGrid(); std::string histtitle = "sample amplitude distribution pad " + inttostring(padnumber); // create histogram TH1F *histamp = new TH1F ("histamp", histtitle.data(), 200,0,200); // create Tree TTree *tpcTree = (TTree*)reco->Get("cbmsim"); // create array TClonesArray *samples = new TClonesArray("TpcSample"); // set branch tpcTree->SetBranchAddress("TpcSample",&samples); // loop over events if (numevents == 0){ numevents = tpcTree->GetEntries(); } for( Int_t ev = 0; ev Clear(); tpcTree->GetEvent(ev); Int_t NumTpcSamples = samples->GetEntries(); if (NumTpcSamples == 0) continue; for (Int_t isample = 0; isample < NumTpcSamples; ++isample){ TpcSample* tpcsample = (TpcSample*) samples->At(isample); unsigned int padid = tpcsample->padId(); if (padid!=padnumber){ continue; } histamp->Fill(tpcsample->amp()); } } //define output filename string filename = "hist681_amp_pad_"+inttostring(padnumber)+ "_" + inttostring(datanumber); string pathname1 = dirname + filename + ".root"; string pathname2 = dirname + filename + ".pdf"; histamp->GetXaxis()->SetTitle("sample amplitude"); histamp->GetYaxis()->SetTitle("# of entries"); histamp->Draw(); c1->SaveAs(pathname1.data()); c1->SaveAs(pathname2.data()); }