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