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