//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Plot amplitude and time distribution of samples // This macro plots a 2d histogram displaying the timestamps of samples and their amplitudes // load macro with .L .C+ to compile it and then enter ExecuteAmpTimeDistribution and press to see the arguments // runnumber: which run? datanumber: which reconstruction of this run? nevents: process how many events? dirname: output directory name // // 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 "TF1.h" #include "TLatex.h" #include "TFile.h" #include "TTree.h" #include "TString.h" #include "TH1I.h" #include "TH2F.h" #include #include #include #include #include //--------------------------------------------- //Helper functions //--------------------------------------------- string inttostring(Int_t input) { string s; stringstream out; out << input; s = out.str(); return s; } //--------------------------------------------- void ExecuteAmpTimeDistribution(bool verbose, int runnumber, int datanumber, int nevents, string dirname = "../plots/"){ 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","sample distribution",1000,700); c1->SetFillColor(00); c1->SetGrid(); c1->Divide(2,1); TCanvas *c2 = new TCanvas("c2","sample 2d distribution",1000,700); c2->SetFillColor(00); c2->SetGrid(); // create histogram TH1I *histtime = new TH1I ("histtime", "time distribution of signals", 300,0,300); TH1I *histamp = new TH1I ("histamp", "amplitude distribution of signals", 100,0,100); TH2F *histampvstime = new TH2F ("histampvstime", "amplitude vs time distribution", 100,0,100, 300,0,300); // create Tree TTree *tpcTree = (TTree*)reco->Get("cbmsim"); //save time and load only necessary branches tpcTree->SetBranchStatus("*",0); tpcTree->SetBranchStatus("TpcSample.*",1); // create arrays TClonesArray *samples = new TClonesArray("TpcSample"); // set branches tpcTree->SetBranchAddress("TpcSample",&samples); // loop over events if (nevents == 0){ nevents = tpcTree->GetEntries(); } for( Int_t ev = 0; ev < nevents; ev++){ if(ev%1000==0){ cout<< "#################### Event done: "<GetEvent(ev); Int_t nsamples = samples->GetEntriesFast(); for (Int_t isample = 0; isample At(isample); //Fill histograms histtime->Fill(tpcsample->t()); histamp->Fill(tpcsample->amp()); histampvstime->Fill(tpcsample->amp(),tpcsample->t()); } } //define output filename string filename = "merge_" + inttostring(runnumber) + "_"+ inttostring(datanumber) + "_ampvstimedistribution"; string pathname1 = dirname + filename +".root"; string pathname2 = dirname + filename +".pdf"; string pathname3 = dirname + filename +"_2dplot.root"; string pathname4 = dirname + filename +"_2dplot.pdf"; // Draw the histogram c1->cd(1); histtime->GetXaxis()->SetTitle("sample time (samples)"); histtime->GetYaxis()->SetTitle("# of entries"); histtime->Draw(); c1->cd(2); histamp->GetXaxis()->SetTitle("sample amplitude (ADC channels)"); histamp->GetYaxis()->SetTitle("# of entries"); histamp->Draw(); c2->cd(); histampvstime->GetXaxis()->SetTitle("sample amplitude"); histampvstime->GetYaxis()->SetTitle("sample time"); histampvstime->Draw("colz"); c1->SaveAs(pathname1.data()); c1->SaveAs(pathname2.data()); c2->SaveAs(pathname3.data()); c2->SaveAs(pathname4.data()); }