...also histos are now correctly booked
[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){
f33cb8ca 234 // Reference values from RUN 145456
235 Double_t refTDCs[6] = {-322.5,-319.1,-320.9,-319.2,-319.7,-319.2};
891ddd89 236 Float_t resTDC=0.;
414b1eb6 237 for(int ibin=1; ibin<=hdata->GetNbinsX(); ibin++){
f33cb8ca 238 if(TMath::Abs((hdata->GetBinContent(ibin))-refTDCs[ibin-1])<3.){
891ddd89 239 res=1.;
240 }
f33cb8ca 241 else if(TMath::Abs((hdata->GetBinContent(ibin))-refTDCs[ibin-1])<5.){
242 res=0.8;
891ddd89 243 }
f33cb8ca 244 else res=0.5;
891ddd89 245 //
246 resTDC += res;
247 test[specie] += res;
248 count++;
249 }
250 Float_t rv=1.;
414b1eb6 251 if(hdata->GetNbinsX() != 0) rv = resTDC/hdata->GetNbinsX();
891ddd89 252 if(rv == 1.) messages.Add(new TObjString("TDCs are OK!"));
f33cb8ca 253 else if(rv<1. && rv>0.75) messages.Add(new TObjString("Minor problem with TDCs"));
891ddd89 254 else{
255 messages.Add(new TObjString("Serious problem in ZDC timing"));
4998d47e 256 messages.Add(new TObjString("IF THIS IS A PHYSICS RUN"));
891ddd89 257 }
258 SetupHisto(messages, *hdata, rv);
259 }
891ddd89 260 irawHisto++;
261
213a7d34 262 }
263 // -------------------------------------------------------------------
f5e4ee59 264 else if(index == AliQAv1::kREC) {
f5e4ee59 265 //
266 // Check REC HIGH GAIN CHAIN histos
267 if(hdata->GetEntries()>0){
c473b43d 268 if(irecHisto==0) meanZNC = hdata->GetMean();
269 else if(irecHisto==1) meanZNA = hdata->GetMean();
270 else if(irecHisto==2) meanZPC = hdata->GetMean();
271 else if(irecHisto==3) meanZPA = hdata->GetMean();
f5e4ee59 272 else if(irecHisto==4) pmQZNC = hdata->GetMean();
273 else if(irecHisto==5) pmQZNA = hdata->GetMean();
274 else if(irecHisto==6) pmQZPC = hdata->GetMean();
275 else if(irecHisto==7) pmQZPA = hdata->GetMean();
276 else if(irecHisto==8) pmCZNC = hdata->GetMean();
277 else if(irecHisto==9) pmCZNA = hdata->GetMean();
278 else if(irecHisto==10) pmCZPC = hdata->GetMean();
279 else if(irecHisto==11) pmCZPA = hdata->GetMean();
280 }
281 //
282 // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
283 if(irecHisto==11){
c473b43d 284 if(TMath::Abs(meanZNC)>1.e-10){
f5e4ee59 285 if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff)
286 res=1.;
287 else
288 res=.5;
289 test[specie] += res;
a42ceb0e 290 count++;
f5e4ee59 291 }
c473b43d 292 if(TMath::Abs(meanZNA)>1.e-10){
f5e4ee59 293 if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff)
294 res=1.;
295 else
296 res=.5;
297 test[specie] += res;
a42ceb0e 298 count++;
f5e4ee59 299 }
c473b43d 300 if(TMath::Abs(meanZPC)>1.e-10){
f5e4ee59 301 if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff)
302 res=1.;
303 else
304 res=.5;
305 test[specie] += res;
a42ceb0e 306 count++;
f5e4ee59 307 }
c473b43d 308 if(TMath::Abs(meanZPA)>1.e-10){
f5e4ee59 309 if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff)
310 res=1.;
311 else
312 res=.5;
313 test[specie] += res;
a42ceb0e 314 count++;
f5e4ee59 315 }
316 }
317 irecHisto++;
318 }
319 // -------------------------------------------------------------------
213a7d34 320 else if(index == AliQAv1::kESD) {
213a7d34 321 //
322 // Check ESD HIGH GAIN CHAIN histos
c473b43d 323 if(hdata->GetEntries()>0){
92664bc8 324 if(esdInd==0) sumADCZNC = hdata->GetMean();
325 else if(esdInd==1) sumADCZNA = hdata->GetMean();
326 else if(esdInd==2) sumADCZPC = hdata->GetMean();
327 else if(esdInd==3) sumADCZPA = hdata->GetMean();
328 else if(esdInd==6) pmQZNC = hdata->GetMean();
329 else if(esdInd==7) pmQZNA = hdata->GetMean();
330 else if(esdInd==8) pmQZPC = hdata->GetMean();
331 else if(esdInd==9) pmQZPA = hdata->GetMean();
332 else if(esdInd==10) pmCZNC = hdata->GetMean();
333 else if(esdInd==11) pmCZNA = hdata->GetMean();
334 else if(esdInd==12) pmCZPC = hdata->GetMean();
335 else if(esdInd==13) pmCZPA = hdata->GetMean();
213a7d34 336 }
337 //
338 // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
c473b43d 339 if(esdInd==15){
340 if(TMath::Abs(sumADCZNC)>1.e-10){
213a7d34 341 if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff)
342 res=1.;
343 else
344 res=.5;
345 test[specie] += res;
a42ceb0e 346 count++;
213a7d34 347 }
c473b43d 348 if(TMath::Abs(sumADCZNA)>1.e-10){
213a7d34 349 if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff)
350 res=1.;
351 else
352 res=.5;
353 test[specie] += res;
a42ceb0e 354 count++;
213a7d34 355 }
c473b43d 356 if(TMath::Abs(sumADCZPC)>1.e-10){
213a7d34 357 if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff)
358 res=1.;
359 else
360 res=.5;
361 test[specie] += res;
a42ceb0e 362 count++;
213a7d34 363 }
c473b43d 364 if(TMath::Abs(sumADCZPA)>1.e-10){
213a7d34 365 if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff)
366 res=1.;
367 else
368 res=.5;
369 test[specie] += res;
a42ceb0e 370 count++;
213a7d34 371 }
fdc38bb2 372 }
57acd2d2 373 esdInd++;
213a7d34 374 }
375 else {
57acd2d2 376 AliWarning(Form("\n\t No ZDC QA for %s task\n",taskName));
a42ceb0e 377 return ;
57acd2d2 378 }
213a7d34 379 }//if(hdata)
380 else AliError("AliZDCQAChecker-> No histos!!!\n");
075a0e70 381 }
213a7d34 382 } // LowMult (p-p)
57acd2d2 383 // ====================================================================
384 // Checks for A-A events
385 // ====================================================================
4998d47e 386 if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kHighMult) {
57acd2d2 387 if(list[specie]->GetEntries()==0){
213a7d34 388 AliWarning("\t The list to be checked is empty!");
a42ceb0e 389 return ;
57acd2d2 390 }
5379c4a3 391 //AliDebug(AliQAv1::GetQADebugLevel(), Form("\n\tAliZDCQAChecker-> checking QA histograms for task %s\n\n",taskName));
213a7d34 392 //
57acd2d2 393 TIter next(list[specie]);
a42ceb0e 394 count = 0;
57acd2d2 395 TH1 * hdata;
c473b43d 396
213a7d34 397 Float_t res=0., percentageDiff=0.10;
c473b43d 398 Float_t meanZNA=0., meanZNC=0., meanZPA=0., meanZPC=0.;
399 Float_t pmCZNA=0., pmCZNC=0., pmCZPA=0., pmCZPC=0.;
400 Float_t pmQZNA=0., pmQZNC=0., pmQZPA=0., pmQZPC=0.;
401 Float_t sumADCZNA=0., sumADCZNC=0., sumADCZPA=0., sumADCZPC=0.;
402 Float_t adcCZNA=0., adcCZNC=0., adcCZPA=0., adcCZPC=0.;
403 Float_t adcQZNA=0., adcQZNC=0., adcQZPA=0., adcQZPC=0.;
4998d47e 404 Int_t nentries=-99;
c473b43d 405
57acd2d2 406 while((hdata = dynamic_cast<TH1 *>(next()))){
407 if(hdata){
5379c4a3 408 //AliDebug(AliQAv1::GetQADebugLevel(), Form("\tAliZDCQAChecker-> checking histo %s",hdata->GetName()));
57acd2d2 409 // -------------------------------------------------------------------
4e25ac79 410 if(index == AliQAv1::kSIM){
213a7d34 411 // Check HITS histos
412 if (!(strncmp(hdata->GetName(),"hHits",5))){
413 if(hdata->GetEntries()>0){
c473b43d 414 if(ihitHisto==0) meanZNC = hdata->GetMean();
415 else if(ihitHisto==1) meanZNA = hdata->GetMean();
416 else if(ihitHisto==2) meanZPC = hdata->GetMean();
417 else if(ihitHisto==3) meanZPA = hdata->GetMean();
418 else if(ihitHisto==4) pmQZNC = hdata->GetMean();
419 else if(ihitHisto==5) pmQZNA = hdata->GetMean();
420 else if(ihitHisto==6) pmQZPC = hdata->GetMean();
421 else if(ihitHisto==7) pmQZPA = hdata->GetMean();
422 else if(ihitHisto==8) pmCZNC = hdata->GetMean();
423 else if(ihitHisto==9) pmCZNA = hdata->GetMean();
424 else if(ihitHisto==10) pmCZPC = hdata->GetMean();
425 else if(ihitHisto==11) pmCZPA = hdata->GetMean();
213a7d34 426 }
427 //
428 // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
429 // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
c473b43d 430 if(ihitHisto==3){
431 if(TMath::Abs(meanZNC)>1.e-10 && TMath::Abs(meanZNA)>1.e-10){
213a7d34 432 if((2*TMath::Abs(meanZNC-meanZNA)/(meanZNA+meanZNC))<percentageDiff)
433 res=1.;
434 else
435 res=.5;
436 test[specie] += res;
a42ceb0e 437 count++;
213a7d34 438 }
c473b43d 439 if(TMath::Abs(meanZPC)>1.e-10 && TMath::Abs(meanZPA)>1.e-10){
213a7d34 440 if((TMath::Abs(meanZPC-meanZPA)/(meanZPA+meanZPC))<percentageDiff)
441 res=1.;
442 else
443 res=.5;
444 test[specie] += res;
a42ceb0e 445 count++;
213a7d34 446 }
57acd2d2 447 }
213a7d34 448 // --- Check whether (mean PMQi - PMC)/PMC < percentageDiff
c473b43d 449 if(ihitHisto==11){
450 if(TMath::Abs(meanZNC)>1.e-10){
213a7d34 451 if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff)
57acd2d2 452 res=1.;
453 else
213a7d34 454 res=.5;
57acd2d2 455 test[specie] += res;
a42ceb0e 456 count++;
213a7d34 457 }
c473b43d 458 if(TMath::Abs(meanZNA)>1.e-10){
213a7d34 459 if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff)
57acd2d2 460 res=1.;
461 else
213a7d34 462 res=.5;
57acd2d2 463 test[specie] += res;
a42ceb0e 464 count++;
213a7d34 465 }
c473b43d 466 if(TMath::Abs(meanZPC)>1.e-10){
213a7d34 467 if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff)
57acd2d2 468 res=1.;
469 else
213a7d34 470 res=.5;
57acd2d2 471 test[specie] += res;
a42ceb0e 472 count++;
213a7d34 473 }
c473b43d 474 if(TMath::Abs(meanZPA)>1.e-10){
213a7d34 475 if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff)
57acd2d2 476 res=1.;
477 else
213a7d34 478 res=.5;
57acd2d2 479 test[specie] += res;
a42ceb0e 480 count++;
213a7d34 481 }
482 }
c473b43d 483 ihitHisto++;
fdc38bb2 484 }
213a7d34 485 // Check DIGITS histos
486 else if (!(strncmp(hdata->GetName(),"hDig",4))){
487 if(hdata->GetEntries()>0){
c473b43d 488 if(idigHisto==0) sumADCZNC = hdata->GetMean();
489 else if(idigHisto==1) sumADCZNA = hdata->GetMean();
490 else if(idigHisto==2) sumADCZPC = hdata->GetMean();
491 else if(idigHisto==3) sumADCZPA = hdata->GetMean();
492 else if(idigHisto==4) adcQZNC = hdata->GetMean();
493 else if(idigHisto==5) adcQZNA = hdata->GetMean();
494 else if(idigHisto==6) adcQZPC = hdata->GetMean();
495 else if(idigHisto==7) adcQZPA = hdata->GetMean();
496 else if(idigHisto==8) adcCZNC = hdata->GetMean();
497 else if(idigHisto==9) adcCZNA = hdata->GetMean();
498 else if(idigHisto==10) adcCZPC = hdata->GetMean();
499 else if(idigHisto==11) adcCZPA = hdata->GetMean();
213a7d34 500 }
501 //
502 // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
503 // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
c473b43d 504 if(idigHisto==3){
505 if(TMath::Abs(sumADCZNC)>1.e-10 && TMath::Abs(sumADCZNA)>1.e-10){
213a7d34 506 if((2*TMath::Abs(sumADCZNC-sumADCZNA)/(sumADCZNA+sumADCZNC))<percentageDiff)
57acd2d2 507 res=1.;
508 else
509 res=.5;
510 test[specie] += res;
a42ceb0e 511 count++;
213a7d34 512 }
c473b43d 513 if(TMath::Abs(sumADCZPC)>1.e-10 && TMath::Abs(sumADCZPA)>1.e-10){
213a7d34 514 if((TMath::Abs(sumADCZPC-sumADCZPA)/(sumADCZPA+sumADCZPC))<percentageDiff)
57acd2d2 515 res=1.;
516 else
517 res=.5;
518 test[specie] += res;
a42ceb0e 519 count++;
213a7d34 520 }
57acd2d2 521 }
213a7d34 522 // --- Check whether (sumADC PMQi - PMC)/PMC < percentageDiff
c473b43d 523 if(idigHisto==11){
524 if(TMath::Abs(sumADCZNC)>1.e-10){
213a7d34 525 if((TMath::Abs(adcQZNC-adcCZNC)/adcCZNC)<percentageDiff)
57acd2d2 526 res=1.;
527 else
213a7d34 528 res=.5;
57acd2d2 529 test[specie] += res;
a42ceb0e 530 count++;
213a7d34 531 }
c473b43d 532 if(TMath::Abs(sumADCZNA)>1.e-10){
213a7d34 533 if((TMath::Abs(adcQZNA-adcCZNA)/adcCZNA)<percentageDiff)
57acd2d2 534 res=1.;
535 else
213a7d34 536 res=.5;
57acd2d2 537 test[specie] += res;
a42ceb0e 538 count++;
213a7d34 539 }
c473b43d 540 if(TMath::Abs(sumADCZPC)>1.e-10){
213a7d34 541 if((TMath::Abs(adcQZPC-adcCZPC)/adcCZPC)<percentageDiff)
57acd2d2 542 res=1.;
543 else
213a7d34 544 res=.5;
57acd2d2 545 test[specie] += res;
a42ceb0e 546 count++;
213a7d34 547 }
c473b43d 548 if(TMath::Abs(sumADCZPA)>1.e-10){
213a7d34 549 if((TMath::Abs(adcQZPA-adcCZPA)/adcCZPA)<percentageDiff)
57acd2d2 550 res=1.;
551 else
213a7d34 552 res=.5;
57acd2d2 553 test[specie] += res;
a42ceb0e 554 count++;
213a7d34 555 }
556 }
c473b43d 557 idigHisto++;
fdc38bb2 558 }
559 }
213a7d34 560 // -------------------------------------------------------------------
561 else if(index == AliQAv1::kRAW){
213a7d34 562 //
563 // Check RAW HIGH GAIN CHAIN histos
891ddd89 564
565 messages.Clear();
566
567 Bool_t iDetPM = kTRUE;
568 // --- Checks
4998d47e 569 if(irawHisto==16) nentries = Int_t (hdata->GetEntries());
92664bc8 570 if(irawHisto==18){
891ddd89 571 Float_t resADC=0.;
572 for(int ibin=1; ibin<=hdata->GetNbinsX(); ibin++){
573 if((hdata->GetBinContent(ibin))>10.){
574 res=1.;
575 }
576 else if((hdata->GetBinContent(ibin))<10. &&
577 (ibin==1 || ibin==6 || ibin==11 || ibin==12 || ibin==13 || ibin==18)){
578 res=0.5;
579 iDetPM = kFALSE;
580 }
581 //
582 resADC += res;
583 test[specie] += res;
584 count++;
585 }
4998d47e 586 if(nentries != -99) messages.Add(new TObjString(Form("#entries %d",nentries)));
587 else messages.Add(new TObjString("#entries not known"));
588 //
891ddd89 589 Float_t rv=1.;
590 if(hdata->GetNbinsX() != 0) rv = resADC/hdata->GetNbinsX();
4998d47e 591 if(rv > 0.98) messages.Add(new TObjString("ADCs are OK!"));
891ddd89 592 else if(iDetPM==kFALSE){
593 messages.Add(new TObjString("Problem with ADCs!"));
4998d47e 594 messages.Add(new TObjString("IF THIS IS A PHYSICS RUN"));
891ddd89 595 }
596 else if(iDetPM==kTRUE) messages.Add(new TObjString("Minor problem with ADCs"));
597 SetupHisto(messages, *hdata, rv);
213a7d34 598 }
92664bc8 599 else if(irawHisto==19){
4998d47e 600 // Reference values from RUN 137161
601 Double_t refTDCs[6] = {-320.7,-319.0,-318.6,-319.9,-321.3,-320.8};
891ddd89 602 Float_t resTDC=0.;
603 for(int ibin=1; ibin<=hdata->GetNbinsX(); ibin++){
4998d47e 604 if(TMath::Abs((hdata->GetBinContent(ibin))-refTDCs[ibin-1])<3.){
891ddd89 605 res=1.;
606 }
4998d47e 607 else if(TMath::Abs((hdata->GetBinContent(ibin))-refTDCs[ibin-1])<4.){
608 res=0.8;
891ddd89 609 }
4998d47e 610 else res=0.5;
891ddd89 611 //
612 resTDC += res;
613 test[specie] += res;
614 count++;
615 }
616 Float_t rv=1.;
617 if(hdata->GetNbinsX() != 0) rv = resTDC/hdata->GetNbinsX();
618 if(rv == 1.) messages.Add(new TObjString("TDCs are OK!"));
4998d47e 619 else if(rv<1 && rv>0.75) messages.Add(new TObjString("Minor problem with TDCs"));
891ddd89 620 else{
621 messages.Add(new TObjString("Serious problem in ZDC timing"));
4998d47e 622 messages.Add(new TObjString("IF THIS IS A PHYSICS RUN"));
891ddd89 623 }
624 SetupHisto(messages, *hdata, rv);
625 }
891ddd89 626 irawHisto++;
627
213a7d34 628 }
629 // -------------------------------------------------------------------
f5e4ee59 630 else if(index == AliQAv1::kREC){
f5e4ee59 631 //
632 // Check RAW HIGH GAIN CHAIN histos
633 if(hdata->GetEntries()>0){
c473b43d 634 if(irecHisto==0) meanZNC = hdata->GetMean();
635 else if(irecHisto==1) meanZNA = hdata->GetMean();
636 else if(irecHisto==2) meanZPC = hdata->GetMean();
637 else if(irecHisto==3) meanZPA = hdata->GetMean();
638 else if(irecHisto==4) pmQZNC = hdata->GetMean();
639 else if(irecHisto==5) pmQZNA = hdata->GetMean();
640 else if(irecHisto==6) pmQZPC = hdata->GetMean();
641 else if(irecHisto==7) pmQZPA = hdata->GetMean();
642 else if(irecHisto==8) pmCZNC = hdata->GetMean();
643 else if(irecHisto==9) pmCZNA = hdata->GetMean();
644 else if(irecHisto==10) pmCZPC = hdata->GetMean();
645 else if(irecHisto==11) pmCZPA = hdata->GetMean();
f5e4ee59 646 }
647 //
648 // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
649 // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
c473b43d 650 if(irecHisto==3){
651 if(TMath::Abs(meanZNC)>1.e-10 && TMath::Abs(meanZNA)>1.e-10){
652 if((2*TMath::Abs(meanZNC-meanZNA)/(meanZNA+meanZNC))<percentageDiff)
f5e4ee59 653 res=1.;
654 else
655 res=.5;
656 test[specie] += res;
a42ceb0e 657 count++;
f5e4ee59 658 }
c473b43d 659 if(TMath::Abs(meanZPC)>1.e-10 && TMath::Abs(meanZPA)>1.e-10){
660 if((TMath::Abs(meanZPC-meanZPA)/(meanZPA+meanZPC))<percentageDiff)
f5e4ee59 661 res=1.;
662 else
663 res=.5;
664 test[specie] += res;
a42ceb0e 665 count++;
f5e4ee59 666 }
667 }
668 // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
c473b43d 669 if(irecHisto==11){
9e05925b 670 if((TMath::Abs(meanZNC)>1.e-10) && (pmCZNC>1.e-10)){
f5e4ee59 671 if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff)
672 res=1.;
673 else
674 res=.5;
675 test[specie] += res;
a42ceb0e 676 count++;
f5e4ee59 677 }
9e05925b 678 if((TMath::Abs(meanZNA)>1.e-10) && (pmCZNA>1.e-10)){
f5e4ee59 679 if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff)
680 res=1.;
681 else
682 res=.5;
683 test[specie] += res;
a42ceb0e 684 count++;
f5e4ee59 685 }
9e05925b 686 if((TMath::Abs(meanZPC)>1.e-10) && (pmCZPC>1.e-10)){
f5e4ee59 687 if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff)
688 res=1.;
689 else
690 res=.5;
691 test[specie] += res;
a42ceb0e 692 count++;
f5e4ee59 693 }
9e05925b 694 if((TMath::Abs(meanZPA)>1.e-10) && (pmCZPA>1.e-10)){
f5e4ee59 695 if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff)
696 res=1.;
697 else
698 res=.5;
699 test[specie] += res;
a42ceb0e 700 count++;
f5e4ee59 701 }
702 }
c473b43d 703 irecHisto++;
f5e4ee59 704 }
705 // -------------------------------------------------------------------
213a7d34 706 else if(index == AliQAv1::kESD){
213a7d34 707 //
708 // Check ESD HIGH GAIN CHAIN histos
c473b43d 709 if(hdata->GetEntries()>0){
92664bc8 710 if(esdInd==0) sumADCZNC = hdata->GetMean();
711 else if(esdInd==1) sumADCZNA = hdata->GetMean();
712 else if(esdInd==2) sumADCZPC = hdata->GetMean();
713 else if(esdInd==3) sumADCZPA = hdata->GetMean();
714 else if(esdInd==6) pmQZNC = hdata->GetMean();
715 else if(esdInd==7) pmQZNA = hdata->GetMean();
716 else if(esdInd==8) pmQZPC = hdata->GetMean();
717 else if(esdInd==9) pmQZPA = hdata->GetMean();
718 else if(esdInd==10) pmCZNC = hdata->GetMean();
719 else if(esdInd==11) pmCZNA = hdata->GetMean();
720 else if(esdInd==12) pmCZPC = hdata->GetMean();
721 else if(esdInd==13) pmCZPA = hdata->GetMean();
213a7d34 722 }
723 //
724 // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
725 // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
726 if(esdInd==5){
c473b43d 727 if(TMath::Abs(sumADCZNC)>1.e-10 && TMath::Abs(sumADCZNA)>1.e-10){
213a7d34 728 if((2*TMath::Abs(sumADCZNC-sumADCZNA)/(sumADCZNA+sumADCZNC))<percentageDiff)
729 res=1.;
730 else
731 res=.5;
732 test[specie] += res;
a42ceb0e 733 count++;
213a7d34 734 }
c473b43d 735 if(TMath::Abs(sumADCZPC)>1.e-10 && TMath::Abs(sumADCZPA)>1.e-10){
213a7d34 736 if((TMath::Abs(sumADCZPC-sumADCZPA)/(sumADCZPA+sumADCZPC))<percentageDiff)
737 res=1.;
738 else
739 res=.5;
740 test[specie] += res;
a42ceb0e 741 count++;
213a7d34 742 }
743 }
744 // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
c473b43d 745 if(esdInd==15){
746 if(TMath::Abs(sumADCZNC)>1.e-10){
213a7d34 747 if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff)
748 res=1.;
749 else
750 res=.5;
751 test[specie] += res;
a42ceb0e 752 count++;
213a7d34 753 }
c473b43d 754 if(TMath::Abs(sumADCZNA)>1.e-10){
213a7d34 755 if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff)
756 res=1.;
757 else
758 res=.5;
759 test[specie] += res;
a42ceb0e 760 count++;
213a7d34 761 }
32e2fda5 762/* if(TMath::Abs(sumADCZPC)>1.e-10){
213a7d34 763 if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff)
764 res=1.;
765 else
766 res=.5;
767 test[specie] += res;
a42ceb0e 768 count++;
213a7d34 769 }
c473b43d 770 if(TMath::Abs(sumADCZPA)>1.e-10){
213a7d34 771 if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff)
772 res=1.;
773 else
774 res=.5;
775 test[specie] += res;
a42ceb0e 776 count++;
213a7d34 777 }
32e2fda5 778*/
213a7d34 779 }
780 esdInd++;
781 }
782 else {
783 AliWarning(Form("\n\t No ZDC QA for %s task\n",taskName));
a42ceb0e 784 return ;
213a7d34 785 }
786 }//if(hdata)
787 else AliError("\t No histos found for ZDC!!!\n");
788 }
789 } // HighMult (Pb-Pb)
f5e4ee59 790 // ====================================================================
791 // Checks for Calibration events
792 // ====================================================================
4998d47e 793 if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCalib) {
794 AliWarning(Form("\n\t No check implemented in ZDC QA for %s task in CALIBRATION events\n",taskName));
a42ceb0e 795 return ;
f5e4ee59 796 } // Calibration
797 // ====================================================================
798 // Checks for cosmic events
799 // ====================================================================
c473b43d 800 else if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCosmic) {
4998d47e 801 AliWarning(Form("\n\t No check needed in ZDC QA for %s task in COSMIC events\n",taskName));
a42ceb0e 802 return ;
f5e4ee59 803 } // Cosmic
c473b43d 804 if(TMath::Abs(count)>1.e-10) test[specie] = test[specie]/count;
213a7d34 805 AliDebug(AliQAv1::GetQADebugLevel(), Form("\n\t ZDC QA check result = %1.2f\n",test[specie]));
a42ceb0e 806 } // Loop on species
075a0e70 807}
891ddd89 808
809//___________________________________________________________________
810void AliZDCQAChecker::SetupHisto(const TObjArray& messages, TH1& histo, Float_t& code)
811{
812 //
813 /// Add text to histos
814 //
815
9d397f52 816 TPaveText* text = new TPaveText(0.70,0.70,0.99,0.99,"NDC");
891ddd89 817
818 TIter next(&messages);
819 TObjString* str;
820
821 while ( ( str = static_cast<TObjString*>(next()) ) ){
822 text->AddText(str->String());
823 }
824
825 TString defaultText = "";
826
827 Int_t color = 0;
828 if(code==1.){
829 color = kGreen;
830 defaultText = "Everything is fine!";
831 }
4998d47e 832 else if(code<1. && code>=0.85){
891ddd89 833 color = kYellow;
834 defaultText = "To be monitored in next runs";
835 }
4998d47e 836 else if(code<0.85 && code>=0.6){
891ddd89 837 color = kOrange;
838 defaultText = "notify the expert DURING THE DAY!";
839 }
9d397f52 840 else if(code<0.6){
891ddd89 841 color = kRed;
4998d47e 842 defaultText = "PLEASE CALL THE EXPERT!!!!";
891ddd89 843 }
844
845
846 text->AddText(defaultText.Data());
847 text->SetFillColor(color);
848
849 //histo.SetFillStyle(1001);
850 //histo.SetFillColor(color);
851
852 histo.SetStats(kFALSE);
853
854 histo.GetListOfFunctions()->Add(text);
855}