//dEdx-Plot for single event //Author: P. Gadow //status: version 1.0 #include #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 "TH1F.h" #include #include #include #include #include #include #include #include #include #include #include #include #include std::string inttostring(Int_t input) { std::string s; std::stringstream out; out << input; s = out.str(); return s; } string doubletostring(double input) { string s; stringstream out; out << input; s = out.str(); return s; } void ExecutedEdxplotSingleTrack(bool verbose, int runnumber, int datasetnumber, unsigned int ev){ TString indirname = "/nfs/mds/data/tpc/alice/ps_test_beam/RecoOut/"; TString infilename = "merge_" + inttostring(runnumber) + "_"+inttostring(datasetnumber)+"_corrected_hough_smoothed.reco.root"; TString inpathname = indirname + infilename; // open file TFile *reco = new TFile(inpathname); // create canvas TCanvas *cdEdx = new TCanvas("cdEdx","dEdx",1000,700); TString histname = "dEdx"; // create histogram TH1F *histdistribution = new TH1F ("histdistribution", histname, 150,0,300); // create Tree TTree *tpcTree = (TTree*)reco->Get("cbmsim"); //save time and load only necessary branches tpcTree->SetBranchStatus("*",0); tpcTree->SetBranchStatus("dEdx.*",1); tpcTree->SetBranchStatus("TrackPostFit.*",1); tpcTree->SetBranchStatus("GEMEvent.*",1); tpcTree->SetBranchStatus("TpcCluster.*",1); // create arrays TClonesArray *dedx = new TClonesArray("TpcdEdx"); TClonesArray *tracks = new TClonesArray("GFTrack"); TClonesArray *gemevent = new TClonesArray("GEMEvent"); TClonesArray *clusters = new TClonesArray("TpcCluster"); // set branches tpcTree->SetBranchAddress("dEdx",&dedx); tpcTree->SetBranchAddress("TrackPostFit",&tracks); tpcTree->SetBranchAddress("GEMEvent",&gemevent); tpcTree->SetBranchAddress("TpcCluster",&clusters); //event tpcTree->GetEvent(ev); Int_t NumTpcdEdx = dedx->GetEntries(); int numberofclusters = clusters->GetEntries(); if(verbose){ std::cout << numberofclusters << std::endl; } int numberoftracks = tracks->GetEntries(); if(verbose){ std::cout << "number of tracks per event:" << numberoftracks << std::endl; } for (Int_t idedex = 0; idedex < NumTpcdEdx; ++idedex){ TpcdEdx* tpcdedx = (TpcdEdx*) dedx->At(idedex); //tracklength //detector length in x = 46.5 cm double tracklength = 0.; for(unsigned int idx=0;idxnEntries();++idx){ tracklength += tpcdedx->getdx(idx); } if(verbose){ std::cout << "tracklength( 35truncMean(0,.25) << ", simple mean: " << tpcdedx->simpleMean() << std::endl; std::cout<< "num of dedx entries:" << NumTpcdEdx <nEntries() <nEntries(); i++){ double dEdx = tpcdedx->getdE(i)/tpcdedx->getdx(i); histdistribution->Fill(dEdx); if(verbose){ std::cout<<"dedx" << i<<" de: " << tpcdedx->getdx(i)<< ", dx: "<getdE(i) << "dE/dx: " << dEdx<cd(); // Draw the histogram histdistribution->GetXaxis()->SetTitle("dE/dx"); histdistribution->GetYaxis()->SetTitle("# of entries"); histdistribution->Draw(); } }