]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGPP/ZDC/trending/MakeTrendingZDCQA.C
Add option to only run on events that have a muon, also a few fixes
[u/mrichter/AliRoot.git] / PWGPP / ZDC / trending / MakeTrendingZDCQA.C
CommitLineData
2845593c 1/******************************************************************************************************************************************
2Contact person: Marco Leoncino (leoncino@to.infn.it)
3Macro to run the ZDC QA trending by accessing the std QA output, to be mainly used with the automatic scripts to fill the QA repository.
4Launch with aliroot -l -b -q "MakeTrendingZDCQA.C(\"${fullpath}/QAresults.root\", ${run}, ...)
5The macro produces a file containing the tree of trending variables and the main plots.
6A feature that displays the plots in canvases must be enable when needed.
7******************************************************************************************************************************************/
8
9#if !defined(__CINT__) || defined(__MAKECINT__)
10
11#include <stdio.h>
12#include <stdlib.h>
13#include <TROOT.h>
14#include <Riostream.h>
15#include <TClassTable.h>
16#include <TStyle.h>
17#include <TMath.h>
18#include <TFile.h>
19#include <TCanvas.h>
20#include <TH1.h>
21#include <TH2.h>
22#include <TProfile.h>
23#include <TLine.h>
24#include <TGrid.h>
25#include <TBits.h>
26#include <TChain.h>
27#include <TNtuple.h>
28#include <TTree.h>
29#include <TBranch.h>
30#include <TFileMerger.h>
31#include <TGridResult.h>
32#include <TSystem.h>
33#include <TGaxis.h>
34
35#endif
36
37Int_t MakeTrendingZDCQA(TString qafilename, //full path of the QA output; set IsOnGrid to prepend "alien://"
38 Int_t runNumber, //run number
39 Bool_t isMC = kFALSE, //MC flag, to disable meaningless checks
40 Bool_t canvasE = kFALSE, //enable display plots on canvas and save png
41 Bool_t IsOnGrid = kFALSE, //set to kTRUE to access files on the grid
42 TString ocdbStorage = "raw://") //set the default ocdb storage
43{
44
45 // macro to generate tree with ZDC QA trending variables
46 // access qa PWGPP output files
47 if (!qafilename) {
48 printf("Error - Invalid input file");
49 return 1;
50 }
51
52 /*set graphic style*/
53 gStyle->SetCanvasColor(kWhite);
54 gStyle->SetFrameFillColor(kWhite);
55 gStyle->SetFrameBorderMode(0);
56 gStyle->SetCanvasBorderMode(0);
57 gStyle->SetTitleFillColor(kWhite);
58 gStyle->SetTitleBorderSize(0);
59 gStyle->SetTitleFont(42);
60 gStyle->SetTextFont(42);
61 gStyle->SetStatColor(kWhite);
62 gStyle->SetStatBorderSize(1);
63 TGaxis::SetMaxDigits(3);
64 gStyle->SetOptStat(10);
65
66 char defaultQAoutput[30]="QAresults.root";
67 char * treePostFileName="trending.root";
68
69 if (IsOnGrid) TGrid::Connect("alien://");
70 TFile * fin = TFile::Open(qafilename,"r");
71 if (!fin) {
72 Printf("ERROR: QA output not found. Exiting...\n");
73 return -1;
74 } else {
75 Printf("INFO: QA output file %s open. \n",fin->GetName());
76 }
77
78 //access histograms lists
79 char zdcQAdirName[20]="ZDC_Performance";
80 char genListName[20]="QAZDCHists";
81
82 TDirectoryFile * zdcQAdir=(TDirectoryFile*)fin->Get(zdcQAdirName);
83 if (!zdcQAdir) {
84 Printf("ERROR: ZDC QA directory not present in input file.\n");
85 return -1;
86 }
87
88 TList * generalList=(TList*)zdcQAdir->Get(genListName);
89
90 if (!generalList) Printf("WARNING: general QA histograms absent or not accessible\n");
91
92 TH1F *fhTDCZNC = (TH1F*)generalList->FindObject("fhTDCZNC"); //! TDC ZNC sum
93 TH1F *fhTDCZNA = (TH1F*)generalList->FindObject("fhTDCZNA"); //! TDC DIFF sum
94 TH1F *fhTDCZNSum = (TH1F*)generalList->FindObject("fhTDCZNSum"); //! TDC ZNC sum
95 TH1F *fhTDCZNDiff = (TH1F*)generalList->FindObject("fhTDCZNDiff"); //! TDC DIFF sum
96 TH1F *fhZNCSumQ = (TH1F*)generalList->FindObject("fhZNCSumQ"); //! ZNC sum 4Q
97 TH1F *fhZNASumQ = (TH1F*)generalList->FindObject("fhZNASumQ"); //! ZNA sum 4Q
98 TH1F *fhZPCSumQ = (TH1F*)generalList->FindObject("fhZPCSumQ"); //! ZPC sum 4Q
99 TH1F *fhZPASumQ = (TH1F*)generalList->FindObject("fhZPASumQ"); //! ZPA sum 4Q
100 TH1F *fhZEM1Spectrum = (TH1F*)generalList->FindObject("fhZEM1Spectrum"); //! ZEM1 spectra
101 TH1F *fhZEM2Spectrum = (TH1F*)generalList->FindObject("fhZEM2Spectrum"); //! ZEM2 spectra
102 TH1F *fhZNCpmc = (TH1F*)generalList->FindObject("fhZNCpmc"); //! ZNC PMCs
103 TH1F *fhZNApmc = (TH1F*)generalList->FindObject("fhZNApmc"); //! ZNA PMCs
104 TH1F *fhZPCpmc = (TH1F*)generalList->FindObject("fhZPCpmc"); //! ZPC PMCs
105 TH1F *fhZPApmc = (TH1F*)generalList->FindObject("fhZPApmc"); //! ZPA PMCs
106 TH2F *fhZNCCentroid = (TH2F*)generalList->FindObject("fhZNCCentroid"); //! ZNC centroid
107 TH2F *fhZNACentroid = (TH2F*)generalList->FindObject("fhZNACentroid"); //! ZNA centroid
108 TH1F *fhPMCZNCemd = (TH1F*)generalList->FindObject("fhPMCZNCemd"); //! ZNC PMC low gain chain
109 TH1F *fhPMCZNAemd = (TH1F*)generalList->FindObject("fhPMCZNAemd"); //! ZNA PMC low gain chain
110 TH2F *fDebunch = (TH2F*)generalList->FindObject("fDebunch"); //! TDC sum vs. diff
111 TH1F *fhTDCZNAcorr = (TH1F*)generalList->FindObject("fhTDCZNAcorr"); //! ZNA corrected TDC
112 TH1F *fhTDCZNCcorr = (TH1F*)generalList->FindObject("fhTDCZNCcorr"); //! ZNC corrected TDC
113
114 Double_t ZNC_mean = fhZNCpmc->GetMean()/TMath::Sqrt(fhZNCpmc->GetEntries());
115 Double_t ZNA_mean = fhZNApmc->GetMean()/TMath::Sqrt(fhZNApmc->GetEntries());
116 Double_t ZPC_mean = fhZPCpmc->GetMean()/TMath::Sqrt(fhZPCpmc->GetEntries());
117 Double_t ZPA_mean = fhZPApmc->GetMean()/TMath::Sqrt(fhZPApmc->GetEntries());
118 Double_t ZEM1_mean = fhZEM1Spectrum->GetMean()/TMath::Sqrt(fhZEM1Spectrum->GetEntries());
119 Double_t ZEM2_mean = fhZEM2Spectrum->GetMean()/TMath::Sqrt(fhZEM2Spectrum->GetEntries());
120 Double_t ZNC_XCent = fhZNCCentroid->GetMean(1);
121 Double_t ZNC_YCent = fhZNCCentroid->GetMean(2);
122 Double_t ZNA_XCent = fhZNACentroid->GetMean(1);
123 Double_t ZNA_YCent = fhZNACentroid->GetMean(2);
124 Double_t ZNC_XCent_err = fhZNCCentroid->GetRMS(1);
125 Double_t ZNC_YCent_err = fhZNCCentroid->GetRMS(2);
126 Double_t ZNA_XCent_err = fhZNACentroid->GetRMS(1);
127 Double_t ZNA_YCent_err = fhZNACentroid->GetRMS(2);
128 Double_t ZN_TDC_Sum = fhTDCZNSum->GetMean();
129 Double_t ZN_TDC_Diff = fhTDCZNDiff->GetMean();
130 Double_t ZN_TDC_Sum_err = fhTDCZNSum->GetRMS();
131 Double_t ZN_TDC_Diff_err = fhTDCZNDiff->GetRMS();
132
133 TTree * ttree=new TTree("trending","tree of trending variables");
134 ttree->Branch("run",&runNumber,"run/I");
135 ttree->Branch("ZNC_mean_value",&ZNC_mean,"ZNC_mean_value/D");
136 ttree->Branch("ZNA_mean_value",&ZNA_mean,"ZNA_mean_value/D");
137 ttree->Branch("ZPC_mean_value",&ZPC_mean,"ZPC_mean_value/D");
138 ttree->Branch("ZPA_mean_value",&ZPA_mean,"ZPA_mean_value/D");
139 ttree->Branch("ZEM1_mean_value",&ZEM1_mean,"ZEM1_mean_value/D");
140 ttree->Branch("ZEM2_mean_value",&ZEM2_mean,"ZEM2_mean_value/D");
141 ttree->Branch("ZNC_X_Centroid",&ZNC_XCent,"ZNC_X_Centroid/D");
142 ttree->Branch("ZNC_Y_Centroid",&ZNC_YCent,"ZNC_Y_Centroid/D");
143 ttree->Branch("ZNA_X_Centroid",&ZNA_XCent,"ZNA_X_Centroid/D");
144 ttree->Branch("ZNA_Y_Centroid",&ZNA_YCent,"ZNA_Y_Centroid/D");
145 ttree->Branch("ZNC_X_Centroid_Err",&ZNC_XCent_err,"ZNC_X_Centroid_Err/D");
146 ttree->Branch("ZNC_Y_Centroid_Err",&ZNC_YCent_err,"ZNC_Y_Centroid_Err/D");
147 ttree->Branch("ZNA_X_Centroid_Err",&ZNA_XCent_err,"ZNA_X_Centroid_Err/D");
148 ttree->Branch("ZNA_Y_Centroid_Err",&ZNA_YCent_err,"ZNA_Y_Centroid_Err/D");
149 ttree->Branch("ZN_TDC_Sum",&ZN_TDC_Sum,"ZN_TDC_Sum/D");
150 ttree->Branch("ZN_TDC_Diff",&ZN_TDC_Diff,"ZN_TDC_Diff/D");
151 ttree->Branch("ZN_TDC_Sum_Err",&ZN_TDC_Sum_err,"ZN_TDC_Sum_Err/D");
152 ttree->Branch("ZN_TDC_Diff_Err",&ZN_TDC_Diff_err,"ZN_TDC_Diff_Err/D");
153
154 Printf(":::: Getting post-analysis info for run %i",runNumber);
155 TFile * trendFile = new TFile(treePostFileName,"recreate");
156
157 printf("============== Saving histograms for run %i ===============\n",runNumber);
158
159 fhTDCZNC->Write();
160 fhTDCZNA->Write();
161 fhTDCZNSum->Write();
162 fhTDCZNDiff->Write();
163 fhZNCSumQ->Write();
164 fhZNASumQ->Write();
165 fhZPCSumQ->Write();
166 fhZPASumQ->Write();
167 fhZEM1Spectrum->Write();
168 fhZEM2Spectrum->Write();
169 fhZNCpmc->Write();
170 fhZNApmc->Write();
171 fhZPCpmc->Write();
172 fhZPApmc->Write();
173 fhZNCCentroid->Write();
174 fhZNACentroid->Write();
175 fhPMCZNCemd->Write();
176 fhPMCZNAemd->Write();
177 fDebunch->Write();
178 fhTDCZNAcorr->Write();
179 fhTDCZNCcorr->Write();
180
181 ttree->Fill();
182 printf("============== Saving trending quantities in tree for run %i ===============\n",runNumber);
183
184 trendFile->cd();
185 ttree->Write();
186 trendFile->Close();
187
188}