--- /dev/null
+/*
+ fbellini@cern.ch - last update on 27/02/2014
+ Macro to draw the TOF QA trending plots by accessing the std tree.
+ To be mainly used with the automatic scripts to fill the QA repository.
+ Launch with
+ aliroot -x -b -q "DrawTrendingTOFQA.C"
+ The macro produces one png file for each trending variables
+ and a .root file with the histograms
+*/
+Int_t DrawTrendingTOFQA(TString mergedTrendFile = "trending.root", // trending tree file
+ Bool_t displayAll = kFALSE) //set to kTRUE to display trending for expert plots
+{
+ //
+ //reads merged trending.root file and draws trending plots from tree
+ //
+ if (!mergedTrendFile) {
+ Printf("Cannot open merged trend file with TOF QA");
+ return 1;
+ }
+
+ char outfilename[200]= "ProductionQA.hist.root";
+ TString plotDir(".");
+ // TString plotDir(Form("PlotsTrending"));
+ // gSystem->Exec(Form("mkdir %s",plotDir.Data()));
+
+ Int_t runNumber=0;
+ Double_t avTime=0., peakTime=0., spreadTime=0., peakTimeErr=0., spreadTimeErr=0.,negTimeRatio=0.,
+ avRawTime=0., peakRawTime=0., spreadRawTime=0., peakRawTimeErr=0., spreadRawTimeErr=0.,
+ avTot=0., peakTot=0.,spreadTot=0., peakTotErr=0.,spreadTotErr=0.,
+ orphansRatio=0., avL=0., negLratio=0.,
+ effPt1=0., effPt2=0., matchEffLinFit1Gev=0.,matchEffLinFit1GevErr=0.;
+ Double_t avDiffTime=0.,peakDiffTime=0., spreadDiffTime=0.,peakDiffTimeErr=0., spreadDiffTimeErr=0.,avT0fillRes=0.;
+
+ Double_t avT0A=0.,peakT0A=0., spreadT0A=0.,peakT0AErr=0., spreadT0AErr=0.;
+ Double_t avT0C=0.,peakT0C=0., spreadT0C=0.,peakT0CErr=0., spreadT0CErr=0.;
+ Double_t avT0AC=0.,peakT0AC=0., spreadT0AC=0.,peakT0ACErr=0., spreadT0ACErr=0.;
+ Double_t avT0res=0.,peakT0res=0., spreadT0res=0.,peakT0resErr=0., spreadT0resErr=0.;
+ Float_t avMulti=0;
+ Float_t fractionEventsWHits=0.0;
+ Double_t goodChannelRatio=0.0;
+
+ TFile * fin = TFile::Open(mergedTrendFile.Data());
+ TTree * ttree = (TTree*) fin->Get("trending");
+ if (!ttree){
+ Printf("Invalid trending tree.");
+ return 2;
+ }
+ ttree->SetBranchAddress("run",&runNumber);
+ ttree->SetBranchAddress("avMulti",&avMulti);
+ ttree->SetBranchAddress("goodChannelsRatio",&goodChannelRatio);
+ ttree->SetBranchAddress("avTime",&avTime); //mean time
+ ttree->SetBranchAddress("peakTime",&peakTime); //main peak time after fit
+ ttree->SetBranchAddress("spreadTime",&spreadTime); //spread of main peak of time after fit
+ ttree->SetBranchAddress("peakTimeErr",&peakTimeErr); //main peak time after fit error
+ ttree->SetBranchAddress("spreadTimeErr",&spreadTimeErr); //spread of main peak of time after fit error
+ ttree->SetBranchAddress("negTimeRatio",&negTimeRatio); //negative time ratio
+ ttree->SetBranchAddress("avRawTime",&avRawTime); //mean raw time
+ ttree->SetBranchAddress("peakRawTime",&peakRawTime); //mean peak of raw time after fit
+ ttree->SetBranchAddress("spreadRawTime",&spreadRawTime); //spread of main peak of raw time after fit
+ ttree->SetBranchAddress("peakRawTimeErr",&peakRawTimeErr); //main peak raw time after fit error
+ ttree->SetBranchAddress("spreadRawTimeErr",&spreadRawTimeErr); //spread of raw main peak of time after fit error
+ ttree->SetBranchAddress("avTot",&avTot); //main peak tot
+ ttree->SetBranchAddress("peakTot",&peakTot); // main peak of tot after fit
+ ttree->SetBranchAddress("spreadTot",&spreadTot); //spread of main peak of tot after fit
+ ttree->SetBranchAddress("peakTotErr",&peakTotErr); // main peak of tot after fit
+ ttree->SetBranchAddress("spreadTotErr",&spreadTotErr); //spread of main peak of tot after fit
+ ttree->SetBranchAddress("orphansRatio",&orphansRatio); //orphans ratio
+ ttree->SetBranchAddress("avL",&avL); //mean track length
+ ttree->SetBranchAddress("negLratio",&negLratio);//ratio of tracks with track length <350 cm
+ ttree->SetBranchAddress("effPt1",&effPt1);//matching eff at 1 GeV/c
+ ttree->SetBranchAddress("effPt2",&effPt2); //matching eff at 2 GeV/c
+ ttree->SetBranchAddress("matchEffLinFit1Gev",&matchEffLinFit1Gev);//matching eff fit param
+ ttree->SetBranchAddress("matchEffLinFit1GevErr",&matchEffLinFit1GevErr);////matching eff fit param error
+ ttree->SetBranchAddress("avPiDiffTime",&avDiffTime); //mean t-texp
+ ttree->SetBranchAddress("peakPiDiffTime",&peakDiffTime); //main peak t-texp after fit
+ ttree->SetBranchAddress("spreadPiDiffTime",&spreadDiffTime); //spread of main peak t-texp after fit
+ ttree->SetBranchAddress("peakPiDiffTimeErr",&peakDiffTimeErr); //main peak t-texp after fit error
+ ttree->SetBranchAddress("spreadPiDiffTimeErr",&spreadDiffTimeErr); //spread of main peak of t-texp after fit error
+ ttree->SetBranchAddress("avT0A",&avT0A); //main peak t0A
+ ttree->SetBranchAddress("peakT0A",&peakT0A); // main peak of t0A after fit
+ ttree->SetBranchAddress("spreadT0A",&spreadT0A); //spread of main peak of t0A after fit
+ ttree->SetBranchAddress("peakT0AErr",&peakT0AErr); // main peak of t0A after fit
+ ttree->SetBranchAddress("spreadT0AErr",&spreadT0AErr); //spread of main peak of t0A after fit
+ ttree->SetBranchAddress("avT0C",&avT0C); //main peak t0C
+ ttree->SetBranchAddress("peakT0C",&peakT0C); // main peak of t0C after fit
+ ttree->SetBranchAddress("spreadT0C",&spreadT0C); //spread of main peak of t0C after fit
+ ttree->SetBranchAddress("peakT0CErr",&peakT0CErr); // main peak of t0C after fit
+ ttree->SetBranchAddress("spreadT0CErr",&spreadT0CErr); //spread of main peak of t0C after fit
+ ttree->SetBranchAddress("avT0AC",&avT0AC); //main peak t0AC
+ ttree->SetBranchAddress("peakT0AC",&peakT0AC); // main peak of t0AC after fit
+ ttree->SetBranchAddress("spreadT0AC",&spreadT0AC); //spread of main peak of t0AC after fit
+ ttree->SetBranchAddress("peakT0ACErr",&peakT0ACErr); // main peak of t0AC after fit
+ ttree->SetBranchAddress("spreadT0ACErr",&spreadT0ACErr); //spread of main peak of t0AC after fit
+ ttree->SetBranchAddress("avT0res",&avT0res); //main peak t0AC
+ ttree->SetBranchAddress("peakT0res",&peakT0res); // main peak of t0AC after fit
+ ttree->SetBranchAddress("spreadT0res",&spreadT0res); //spread of main peak of t0AC after fit
+ ttree->SetBranchAddress("peakT0resErr",&peakT0resErr); // main peak of t0AC after fit
+ ttree->SetBranchAddress("spreadT0resErr",&spreadT0resErr); //spread of main peak of t0AC after fit
+ ttree->SetBranchAddress("avT0fillRes",&avT0fillRes); //t0 fill res
+
+ Int_t nRuns=ttree->GetEntries();
+ TList lista;
+
+ TH1F * hAvMulti=new TH1F("hAvMulti","Average multiplicity of matched tracks <N_{TOF}>;; <N_{TOF}>", nRuns,0., nRuns);//, 600, 0. , 600.);
+ hAvMulti->SetDrawOption("E1");
+ hAvMulti->SetMarkerStyle(20);
+ hAvMulti->SetMarkerColor(kBlue);
+
+ TH1F * hAvDiffTimeVsRun=new TH1F("hAvDiffTimeVsRun","Mean t-t_{exp} (no fit);run;<t^{TOF}-t_{exp,#pi}> (ps)",nRuns,0., nRuns);//, 600, 0. , 600.);
+ hAvDiffTimeVsRun->SetDrawOption("E1");
+ hAvDiffTimeVsRun->SetMarkerStyle(20);
+ hAvDiffTimeVsRun->SetMarkerColor(kBlue);
+ // hAvTimeVsRun->GetYaxis()->SetRangeUser(0.0, 50.0);
+
+ TH1F * hPeakDiffTimeVsRun=new TH1F("hPeakDiffTimeVsRun","t-t_{exp} (gaussian fit) ;; <t^{TOF}-t_{exp,#pi}> (ps)",nRuns,0., nRuns);//,600, 0. , 600. );
+ hPeakDiffTimeVsRun->SetDrawOption("E1");
+ hPeakDiffTimeVsRun->SetMarkerStyle(20);
+ hPeakDiffTimeVsRun->SetMarkerColor(kBlue);
+
+ TH1F * hSpreadDiffTimeVsRun=new TH1F("hSpreadDiffTimeVsRun","#sigma(t-t_{exp}) (gaussian fit);; #sigma(t^{TOF}-t_{exp,#pi}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.);
+ hSpreadDiffTimeVsRun->SetDrawOption("E1");
+ hSpreadDiffTimeVsRun->SetMarkerStyle(20);
+ hSpreadDiffTimeVsRun->SetMarkerColor(kBlue);
+
+ TH1F * hAvTimeVsRun=new TH1F("hAvTimeVsRun","<t^{TOF}>;;<t^{TOF}> (ns)",nRuns,0., nRuns);//, 600, 0. , 600.);
+ hAvTimeVsRun->SetDrawOption("E1");
+ hAvTimeVsRun->SetMarkerStyle(20);
+ hAvTimeVsRun->SetMarkerColor(kBlue);
+ // hAvTimeVsRun->GetYaxis()->SetRangeUser(0.0, 50.0);
+
+ TH1F * hPeakTimeVsRun=new TH1F("hPeakTimeVsRun","Peak value of t^{TOF} (landau fit);;t_{peak}^{TOF} (ns)",nRuns,0., nRuns);//,600, 0. , 600. );
+ hPeakTimeVsRun->SetDrawOption("E1");
+ hPeakTimeVsRun->SetMarkerStyle(20);
+ hPeakTimeVsRun->SetMarkerColor(kBlue);
+
+ TH1F * hSpreadTimeVsRun=new TH1F("hSpreadTimeVsRun","Spread of t^{TOF} (landau fit);; #sigma(t^{TOF}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.);
+ hSpreadTimeVsRun->SetDrawOption("E1");
+ hSpreadTimeVsRun->SetMarkerStyle(20);
+ hSpreadTimeVsRun->SetMarkerColor(kBlue);
+
+ TH1F * hAvRawTimeVsRun=new TH1F("hAvRawTimeVsRun","Peak value of raw t^{TOF};;<t_{raw}^{TOF}> (ns)",nRuns,0., nRuns);//, 600, 0. , 600.);
+ hAvRawTimeVsRun->SetDrawOption("E1");
+ hAvRawTimeVsRun->SetMarkerStyle(21);
+ hAvRawTimeVsRun->SetMarkerColor(kGreen);
+
+ TH1F * hPeakRawTimeVsRun=new TH1F("hPeakRawTimeVsRun","Peak value of raw t^{TOF} (landau fit);;t_{peak,raw}^{TOF} (ns)",nRuns,0., nRuns);//, 600, 0. , 600.);
+ hPeakRawTimeVsRun->SetDrawOption("E1");
+ hPeakRawTimeVsRun->SetMarkerStyle(21);
+ hPeakRawTimeVsRun->SetMarkerColor(kGreen);
+
+ TH1F * hSpreadRawTimeVsRun=new TH1F("hSpreadRawTimeVsRun","Spread of raw t^{TOF} (landau fit);;#sigma(t_{raw}^{TOF}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.);
+ hSpreadRawTimeVsRun->SetDrawOption("E1");
+ hSpreadRawTimeVsRun->SetMarkerStyle(21);
+ hSpreadRawTimeVsRun->SetMarkerColor(kGreen);
+
+ TH1F * hAvTotVsRun=new TH1F("hAvTotVsRun","<ToT> (no fit);run;<ToT> (ns)",nRuns,0., nRuns);//, 50, 0. , 50.);
+ hAvTotVsRun->SetDrawOption("E1");
+ hAvTotVsRun->SetMarkerStyle(22);
+
+ TH1F * hPeakTotVsRun=new TH1F("hPeakTotVsRun","<ToT> (gaussian fit);;ToT_{peak} (ns)",nRuns,0., nRuns);//, 50, 0. , 50.);
+ hPeakTotVsRun->SetDrawOption("E1");
+ hPeakTotVsRun->SetMarkerStyle(22);
+
+ TH1F * hSpreadTotVsRun=new TH1F("hSpreadTotVsRun","#sigma(ToT) (gaussian fit);#sigma(ToT) (ns)",nRuns,0., nRuns);//, 50, 0. , 50.);
+ hSpreadTotVsRun->SetDrawOption("E1");
+ hSpreadTotVsRun->SetMarkerStyle(22);
+
+ TH1F * hNegTimeRatioVsRun=new TH1F("hNegTimeRatioVsRun","Ratio of tracks with t^{TOF}<12.5 ns; ; ratio of tracks with t^{TOF}<12.5 ns (%)",nRuns, 0., nRuns);//, 100, 0. , 100.);
+ hNegTimeRatioVsRun->SetDrawOption("E");
+
+ TH1F * hOrphansRatioVsRun=new TH1F("hOrphansRatioVsRun","Ratio of orphans (hits with ToT=0); ; ratio of orphans (%)",nRuns, 0., nRuns);//, 1000, 0. , 100.);
+ hOrphansRatioVsRun->SetDrawOption("E");
+
+ TH1F * hMeanLVsRun=new TH1F("hMeanLVsRun","Average track length;; <L> (cm)",nRuns, 0., nRuns);//, 350, 350. , 700.);
+ hMeanLVsRun->SetDrawOption("E");
+ TH1F * hNegLRatioVsRun=new TH1F("hNegLRatioVsRun","Ratio of tracks with L<350 cm;; ratio of tracks with L<350 cm (%)",nRuns, 0., nRuns);//, 1000, 0. , 100.);
+ hNegLRatioVsRun->SetDrawOption("E");
+ TH1F * hMatchEffVsRun=new TH1F("hMatchEffVsRun","Matching efficiency (linear fit for p_{T}>1.0 GeV/c);;matching efficiency (pT>1.0 GeV/c)",nRuns, 0., nRuns);//, 100, 0. , 1.);
+ hMatchEffVsRun->SetDrawOption("E");
+ TH1F * hMatchEffVsRunNormToGoodCh=new TH1F("hMatchEffVsRunNormToGoodCh","Matching efficiency normalized to percentage of TOF good channels;;matching efficiency (pT>1.0 GeV/c)",nRuns, 0., nRuns);//, 100, 0. , 1.);
+ hMatchEffVsRunNormToGoodCh->SetDrawOption("E");
+
+ TH1F * hMatchEffVsRun1=new TH1F("hMatchEffVsRun1","Matching efficiency (value for p_{T}=1.0 GeV/c);;matching efficiency (pT=1.0 GeV/c)",nRuns, 0., nRuns);
+ hMatchEffVsRun1->SetDrawOption("E");
+ TH1F * hPeakT0AVsRun=new TH1F("hPeakT0AVsRun","Peak value of T0A (gaussian fit);;t0A (ps)",nRuns,0., nRuns);
+ TH1F * hPeakT0CVsRun=new TH1F("hPeakT0CVsRun","Peak value of T0C (gaussian fit);;t0AC (ps)",nRuns,0., nRuns);
+ TH1F * hPeakT0ACVsRun=new TH1F("hPeakT0ACVsRun","Peak value of T0AC (gaussian fit);;t0AC (ps)",nRuns,0., nRuns);
+ TH1F * hT0fillResVsRun=new TH1F("hT0fillResVsRun","t0_fill spread;;t0_spread (ps)",nRuns,0., nRuns);
+
+
+ lista.Add(hAvMulti);
+ lista.Add(hAvDiffTimeVsRun);
+ lista.Add(hPeakDiffTimeVsRun);
+ lista.Add(hSpreadDiffTimeVsRun);
+ lista.Add(hAvTimeVsRun);
+ lista.Add(hPeakTimeVsRun);
+ lista.Add(hSpreadTimeVsRun);
+ lista.Add( hAvRawTimeVsRun);
+ lista.Add( hPeakRawTimeVsRun);
+ lista.Add( hSpreadRawTimeVsRun);
+ lista.Add( hAvTotVsRun);
+ lista.Add( hPeakTotVsRun);
+ lista.Add( hSpreadTotVsRun);
+ lista.Add( hNegTimeRatioVsRun);
+ lista.Add( hOrphansRatioVsRun);
+ lista.Add( hMeanLVsRun);
+ lista.Add( hNegLRatioVsRun);
+ lista.Add( hMatchEffVsRun);
+ lista.Add(hMatchEffVsRunNormToGoodCh);
+ lista.Add(hPeakT0AVsRun);
+ lista.Add(hPeakT0CVsRun);
+ lista.Add(hPeakT0ACVsRun);
+ lista.Add(hT0fillResVsRun);
+ char runlabel[6];
+
+ for (Int_t irun=0;irun<nRuns;irun++){
+ ttree->GetEntry(irun);
+
+ sprintf(runlabel,"%i",runNumber);
+
+ hAvMulti->SetBinContent(irun+1, avMulti);
+ hAvMulti->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hAvDiffTimeVsRun->SetBinContent(irun+1, avDiffTime);
+ hAvDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hPeakDiffTimeVsRun->SetBinContent(irun+1,peakDiffTime);
+ hPeakDiffTimeVsRun->SetBinError(irun+1,peakDiffTimeErr);
+ hPeakDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hSpreadDiffTimeVsRun->SetBinContent(irun+1,spreadDiffTime);
+ hSpreadDiffTimeVsRun->SetBinError(irun+1,spreadDiffTimeErr);
+ hSpreadDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hAvTimeVsRun->SetBinContent(irun+1, avTime);
+ hAvTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hPeakTimeVsRun->SetBinContent(irun+1,peakTime);
+ hPeakTimeVsRun->SetBinError(irun+1,peakTimeErr);
+ hPeakTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hSpreadTimeVsRun->SetBinContent(irun+1,spreadTime);
+ hSpreadTimeVsRun->SetBinError(irun+1,spreadTimeErr);
+ hSpreadTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hAvRawTimeVsRun->SetBinContent(irun+1, avRawTime);
+ hAvRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hPeakRawTimeVsRun->SetBinContent(irun+1,peakRawTime);
+ hPeakRawTimeVsRun->SetBinError(irun+1,peakRawTimeErr);
+ hPeakRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hSpreadRawTimeVsRun->SetBinContent(irun+1,spreadRawTime);
+ hSpreadRawTimeVsRun->SetBinError(irun+1,spreadRawTimeErr);
+ hSpreadRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hAvTotVsRun->SetBinContent(irun+1,avTot);
+ hAvTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hPeakTotVsRun->SetBinContent(irun+1,peakTot);
+ hPeakTotVsRun->SetBinError(irun+1,peakTotErr);
+ hPeakTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hSpreadTotVsRun->SetBinContent(irun+1,spreadTot);
+ hSpreadTotVsRun->SetBinError(irun+1,spreadTotErr);
+ hSpreadTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hNegTimeRatioVsRun->SetBinContent(irun+1,negTimeRatio);
+ hNegTimeRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hOrphansRatioVsRun->SetBinContent(irun+1,orphansRatio);
+ hOrphansRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hMeanLVsRun->SetBinContent(irun+1,avL);
+ hMeanLVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hNegLRatioVsRun->SetBinContent(irun+1,negLratio);
+ hNegLRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hMatchEffVsRun->SetBinContent(irun+1,matchEffLinFit1Gev);
+ hMatchEffVsRun->SetBinError(irun+1,matchEffLinFit1GevErr);
+ hMatchEffVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+ hMatchEffVsRun->SetLineColor(kRed);
+ hMatchEffVsRun->SetLineWidth(2);
+
+ if (goodChannelRatio>0)
+ hMatchEffVsRunNormToGoodCh->SetBinContent(irun+1,matchEffLinFit1Gev/goodChannelRatio);
+ else
+ hMatchEffVsRunNormToGoodCh->SetBinContent(irun+1, 0.0);
+ hMatchEffVsRunNormToGoodCh->SetBinError(irun+1,matchEffLinFit1GevErr);
+ hMatchEffVsRunNormToGoodCh->GetXaxis()->SetBinLabel(irun+1,runlabel);
+ hMatchEffVsRunNormToGoodCh->SetLineColor(kBlue);
+ hMatchEffVsRunNormToGoodCh->SetLineWidth(2);
+
+ hPeakT0AVsRun->SetBinContent(irun+1,peakT0A);
+ hPeakT0AVsRun->SetBinError(irun+1,spreadT0A);
+ hPeakT0AVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hPeakT0CVsRun->SetBinContent(irun+1,peakT0C);
+ hPeakT0CVsRun->SetBinError(irun+1,spreadT0C);
+ hPeakT0CVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hPeakT0ACVsRun->SetBinContent(irun+1,peakT0AC);
+ hPeakT0ACVsRun->SetBinError(irun+1,spreadT0AC);
+ hPeakT0ACVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+
+ hT0fillResVsRun->SetBinContent(irun+1,avT0fillRes);
+ hT0fillResVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
+ }
+
+ TFile * fout=new TFile(outfilename,"recreate");
+ fout->cd();
+ lista.Write();
+ fout->Close();
+
+ TCanvas* cPeakDiffTimeVsRun = new TCanvas("cPeakDiffTimeVsRun","cPeakDiffTimeVsRun", 50,50,750,550);
+ hPeakDiffTimeVsRun->GetYaxis()->SetRangeUser(-50.,50.);
+ hPeakDiffTimeVsRun->Draw();
+ cPeakDiffTimeVsRun->Print(Form("%s/cPeakDiffTimeVsRun.png",plotDir.Data()));
+
+ TCanvas* cSpreadDiffTimeVsRun = new TCanvas("cSpreadDiffTimeVsRun","cSpreadDiffTimeVsRun", 50,50,750,550);
+ hSpreadDiffTimeVsRun->GetYaxis()->SetRangeUser(200.,400.);
+ hSpreadDiffTimeVsRun->Draw();
+ cSpreadDiffTimeVsRun->Print(Form("%s/cSpreadDiffTimeVsRun.png",plotDir.Data()));
+
+ TCanvas* cMatchEffVsRun = new TCanvas("cMatchEffVsRun","cMatchEffVsRun",50, 50, 750,550);
+ hMatchEffVsRun->GetYaxis()->SetRangeUser(0.,1.);
+ hMatchEffVsRun->Draw();
+ cMatchEffVsRun->Print(Form("%s/cMatchEffVsRun.png",plotDir.Data()));
+
+ TCanvas* cMatchEffNormToGoodCh = new TCanvas("cMatchEffNormToGoodCh","cMatchEffNormToGoodCh",50, 50,750,550);
+ hMatchEffVsRunNormToGoodCh->GetYaxis()->SetRangeUser(0.,1.);
+ hMatchEffVsRunNormToGoodCh->Draw();
+ cMatchEffNormToGoodCh->Print(Form("%s/cMatchEffNormToGoodCh.png",plotDir.Data()));
+
+ TCanvas* cPeakT0AVsRun = new TCanvas("cPeakT0AVsRun","cPeakT0AVsRun", 50,50,750,550);
+ hPeakT0AVsRun->Draw();
+ cPeakT0AVsRun->Print(Form("%s/cPeakT0AVsRun.png",plotDir.Data()));
+
+ TCanvas* cPeakT0CVsRun = new TCanvas("cPeakT0CVsRun","cPeakT0CVsRun", 50,50,750,550);
+ hPeakT0CVsRun->Draw();
+ cPeakT0CVsRun->Print(Form("%s/cPeakT0CVsRun.png",plotDir.Data()));
+
+ TCanvas* cPeakT0ACVsRun = new TCanvas("cPeakT0ACVsRun","cPeakT0ACVsRun", 50,50,750,550);
+ hPeakT0ACVsRun->Draw();
+ cPeakT0ACVsRun->Print(Form("%s/cPeakT0ACVsRun.png",plotDir.Data()));
+
+ TCanvas* cT0fillResVsRun = new TCanvas("cT0fillResVsRun","cT0fillResVsRun", 50,50,750,550);
+ hT0fillResVsRun->Draw();
+ cT0fillResVsRun->Print(Form("%s/cT0fillResVsRun.png",plotDir.Data()));
+
+ if (displayAll) {
+ TCanvas* cAvDiffTimeVsRun = new TCanvas("cAvDiffTimeVsRun","cAvDiffTimeVsRun",50,50,750,550);
+ gPad->SetGridx();
+ gPad->SetGridy();
+ hAvDiffTimeVsRun->Draw();
+ cAvDiffTimeVsRun->Print(Form("%s/cAvDiffTimeVsRun.png",plotDir.Data()));
+
+ TCanvas* cAvTimeVsRun = new TCanvas("cAvTimeVsRun","cAvTimeVsRun", 50,50,750,550);
+ hAvTimeVsRun->Draw();
+ cAvTimeVsRun->Print(Form("%s/cAvTimeVsRun.png",plotDir.Data()));
+
+ TCanvas* cPeakTimeVsRun = new TCanvas("cPeakTimeVsRun","cPeakTimeVsRun", 50,50,750,550);
+ hPeakTimeVsRun->Draw();
+ cPeakTimeVsRun->Print(Form("%s/cPeakTimeVsRun.png",plotDir.Data()));
+
+ TCanvas* cSpreadTimeVsRun = new TCanvas("cSpreadTimeVsRun","cSpreadTimeVsRun", 50,50,750,550);
+ hSpreadTimeVsRun->Draw();
+ cSpreadTimeVsRun->Print(Form("%s/cSpreadTimeVsRun.png",plotDir.Data()));
+
+ TCanvas* cAvRawTimeVsRun = new TCanvas("cAvRawTimeVsRun","cAvRawTimeVsRun", 50,50,750,550);
+ hAvRawTimeVsRun->Draw();
+ cAvRawTimeVsRun->Print(Form("%s/cAvRawTimeVsRun.png",plotDir.Data()));
+
+ TCanvas* cPeakRawTimeVsRun = new TCanvas("cPeakRawTimeVsRun","cPeakRawTimeVsRun", 50,50,750,550);
+ hPeakRawTimeVsRun->Draw();
+ cPeakRawTimeVsRun->Print(Form("%s/cPeakRawTimeVsRun.png",plotDir.Data()));
+
+ TCanvas* cSpreadRawTimeVsRun = new TCanvas("cSpreadRawTimeVsRun","cSpreadRawTimeVsRun", 50,50,750,550);
+ hSpreadRawTimeVsRun->Draw();
+ cSpreadRawTimeVsRun->Print(Form("%s/cSpreadRawTimeVsRun.png",plotDir.Data()));
+
+ TCanvas* cAvTotVsRun = new TCanvas("cAvTotVsRun","cAvTotVsRun", 50,50,750,550);
+ hAvTotVsRun->Draw();
+ cAvTotVsRun->Print(Form("%s/cAvTotVsRun.png",plotDir.Data()));
+
+ TCanvas* cPeakTotVsRun = new TCanvas("cPeakTotVsRun","cPeakTotVsRun", 50,50,750,550);
+ hPeakTotVsRun->Draw();
+ cPeakTotVsRun->Print(Form("%s/cPeakTotVsRun.png",plotDir.Data()));
+
+ TCanvas* cSpreadTotVsRun = new TCanvas("cSpreadTotVsRun","cSpreadTotVsRun", 50,50,750,550);
+ hSpreadTotVsRun->Draw();
+ cSpreadTotVsRun->Print(Form("%s/cSpreadTotVsRun.png",plotDir.Data()));
+
+ TCanvas* cNegTimeRatioVsRun = new TCanvas("cNegTimeRatioVsRun","cNegTimeRatioVsRun", 50,50,750,550);
+ hNegTimeRatioVsRun->Draw();
+ cNegTimeRatioVsRun->Print(Form("%s/cNegTimeRatioVsRun.png",plotDir.Data()));
+
+ TCanvas* cOrphansRatioVsRun = new TCanvas("cOrphansRatioVsRun","cOrphansRatioVsRun", 50,50,750,550);
+ hOrphansRatioVsRun->Draw();
+ cOrphansRatioVsRun->Print(Form("%s/cOrphansRatioVsRun.png",plotDir.Data()));
+
+ TCanvas* cMeanLVsRun = new TCanvas("cMeanLVsRun","cMeanLVsRun", 50,50,750,550);
+ hMeanLVsRun->Draw();
+ cMeanLVsRun->Print(Form("%s/cMeanLVsRun.png",plotDir.Data()));
+
+ TCanvas* cNegLRatioVsRun = new TCanvas("cNegLRatioVsRun","cNegLRatioVsRun", 50,50,750,550);
+ hNegLRatioVsRun->Draw();
+ cNegLRatioVsRun->Print(Form("%s/cNegLRatioVsRun.png",plotDir.Data()));
+ }
+
+ return 0;
+}
--- /dev/null
+/*
+ fbellini@cern.ch - last update on 21/02/2014
+ Macro to run the TOF QA trending by accessing the std QA output,
+ to be mainly used with the automatic scripts to fill the QA repository.
+ Launch with
+ aliroot -l -b -q "MakeTrendingTOFQA.C(\"${fullpath}/QAresults.root\", ${run}, ...)
+ The macro produces a file containing the tree of trending variables and the main plots.
+ A feature that displays the plots in canvases must be enable when needed.
+*/
+
+Int_t MakeTrendingTOFQA(TString qafilename, //full path of the QA output; set IsOnGrid to prepend "alien://"
+ Int_t runNumber, // run number
+ Bool_t isMC=kFALSE, //MC flag, to disable meaningless checks
+ Bool_t canvasE = kFALSE, //enable display plots on canvas and save png
+ Bool_t IsOnGrid = kFALSE) //set to kTRUE to access files on the grid
+{
+ // macro to generate tree with TOF QA trending variables
+ // access qa PWGPP output files
+ if (!qafilename) {
+ Printf("Error - Invalid input file");
+ return 1;
+ }
+
+ /*set graphic style*/
+ gStyle->SetCanvasColor(kWhite);
+ gStyle->SetFrameFillColor(kWhite);
+ gStyle->SetFrameBorderMode(0);
+ gStyle->SetCanvasBorderMode(0);
+ gStyle->SetTitleFillColor(kWhite);
+ gStyle->SetTitleBorderSize(0) ;
+ gStyle->SetTitleFont(42);
+ gStyle->SetTextFont(42);
+ gStyle->SetStatColor(kWhite);
+ gStyle->SetStatBorderSize(1);
+ TGaxis::SetMaxDigits(3);
+ gStyle->SetOptStat(10);
+
+ char defaultQAoutput[30]="QAresults.root";
+ char * treePostFileName="trending.root";
+
+ if (IsOnGrid) TGrid::Connect("alien://");
+ TFile * fin = TFile::Open(qafilename,"r");
+ if (!fin) {
+ printf("ERROR: QA output not found. Exiting with status -1\n");
+ return -1;
+ } else {
+ printf("INFO: QA output file %s open. \n",fin->GetName());
+ }
+
+ //access histograms lists
+ char tofQAdirName[15]="TOF_Performance";
+ char genListName[15]="cGeneralTOFqa";
+ char t0ListName[15]="cTimeZeroTOFqa";
+ char pidListName[15]="cPIDTOFqa";
+ char posListName[15]="cPositiveTOFqa";
+ char negListName[15]="cNegativeTOFqa";
+
+ TDirectoryFile * tofQAdir=(TDirectoryFile*)fin->Get(tofQAdirName);
+ TList * generalList=(TList*)tofQAdir->Get(genListName);
+ TList *timeZeroList=(TList*)tofQAdir->Get(t0ListName);
+ TList *pidList=(TList*)tofQAdir->Get(pidListName);
+ TList *posList=(TList*)tofQAdir->Get(posListName);
+ TList *negList=(TList*)tofQAdir->Get(negListName);
+
+ if (!generalList) printf("WARNING: general QA histograms absent or not accessible\n");
+ if (!timeZeroList) printf("WARNING: timeZero QA histograms absent or not accessible\n");
+ if (!pidList) printf("WARNING: PID QA histograms absent or not accessible\n");
+ if (!posList) printf("WARNING: general QA histograms for positive tracks absent or not accessible\n");
+ if (!negList) printf("WARNING: general QA histograms for negative tracks absent or not accessible\n");
+
+ if ( (!generalList) && (!timeZeroList) && (!pidList) ){
+ printf("ERROR: no QA available \n");
+ return 1;
+ }
+
+ Printf("============== Getting post-analysis info for run %i ===============\n",runNumber);
+ TFile * trendFile = new TFile(treePostFileName,"recreate");
+
+ Double_t avTime=-9999., peakTime=-9999., spreadTime=-9999., peakTimeErr=-9999., spreadTimeErr=-9999., negTimeRatio=-9999.,
+ avRawTime=-9999., peakRawTime=-9999., spreadRawTime=-9999., peakRawTimeErr=-9999., spreadRawTimeErr=-9999.,
+ avTot=-9999., peakTot=-9999.,spreadTot=-9999., peakTotErr=-9999.,spreadTotErr=-9999.,
+ orphansRatio=-9999., avL=-9999., negLratio=-9999.,
+ effPt1=-9999., effPt2=-9999., matchEffLinFit1Gev=-9999.,matchEffLinFit1GevErr=-9999.;
+
+ Double_t avPiDiffTime=-9999.,peakPiDiffTime=-9999., spreadPiDiffTime=-9999.,peakPiDiffTimeErr=-9999., spreadPiDiffTimeErr=-9999.;
+
+ Double_t avT0A=-9999.,peakT0A=-9999., spreadT0A=-9999.,peakT0AErr=-9999., spreadT0AErr=-9999.;
+ Double_t avT0C=-9999.,peakT0C=-9999., spreadT0C=-9999.,peakT0CErr=-9999., spreadT0CErr=-9999.;
+ Double_t avT0AC=-9999.,peakT0AC=-9999., spreadT0AC=-9999.,peakT0ACErr=-9999., spreadT0ACErr=-9999.;
+ Double_t avT0res=-9999.,peakT0res=-9999., spreadT0res=-9999.,peakT0resErr=-9999., spreadT0resErr=-9999.;
+ Double_t avT0fillRes=-9999.;
+
+ Float_t avMulti=0;
+ Float_t fractionEventsWHits=-9999.;
+ /*number of good (HW ok && efficient && !noisy) TOF channels from OCDB*/
+ Double_t goodChannelRatio=0.0;
+
+ TTree * ttree=new TTree("trending","tree of trending variables");
+ ttree->Branch("run",&runNumber,"run/I");
+ ttree->Branch("avMulti",&avMulti,"avMulti/F");
+ ttree->Branch("fractionEventsWHits",&fractionEventsWHits,"fractionEventsWHits/F");
+ ttree->Branch("goodChannelsRatio",&goodChannelRatio,"goodChannelRatio/D");
+ ttree->Branch("avTime",&avTime,"avTime/D"); //mean time
+ ttree->Branch("peakTime",&peakTime,"peakTime/D"); //main peak time after fit
+ ttree->Branch("spreadTime",&spreadTime,"spreadTime/D"); //spread of main peak of time after fit
+ ttree->Branch("peakTimeErr",&peakTimeErr,"peakTimeErr/D"); //main peak time after fit error
+ ttree->Branch("spreadTimeErr",&spreadTimeErr,"spreadTimeErr/D"); //spread of main peak of time after fit error
+ ttree->Branch("negTimeRatio",&negTimeRatio,"negTimeRatio/D"); //negative time ratio
+
+ ttree->Branch("avRawTime",&avRawTime,"avRawTime/D"); //mean raw time
+ ttree->Branch("peakRawTime",&peakRawTime,"peakRawTime/D"); //mean peak of RAW TIME after fit
+ ttree->Branch("spreadRawTime",&spreadRawTime,"spreadRawTime/D"); //spread of main peak of raw time after fit
+ ttree->Branch("peakRawTimeErr",&peakRawTimeErr,"peakRawTimeErr/D"); //main peak raw time after fit error
+ ttree->Branch("spreadRawTimeErr",&spreadRawTimeErr,"spreadRawTimeErr/D"); //spread of raw main peak of time after fit error
+
+ ttree->Branch("avTot",&avTot,"avTot/D"); //main peak tot
+ ttree->Branch("peakTot",&peakTot,"peakTot/D"); // main peak of tot after fit
+ ttree->Branch("spreadTot",&spreadTot,"spreadTot/D"); //spread of main peak of tot after fit
+ ttree->Branch("peakTotErr",&peakTotErr,"peakTotErr/D"); // main peak of tot after fit
+ ttree->Branch("spreadTotErr",&spreadTotErr,"spreadTotErr/D"); //spread of main peak of tot after fit
+
+ ttree->Branch("orphansRatio",&orphansRatio,"orphansRatio/D"); //orphans ratio
+
+ ttree->Branch("avL",&avL,"avL/D"); //mean track length
+ ttree->Branch("negLratio",&negLratio,"negLratio/D");//ratio of tracks with track length <350 cm
+ ttree->Branch("effPt1",&effPt1,"effPt1/D");//matching eff at 1 GeV/c
+ ttree->Branch("effPt2",&effPt2,"effPt2/D"); //matching eff at 2 GeV/c
+ ttree->Branch("matchEffLinFit1Gev",&matchEffLinFit1Gev,"matchEffLinFit1Gev/D");//matching eff fit param
+ ttree->Branch("matchEffLinFit1GevErr",&matchEffLinFit1GevErr,"matchEffLinFit1GevErr/D");////matching eff fit param error
+
+ ttree->Branch("avPiDiffTime",&avPiDiffTime,"avPiDiffTime/D"); //mean t-texp
+ ttree->Branch("peakPiDiffTime",&peakPiDiffTime,"peakPiDiffTime/D"); //main peak t-texp after fit
+ ttree->Branch("spreadPiDiffTime",&spreadPiDiffTime,"spreadPiDiffTime/D"); //spread of main peak t-texp after fit
+ ttree->Branch("peakPiDiffTimeErr",&peakPiDiffTimeErr,"peakPiDiffTimeErr/D"); //main peak t-texp after fit error
+ ttree->Branch("spreadPiDiffTimeErr",&spreadPiDiffTimeErr,"spreadPiDiffTimeErr/D"); //spread of main peak of t-texp after fit error
+
+ ttree->Branch("avT0A",&avT0A,"avT0A/D"); //main peak t0A
+ ttree->Branch("peakT0A",&peakT0A,"peakT0A/D"); // main peak of t0A after fit
+ ttree->Branch("spreadT0A",&spreadT0A,"spreadTot/D"); //spread of main peak of t0A after fit
+ ttree->Branch("peakT0AErr",&peakT0AErr,"peakT0AErr/D"); // main peak of t0A after fit
+ ttree->Branch("spreadT0AErr",&spreadT0AErr,"spreadT0AErr/D"); //spread of main peak of t0A after fit
+
+ ttree->Branch("avT0C",&avT0C,"avT0C/D"); //main peak t0C
+ ttree->Branch("peakT0C",&peakT0C,"peakT0C/D"); // main peak of t0C after fit
+ ttree->Branch("spreadT0C",&spreadT0C,"spreadT0C/D"); //spread of main peak of t0C after fit
+ ttree->Branch("peakT0CErr",&peakT0CErr,"peakT0CErr/D"); // main peak of t0C after fit
+ ttree->Branch("spreadT0CErr",&spreadT0CErr,"spreadT0CErr/D"); //spread of main peak of t0C after fit
+
+ ttree->Branch("avT0AC",&avT0AC,"avT0AC/D"); //main peak t0AC
+ ttree->Branch("peakT0AC",&peakT0AC,"peakT0AC/D"); // main peak of t0AC after fit
+ ttree->Branch("spreadT0AC",&spreadT0AC,"spreadT0AC/D"); //spread of main peak of t0AC after fit
+ ttree->Branch("peakT0ACErr",&peakT0ACErr,"peakT0ACErr/D"); // main peak of t0AC after fit
+ ttree->Branch("spreadT0ACErr",&spreadT0ACErr,"spreadT0ACErr/D"); //spread of main peak of t0AC after fit
+
+ ttree->Branch("avT0res",&avT0res,"avT0res/D"); //main peak t0AC
+ ttree->Branch("peakT0res",&peakT0res,"peakT0res/D"); // main peak of t0AC after fit
+ ttree->Branch("spreadT0res",&spreadT0res,"spreadT0res/D"); //spread of main peak of t0AC after fit
+ ttree->Branch("peakT0resErr",&peakT0resErr,"peakT0resErr/D"); // main peak of t0AC after fit
+ ttree->Branch("spreadT0resErr",&spreadT0resErr,"spreadT0resErr/D"); //spread of main peak of t0AC after fit
+ ttree->Branch("avT0fillRes",&avT0fillRes,"avT0fillRes/D"); //t0 fill res
+
+ //save quantities for trending
+ goodChannelRatio=(Double_t)GetGoodTOFChannelsRatio(runNumber);
+
+ //--------------------------------- Multiplicity ----------------------------------//
+
+ TH1F * hMulti = (TH1F*) generalList->FindObject("hTOFmatchedPerEvt");
+ TH1F* hFractionEventsWhits = new TH1F("hFractionEventsWhits","hFractionEventsWhits;fraction of events with hits (%)",200,0.,100.);
+ Float_t fraction=0.0;
+ if (hMulti->GetEntries()>0.0) {
+ fraction = ((Float_t) hMulti->GetBinContent(1))/((Float_t) hMulti->GetEntries());
+ avMulti = hMulti->GetMean();
+ } else fraction=0.0;
+ hFractionEventsWhits->Fill(fraction*100.);
+
+ //--------------------------------- T0F signal ----------------------------------//
+ TH1F * hRawTime = (TH1F*)generalList->FindObject("hTOFmatchedESDrawTime");
+ if ((hRawTime)&&(hRawTime->GetEntries()>0)){
+ avRawTime=hRawTime->GetMean();
+ if (!isMC){
+ hRawTime->Fit("landau","RQ0","",200.,250.);
+ peakRawTime=(hRawTime->GetFunction("landau"))->GetParameter(1);
+ spreadRawTime=(hRawTime->GetFunction("landau"))->GetParameter(2);
+ peakRawTimeErr=(hRawTime->GetFunction("landau"))->GetParError(1);
+ spreadRawTimeErr=(hRawTime->GetFunction("landau"))->GetParError(2);
+ printf("Main peak raw time (landau): mean = %f +- %f\n",peakTime,peakTimeErr );
+ printf("Main peak raw time (landau): spread = %f +- %f\n",spreadRawTime,spreadRawTimeErr );
+ } else {
+ printf("Reminder: Raw time not available in MC simulated data.");
+ }
+ }
+ MakeUpHisto(hRawTime, "matched tracks", 21, kGreen+2);
+ hRawTime->Rebin(2);
+
+ TH1F * hTime = (TH1F*)generalList->FindObject("hTOFmatchedESDtime");
+ if ((hTime)&&(hTime->GetEntries()>0)) {
+ avTime=hTime->GetMean();
+ hTime->Fit("landau","RQ0","",0.,50.);
+ peakTime=(hTime->GetFunction("landau"))->GetParameter(1);
+ spreadTime=(hTime->GetFunction("landau"))->GetParameter(2);
+ peakTimeErr=(hTime->GetFunction("landau"))->GetParError(1);
+ spreadTimeErr=(hTime->GetFunction("landau"))->GetParError(2);
+ negTimeRatio=((Double_t)hTime->Integral(1,3)*100.)/((Double_t)hTime->Integral());
+ printf("Main peak time (landau): mean = %f +- %f\n",peakTime,peakTimeErr );
+ printf("Main peak time (landau): spread = %f +- %f\n",spreadTime,spreadTimeErr );
+ printf("Ratio of tracks with time<12.5 ns / total = %f\n",negTimeRatio );
+ MakeUpHisto(hTime, "matched tracks", 20, kBlue+2);
+ hTime->Rebin(2);
+
+ TLegend *lTime = new TLegend(0.7125881,0.6052519,0.979435,0.7408306,NULL,"brNDC");
+ lTime->SetTextSize(0.04281433);
+ lTime->AddEntry(hRawTime, "raw","L");
+ lTime->AddEntry(hTime, "ESD","L");
+ lTime->SetFillColor(kWhite);
+ lTime->SetShadowColor(0);
+ }
+
+ TH1F * hTot = (TH1F*)generalList->FindObject("hTOFmatchedESDToT");
+ if ((hTot)&&(hTot->GetEntries()>0)){
+ avTot=hTot->GetMean();
+ hTot->Fit("gaus","","",0.,50.);
+ peakTot=(hTot->GetFunction("gaus"))->GetParameter(1);
+ spreadTot=(hTot->GetFunction("gaus"))->GetParameter(2);
+ peakTotErr=(hTot->GetFunction("gaus"))->GetParError(1);
+ spreadTotErr=(hTot->GetFunction("gaus"))->GetParError(2);
+ printf("Main peak ToT (gaus): mean = %f +- %f\n",peakTot,peakTotErr );
+ printf("Main peak ToT (gaus): spread = %f +- %f\n",spreadTot,spreadTotErr );
+ }
+ MakeUpHisto(hTot, "matched tracks", 8, kViolet-3);
+
+ char orphansTxt[200];
+ if (hTot->GetEntries()>1){
+ orphansRatio=((Float_t) hTot->GetBinContent(1))/((Float_t) hTot->GetEntries()) ;
+ }
+ sprintf(orphansTxt,"orphans/matched = %4.2f%%",orphansRatio*100.);
+ TPaveText *tOrphans = new TPaveText(0.38,0.63,0.88,0.7, "NDC");
+ tOrphans->SetBorderSize(0);
+ tOrphans->SetTextSize(0.045);
+ tOrphans->SetFillColor(0); //white background
+ tOrphans->SetTextAlign(12);
+ tOrphans->SetTextColor(kViolet-3);
+ tOrphans->AddText(orphansTxt);
+
+ TH1F * hL=(TH1F*)generalList->FindObject("hTOFmatchedESDtrkLength");
+ char negLengthTxt[200];
+ if (hL->GetEntries()>0){
+ avL=hL->GetMean();
+ negLRatio=(hL->Integral(1,750))/((Float_t) hL->GetEntries()) ;
+ }
+ MakeUpHisto(hL, "matched tracks", 1, kBlue+2);
+ sprintf(negLengthTxt,"trk with L<350cm /matched = %4.2f%%", negLRatio*100.);
+ TPaveText *tLength = new TPaveText(0.15,0.83,0.65,0.87, "NDC");
+ tLength->SetBorderSize(0);
+ tLength->SetTextSize(0.04);
+ tLength->SetFillColor(0); //white background
+ tLength->SetTextAlign(11);
+ tLength->SetTextColor(kOrange-3);
+ tLength->AddText(negLengthTxt);
+
+ //--------------------------------- residuals -------------------------------------//
+ TH2F* hDxPos4profile = (TH2F*) generalList->FindObject("hTOFmatchedDxVsPtPos");
+ TH2F* hDxNeg4profile = (TH2F*) generalList->FindObject("hTOFmatchedDxVsPtNeg");
+ const Int_t ybinMin = 0;
+ const Int_t ybinMax = hDxPos4profile->GetYaxis()->GetNbins() ;
+ TProfile * profDxPos = (TProfile*)hDxPos4profile->ProfileX("profDxPos", ybinMin,ybinMax);
+ profDxPos->SetLineWidth(2);
+ TProfile * profDxNeg = (TProfile*)hDxNeg4profile->ProfileX("profDxNeg", ybinMin, ybinMax);
+ profDxNeg->SetLineWidth(2);
+
+ TH1 *profRatioPosOverNegDx = (TH1*) profDxPos->Clone();
+ profRatioPosOverNegDx->SetName("profRatioPosOverNegDx");
+ profRatioPosOverNegDx->Divide((TH1*) profDxNeg);
+ profRatioPosOverNegDx->GetYaxis()->SetRangeUser(-5.,5.);
+ profRatioPosOverNegDx->GetXaxis()->SetRangeUser(0.,2.);
+
+ TH2F* hTOFmatchedDzVsStrip = (TH2F*)generalList->FindObject("hTOFmatchedDzVsStrip");
+
+ // fout->cd();
+ // hTOFmatchedDzVsStrip->Write();
+ // hDxPos4profile->Write();
+ // hDxNeg4profile->Write();
+ // profDxPos->Write();
+ // profDxNeg->Write();
+ // profRatioPosOverNegDx->Write();
+
+ //--------------------------------- matching eff ----------------------------------//
+ //matching as function of pT
+ TH1F * hMatchingVsPt = new TH1F("hMatchingVsPt","Matching probability vs. Pt; Pt(GeV/c); matching probability", 50, 0., 5. );
+ TH1F * hDenom = (TH1F*)generalList->FindObject("hESDprimaryTrackPt");
+ if (hDenom) {
+ hMatchingVsPt=(TH1F*) generalList->FindObject("hTOFmatchedESDPt")->Clone();
+ hMatchingVsPt->Rebin(5);
+ hDenom->Rebin(5);
+ hMatchingVsPt->Divide(hDenom);
+ hMatchingVsPt->GetYaxis()->SetTitle("matching efficiency");
+ hMatchingVsPt->SetTitle("TOF matching efficiency as function of transverse momentum");
+ hMatchingVsPt->GetYaxis()->SetRangeUser(0,1.2);
+ }
+
+ if (hMatchingVsPt->GetEntries()>0){
+ hMatchingVsPt->Fit("pol0","","",1.0,10.);
+ hMatchingVsPt->Draw();
+ if (hMatchingVsPt->GetFunction("pol0")){
+ matchEffLinFit1Gev=(hMatchingVsPt->GetFunction("pol0"))->GetParameter(0);
+ matchEffLinFit1GevErr=(hMatchingVsPt->GetFunction("pol0"))->GetParError(0);
+ printf("Matching efficiency fit param is %f +- %f\n",matchEffLinFit1Gev,matchEffLinFit1GevErr );
+ }
+ } else {
+ printf("WARNING: matching efficiency plot has 0 entries. Skipped!\n");
+ }
+ MakeUpHisto(hMatchingVsPt, "efficiency", 1, kBlue+2);
+
+ //matching as function of eta
+ TH1F * hMatchingVsEta =new TH1F("hMatchingVsEta","Matching probability vs. #\Eta; #\Eta; matching probability", 20, -1., 1.);
+ hDenom->Clear();
+ hDenom=(TH1F*)generalList->FindObject("hTOFprimaryESDeta");
+ if (hDenom) {
+ hMatchingVsEta=(TH1F*) generalList->FindObject("hTOFmatchedESDeta")->Clone();
+ hMatchingVsEta->Rebin(5);
+ hDenom->Rebin(5);
+ hMatchingVsEta->Divide(hDenom);
+ hMatchingVsEta->GetXaxis()->SetRangeUser(-1,1);
+ hMatchingVsEta->GetYaxis()->SetTitle("matching efficiency");
+ hMatchingVsEta->GetYaxis()->SetRangeUser(0,1.2);
+ hMatchingVsEta->SetTitle("TOF matching efficiency as function of pseudorapidity");
+ }
+ MakeUpHisto(hMatchingVsEta, "efficiency", 1, kBlue+2);
+
+
+ //matching as function of phi
+ TH1F * hMatchingVsPhi = new TH1F("hMatchingVsPhi","Matching probability vs. Phi; Phi(rad); matching probability", 628, 0., 6.28);
+ hDenom->Clear();
+ hDenom=(TH1F*)generalList->FindObject("hTOFprimaryESDphi");
+ if (hDenom) {
+ hMatchingVsPhi=(TH1F*) generalList->FindObject("hTOFmatchedESDphi")->Clone();
+ hMatchingVsPhi->Rebin(2);
+ hDenom->Rebin(2);
+ hMatchingVsPhi->Divide(hDenom);
+ hMatchingVsPhi->GetYaxis()->SetTitle("matching efficiency");
+ hMatchingVsPhi->SetTitle("TOF matching efficiency as function of phi");
+ hMatchingVsPhi->GetYaxis()->SetRangeUser(0,1.2);
+ }
+ MakeUpHisto(hMatchingVsPhi, "efficiency", 1, kBlue+2);
+
+ // fout->cd();
+ // hMatchingVsPt->Write();
+ // hMatchingVsEta->Write();
+ // hMatchingVsPhi->Write();
+
+
+ //--------------------------------- t-texp ----------------------------------//
+ TH2F * hBetaP=(TH2F*)pidList->FindObject("hTOFmatchedESDpVsBeta");
+ if (hBetaP) hBetaP->GetYaxis()->SetRangeUser(0.,1.2);
+
+ TH1F * hMass=(TH1F*)pidList->FindObject("hTOFmatchedMass");
+ MakeUpHisto(hMass, "tracks", 1, kBlue+2);
+ // hMass->SetFillColor(kAzure+10);
+ // hMass->SetFillStyle(1001);
+ hMass->Rebin(2);
+
+ //pions
+ TH2F * hDiffTimeT0TOFPion1GeV=(TH2F*)pidList->FindObject("hTOFmatchedTimePion1GeV");
+ TH1F * hPionDiff=(TH1F*)pidList->FindObject("hTOFmatchedExpTimePi");
+ TH1F * hKaonDiff=(TH1F*)pidList->FindObject("hTOFmatchedExpTimeKa");
+ TH1F * hProtonDiff=(TH1F*)pidList->FindObject("hTOFmatchedExpTimePro");
+ if ((hPionDiff)&&(hPionDiff->GetEntries()>0)) {
+ avPiDiffTime=hPionDiff->GetMean();
+ hPionDiff->Fit("gaus","","",-1000.,500.);
+ if (hPionDiff->GetFunction("gaus")){
+ peakPiDiffTime=(hPionDiff->GetFunction("gaus"))->GetParameter(1);
+ spreadPiDiffTime=(hPionDiff->GetFunction("gaus"))->GetParameter(2);
+ peakPiDiffTimeErr=(hPionDiff->GetFunction("gaus"))->GetParError(1);
+ spreadPiDiffTimeErr=(hPionDiff->GetFunction("gaus"))->GetParError(2);
+ printf("Main peak t-t_exp (gaus): mean = %f +- %f\n",peakPiDiffTime,peakPiDiffTimeErr );
+ printf("Main peak t-t_exp (gaus): spread = %f +- %f\n",spreadPiDiffTime,spreadPiDiffTimeErr );
+ }
+ }
+
+ TH2F * hDiffTimePi=(TH2F*)pidList->FindObject("hTOFmatchedExpTimePiVsP");
+ hDiffTimePi->GetYaxis()->SetRangeUser(-5000.,5000.);
+ hDiffTimePi->SetTitle("PIONS t-t_{exp,#pi} (from tracking) vs. P");
+
+ // TProfile * profDiffTimePi = (TProfile*)hDiffTimePi->ProfileX("profDiffTimePi", 490, 510);
+ // if (profDiffTimePi){
+ // profDiffTimePi->SetLineWidth(2);
+ // profDiffTimePi->SetLineColor(kRed+2);
+ // }
+
+ //Kaon
+ TH2F * hDiffTimeKa=(TH2F*)pidList->FindObject("hTOFmatchedExpTimeKaVsP");
+ hDiffTimeKa->SetTitle("KAONS t-t_{exp,K} (from tracking) vs. P");
+ hDiffTimeKa->GetYaxis()->SetRangeUser(-5000.,5000.);
+
+ // TProfile * profDiffTimeKa = (TProfile*)hDiffTimeKa->ProfileX("profDiffTimeKa", 490, 510);
+ // if (profDiffTimeKa) {
+ // profDiffTimeKa->SetLineWidth(2);
+ // profDiffTimeKa->SetLineColor(kBlue);
+ // }
+
+ //Protons
+ TH2F * hDiffTimePro=(TH2F*)pidList->FindObject("hTOFmatchedExpTimeProVsP");
+ hDiffTimePro->SetTitle("PROTONS t-t_{exp,p} (from tracking) vs. P");
+ hDiffTimePro->GetYaxis()->SetRangeUser(-5000.,5000.);
+
+ // TProfile * profDiffTimePro = (TProfile*)hDiffTimePro->ProfileX("profDiffTimePro", 490, 510);
+ // if (profDiffTimePro) {
+ // profDiffTimePro->SetLineWidth(2);
+ // profDiffTimePro->SetLineColor(kGreen+2);
+ // }
+
+ /*
+ TH2F * hDiffTimePiTh=(TH2F*)pidList->FindObject("hTOFtheoreticalExpTimePiVsP");
+ hDiffTimePiTh->GetYaxis()->SetRangeUser(-2000.,2000.);
+
+ TProfile * profDiffTimePiTh = (TProfile*)hDiffTimePiTh->ProfileX("profDiffTimePiTh", 490, 510);
+ if (profDiffTimePiTh) {
+ profDiffTimePiTh->SetLineWidth(2);
+ profDiffTimePiTh->SetLineColor(kRed+2);
+ }
+
+ TH2F * hDiffTimeKaTh=(TH2F*)pidList->FindObject("hTOFtheoreticalExpTimeKaVsP");
+ hDiffTimeKaTh->GetYaxis()->SetRangeUser(-2000.,2000.);
+
+ TProfile * profDiffTimeKaTh = (TProfile*)hDiffTimeKaTh->ProfileX("profDiffTimeKaTh", 490, 510);
+ if (profDiffTimeKaTh) {
+ profDiffTimeKaTh->SetLineWidth(2);
+ profDiffTimeKaTh->SetLineColor(kBlue);
+ }
+
+ TH2F * hDiffTimeProTh=(TH2F*)pidList->FindObject("hTOFtheoreticalExpTimePro");
+ hDiffTimeProTh->GetYaxis()->SetRangeUser(-2000.,2000.);
+
+ TProfile * profDiffTimeProTh = (TProfile*)hDiffTimeProTh->ProfileX("profDiffTimeProTh", 490, 510);
+ if (profDiffTimeProTh) {
+ profDiffTimeProTh->SetLineWidth(2);
+ profDiffTimeProTh->SetLineColor(kGreen+2);
+ }
+ TLegend * lPid=new TLegend(0.75,0.75,0.95,0.95,"PID");
+ lPid->AddEntry(profDiffTimePi,"#pi^{#pm}","l");
+ lPid->AddEntry(profDiffTimeKa,"K^{#pm}","l");
+ lPid->AddEntry(profDiffTimePro,"p^{#pm}","l");
+
+ if (canvasE){
+ TCanvas *cPidPerformanceTh= new TCanvas("cPidPerformanceTh","summary of pid performance - theoretical times",700,700);
+ cPidPerformanceTh->Divide(2,2);
+ cPidPerformanceTh->cd(1);
+ gPad->SetLogz();
+ gPad->SetGridx();
+ gPad->SetGridy();
+ hDiffTimePiTh->Draw("colz");
+ profDiffTimePiTh->Draw("same");
+ cPidPerformanceTh->cd(2);
+ gPad->SetLogz();
+ gPad->SetGridx();
+ gPad->SetGridy();
+ hDiffTimeKaTh->Draw("colz");
+ profDiffTimeKaTh->Draw("same");
+ cPidPerformanceTh->cd(3);
+ gPad->SetLogz();
+ gPad->SetGridx();
+ gPad->SetGridy();
+ hDiffTimeProTh->Draw("colz");
+ profDiffTimeProTh->Draw("same");
+ }
+ fout->cd();
+ hPionDiff->Write();
+ hKaonDiff->Write();
+ hProtonDiff->Write();
+ hBetaP->Write();
+ hMass->Write();
+ hDiffTimeT0TOFPion1GeV->Write();
+ hDiffTimePi->Write();
+ profDiffTimePi->Write();
+ hDiffTimeKa->Write();
+ profDiffTimeKa->Write();
+ hDiffTimePro->Write();
+ profDiffTimePro->Write();
+ //lPid->Draw();
+ hDiffTimePiTh->Write();
+ profDiffTimePiTh->Write();
+ hDiffTimeKaTh->Write();
+ profDiffTimeKaTh->Write();
+ hDiffTimeProTh->Write();
+ profDiffTimeProTh->Write();
+ */
+
+ TH2F * hSigmaPi=(TH2F*)pidList->FindObject("hTOFExpSigmaPi");
+ hSigmaPi->GetYaxis()->SetRangeUser(-5.,5.);
+ TProfile * profSigmaPi = (TProfile*)hSigmaPi->ProfileX("profSigmaPi");
+ profSigmaPi->SetLineWidth(2);
+ profSigmaPi->SetLineColor(kRed+2);
+
+ TH2F * hSigmaKa=(TH2F*)pidList->FindObject("hTOFExpSigmaKa");
+ hSigmaKa->GetYaxis()->SetRangeUser(-5.,5.);
+ TProfile * profSigmaKa = (TProfile*)hSigmaKa->ProfileX("profSigmaKa");
+ profSigmaKa->SetLineWidth(2);
+ profSigmaKa->SetLineColor(kBlue);
+
+ TH2F * hSigmaPro=(TH2F*)pidList->FindObject("hTOFExpSigmaPro");
+ hSigmaPro->GetYaxis()->SetRangeUser(-5.,5.);
+ TProfile * profSigmaPro = (TProfile*)hSigmaPro->ProfileX("profSigmaPro");
+ profSigmaPro->SetLineWidth(2);
+ profSigmaPro->SetLineColor(kGreen+2);
+
+ // fout->cd();
+ // hSigmaPi->Write();
+ // profSigmaPi->Write();
+ // hSigmaKa->Write();
+ // profSigmaKa->Write();
+ // hSigmaPro->Write();
+ // profSigmaPro->Write();
+
+ //--------------------------------- T0 detector ----------------------------------//
+
+ TH1F*hT0A=(TH1F*)timeZeroList->FindObject("hEventT0DetA");
+ if ((hT0A)&&(hT0A->GetEntries()>0)) {
+ avT0A = hT0A->GetMean();
+ hT0A->Fit("gaus","RQ0", "", -1000., 1000.);
+ peakT0A=(hT0A->GetFunction("gaus"))->GetParameter(1);
+ spreadT0A=(hT0A->GetFunction("gaus"))->GetParameter(2);
+ peakT0AErr=(hT0A->GetFunction("gaus"))->GetParError(1);
+ spreadT0AErr=(hT0A->GetFunction("gaus"))->GetParError(2);
+ printf("Main peak T0A(gaus): mean = %f +- %f\n",peakT0A,peakT0AErr );
+ printf("Main peak T0A (gaus): spread = %f +- %f\n",spreadT0A,spreadT0AErr );
+ //add integral of main peak over total
+ }
+ MakeUpHisto(hT0A, "events", 8, kBlue);
+ hT0A->Rebin(2);
+
+ TH1F*hT0C=(TH1F*)timeZeroList->FindObject("hEventT0DetC");
+ if ((hT0C)&&(hT0C->GetEntries()>0)) {
+ avT0C=hT0C->GetMean();
+ hT0C->Fit("gaus","RQ0","", -1000., 1000.);
+ peakT0C=(hT0C->GetFunction("gaus"))->GetParameter(1);
+ spreadT0C=(hT0C->GetFunction("gaus"))->GetParameter(2);
+ peakT0CErr=(hT0C->GetFunction("gaus"))->GetParError(1);
+ spreadT0CErr=(hT0C->GetFunction("gaus"))->GetParError(2);
+ printf("Main peak T0C(gaus): mean = %f +- %f\n",peakT0C,peakT0CErr );
+ printf("Main peak T0C (gaus): spread = %f +- %f\n",spreadT0C,spreadT0CErr );
+ //add integral of main peak over total
+ }
+ MakeUpHisto(hT0C, "events", 8, kGreen+1);
+ hT0C->Rebin(2);
+
+ TH1F*hT0AC=(TH1F*)timeZeroList->FindObject("hEventT0DetAND");
+ if ((hT0AC)&&(hT0AC->GetEntries()>0)) {
+ avT0AC=hT0AC->GetMean();
+ hT0AC->Fit("gaus","RQ0", "",-1000., 1000.);
+ peakT0AC=(hT0AC->GetFunction("gaus"))->GetParameter(1);
+ spreadT0AC=(hT0AC->GetFunction("gaus"))->GetParameter(2);
+ peakT0ACErr=(hT0AC->GetFunction("gaus"))->GetParError(1);
+ spreadT0ACErr=(hT0AC->GetFunction("gaus"))->GetParError(2);
+ printf("Main peak T0AC(gaus): mean = %f +- %f\n",peakT0AC,peakT0ACErr );
+ printf("Main peak T0AC (gaus): spread = %f +- %f\n",spreadT0AC,spreadT0ACErr );
+ }
+ MakeUpHisto(hT0AC, "events", 8, kRed+1);
+ hT0AC->Rebin(2);
+
+ TLegend *lT0 = new TLegend(0.7125881,0.6052519,0.979435,0.7408306,NULL,"brNDC");
+ lT0->SetTextSize(0.041);
+ lT0->AddEntry(hT0AC, "T0 A&C","L");
+ lT0->AddEntry(hT0A, "T0 A","L");
+ lT0->AddEntry(hT0C, "T0 C","L");
+ lT0->SetFillColor(kWhite);
+ lT0->SetShadowColor(0);
+
+ TH1F*hT0res=(TH1F*)timeZeroList->FindObject("hT0DetRes");
+ if ((hT0res)&&(hT0res->GetEntries()>0)) {
+ avT0res=hT0res->GetMean();
+ hT0res->Fit("gaus");
+ peakT0res=(hT0res->GetFunction("gaus"))->GetParameter(1);
+ spreadT0res=(hT0res->GetFunction("gaus"))->GetParameter(2);
+ peakT0resErr=(hT0res->GetFunction("gaus"))->GetParError(1);
+ spreadT0resErr=(hT0res->GetFunction("gaus"))->GetParError(2);
+ printf("Main peak T0res(gaus): mean = %f +- %f\n",peakT0res,peakT0resErr );
+ printf("Main peak T0res (gaus): spread = %f +- %f\n",spreadT0res,spreadT0resErr );
+ //add integral of main peak over total
+ }
+
+ TH1F*hT0fillRes=(TH1F*)timeZeroList->FindObject("hT0fillRes");
+ if ((hT0fillRes)&&(hT0fillRes->GetEntries()>0)) {
+ avT0fillRes=hT0fillRes->GetMean();
+ }
+
+ // fout->cd();
+ // hT0AC->Write();
+ // hT0A->Write();
+ // hT0C->Write();
+ // hT0res->Write();
+ // hT0fillRes->Write();
+ // lT0->Write();
+
+ //Fill tree and save to file
+ ttree->Fill();
+ printf("============== Saving trending quantities in tree for run %i ===============\n",runNumber);
+ trendFile->cd();
+ ttree->Write();
+ trendFile->Close();
+
+ if (canvasE){
+ // TString plotDir(Form("Plots_run%d",runNumber));
+ // gSystem->Exec(Form("mkdir %s",plotDir.Data()));
+ TString plotDir(".");
+
+ TCanvas *cTrackProperties= new TCanvas("cTrackProperties","summary of matched tracks properties", 1200, 500);
+ cTrackProperties->Divide(3,1);
+ cTrackProperties->cd(1);
+ gPad->SetLogy();
+ hTime->Draw("");
+ hRawTime ->Draw("same");
+ lTime->Draw();
+ cTrackProperties->cd(2);
+ gPad->SetLogy();
+ hTot->Draw("");
+ tOrphans->Draw();
+ cTrackProperties->cd(3);
+ gPad->SetLogy();
+ hL->Draw("");
+ tLength->Draw();
+
+ TCanvas *cResiduals= new TCanvas("residuals","residuals", 900,500);
+ cResiduals->Divide(2,1);
+ cResiduals->cd(1);
+ gPad->SetLogz();
+ hDxPos4profile->GetYaxis()->SetRangeUser(-5.,5.);
+ hDxPos4profile->Draw("colz");
+ profDxPos->SetLineColor(kRed);
+ profDxPos ->Draw("same");
+ cResiduals->cd(2);
+ gPad->SetLogz();
+ hDxNeg4profile->GetYaxis()->SetRangeUser(-5.,5.);
+ hDxNeg4profile->Draw("colz");
+ profDxNeg->SetLineColor(kBlue);
+ profDxNeg->Draw("same");
+
+ TCanvas* cProfile = new TCanvas("cProfile","cProfile",50,50, 750,550);
+ cProfile->cd();
+ gPad->SetLogz();
+ hTOFmatchedDzVsStrip->Draw("colz");
+ Int_t binmin = hTOFmatchedDzVsStrip->GetYaxis()->FindBin(-3);
+ Int_t binmax = hTOFmatchedDzVsStrip->GetYaxis()->FindBin(3);
+ TProfile* hDzProfile = (TProfile*)hTOFmatchedDzVsStrip->ProfileX("hDzProfile",binmin, binmax);
+ hDzProfile->SetLineWidth(3);
+ hDzProfile->Draw("same");
+
+ TCanvas *cMatchingPerformance= new TCanvas("cMatchingPerformance","summary of matching performance",1200,500);
+ cMatchingPerformance->Divide(3,1);
+ cMatchingPerformance->cd(1);
+ hMatchingVsPt->Draw();
+ cMatchingPerformance->cd(2);
+ hMatchingVsEta->Draw();
+ cMatchingPerformance->cd(3);
+ hMatchingVsPhi->Draw();
+
+ TCanvas *cPidPerformance= new TCanvas("cPidPerformance","summary of pid performance", 900,500);
+ cPidPerformance->Divide(2,1);
+ cPidPerformance->cd(1);
+ gPad->SetLogz();
+ hBetaP->Draw("colz");
+ cPidPerformance->cd(2);
+ gPad->SetLogy();
+ hMass->Draw("HIST ");
+
+ TCanvas *cPidPerformance2= new TCanvas("cPidPerformance2","summary of pid performance - expected times", 1200, 500);
+ cPidPerformance2->Divide(3,1);
+ cPidPerformance2->cd(1);
+ gPad->SetLogz();
+ hDiffTimePi->Draw("colz");
+ //profDiffTimePi->Draw("same");
+ cPidPerformance2->cd(2);
+ gPad->SetLogz();
+ hDiffTimeKa->Draw("colz");
+ //profDiffTimeKa->Draw("same");
+ cPidPerformance2->cd(3);
+ gPad->SetLogz();
+ hDiffTimePro->Draw("colz");
+ //profDiffTimePro->Draw("same");
+
+ TLegend * lSigmaPid=new TLegend(0.75,0.75,0.95,0.95,"#sigma_{PID}");
+ lSigmaPid->AddEntry(profSigmaPi,"#pi^{#pm}","l");
+ lSigmaPid->AddEntry(profSigmaKa,"K^{#pm}","l");
+ lSigmaPid->AddEntry(profSigmaPro,"p^{#pm}","l");
+ TCanvas *cPidPerformance3= new TCanvas("cPidPerformance3","summary of pid performance - sigmas",1200,500);
+ cPidPerformance3->Divide(3,1);
+ cPidPerformance3->cd(1);
+ gPad->SetLogz();
+ hSigmaPi->Draw("colz");
+ profSigmaPi->Draw("same");
+ cPidPerformance3->cd(2);
+ gPad->SetLogz();
+ hSigmaKa->Draw("colz");
+ profSigmaKa->Draw("same");
+ cPidPerformance3->cd(3);
+ gPad->SetLogz();
+ hSigmaPro->Draw("colz");
+ profSigmaPro->Draw("same");
+
+ TCanvas *cT0detector= new TCanvas("cT0detector","T0 detector",800,600);
+ cT0detector->Divide(2,1);
+ cT0detector->cd(1);
+ gPad->SetGridx();
+ hT0AC->Draw("");
+ hT0AC->SetTitle("timeZero measured by T0 detector");
+ hT0A ->Draw("same");
+ hT0C ->Draw("same");
+ lT0->Draw();
+ cT0detector->cd(2);
+ hT0res->Draw();
+
+ cPidPerformance3->Print(Form("%s/%i_PID_sigmas.png", plotDir.Data(), runNumber));
+ cPidPerformance->Print(Form("%s/%i_PID.png",plotDir.Data(), runNumber));
+ //cPidPerformanceTh->Print(Form("%s/PID_theoreticalTimes.png",plotDir.Data()));
+ cPidPerformance2->Print(Form("%s/%i_PID_ExpTimes.png",plotDir.Data(), runNumber));
+ cMatchingPerformance->Print(Form("%s/%i_Matching.png",plotDir.Data(), runNumber));
+ cTrackProperties->Print(Form("%s/%i_TrackProperties.png",plotDir.Data(), runNumber));
+ cResiduals->Print(Form("%s/%i_Residuals.png",plotDir.Data(), runNumber));
+ cProfile->Print(Form("%s/%i_ProfileDZvsStripNumber.png",plotDir.Data(), runNumber));
+ cT0detector->Print(Form("%s/%i_T0Detector.png",plotDir.Data(), runNumber));
+ }
+
+ return 0;
+}
+
+
+//----------------------------------------------------------
+Double_t GetGoodTOFChannelsRatio(Int_t run = -1, Bool_t saveMap = kFALSE, TString OCDBstorage = "raw://")
+{
+ /*
+ It retrieves from OCDB the number of good (= efficient && not noisy && HW ok) TOF channels.
+ Optionally is saves the channel map
+ */
+ if (run<=0) {
+ printf("MakeTrendingTOFqa.C - ERROR in CheckCalibStatus(): invalid run number. Please set a run number.\n");
+ return 0.0;
+ }
+
+ AliCDBManager *cdb = AliCDBManager::Instance();
+ cdb->SetDefaultStorage(OCDBstorage.Data());
+ cdb->SetRun(run);
+
+ AliCDBEntry *cdbe = cdb->Get("TOF/Calib/Status");
+ if (!cdbe) {
+ printf("MakeTrendingTOFqa.C - ERROR in CheckCalibStatus(): OCDB entry not available. Please, try again.\n");
+ return 0.0;
+ }
+
+ AliTOFChannelOnlineStatusArray *array = (AliTOFChannelOnlineStatusArray *)cdbe->GetObject();
+ TH2F *hOkMap = new TH2F("hOkMap", "Ok map (!noisy & !problematic & efficient);sector;strip", 72, 0., 18., 91, 0., 91.);
+
+ AliTOFcalibHisto calibHisto;
+ calibHisto.LoadCalibHisto();
+ AliTOFcalib calib;
+ calib.Init();
+ Int_t sector, sectorStrip, padx, fea;
+ Float_t hitmapx, hitmapy;
+ for (Int_t i = 0; i < array->GetSize(); i++) {
+ sector = calibHisto.GetCalibMap(AliTOFcalibHisto::kSector, i);
+ sectorStrip = calibHisto.GetCalibMap(AliTOFcalibHisto::kSectorStrip, i);
+ padx = calibHisto.GetCalibMap(AliTOFcalibHisto::kPadX, i);
+ fea = padx / 12;
+ hitmapx = sector + ((Double_t)(3 - fea) + 0.5) / 4.;
+ hitmapy = sectorStrip;
+ if ( !(array->GetNoiseStatus(i) == AliTOFChannelOnlineStatusArray::kTOFNoiseBad) &&
+ (calib.IsChannelEnabled(i,kTRUE,kTRUE)))
+ hOkMap->Fill(hitmapx,hitmapy);
+ }
+ Int_t nOk=(Int_t) hOkMap->GetEntries();
+ Double_t ratioOk=nOk/152928.;
+ if (saveMap) hOkMap->SaveAs(Form("run%i_OKChannelsMap.root",run));
+ cout << "### Run " << run << ": TOF channels ok = " << nOk << "/ total 152928 channels = " << ratioOk*100. << "% of whole TOF" << endl;
+ return ratioOk;
+}
+
+//----------------------------------------------------------
+void MakeUpHisto(TH1* histo, TString titleY, Int_t marker=20, Color_t color=kBlue+2)
+{
+ if (!histo) return;
+ histo->SetMarkerStyle(marker);
+ histo->SetMarkerSize(0.7);
+ histo->SetMarkerColor(color);
+ histo->SetLineColor(color);
+ histo->SetFillColor(kWhite);
+ histo->SetFillStyle(0);
+ histo->GetYaxis()->SetTitle(titleY.Data());
+ histo->GetYaxis()->SetTitleOffset(1.35);
+ histo->GetXaxis()->SetLabelSize(0.03);
+
+ return;
+}