//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Plot pad hit found by PSA (amplitude vs time) // This macro plots the samples of a pad hit found by the Pulse Shape analysis for events. Don't choose a too large (not larger than 10)! // load macro with .L .C+ to compile it and then enter ExecuteShapeofDigi and press to see the arguments // runnumber: which run? datanumber: which reconstruction of this run? nevents: process how many events? singletrackevents: only single track 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 "TClonesArray.h" #include "TCanvas.h" #include "TGraphErrors.h" #include "TAxis.h" #include "TFrame.h" #include "TF1.h" #include "TLegend.h" #include "TArrow.h" #include "TLatex.h" #include "TFile.h" #include "TTree.h" #include "TString.h" #include "TROOT.h" #include #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 ExecuteShapeofDigi(bool verbose, int runnumber, int datanumber, int nevents, bool singletrackevents = false, bool pretty = false, string dirname = "../plots/shapeofdigi/"){ 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: amp vs t",200,10,700,500); c1->SetFillColor(00); c1->SetGrid(); // create Tree TTree *tpcTree = (TTree*)reco->Get("cbmsim"); //save time and load only necessary branches tpcTree->SetBranchStatus("*",0); tpcTree->SetBranchStatus("TpcSample.*",1); tpcTree->SetBranchStatus("TpcDigi.*",1); tpcTree->SetBranchStatus("TpcCluster.*",1); tpcTree->SetBranchStatus("TpcTrackPreFit.*",1); // create arrays TClonesArray *clusters = new TClonesArray("TpcCluster"); TClonesArray *digis = new TClonesArray("TpcDigi"); TClonesArray *samples = new TClonesArray("TpcSample"); TClonesArray *tracks = new TClonesArray("GFTrack"); // set branches tpcTree->SetBranchAddress("TpcSample",&samples); tpcTree->SetBranchAddress("TpcDigi",&digis); tpcTree->SetBranchAddress("TpcCluster",&clusters); tpcTree->SetBranchAddress("TpcTrackPreFit",&tracks); // loop over events, clusters, digis and samples //events if (nevents == 0){ nevents = tpcTree->GetEntries(); } for( Int_t ev = 0; ev GetEvent(ev); int numberoftracks = tracks->GetEntries(); std::cout << "number of tracks per event:" << numberoftracks << std::endl; //select only single track events if (singletrackevents){ if (numberoftracks!=1) continue; } Int_t NumTpcClusters = clusters->GetEntries(); if (NumTpcClusters == 0) continue; //clusters - gehe array von clustern durch, die zu einem event gehoeren for (Int_t clu = 0; clu < NumTpcClusters; ++clu){ TpcCluster* tpccluster = (TpcCluster*) clusters->At(clu); Int_t tpcdigispercluster = tpccluster->size(); if (verbose){ cout<<"Cluster: "< tpcdigiIDs = tpccluster->getDigiIDs(); for(unsigned int iDigi = 0; iDigi < tpcdigiIDs.size();++iDigi){ TpcDigi* tpcdigi = (TpcDigi*) digis->At(tpcdigiIDs[iDigi]); double tpcdigiT = tpcdigi->t(); Double_t digiTx[] = {tpcdigiT,tpcdigiT}; // finde die zugehoerigen sample IDs const std::map* tpcsampleIDs = tpcdigi->getSampleMap(); std::map::const_iterator it; if(tpcsampleIDs->size()==0) { continue; } if (verbose){ cout<<"Digi: "<size()< sampleT; std::vector sampleAmp; int size = 0; double maxamp = 0; double minT = 10000000; //just a very large number, not good coding style, but it works... double maxT = 0.; for (it = tpcsampleIDs->begin(); it!=tpcsampleIDs->end(); ++it){ if(verbose){ cout<<"sampleId "<first<<" weight: "<second<first>4294967294) { cerr << "sampleID larger than max number that can be processed!" << endl; continue; } TpcSample* tpcsample = (TpcSample*) samples->At(it->first); ++size; double ampl = tpcsample->amp(); double time = tpcsample->t(); sampleT.push_back(time); sampleAmp.push_back(ampl); if (ampl>maxamp){ maxamp = ampl; } if (time>maxT){ maxT = time; } if (timepadId()<<" t: "<t() <<" A: "<amp()<GetXaxis()->SetLimits(minT-15,maxT+15); TGraph* gr2 = new TGraph(2,digiTx,digiTy); string outfilename = "merge_" + inttostring(runnumber) + "_" + inttostring(datanumber) +"_digiplot_" + inttostring(ev) + "_" + inttostring(clu) + "_"+ inttostring(iDigi); string outpathname1 = dirname + outfilename + ".pdf"; string outpathname2 = dirname + outfilename + ".root"; // Draw Plot gr->SetLineColor(2); gr->SetLineWidth(4); gr->SetMarkerColor(4); gr->SetMarkerStyle(21); gr->SetTitle("Pad Hit"); gr->GetXaxis()->SetTitle("time (samples)"); gr->GetYaxis()->SetTitle("amplitude (ADC channels)"); gr->Draw("AP"); gr->SetLineColor(2); gr->SetLineWidth(6); gr2->Draw("C"); c1->Update(); c1->GetFrame()->SetFillColor(00); c1->GetFrame()->SetBorderSize(12); c1->Modified(); c1->SaveAs(outpathname1.data()); c1->SaveAs(outpathname2.data()); } } } }