]> git.uio.no Git - u/mrichter/AliRoot.git/blame - T0/drawPerformanceT0QATrends.C
add docs on settable ocdbStorage + modify T0 script to allow setting of local ocdb
[u/mrichter/AliRoot.git] / T0 / drawPerformanceT0QATrends.C
CommitLineData
b1a2430c 1
2TGraphErrors * MakeGraphSparse(TTree * tree, const Char_t * expr="mean-fdelta:run", const Char_t * cut="isTPC&&ptype==0&&theta>0"){
3 // Format of expr: Var:Error:Run
4 //
5 // Make a sparse draw of the variables
6 // Format of expr : Var:Error:Run
7 //
8
9 const Int_t entries = tree->Draw(expr,cut,"goff");
10
11 Double_t *graphX, *graphY, *graphError;
12
13 //check whether error argument exists in expr
14 if(!tree->GetV3()){
15 graphX = tree->GetV2();
16 graphY = tree->GetV1();
17 }
18 else{
19 graphX = tree->GetV3();
20 graphY = tree->GetV1();
21 graphError = tree->GetV2();
22 }
23
24 // sort according to run number
25 Int_t *index = new Int_t[entries];
26 TMath::Sort(entries,graphX,index,false);
27
28 // define arrays for the new graph
29 Double_t *tempArray = new Double_t[entries];
30 Double_t *xError = new Double_t[entries];
31 Double_t *yError = new Double_t[entries];
32 Int_t *vrun = new Int_t[entries];
33 Double_t count = 0.5;
34
35 // evaluate arrays for the new graph accroding to the run-number
36 Int_t icount=0;
37 tempArray[index[0]] = count;
38 xError[0] = 0;
39 yError[0] = 0;
40 if(tree->GetV3())
41 yError[index[0]] = graphError[index[0]];
42 vrun[0] = graphX[index[0]];
43
44 // loop the rest entries
45 for(Int_t i=1;i<entries;i++){
46 xError[i] = 0;
47 yError[i] = 0;
48
49 if(tree->GetV3())
50 yError[i] = graphError[index[i]];
51
52
53 if(graphX[index[i]]==graphX[index[i-1]])
54 tempArray[index[i]] = count;
55 else if((graphX[index[i]]!=graphX[index[i-1]])){
56 count++;
57 icount++;
58 tempArray[index[i]] = count;
59 vrun[icount]=graphX[index[i]];
60 }
61 }
62
63 // count the number of xbins (run-wise) for the new graph
64 const Int_t newNbins = int(count+0.5);
65 Double_t *newBins = new Double_t[newNbins+1];
66 for(Int_t i=0; i<=count+1;i++){
67 newBins[i] = i;
68 }
69
70 // define and fill the new graph
71 TGraphErrors *graphNew = new TGraphErrors(entries,tempArray,graphY,xError,yError);
72 graphNew->GetXaxis()->Set(newNbins,newBins);
73
74 // set the bins for the x-axis
75 Char_t xName[50];
76 for(Int_t i=0;i<count;i++){
77 sprintf(xName,"%d",Int_t(vrun[i]));
78 graphNew->GetXaxis()->SetBinLabel(i+1,xName);
79 }
80 graphNew->GetHistogram()->SetTitle("");
81
82 // memory clearing
83 delete [] xError;
84 delete [] yError;
85 delete [] tempArray;
86 delete [] index;
87 delete [] newBins;
88 delete [] vrun;
89 return graphNew;
90
91}
92//------------------------------------------------------------------------------------------------
93drawPerformanceT0QATrends(const char* inFile = "trending.root", const char* runType="pp") {
94 //
95 //
96 gROOT->Reset();
97 gROOT->SetStyle("Plain");
98 gStyle->SetPalette(1);
99 gStyle->SetLabelSize(0.04,"x");
100
101
102 // open input file
103 //
104 TFile *file = TFile::Open(inFile);
105 if(!file) return;
106 file->cd();
107
108 TTree *tree = (TTree*)file->Get("t0QA");
109 if(!tree) return;
110 int const entries = tree->GetEntries();
111 cout<<"number of entries "<<entries<<endl;
112 TH1F *frame = new TH1F();
113
114 //const float norm_runs = 8.0;
115 if(entries<8)
116 const float norm_runs =10.0;
117 else if(entries>=8&&entries<16)
118 const float norm_runs =20.0;
119 else
120 const float norm_runs =50.0;
121 int const canvas_width = int(((entries*1.0)/norm_runs)*2000.0);
122 if(entries>50){
123 gStyle->SetTickLength(0.03*norm_runs/(entries*1.0),"Y");
124 gStyle->SetTitleYOffset((norm_runs/(entries*1.0))*0.8);
125 gStyle->SetPadLeftMargin(0.1*norm_runs/(entries*1.0));
126 gStyle->SetPadRightMargin(0.1*norm_runs/(entries*1.0));
127 }
128
129 //Define ranges of you trending plots
130 double resolutionMin = 10, resolutionMax = 50; // OR A - OR C
131 double oraplusorcMin = -100, oraplusorcMax = 100; // OR A + OR CA
132 double oraMin = -100, oraMax = 100; // OR A
133 double orcMin = -100, orcMax = 100; // OR C
134 double amplMin =0, amplMax =3 ; // amplitude in each PMT
135 double timeMin , timeMax ; // amplitude in each PMT
136 //-----> add ranges of your new trending plot
137
138
139 TCanvas *c1 = new TCanvas("can","can",canvas_width,500);
140 c1->SetGridy(1);
141 c1->SetGridx(1);
142 c1->SetBottomMargin(0.17);
143
144 /****** T0 ORA+ORC ******/
145 TGraphErrors *grSum = MakeGraphSparse(tree,"tzeroOrAPlusOrC:run","");
146 grSum->SetMarkerStyle(20);
147 grSum->SetMarkerSize(1.0);
148 grSum->SetMarkerColor(2);
149 TGraphErrors *grORA = MakeGraphSparse(tree,"tzeroOrA:run","");
150 grORA->SetMarkerStyle(28);
151 grORA->SetMarkerSize(1.0);
152 grORA->SetMarkerColor(4);
153 TGraphErrors *grORC = MakeGraphSparse(tree,"tzeroOrC:run","");
154 grORC->SetMarkerStyle(25);
155 grORC->SetMarkerSize(1.0);
156 grORC->SetMarkerColor(1);
157
158 grSum->GetHistogram()->SetYTitle("mean [ps]");
159 grSum->GetHistogram()->SetTitle("T0 ORA, ORC and (ORA+ORC)/2");
160 grSum->GetHistogram()->SetMinimum(oraplusorcMin);
161 grSum->GetHistogram()->SetMaximum(oraplusorcMax);
162 grSum->Draw("AP");
163 grORA->Draw("psame");
164 grORC->Draw("psame");
165 TLegend *leg = new TLegend(0.1,0.85,0.3,0.95," ","brNDC");
166 leg->SetFillStyle(0); leg->SetBorderSize(0); leg->SetTextSize(0.05);leg->SetNColumns(3);leg->SetColumnSeparation(1);
167 leg->AddEntry(grORA,"ORA","p");
168 leg->AddEntry(grORC,"ORC","p");
169 leg->AddEntry(grSum,"(ORA+ORC)/2","p");
170 leg->Draw();
171
172 grSum->GetXaxis()->LabelsOption("v");
173 c1->SaveAs("meanT0OrAPlusOrC_vs_run.gif");
174
175 /****** T0 Resolution ******/
176 TGraphErrors *gr = MakeGraphSparse(tree,"resolution:run","");
177 gr->SetMarkerStyle(20);
178 gr->SetMarkerSize(1.0);
179 gr->SetMarkerColor(2);
180 gr->GetHistogram()->SetMinimum(resolutionMin);
181 gr->GetHistogram()->SetMaximum(resolutionMax);
182 gr->Draw("AP");
183 gr->GetXaxis()->LabelsOption("v");
184 gr->GetHistogram()->SetYTitle("sigma [ps]");
185 gr->GetHistogram()->SetTitle("T0 resolution (ORA -ORC)/2");
186 c1->SaveAs("sigmaResolutionT0_vs_run.gif");
187
188
189 /****** Mean T0 OR A ******/
190 /* TGraphErrors *gr = MakeGraphSparse(tree,"tzeroOrA:run","");
191 gr->SetMarkerStyle(20);
192 gr->SetMarkerSize(1.0);
193 gr->SetMarkerColor(2);
194 gr->GetHistogram()->SetYTitle("mean [ps]");
195 gr->GetHistogram()->SetTitle("T0 OR A");
196 gr->GetHistogram()->SetMinimum(oraMin);
197 gr->GetHistogram()->SetMaximum(oraMax);
198 gr->Draw("AP");
199 gr->GetXaxis()->LabelsOption("v");
200 c1->SaveAs("meanT0OrA_vs_run.gif");
201*/
202
203 /****** Mean T0 OR C ******/
204 /* TGraphErrors *gr = MakeGraphSparse(tree,"tzeroOrC:run","");
205 gr->SetMarkerStyle(20);
206 gr->SetMarkerSize(1.0);
207 gr->SetMarkerColor(2);
208 gr->GetHistogram()->SetYTitle("mean [ps]");
209 gr->GetHistogram()->SetTitle("T0 OR C");
210 gr->GetHistogram()->SetMinimum(orcMin);
211 gr->GetHistogram()->SetMaximum(orcMax);
212 gr->Draw("AP");
213 gr->GetXaxis()->LabelsOption("v");
214 c1->SaveAs("meanT0OrC_vs_run.gif");
215*/
216
217 /****** Mean Amplitude in PMT ******/
218 const int kNPMTs = 24;
219 char name[200];
220
221 for(int ipmt=1;ipmt<=kNPMTs; ipmt++){
222 sprintf(name,"amplPMT%d:run",ipmt);
223 gr = MakeGraphSparse(tree,name,"");
224 gr->SetMarkerStyle(20);
225 gr->SetMarkerSize(1.0);
226 gr->SetMarkerColor(6);
227 gr->GetHistogram()->SetYTitle("mean");
228 gr->GetHistogram()->SetTitle(Form("Amplitude PMT%d",ipmt));
229
230 int nRuns = gr->GetN();
231 double *y = gr->GetY();
232 double min = y[0];
233 double max = y[0];
234 for(int irun =1; irun<nRuns;irun++){
235 if(min > y[irun] & y[irun]>0) min = y[irun];
236 if(max < y[irun]) max = y[irun];
237 }
238 // amplMin = min - 2;
239 // amplMax = max + 2;
240
241 gr->GetHistogram()->SetMinimum(amplMin);
242 gr->GetHistogram()->SetMaximum(amplMax);
243 gr->Draw("AP");
244 gr->GetXaxis()->LabelsOption("v");
245 c1->SaveAs(Form("meanAmplPMT%d_vs_run.gif",ipmt));
246 }
247 /****** Mean Time in PMT ******/
248 for(int ipmt=1;ipmt<=kNPMTs; ipmt++){
249 sprintf(name,"timePMT%d:run",ipmt);
250 gr = MakeGraphSparse(tree,name,"");
251
252
253 sprintf(name,"timeDelayPMT%d:run",ipmt);
254 TGraphErrors *grDelay = MakeGraphSparse(tree,name,"");
255 //regular run
256 int nRuns = gr->GetN();
257 double *y = gr->GetY();
258 double min = y[0];
259 double max = y[0];
260 for(int irun =1; irun<nRuns;irun++){
261 if(min > y[irun] && y[irun]>0) min = y[irun];
262 if(max < y[irun]) max = y[irun];
263 }
264 //Delay
265 // double *yDelay = grDelay->GetY();
266 // nRuns = grDelay->GetN();
267 // for(int irun =0; irun<nRuns;irun++){
268 // if(min > yDelay[irun] && yDelay[irun]>0) min = yDelay[irun];
269 // if(max < yDelay[irun]) max = yDelay[irun];
270 // }
271
272 timeMin = min - 2;
273 timeMax = max + 2;
274
275 gr->SetMarkerStyle(20);
276 gr->SetMarkerSize(1.0);
277 gr->SetMarkerColor(2);
278 grDelay->SetMarkerStyle(24);
279 grDelay->SetMarkerSize(1.0);
280 grDelay->SetMarkerColor(1);
281
282 gr->GetHistogram()->SetYTitle("mean [channels]");
283 gr->GetHistogram()->SetTitle(Form("Time PMT%d",ipmt));
284 gr->GetHistogram()->SetMinimum(timeMin);
285 gr->GetHistogram()->SetMaximum(timeMax);
286 gr->GetXaxis()->LabelsOption("v");
287 gr->Draw("AP");
288 grDelay->Draw("Psame");
289
290 TLegend *leg = new TLegend(0.1,0.85,0.3,0.95," ","brNDC");
291 leg->SetFillStyle(0); leg->SetBorderSize(0); leg->SetTextSize(0.05);leg->SetNColumns(3);
292 leg->AddEntry(gr,"mean time","p");
293 //leg->AddEntry(grDelay,"Time Delay OCDB","p");
294 leg->Draw();
295
296 c1->SaveAs(Form("meanTimePMT%d_vs_run.gif",ipmt));
297 }
298
299
300 //-----> draw your new trending plot here
301}
302