]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ZDC/AliZDCQAChecker.cxx
Added protection for gDirectory=0
[u/mrichter/AliRoot.git] / ZDC / AliZDCQAChecker.cxx
CommitLineData
075a0e70 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16
17// --- ROOT system ---
075a0e70 18#include <TH1F.h>
075a0e70 19#include <TIterator.h>
fdc38bb2 20#include <TString.h>
891ddd89 21#include <TPaveText.h>
22#include <TObjArray.h>
23#include "TList.h"
075a0e70 24
25// --- Standard library ---
26
27// --- AliRoot header files ---
28#include "AliLog.h"
075a0e70 29#include "AliZDCQAChecker.h"
30
31ClassImp(AliZDCQAChecker)
32
075a0e70 33//____________________________________________________________________________
a42ceb0e 34void AliZDCQAChecker::Check(Double_t * test, AliQAv1::ALITASK_t index, TObjArray ** list,
486788fc 35 const AliDetectorRecoParam * /*recoParam*/)
075a0e70 36{
57acd2d2 37 // Checks the QA histograms on the input list:
38 //
4e25ac79 39 const char* taskName = AliQAv1::GetAliTaskName(index);
2d9c70ab 40 //printf("\n\tAliZDCQAChecker -> checking QA histos for task %s\n",taskName);
57acd2d2 41 //
c473b43d 42 Int_t ihitHisto=0, idigHisto=0;
43 Int_t irecHisto=0, irawHisto=0, esdInd=0;
44
891ddd89 45 TObjArray messages;
46 messages.SetOwner(kTRUE);
47
f5e4ee59 48 for(Int_t specie = 0; specie<AliRecoParam::kNSpecies; specie++){
a42ceb0e 49 Int_t count = 0;
c473b43d 50 if(!AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)))
51 continue ;
52 //printf("\tAliZDCQAChecker -> specie %d, AliRecoParam::ConvertIndex(specie) %d, AliRecoParam::kLowMult %d, IsEventSpecieSet(specie) %d\n",
53 // specie, AliRecoParam::ConvertIndex(specie) ,AliRecoParam::kLowMult,
54 // AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)));
f5e4ee59 55
57acd2d2 56 // ====================================================================
57 // Checks for p-p events
58 // ====================================================================
c473b43d 59 if(AliRecoParam::ConvertIndex(specie) == AliRecoParam::kLowMult){
57acd2d2 60 if(list[specie]->GetEntries()==0){
213a7d34 61 AliWarning("\t The list to be checked is empty!"); // nothing to check
c473b43d 62 return;
12b9729c 63 }
5379c4a3 64 //AliDebug(AliQAv1::GetQADebugLevel(), Form("\n\tAliZDCQAChecker-> checking QA histograms for task %s\n\n",taskName));
57acd2d2 65 TIter next(list[specie]);
a42ceb0e 66 count = 0;
57acd2d2 67 TH1 * hdata;
c473b43d 68
331464fb 69 Float_t res=0., percentageDiff=0.30;
c473b43d 70 Float_t meanZNA=0., meanZNC=0., meanZPA=0., meanZPC=0.;
71 Float_t pmCZNA=0., pmCZNC=0., pmCZPA=0., pmCZPC=0.;
72 Float_t pmQZNA=0., pmQZNC=0., pmQZPA=0., pmQZPC=0.;
73 Float_t sumADCZNA=0., sumADCZNC=0., sumADCZPA=0., sumADCZPC=0.;
74 Float_t adcCZNA=0., adcCZNC=0., adcCZPA=0., adcCZPC=0.;
75 Float_t adcQZNA=0., adcQZNC=0., adcQZPA=0., adcQZPC=0.;
4998d47e 76 Int_t nentries = -99;
c473b43d 77
57acd2d2 78 while((hdata = dynamic_cast<TH1 *>(next()))){
79 if(hdata){
80 // -------------------------------------------------------------------
4e25ac79 81 if(index == AliQAv1::kSIM){
5379c4a3 82 //AliDebug(AliQAv1::GetQADebugLevel(), Form("\tAliZDCQAChecker-> checking histo %s",hdata->GetName()));
57acd2d2 83 // Check HITS histos
213a7d34 84 //
85 if(!(strncmp(hdata->GetName(),"hHits",5))){
57acd2d2 86 if(hdata->GetEntries()>0){
c473b43d 87 if(ihitHisto==0) meanZNC = hdata->GetMean();
88 else if(ihitHisto==1) meanZNA = hdata->GetMean();
89 else if(ihitHisto==2) meanZPC = hdata->GetMean();
90 else if(ihitHisto==3) meanZPA = hdata->GetMean();
213a7d34 91 else if(ihitHisto==4) pmQZNC = hdata->GetMean();
92 else if(ihitHisto==5) pmQZNA = hdata->GetMean();
93 else if(ihitHisto==6) pmQZPC = hdata->GetMean();
94 else if(ihitHisto==7) pmQZPA = hdata->GetMean();
95 else if(ihitHisto==8) pmCZNC = hdata->GetMean();
96 else if(ihitHisto==9) pmCZNA = hdata->GetMean();
97 else if(ihitHisto==10) pmCZPC = hdata->GetMean();
98 else if(ihitHisto==11) pmCZPA = hdata->GetMean();
99 }
100 //
101 // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
102 if(ihitHisto==11){
c473b43d 103 if(TMath::Abs(meanZNC)>1.e-10){
213a7d34 104 if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff)
105 res=1.;
106 else
107 res=.5;
108 test[specie] += res;
a42ceb0e 109 count++;
213a7d34 110 }
c473b43d 111 if(TMath::Abs(meanZNA)>1.e-10){
213a7d34 112 if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff)
113 res=1.;
114 else percentageDiff=
115 res=.5;
116 test[specie] += res;
a42ceb0e 117 count++;
213a7d34 118 }
c473b43d 119 if(TMath::Abs(meanZPC)>1.e-10){
213a7d34 120 if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff)
121 res=1.;
122 else
123 res=.5;
124 test[specie] += res;
a42ceb0e 125 count++;
213a7d34 126 }
c473b43d 127 if(TMath::Abs(meanZPA)>1.e-10){
213a7d34 128 if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff)
129 res=1.;
130 else
131 res=.5;
132 test[specie] += res;
a42ceb0e 133 count++;
213a7d34 134 }
135 }
136 ihitHisto++;
fdc38bb2 137 }
213a7d34 138 // Check DIGIT HIGH GAIN CHAIN histos
139 else if(!(strncmp(hdata->GetName(),"hDig",4))){
140 if(hdata->GetEntries()>0){
141 if(idigHisto==0) sumADCZNC = hdata->GetMean();
142 else if(idigHisto==1) sumADCZNA = hdata->GetMean();
143 else if(idigHisto==2) sumADCZPC = hdata->GetMean();
144 else if(idigHisto==3) sumADCZPA = hdata->GetMean();
145 else if(idigHisto==4) pmQZNC = hdata->GetMean();
146 else if(idigHisto==5) pmQZNA = hdata->GetMean();
147 else if(idigHisto==6) pmQZPC = hdata->GetMean();
148 else if(idigHisto==7) pmQZPA = hdata->GetMean();
149 else if(idigHisto==8) pmCZNC = hdata->GetMean();
150 else if(idigHisto==9) pmCZNA = hdata->GetMean();
151 else if(idigHisto==10) pmCZPC = hdata->GetMean();
152 else if(idigHisto==11) pmCZPA = hdata->GetMean();
153 }
154 //
155 // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
156 if(idigHisto==11){
c473b43d 157 if(TMath::Abs(sumADCZNC)>1.e-10){
213a7d34 158 if((TMath::Abs(adcQZNC-adcCZNC)/adcCZNC)<percentageDiff)
159 res=1.;
160 else
161 res=.5;
162 test[specie] += res;
a42ceb0e 163 count++;
213a7d34 164 }
c473b43d 165 if(TMath::Abs(sumADCZNA)>1.e-10){
213a7d34 166 if((TMath::Abs(adcQZNA-adcCZNA)/adcCZNA)<percentageDiff)
167 res=1.;
168 else
169 res=.5;
170 test[specie] += res;
a42ceb0e 171 count++;
213a7d34 172 }
c473b43d 173 if(TMath::Abs(sumADCZPC)>1.e-10){
213a7d34 174 if((TMath::Abs(adcQZPC-adcCZPC)/adcCZPC)<percentageDiff)
175 res=1.;
176 else
177 res=.5;
178 test[specie] += res;
a42ceb0e 179 count++;
213a7d34 180 }
c473b43d 181 if(TMath::Abs(sumADCZPA)>1.e-10){
213a7d34 182 if((TMath::Abs(adcQZPA-adcCZPA)/adcCZPA)<percentageDiff)
183 res=1.;
184 else
185 res=.5;
186 test[specie] += res;
a42ceb0e 187 count++;
213a7d34 188 }
189 }
190 idigHisto++;
fdc38bb2 191 }
213a7d34 192 }
193 // -------------------------------------------------------------------
194 else if(index == AliQAv1::kRAW) {
213a7d34 195 //
196 // Check RAW HIGH GAIN CHAIN histos
891ddd89 197
198 messages.Clear();
199
200 Bool_t iDetPM = kTRUE;
201 // --- Checks
4998d47e 202 if(irawHisto==16) nentries = Int_t (hdata->GetEntries());
92664bc8 203 if(irawHisto==18){
891ddd89 204 Float_t resADC=0.;
205 for(int ibin=1; ibin<=hdata->GetNbinsX(); ibin++){
206 if((hdata->GetBinContent(ibin))>10.){
207 res=1.;
208 }
17ffe44a 209 else if((hdata->GetBinContent(ibin))<10.){
891ddd89 210 res=0.5;
17ffe44a 211 if(ibin==1 || ibin==6 || ibin==11 || ibin==12 || ibin==13 || ibin==18){
212 iDetPM = kFALSE;
213 }
891ddd89 214 }
215 //
216 resADC += res;
217 test[specie] += res;
218 count++;
219 }
4998d47e 220 if(nentries != -99) messages.Add(new TObjString(Form("#entries %d",nentries)));
221 else messages.Add(new TObjString("#entries not known"));
222 //
891ddd89 223 Float_t rv=1.;
224 if(hdata->GetNbinsX() != 0) rv = resADC/hdata->GetNbinsX();
225 if(rv == 1.) messages.Add(new TObjString("ADCs are OK!"));
226 else if(iDetPM==kFALSE){
4998d47e 227 messages.Add(new TObjString("Problem with some ADC!"));
228 messages.Add(new TObjString("IF THIS IS A PHYSICS RUN"));
891ddd89 229 }
230 else if(iDetPM==kTRUE) messages.Add(new TObjString("Minor problem with ADCs"));
231 SetupHisto(messages, *hdata, rv);
213a7d34 232 }
92664bc8 233 else if(irawHisto==19){
ce9bf216 234 // Reference values must be inserted in the order:
235 // ZNC, ZPC, ZNA, ZPA, ZEM1, ZEM2
f33cb8ca 236 // Reference values from RUN 145456
ce9bf216 237 //Double_t refTDCs[6] = {-322.5,-319.1,-320.9,-319.2,-319.7,-319.2};
238 // 2012 -> Reference values from RUN 177399
239 Double_t refTDCs[6] = {-322.7,-321.4,-321.6,-321.7,-316.2,-315.4};
891ddd89 240 Float_t resTDC=0.;
414b1eb6 241 for(int ibin=1; ibin<=hdata->GetNbinsX(); ibin++){
f33cb8ca 242 if(TMath::Abs((hdata->GetBinContent(ibin))-refTDCs[ibin-1])<3.){
891ddd89 243 res=1.;
244 }
f33cb8ca 245 else if(TMath::Abs((hdata->GetBinContent(ibin))-refTDCs[ibin-1])<5.){
246 res=0.8;
891ddd89 247 }
f33cb8ca 248 else res=0.5;
891ddd89 249 //
250 resTDC += res;
251 test[specie] += res;
252 count++;
253 }
254 Float_t rv=1.;
414b1eb6 255 if(hdata->GetNbinsX() != 0) rv = resTDC/hdata->GetNbinsX();
891ddd89 256 if(rv == 1.) messages.Add(new TObjString("TDCs are OK!"));
f33cb8ca 257 else if(rv<1. && rv>0.75) messages.Add(new TObjString("Minor problem with TDCs"));
891ddd89 258 else{
259 messages.Add(new TObjString("Serious problem in ZDC timing"));
4998d47e 260 messages.Add(new TObjString("IF THIS IS A PHYSICS RUN"));
891ddd89 261 }
262 SetupHisto(messages, *hdata, rv);
263 }
891ddd89 264 irawHisto++;
265
213a7d34 266 }
267 // -------------------------------------------------------------------
f5e4ee59 268 else if(index == AliQAv1::kREC) {
f5e4ee59 269 //
270 // Check REC HIGH GAIN CHAIN histos
271 if(hdata->GetEntries()>0){
c473b43d 272 if(irecHisto==0) meanZNC = hdata->GetMean();
273 else if(irecHisto==1) meanZNA = hdata->GetMean();
274 else if(irecHisto==2) meanZPC = hdata->GetMean();
275 else if(irecHisto==3) meanZPA = hdata->GetMean();
f5e4ee59 276 else if(irecHisto==4) pmQZNC = hdata->GetMean();
277 else if(irecHisto==5) pmQZNA = hdata->GetMean();
278 else if(irecHisto==6) pmQZPC = hdata->GetMean();
279 else if(irecHisto==7) pmQZPA = hdata->GetMean();
280 else if(irecHisto==8) pmCZNC = hdata->GetMean();
281 else if(irecHisto==9) pmCZNA = hdata->GetMean();
282 else if(irecHisto==10) pmCZPC = hdata->GetMean();
283 else if(irecHisto==11) pmCZPA = hdata->GetMean();
284 }
285 //
286 // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
287 if(irecHisto==11){
c473b43d 288 if(TMath::Abs(meanZNC)>1.e-10){
f5e4ee59 289 if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff)
290 res=1.;
291 else
292 res=.5;
293 test[specie] += res;
a42ceb0e 294 count++;
f5e4ee59 295 }
c473b43d 296 if(TMath::Abs(meanZNA)>1.e-10){
f5e4ee59 297 if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff)
298 res=1.;
299 else
300 res=.5;
301 test[specie] += res;
a42ceb0e 302 count++;
f5e4ee59 303 }
c473b43d 304 if(TMath::Abs(meanZPC)>1.e-10){
f5e4ee59 305 if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff)
306 res=1.;
307 else
308 res=.5;
309 test[specie] += res;
a42ceb0e 310 count++;
f5e4ee59 311 }
c473b43d 312 if(TMath::Abs(meanZPA)>1.e-10){
f5e4ee59 313 if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff)
314 res=1.;
315 else
316 res=.5;
317 test[specie] += res;
a42ceb0e 318 count++;
f5e4ee59 319 }
320 }
321 irecHisto++;
322 }
323 // -------------------------------------------------------------------
213a7d34 324 else if(index == AliQAv1::kESD) {
213a7d34 325 //
326 // Check ESD HIGH GAIN CHAIN histos
c473b43d 327 if(hdata->GetEntries()>0){
92664bc8 328 if(esdInd==0) sumADCZNC = hdata->GetMean();
329 else if(esdInd==1) sumADCZNA = hdata->GetMean();
330 else if(esdInd==2) sumADCZPC = hdata->GetMean();
331 else if(esdInd==3) sumADCZPA = hdata->GetMean();
332 else if(esdInd==6) pmQZNC = hdata->GetMean();
333 else if(esdInd==7) pmQZNA = hdata->GetMean();
334 else if(esdInd==8) pmQZPC = hdata->GetMean();
335 else if(esdInd==9) pmQZPA = hdata->GetMean();
336 else if(esdInd==10) pmCZNC = hdata->GetMean();
337 else if(esdInd==11) pmCZNA = hdata->GetMean();
338 else if(esdInd==12) pmCZPC = hdata->GetMean();
339 else if(esdInd==13) pmCZPA = hdata->GetMean();
213a7d34 340 }
341 //
342 // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
c473b43d 343 if(esdInd==15){
344 if(TMath::Abs(sumADCZNC)>1.e-10){
213a7d34 345 if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff)
346 res=1.;
347 else
348 res=.5;
349 test[specie] += res;
a42ceb0e 350 count++;
213a7d34 351 }
c473b43d 352 if(TMath::Abs(sumADCZNA)>1.e-10){
213a7d34 353 if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff)
354 res=1.;
355 else
356 res=.5;
357 test[specie] += res;
a42ceb0e 358 count++;
213a7d34 359 }
c473b43d 360 if(TMath::Abs(sumADCZPC)>1.e-10){
213a7d34 361 if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff)
362 res=1.;
363 else
364 res=.5;
365 test[specie] += res;
a42ceb0e 366 count++;
213a7d34 367 }
c473b43d 368 if(TMath::Abs(sumADCZPA)>1.e-10){
213a7d34 369 if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff)
370 res=1.;
371 else
372 res=.5;
373 test[specie] += res;
a42ceb0e 374 count++;
213a7d34 375 }
fdc38bb2 376 }
57acd2d2 377 esdInd++;
213a7d34 378 }
379 else {
57acd2d2 380 AliWarning(Form("\n\t No ZDC QA for %s task\n",taskName));
a42ceb0e 381 return ;
57acd2d2 382 }
213a7d34 383 }//if(hdata)
384 else AliError("AliZDCQAChecker-> No histos!!!\n");
075a0e70 385 }
213a7d34 386 } // LowMult (p-p)
57acd2d2 387 // ====================================================================
388 // Checks for A-A events
389 // ====================================================================
4998d47e 390 if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kHighMult) {
57acd2d2 391 if(list[specie]->GetEntries()==0){
213a7d34 392 AliWarning("\t The list to be checked is empty!");
a42ceb0e 393 return ;
57acd2d2 394 }
5379c4a3 395 //AliDebug(AliQAv1::GetQADebugLevel(), Form("\n\tAliZDCQAChecker-> checking QA histograms for task %s\n\n",taskName));
213a7d34 396 //
57acd2d2 397 TIter next(list[specie]);
a42ceb0e 398 count = 0;
57acd2d2 399 TH1 * hdata;
c473b43d 400
213a7d34 401 Float_t res=0., percentageDiff=0.10;
c473b43d 402 Float_t meanZNA=0., meanZNC=0., meanZPA=0., meanZPC=0.;
403 Float_t pmCZNA=0., pmCZNC=0., pmCZPA=0., pmCZPC=0.;
404 Float_t pmQZNA=0., pmQZNC=0., pmQZPA=0., pmQZPC=0.;
405 Float_t sumADCZNA=0., sumADCZNC=0., sumADCZPA=0., sumADCZPC=0.;
406 Float_t adcCZNA=0., adcCZNC=0., adcCZPA=0., adcCZPC=0.;
407 Float_t adcQZNA=0., adcQZNC=0., adcQZPA=0., adcQZPC=0.;
4998d47e 408 Int_t nentries=-99;
c473b43d 409
57acd2d2 410 while((hdata = dynamic_cast<TH1 *>(next()))){
411 if(hdata){
5379c4a3 412 //AliDebug(AliQAv1::GetQADebugLevel(), Form("\tAliZDCQAChecker-> checking histo %s",hdata->GetName()));
57acd2d2 413 // -------------------------------------------------------------------
4e25ac79 414 if(index == AliQAv1::kSIM){
213a7d34 415 // Check HITS histos
416 if (!(strncmp(hdata->GetName(),"hHits",5))){
417 if(hdata->GetEntries()>0){
c473b43d 418 if(ihitHisto==0) meanZNC = hdata->GetMean();
419 else if(ihitHisto==1) meanZNA = hdata->GetMean();
420 else if(ihitHisto==2) meanZPC = hdata->GetMean();
421 else if(ihitHisto==3) meanZPA = hdata->GetMean();
422 else if(ihitHisto==4) pmQZNC = hdata->GetMean();
423 else if(ihitHisto==5) pmQZNA = hdata->GetMean();
424 else if(ihitHisto==6) pmQZPC = hdata->GetMean();
425 else if(ihitHisto==7) pmQZPA = hdata->GetMean();
426 else if(ihitHisto==8) pmCZNC = hdata->GetMean();
427 else if(ihitHisto==9) pmCZNA = hdata->GetMean();
428 else if(ihitHisto==10) pmCZPC = hdata->GetMean();
429 else if(ihitHisto==11) pmCZPA = hdata->GetMean();
213a7d34 430 }
431 //
432 // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
433 // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
c473b43d 434 if(ihitHisto==3){
435 if(TMath::Abs(meanZNC)>1.e-10 && TMath::Abs(meanZNA)>1.e-10){
213a7d34 436 if((2*TMath::Abs(meanZNC-meanZNA)/(meanZNA+meanZNC))<percentageDiff)
437 res=1.;
438 else
439 res=.5;
440 test[specie] += res;
a42ceb0e 441 count++;
213a7d34 442 }
c473b43d 443 if(TMath::Abs(meanZPC)>1.e-10 && TMath::Abs(meanZPA)>1.e-10){
213a7d34 444 if((TMath::Abs(meanZPC-meanZPA)/(meanZPA+meanZPC))<percentageDiff)
445 res=1.;
446 else
447 res=.5;
448 test[specie] += res;
a42ceb0e 449 count++;
213a7d34 450 }
57acd2d2 451 }
213a7d34 452 // --- Check whether (mean PMQi - PMC)/PMC < percentageDiff
c473b43d 453 if(ihitHisto==11){
454 if(TMath::Abs(meanZNC)>1.e-10){
213a7d34 455 if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff)
57acd2d2 456 res=1.;
457 else
213a7d34 458 res=.5;
57acd2d2 459 test[specie] += res;
a42ceb0e 460 count++;
213a7d34 461 }
c473b43d 462 if(TMath::Abs(meanZNA)>1.e-10){
213a7d34 463 if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff)
57acd2d2 464 res=1.;
465 else
213a7d34 466 res=.5;
57acd2d2 467 test[specie] += res;
a42ceb0e 468 count++;
213a7d34 469 }
c473b43d 470 if(TMath::Abs(meanZPC)>1.e-10){
213a7d34 471 if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff)
57acd2d2 472 res=1.;
473 else
213a7d34 474 res=.5;
57acd2d2 475 test[specie] += res;
a42ceb0e 476 count++;
213a7d34 477 }
c473b43d 478 if(TMath::Abs(meanZPA)>1.e-10){
213a7d34 479 if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff)
57acd2d2 480 res=1.;
481 else
213a7d34 482 res=.5;
57acd2d2 483 test[specie] += res;
a42ceb0e 484 count++;
213a7d34 485 }
486 }
c473b43d 487 ihitHisto++;
fdc38bb2 488 }
213a7d34 489 // Check DIGITS histos
490 else if (!(strncmp(hdata->GetName(),"hDig",4))){
491 if(hdata->GetEntries()>0){
c473b43d 492 if(idigHisto==0) sumADCZNC = hdata->GetMean();
493 else if(idigHisto==1) sumADCZNA = hdata->GetMean();
494 else if(idigHisto==2) sumADCZPC = hdata->GetMean();
495 else if(idigHisto==3) sumADCZPA = hdata->GetMean();
496 else if(idigHisto==4) adcQZNC = hdata->GetMean();
497 else if(idigHisto==5) adcQZNA = hdata->GetMean();
498 else if(idigHisto==6) adcQZPC = hdata->GetMean();
499 else if(idigHisto==7) adcQZPA = hdata->GetMean();
500 else if(idigHisto==8) adcCZNC = hdata->GetMean();
501 else if(idigHisto==9) adcCZNA = hdata->GetMean();
502 else if(idigHisto==10) adcCZPC = hdata->GetMean();
503 else if(idigHisto==11) adcCZPA = hdata->GetMean();
213a7d34 504 }
505 //
506 // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
507 // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
c473b43d 508 if(idigHisto==3){
509 if(TMath::Abs(sumADCZNC)>1.e-10 && TMath::Abs(sumADCZNA)>1.e-10){
213a7d34 510 if((2*TMath::Abs(sumADCZNC-sumADCZNA)/(sumADCZNA+sumADCZNC))<percentageDiff)
57acd2d2 511 res=1.;
512 else
513 res=.5;
514 test[specie] += res;
a42ceb0e 515 count++;
213a7d34 516 }
c473b43d 517 if(TMath::Abs(sumADCZPC)>1.e-10 && TMath::Abs(sumADCZPA)>1.e-10){
213a7d34 518 if((TMath::Abs(sumADCZPC-sumADCZPA)/(sumADCZPA+sumADCZPC))<percentageDiff)
57acd2d2 519 res=1.;
520 else
521 res=.5;
522 test[specie] += res;
a42ceb0e 523 count++;
213a7d34 524 }
57acd2d2 525 }
213a7d34 526 // --- Check whether (sumADC PMQi - PMC)/PMC < percentageDiff
c473b43d 527 if(idigHisto==11){
528 if(TMath::Abs(sumADCZNC)>1.e-10){
213a7d34 529 if((TMath::Abs(adcQZNC-adcCZNC)/adcCZNC)<percentageDiff)
57acd2d2 530 res=1.;
531 else
213a7d34 532 res=.5;
57acd2d2 533 test[specie] += res;
a42ceb0e 534 count++;
213a7d34 535 }
c473b43d 536 if(TMath::Abs(sumADCZNA)>1.e-10){
213a7d34 537 if((TMath::Abs(adcQZNA-adcCZNA)/adcCZNA)<percentageDiff)
57acd2d2 538 res=1.;
539 else
213a7d34 540 res=.5;
57acd2d2 541 test[specie] += res;
a42ceb0e 542 count++;
213a7d34 543 }
c473b43d 544 if(TMath::Abs(sumADCZPC)>1.e-10){
213a7d34 545 if((TMath::Abs(adcQZPC-adcCZPC)/adcCZPC)<percentageDiff)
57acd2d2 546 res=1.;
547 else
213a7d34 548 res=.5;
57acd2d2 549 test[specie] += res;
a42ceb0e 550 count++;
213a7d34 551 }
c473b43d 552 if(TMath::Abs(sumADCZPA)>1.e-10){
213a7d34 553 if((TMath::Abs(adcQZPA-adcCZPA)/adcCZPA)<percentageDiff)
57acd2d2 554 res=1.;
555 else
213a7d34 556 res=.5;
57acd2d2 557 test[specie] += res;
a42ceb0e 558 count++;
213a7d34 559 }
560 }
c473b43d 561 idigHisto++;
fdc38bb2 562 }
563 }
213a7d34 564 // -------------------------------------------------------------------
565 else if(index == AliQAv1::kRAW){
213a7d34 566 //
567 // Check RAW HIGH GAIN CHAIN histos
891ddd89 568
569 messages.Clear();
570
571 Bool_t iDetPM = kTRUE;
572 // --- Checks
4998d47e 573 if(irawHisto==16) nentries = Int_t (hdata->GetEntries());
92664bc8 574 if(irawHisto==18){
891ddd89 575 Float_t resADC=0.;
576 for(int ibin=1; ibin<=hdata->GetNbinsX(); ibin++){
577 if((hdata->GetBinContent(ibin))>10.){
578 res=1.;
579 }
580 else if((hdata->GetBinContent(ibin))<10. &&
581 (ibin==1 || ibin==6 || ibin==11 || ibin==12 || ibin==13 || ibin==18)){
582 res=0.5;
583 iDetPM = kFALSE;
584 }
585 //
586 resADC += res;
587 test[specie] += res;
588 count++;
589 }
4998d47e 590 if(nentries != -99) messages.Add(new TObjString(Form("#entries %d",nentries)));
591 else messages.Add(new TObjString("#entries not known"));
592 //
891ddd89 593 Float_t rv=1.;
594 if(hdata->GetNbinsX() != 0) rv = resADC/hdata->GetNbinsX();
4998d47e 595 if(rv > 0.98) messages.Add(new TObjString("ADCs are OK!"));
891ddd89 596 else if(iDetPM==kFALSE){
597 messages.Add(new TObjString("Problem with ADCs!"));
4998d47e 598 messages.Add(new TObjString("IF THIS IS A PHYSICS RUN"));
891ddd89 599 }
600 else if(iDetPM==kTRUE) messages.Add(new TObjString("Minor problem with ADCs"));
601 SetupHisto(messages, *hdata, rv);
213a7d34 602 }
92664bc8 603 else if(irawHisto==19){
4998d47e 604 // Reference values from RUN 137161
605 Double_t refTDCs[6] = {-320.7,-319.0,-318.6,-319.9,-321.3,-320.8};
891ddd89 606 Float_t resTDC=0.;
607 for(int ibin=1; ibin<=hdata->GetNbinsX(); ibin++){
4998d47e 608 if(TMath::Abs((hdata->GetBinContent(ibin))-refTDCs[ibin-1])<3.){
891ddd89 609 res=1.;
610 }
4998d47e 611 else if(TMath::Abs((hdata->GetBinContent(ibin))-refTDCs[ibin-1])<4.){
612 res=0.8;
891ddd89 613 }
4998d47e 614 else res=0.5;
891ddd89 615 //
616 resTDC += res;
617 test[specie] += res;
618 count++;
619 }
620 Float_t rv=1.;
621 if(hdata->GetNbinsX() != 0) rv = resTDC/hdata->GetNbinsX();
622 if(rv == 1.) messages.Add(new TObjString("TDCs are OK!"));
4998d47e 623 else if(rv<1 && rv>0.75) messages.Add(new TObjString("Minor problem with TDCs"));
891ddd89 624 else{
625 messages.Add(new TObjString("Serious problem in ZDC timing"));
4998d47e 626 messages.Add(new TObjString("IF THIS IS A PHYSICS RUN"));
891ddd89 627 }
628 SetupHisto(messages, *hdata, rv);
629 }
891ddd89 630 irawHisto++;
631
213a7d34 632 }
633 // -------------------------------------------------------------------
f5e4ee59 634 else if(index == AliQAv1::kREC){
f5e4ee59 635 //
636 // Check RAW HIGH GAIN CHAIN histos
637 if(hdata->GetEntries()>0){
c473b43d 638 if(irecHisto==0) meanZNC = hdata->GetMean();
639 else if(irecHisto==1) meanZNA = hdata->GetMean();
640 else if(irecHisto==2) meanZPC = hdata->GetMean();
641 else if(irecHisto==3) meanZPA = hdata->GetMean();
642 else if(irecHisto==4) pmQZNC = hdata->GetMean();
643 else if(irecHisto==5) pmQZNA = hdata->GetMean();
644 else if(irecHisto==6) pmQZPC = hdata->GetMean();
645 else if(irecHisto==7) pmQZPA = hdata->GetMean();
646 else if(irecHisto==8) pmCZNC = hdata->GetMean();
647 else if(irecHisto==9) pmCZNA = hdata->GetMean();
648 else if(irecHisto==10) pmCZPC = hdata->GetMean();
649 else if(irecHisto==11) pmCZPA = hdata->GetMean();
f5e4ee59 650 }
651 //
652 // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
653 // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
c473b43d 654 if(irecHisto==3){
655 if(TMath::Abs(meanZNC)>1.e-10 && TMath::Abs(meanZNA)>1.e-10){
656 if((2*TMath::Abs(meanZNC-meanZNA)/(meanZNA+meanZNC))<percentageDiff)
f5e4ee59 657 res=1.;
658 else
659 res=.5;
660 test[specie] += res;
a42ceb0e 661 count++;
f5e4ee59 662 }
c473b43d 663 if(TMath::Abs(meanZPC)>1.e-10 && TMath::Abs(meanZPA)>1.e-10){
664 if((TMath::Abs(meanZPC-meanZPA)/(meanZPA+meanZPC))<percentageDiff)
f5e4ee59 665 res=1.;
666 else
667 res=.5;
668 test[specie] += res;
a42ceb0e 669 count++;
f5e4ee59 670 }
671 }
672 // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
c473b43d 673 if(irecHisto==11){
9e05925b 674 if((TMath::Abs(meanZNC)>1.e-10) && (pmCZNC>1.e-10)){
f5e4ee59 675 if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff)
676 res=1.;
677 else
678 res=.5;
679 test[specie] += res;
a42ceb0e 680 count++;
f5e4ee59 681 }
9e05925b 682 if((TMath::Abs(meanZNA)>1.e-10) && (pmCZNA>1.e-10)){
f5e4ee59 683 if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff)
684 res=1.;
685 else
686 res=.5;
687 test[specie] += res;
a42ceb0e 688 count++;
f5e4ee59 689 }
9e05925b 690 if((TMath::Abs(meanZPC)>1.e-10) && (pmCZPC>1.e-10)){
f5e4ee59 691 if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff)
692 res=1.;
693 else
694 res=.5;
695 test[specie] += res;
a42ceb0e 696 count++;
f5e4ee59 697 }
9e05925b 698 if((TMath::Abs(meanZPA)>1.e-10) && (pmCZPA>1.e-10)){
f5e4ee59 699 if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff)
700 res=1.;
701 else
702 res=.5;
703 test[specie] += res;
a42ceb0e 704 count++;
f5e4ee59 705 }
706 }
c473b43d 707 irecHisto++;
f5e4ee59 708 }
709 // -------------------------------------------------------------------
213a7d34 710 else if(index == AliQAv1::kESD){
213a7d34 711 //
712 // Check ESD HIGH GAIN CHAIN histos
c473b43d 713 if(hdata->GetEntries()>0){
92664bc8 714 if(esdInd==0) sumADCZNC = hdata->GetMean();
715 else if(esdInd==1) sumADCZNA = hdata->GetMean();
716 else if(esdInd==2) sumADCZPC = hdata->GetMean();
717 else if(esdInd==3) sumADCZPA = hdata->GetMean();
718 else if(esdInd==6) pmQZNC = hdata->GetMean();
719 else if(esdInd==7) pmQZNA = hdata->GetMean();
720 else if(esdInd==8) pmQZPC = hdata->GetMean();
721 else if(esdInd==9) pmQZPA = hdata->GetMean();
722 else if(esdInd==10) pmCZNC = hdata->GetMean();
723 else if(esdInd==11) pmCZNA = hdata->GetMean();
724 else if(esdInd==12) pmCZPC = hdata->GetMean();
725 else if(esdInd==13) pmCZPA = hdata->GetMean();
213a7d34 726 }
727 //
728 // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
729 // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
730 if(esdInd==5){
c473b43d 731 if(TMath::Abs(sumADCZNC)>1.e-10 && TMath::Abs(sumADCZNA)>1.e-10){
213a7d34 732 if((2*TMath::Abs(sumADCZNC-sumADCZNA)/(sumADCZNA+sumADCZNC))<percentageDiff)
733 res=1.;
734 else
735 res=.5;
736 test[specie] += res;
a42ceb0e 737 count++;
213a7d34 738 }
c473b43d 739 if(TMath::Abs(sumADCZPC)>1.e-10 && TMath::Abs(sumADCZPA)>1.e-10){
213a7d34 740 if((TMath::Abs(sumADCZPC-sumADCZPA)/(sumADCZPA+sumADCZPC))<percentageDiff)
741 res=1.;
742 else
743 res=.5;
744 test[specie] += res;
a42ceb0e 745 count++;
213a7d34 746 }
747 }
748 // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
c473b43d 749 if(esdInd==15){
750 if(TMath::Abs(sumADCZNC)>1.e-10){
213a7d34 751 if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff)
752 res=1.;
753 else
754 res=.5;
755 test[specie] += res;
a42ceb0e 756 count++;
213a7d34 757 }
c473b43d 758 if(TMath::Abs(sumADCZNA)>1.e-10){
213a7d34 759 if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff)
760 res=1.;
761 else
762 res=.5;
763 test[specie] += res;
a42ceb0e 764 count++;
213a7d34 765 }
32e2fda5 766/* if(TMath::Abs(sumADCZPC)>1.e-10){
213a7d34 767 if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff)
768 res=1.;
769 else
770 res=.5;
771 test[specie] += res;
a42ceb0e 772 count++;
213a7d34 773 }
c473b43d 774 if(TMath::Abs(sumADCZPA)>1.e-10){
213a7d34 775 if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff)
776 res=1.;
777 else
778 res=.5;
779 test[specie] += res;
a42ceb0e 780 count++;
213a7d34 781 }
32e2fda5 782*/
213a7d34 783 }
784 esdInd++;
785 }
786 else {
787 AliWarning(Form("\n\t No ZDC QA for %s task\n",taskName));
a42ceb0e 788 return ;
213a7d34 789 }
790 }//if(hdata)
791 else AliError("\t No histos found for ZDC!!!\n");
792 }
793 } // HighMult (Pb-Pb)
f5e4ee59 794 // ====================================================================
795 // Checks for Calibration events
796 // ====================================================================
4998d47e 797 if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCalib) {
798 AliWarning(Form("\n\t No check implemented in ZDC QA for %s task in CALIBRATION events\n",taskName));
a42ceb0e 799 return ;
f5e4ee59 800 } // Calibration
801 // ====================================================================
802 // Checks for cosmic events
803 // ====================================================================
c473b43d 804 else if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCosmic) {
4998d47e 805 AliWarning(Form("\n\t No check needed in ZDC QA for %s task in COSMIC events\n",taskName));
a42ceb0e 806 return ;
f5e4ee59 807 } // Cosmic
c473b43d 808 if(TMath::Abs(count)>1.e-10) test[specie] = test[specie]/count;
213a7d34 809 AliDebug(AliQAv1::GetQADebugLevel(), Form("\n\t ZDC QA check result = %1.2f\n",test[specie]));
a42ceb0e 810 } // Loop on species
075a0e70 811}
891ddd89 812
813//___________________________________________________________________
814void AliZDCQAChecker::SetupHisto(const TObjArray& messages, TH1& histo, Float_t& code)
815{
816 //
817 /// Add text to histos
818 //
819
9d397f52 820 TPaveText* text = new TPaveText(0.70,0.70,0.99,0.99,"NDC");
891ddd89 821
822 TIter next(&messages);
823 TObjString* str;
824
825 while ( ( str = static_cast<TObjString*>(next()) ) ){
826 text->AddText(str->String());
827 }
828
829 TString defaultText = "";
830
831 Int_t color = 0;
832 if(code==1.){
833 color = kGreen;
834 defaultText = "Everything is fine!";
835 }
4998d47e 836 else if(code<1. && code>=0.85){
891ddd89 837 color = kYellow;
838 defaultText = "To be monitored in next runs";
839 }
4998d47e 840 else if(code<0.85 && code>=0.6){
891ddd89 841 color = kOrange;
842 defaultText = "notify the expert DURING THE DAY!";
843 }
9d397f52 844 else if(code<0.6){
891ddd89 845 color = kRed;
4998d47e 846 defaultText = "PLEASE CALL THE EXPERT!!!!";
891ddd89 847 }
848
849
850 text->AddText(defaultText.Data());
851 text->SetFillColor(color);
852
853 //histo.SetFillStyle(1001);
854 //histo.SetFillColor(color);
855
856 histo.SetStats(kFALSE);
321e378b 857
858 TList* lst = histo.GetListOfFunctions();
859 if(lst){
860 TObject *stats = lst->FindObject("stats");
861 lst->Remove(stats);
862 TObject *obj;
863 while ((obj = lst->First())) {
864 while(lst->Remove(obj)) { }
865 delete obj;
866 }
867 if(stats) lst->Add(stats);
321e378b 868 lst->Add(text);
07e38cef 869 }
891ddd89 870}