]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/AliZDCQAChecker.cxx
Bug corrected in QA checker
[u/mrichter/AliRoot.git] / ZDC / AliZDCQAChecker.cxx
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 ---
18 #include <TH1F.h> 
19 #include <TIterator.h> 
20 #include <TString.h> 
21
22 // --- Standard library ---
23
24 // --- AliRoot header files ---
25 #include "AliLog.h"
26 #include "AliZDCQAChecker.h"
27
28 ClassImp(AliZDCQAChecker)
29
30 //____________________________________________________________________________
31 void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArray ** list,
32       const AliDetectorRecoParam * /*recoParam*/) 
33 {
34   // Checks the QA histograms on the input list: 
35   //
36   const char* taskName = AliQAv1::GetAliTaskName(index);
37   //printf("\n\tAliZDCQAChecker -> checking QA histos for task %s\n",taskName);
38   //
39   Int_t ihitHisto=0, idigHisto=0;
40   Int_t irecHisto=0, irawHisto=0, esdInd=0;
41
42   for(Int_t specie = 0; specie<AliRecoParam::kNSpecies; specie++){
43     Int_t count = 0; 
44     if(!AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie))) 
45       continue ;
46     //printf("\tAliZDCQAChecker -> specie %d, AliRecoParam::ConvertIndex(specie) %d, AliRecoParam::kLowMult %d, IsEventSpecieSet(specie) %d\n",
47     //  specie, AliRecoParam::ConvertIndex(specie) ,AliRecoParam::kLowMult,
48     //  AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)));
49     
50     // ====================================================================
51     //  Checks for p-p events
52     // ====================================================================
53     if(AliRecoParam::ConvertIndex(specie) == AliRecoParam::kLowMult){
54       if(list[specie]->GetEntries()==0){  
55         AliWarning("\t The list to be checked is empty!"); // nothing to check
56         return;
57       }
58       //AliDebug(AliQAv1::GetQADebugLevel(), Form("\n\tAliZDCQAChecker-> checking QA histograms for task %s\n\n",taskName));
59       TIter next(list[specie]); 
60       count = 0; 
61       TH1 * hdata;        
62       
63       Float_t res=0., percentageDiff=0.20;
64       Float_t meanZNA=0., meanZNC=0., meanZPA=0., meanZPC=0.;
65       Float_t pmCZNA=0., pmCZNC=0., pmCZPA=0., pmCZPC=0.;
66       Float_t pmQZNA=0., pmQZNC=0., pmQZPA=0., pmQZPC=0.;
67       Float_t sumADCZNA=0., sumADCZNC=0., sumADCZPA=0., sumADCZPC=0.;
68       Float_t adcCZNA=0., adcCZNC=0., adcCZPA=0., adcCZPC=0.;
69       Float_t adcQZNA=0., adcQZNC=0., adcQZPA=0., adcQZPC=0.;
70       
71       while((hdata = dynamic_cast<TH1 *>(next()))){
72         if(hdata){ 
73           // -------------------------------------------------------------------
74           if(index == AliQAv1::kSIM){
75             //AliDebug(AliQAv1::GetQADebugLevel(), Form("\tAliZDCQAChecker-> checking histo %s",hdata->GetName()));
76             // Check HITS histos
77             //
78             if(!(strncmp(hdata->GetName(),"hHits",5))){
79               if(hdata->GetEntries()>0){
80                 if(ihitHisto==0)      meanZNC = hdata->GetMean();
81                 else if(ihitHisto==1) meanZNA = hdata->GetMean();
82                 else if(ihitHisto==2) meanZPC = hdata->GetMean();
83                 else if(ihitHisto==3) meanZPA = hdata->GetMean();
84                 else if(ihitHisto==4) pmQZNC = hdata->GetMean();
85                 else if(ihitHisto==5) pmQZNA = hdata->GetMean();
86                 else if(ihitHisto==6) pmQZPC = hdata->GetMean();
87                 else if(ihitHisto==7) pmQZPA = hdata->GetMean();
88                 else if(ihitHisto==8)  pmCZNC = hdata->GetMean();
89                 else if(ihitHisto==9)  pmCZNA = hdata->GetMean();
90                 else if(ihitHisto==10) pmCZPC = hdata->GetMean();
91                 else if(ihitHisto==11) pmCZPA = hdata->GetMean();
92               }
93               //
94               // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
95               if(ihitHisto==11){
96                 if(TMath::Abs(meanZNC)>1.e-10){
97                   if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff) 
98                     res=1.;
99                   else 
100                     res=.5;
101                   test[specie] += res;
102                   count++;
103                 }
104                 if(TMath::Abs(meanZNA)>1.e-10){
105                   if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff) 
106                     res=1.;
107                   else percentageDiff=
108                     res=.5;
109                   test[specie] += res;
110                   count++;
111                 }
112                 if(TMath::Abs(meanZPC)>1.e-10){
113                   if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff) 
114                     res=1.;
115                   else 
116                     res=.5;
117                   test[specie] += res;
118                   count++;
119                 }
120                 if(TMath::Abs(meanZPA)>1.e-10){
121                   if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff) 
122                     res=1.;
123                   else 
124                     res=.5;
125                   test[specie] += res;
126                   count++;
127                 }
128               }
129               ihitHisto++;
130             }
131             // Check DIGIT HIGH GAIN CHAIN histos
132             else if(!(strncmp(hdata->GetName(),"hDig",4))){ 
133               if(hdata->GetEntries()>0){
134                 if(idigHisto==0)      sumADCZNC = hdata->GetMean();
135                 else if(idigHisto==1) sumADCZNA = hdata->GetMean();
136                 else if(idigHisto==2) sumADCZPC = hdata->GetMean();
137                 else if(idigHisto==3) sumADCZPA = hdata->GetMean();
138                 else if(idigHisto==4) pmQZNC = hdata->GetMean();
139                 else if(idigHisto==5) pmQZNA = hdata->GetMean();
140                 else if(idigHisto==6) pmQZPC = hdata->GetMean();
141                 else if(idigHisto==7) pmQZPA = hdata->GetMean();
142                 else if(idigHisto==8)  pmCZNC = hdata->GetMean();
143                 else if(idigHisto==9)  pmCZNA = hdata->GetMean();
144                 else if(idigHisto==10) pmCZPC = hdata->GetMean();
145                 else if(idigHisto==11) pmCZPA = hdata->GetMean();
146               }
147               //
148               // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
149               if(idigHisto==11){
150                 if(TMath::Abs(sumADCZNC)>1.e-10){
151                   if((TMath::Abs(adcQZNC-adcCZNC)/adcCZNC)<percentageDiff) 
152                     res=1.;
153                   else 
154                     res=.5;
155                   test[specie] += res;
156                   count++;
157                 }
158                 if(TMath::Abs(sumADCZNA)>1.e-10){
159                   if((TMath::Abs(adcQZNA-adcCZNA)/adcCZNA)<percentageDiff) 
160                     res=1.;
161                   else 
162                     res=.5;
163                   test[specie] += res;
164                   count++;
165                 }
166                 if(TMath::Abs(sumADCZPC)>1.e-10){
167                   if((TMath::Abs(adcQZPC-adcCZPC)/adcCZPC)<percentageDiff) 
168                     res=1.;
169                   else 
170                     res=.5;
171                   test[specie] += res;
172                   count++;
173                 }
174                 if(TMath::Abs(sumADCZPA)>1.e-10){
175                   if((TMath::Abs(adcQZPA-adcCZPA)/adcCZPA)<percentageDiff) 
176                     res=1.;
177                   else 
178                     res=.5;
179                   test[specie] += res;
180                   count++;
181                 }
182               }
183               idigHisto++;            
184             }
185           } 
186           // -------------------------------------------------------------------
187           else if(index == AliQAv1::kRAW) {
188             //
189             // Check RAW HIGH GAIN CHAIN histos
190             if(hdata->GetEntries()>0){
191               if(irawHisto==0)      sumADCZNC = hdata->GetMean();
192               else if(irawHisto==1) sumADCZNA = hdata->GetMean();
193               else if(irawHisto==2) sumADCZPC = hdata->GetMean();
194               else if(irawHisto==3) sumADCZPA = hdata->GetMean();
195               else if(irawHisto==6) adcQZNC = hdata->GetMean();
196               else if(irawHisto==7) adcQZNA = hdata->GetMean();
197               else if(irawHisto==8) adcQZPC = hdata->GetMean();
198               else if(irawHisto==9) adcQZPA = hdata->GetMean();
199               else if(irawHisto==10) adcCZNC = hdata->GetMean();
200               else if(irawHisto==11) adcCZNA = hdata->GetMean();
201               else if(irawHisto==12) adcCZPC = hdata->GetMean();
202               else if(irawHisto==13) adcCZPA = hdata->GetMean();
203             }
204             //
205             // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
206             if(irawHisto==13){
207               if(TMath::Abs(sumADCZNC)>1.e-10){
208                 if((TMath::Abs(adcQZNC-adcCZNC)/adcCZNC)<percentageDiff) 
209                   res=1.;
210                 else 
211                   res=.5;
212                 test[specie] += res;
213                 count++;
214               }
215               if(TMath::Abs(sumADCZNA)>1.e-10){
216                 if((TMath::Abs(adcQZNA-adcCZNA)/adcCZNA)<percentageDiff) 
217                   res=1.;
218                 else 
219                   res=.5;
220                 test[specie] += res;
221                 count++;
222               }
223               if(TMath::Abs(sumADCZPC)>1.e-10){
224                 if((TMath::Abs(adcQZPC-adcCZPC)/adcCZPC)<percentageDiff) 
225                   res=1.;
226                 else 
227                   res=.5;
228                 test[specie] += res;
229                 count++;
230               }
231               if(TMath::Abs(sumADCZPA)>1.e-10){
232                 if((TMath::Abs(adcQZPA-adcCZPA)/adcCZPA)<percentageDiff) 
233                   res=1.;
234                 else 
235                   res=.5;
236                 test[specie] += res;
237                 count++;
238               }
239             }
240             irawHisto++;            
241           } 
242           // -------------------------------------------------------------------
243           else if(index == AliQAv1::kREC) {
244             //
245             // Check REC HIGH GAIN CHAIN histos
246             if(hdata->GetEntries()>0){
247               if(irecHisto==0)       meanZNC = hdata->GetMean();
248               else if(irecHisto==1)  meanZNA = hdata->GetMean();
249               else if(irecHisto==2)  meanZPC = hdata->GetMean();
250               else if(irecHisto==3)  meanZPA = hdata->GetMean();
251               else if(irecHisto==4)  pmQZNC = hdata->GetMean();
252               else if(irecHisto==5)  pmQZNA = hdata->GetMean();
253               else if(irecHisto==6)  pmQZPC = hdata->GetMean();
254               else if(irecHisto==7)  pmQZPA = hdata->GetMean();
255               else if(irecHisto==8)  pmCZNC = hdata->GetMean();
256               else if(irecHisto==9)  pmCZNA = hdata->GetMean();
257               else if(irecHisto==10) pmCZPC = hdata->GetMean();
258               else if(irecHisto==11) pmCZPA = hdata->GetMean();
259             }
260             //
261             // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
262             if(irecHisto==11){
263               if(TMath::Abs(meanZNC)>1.e-10){
264                 if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff) 
265                   res=1.;
266                 else 
267                   res=.5;
268                 test[specie] += res;
269                 count++;
270               }
271               if(TMath::Abs(meanZNA)>1.e-10){
272                 if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff) 
273                   res=1.;
274                 else 
275                   res=.5;
276                 test[specie] += res;
277                 count++;
278               }
279               if(TMath::Abs(meanZPC)>1.e-10){
280                 if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff) 
281                   res=1.;
282                 else 
283                   res=.5;
284                 test[specie] += res;
285                 count++;
286               }
287               if(TMath::Abs(meanZPA)>1.e-10){
288                 if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff) 
289                   res=1.;
290                 else 
291                   res=.5;
292                 test[specie] += res;
293                 count++;
294               }
295             }
296             irecHisto++;            
297           } 
298           // -------------------------------------------------------------------
299           else if(index == AliQAv1::kESD) {
300             //
301             // Check ESD HIGH GAIN CHAIN histos
302             if(hdata->GetEntries()>0){
303               if(esdInd==2)      sumADCZNC = hdata->GetMean();
304               else if(esdInd==3) sumADCZNA = hdata->GetMean();
305               else if(esdInd==4) sumADCZPC = hdata->GetMean();
306               else if(esdInd==5) sumADCZPA = hdata->GetMean();
307               else if(esdInd==8)  pmQZNC = hdata->GetMean();
308               else if(esdInd==9)  pmQZNA = hdata->GetMean();
309               else if(esdInd==10) pmQZPC = hdata->GetMean();
310               else if(esdInd==11) pmQZPA = hdata->GetMean();
311               else if(esdInd==12) pmCZNC = hdata->GetMean();
312               else if(esdInd==13) pmCZNA = hdata->GetMean();
313               else if(esdInd==14) pmCZPC = hdata->GetMean();
314               else if(esdInd==15) pmCZPA = hdata->GetMean();
315             }
316             //
317             // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
318             if(esdInd==15){
319               if(TMath::Abs(sumADCZNC)>1.e-10){
320                 if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff) 
321                   res=1.;
322                 else 
323                   res=.5;
324                 test[specie] += res;
325                 count++;
326               }
327               if(TMath::Abs(sumADCZNA)>1.e-10){
328                 if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff) 
329                   res=1.;
330                 else 
331                   res=.5;
332                 test[specie] += res;
333                 count++;
334               }
335               if(TMath::Abs(sumADCZPC)>1.e-10){
336                 if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff) 
337                   res=1.;
338                 else 
339                   res=.5;
340                 test[specie] += res;
341                 count++;
342               }
343               if(TMath::Abs(sumADCZPA)>1.e-10){
344                 if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff) 
345                   res=1.;
346                 else 
347                   res=.5;
348                 test[specie] += res;
349                 count++;
350               }
351             }
352             esdInd++;
353          }  
354          else {
355            AliWarning(Form("\n\t No ZDC QA for %s task\n",taskName)); 
356            return ;
357          }
358         }//if(hdata) 
359         else AliError("AliZDCQAChecker-> No histos!!!\n");
360       }
361     } // LowMult (p-p)
362     // ====================================================================
363     //  Checks for A-A events
364     // ====================================================================
365     else if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kHighMult) {
366       if(list[specie]->GetEntries()==0){  
367         AliWarning("\t The list to be checked is empty!");
368         return ;
369       }
370       //AliDebug(AliQAv1::GetQADebugLevel(), Form("\n\tAliZDCQAChecker-> checking QA histograms for task %s\n\n",taskName));
371       //
372       TIter next(list[specie]); 
373       count = 0; 
374       TH1 * hdata;        
375       
376       Float_t res=0., percentageDiff=0.10;
377       Float_t meanZNA=0., meanZNC=0., meanZPA=0., meanZPC=0.;
378       Float_t pmCZNA=0., pmCZNC=0., pmCZPA=0., pmCZPC=0.;
379       Float_t pmQZNA=0., pmQZNC=0., pmQZPA=0., pmQZPC=0.;
380       Float_t sumADCZNA=0., sumADCZNC=0., sumADCZPA=0., sumADCZPC=0.;
381       Float_t adcCZNA=0., adcCZNC=0., adcCZPA=0., adcCZPC=0.;
382       Float_t adcQZNA=0., adcQZNC=0., adcQZPA=0., adcQZPC=0.;
383       
384       while((hdata = dynamic_cast<TH1 *>(next()))){
385         if(hdata){ 
386           //AliDebug(AliQAv1::GetQADebugLevel(), Form("\tAliZDCQAChecker-> checking histo %s",hdata->GetName()));
387           // -------------------------------------------------------------------
388           if(index == AliQAv1::kSIM){
389             // Check HITS histos
390             if (!(strncmp(hdata->GetName(),"hHits",5))){
391               if(hdata->GetEntries()>0){
392                 if(ihitHisto==0)      meanZNC = hdata->GetMean();
393                 else if(ihitHisto==1) meanZNA = hdata->GetMean();
394                 else if(ihitHisto==2) meanZPC = hdata->GetMean();
395                 else if(ihitHisto==3) meanZPA = hdata->GetMean();
396                 else if(ihitHisto==4) pmQZNC = hdata->GetMean();
397                 else if(ihitHisto==5) pmQZNA = hdata->GetMean();
398                 else if(ihitHisto==6) pmQZPC = hdata->GetMean();
399                 else if(ihitHisto==7) pmQZPA = hdata->GetMean();
400                 else if(ihitHisto==8)  pmCZNC = hdata->GetMean();
401                 else if(ihitHisto==9)  pmCZNA = hdata->GetMean();
402                 else if(ihitHisto==10) pmCZPC = hdata->GetMean();
403                 else if(ihitHisto==11) pmCZPA = hdata->GetMean();
404               }
405               //
406               // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
407               // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
408               if(ihitHisto==3){
409                 if(TMath::Abs(meanZNC)>1.e-10 && TMath::Abs(meanZNA)>1.e-10){
410                   if((2*TMath::Abs(meanZNC-meanZNA)/(meanZNA+meanZNC))<percentageDiff) 
411                     res=1.;
412                   else 
413                     res=.5;
414                   test[specie] += res;
415                   count++;
416                 }
417                 if(TMath::Abs(meanZPC)>1.e-10 && TMath::Abs(meanZPA)>1.e-10){
418                   if((TMath::Abs(meanZPC-meanZPA)/(meanZPA+meanZPC))<percentageDiff) 
419                     res=1.;
420                   else 
421                     res=.5;
422                   test[specie] += res;
423                   count++;
424                 }
425               }
426               // --- Check whether (mean PMQi - PMC)/PMC < percentageDiff
427               if(ihitHisto==11){
428                 if(TMath::Abs(meanZNC)>1.e-10){
429                   if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff) 
430                     res=1.;
431                   else 
432                     res=.5;
433                   test[specie] += res;
434                   count++;
435                 }
436                 if(TMath::Abs(meanZNA)>1.e-10){
437                   if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff) 
438                     res=1.;
439                   else 
440                     res=.5;
441                   test[specie] += res;
442                   count++;
443                 }
444                 if(TMath::Abs(meanZPC)>1.e-10){
445                   if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff) 
446                     res=1.;
447                   else 
448                     res=.5;
449                   test[specie] += res;
450                   count++;
451                 }
452                 if(TMath::Abs(meanZPA)>1.e-10){
453                   if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff) 
454                     res=1.;
455                   else 
456                     res=.5;
457                   test[specie] += res;
458                   count++;
459                 }
460               }
461               ihitHisto++;
462             }
463             // Check DIGITS histos
464             else if (!(strncmp(hdata->GetName(),"hDig",4))){
465               if(hdata->GetEntries()>0){
466                 if(idigHisto==0)      sumADCZNC = hdata->GetMean();
467                 else if(idigHisto==1) sumADCZNA = hdata->GetMean();
468                 else if(idigHisto==2) sumADCZPC = hdata->GetMean();
469                 else if(idigHisto==3) sumADCZPA = hdata->GetMean();
470                 else if(idigHisto==4) adcQZNC = hdata->GetMean();
471                 else if(idigHisto==5) adcQZNA = hdata->GetMean();
472                 else if(idigHisto==6) adcQZPC = hdata->GetMean();
473                 else if(idigHisto==7) adcQZPA = hdata->GetMean();
474                 else if(idigHisto==8)  adcCZNC = hdata->GetMean();
475                 else if(idigHisto==9)  adcCZNA = hdata->GetMean();
476                 else if(idigHisto==10) adcCZPC = hdata->GetMean();
477                 else if(idigHisto==11) adcCZPA = hdata->GetMean();
478               }
479               //
480               // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
481               // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
482               if(idigHisto==3){
483                 if(TMath::Abs(sumADCZNC)>1.e-10 && TMath::Abs(sumADCZNA)>1.e-10){
484                   if((2*TMath::Abs(sumADCZNC-sumADCZNA)/(sumADCZNA+sumADCZNC))<percentageDiff) 
485                     res=1.;
486                   else 
487                     res=.5;
488                   test[specie] += res;
489                   count++;
490                 }
491                 if(TMath::Abs(sumADCZPC)>1.e-10 && TMath::Abs(sumADCZPA)>1.e-10){
492                   if((TMath::Abs(sumADCZPC-sumADCZPA)/(sumADCZPA+sumADCZPC))<percentageDiff) 
493                     res=1.;
494                   else 
495                     res=.5;
496                   test[specie] += res;
497                   count++;
498                 }
499               }
500               // --- Check whether (sumADC PMQi - PMC)/PMC < percentageDiff
501               if(idigHisto==11){
502                 if(TMath::Abs(sumADCZNC)>1.e-10){
503                   if((TMath::Abs(adcQZNC-adcCZNC)/adcCZNC)<percentageDiff) 
504                     res=1.;
505                   else 
506                     res=.5;
507                   test[specie] += res;
508                   count++;
509                 }
510                 if(TMath::Abs(sumADCZNA)>1.e-10){
511                   if((TMath::Abs(adcQZNA-adcCZNA)/adcCZNA)<percentageDiff) 
512                     res=1.;
513                   else 
514                     res=.5;
515                   test[specie] += res;
516                   count++;
517                 }
518                 if(TMath::Abs(sumADCZPC)>1.e-10){
519                   if((TMath::Abs(adcQZPC-adcCZPC)/adcCZPC)<percentageDiff) 
520                     res=1.;
521                   else 
522                     res=.5;
523                   test[specie] += res;
524                   count++;
525                 }
526                 if(TMath::Abs(sumADCZPA)>1.e-10){
527                   if((TMath::Abs(adcQZPA-adcCZPA)/adcCZPA)<percentageDiff) 
528                     res=1.;
529                   else 
530                     res=.5;
531                   test[specie] += res;
532                   count++;
533                 }
534               }
535               idigHisto++;
536             }
537           }
538           // -------------------------------------------------------------------
539           else if(index == AliQAv1::kRAW){
540             //
541             // Check RAW HIGH GAIN CHAIN histos
542             if(hdata->GetEntries()>0){
543               if(irawHisto==0)      sumADCZNC = hdata->GetMean();
544               else if(irawHisto==1) sumADCZNA = hdata->GetMean();
545               else if(irawHisto==2) sumADCZPC = hdata->GetMean();
546               else if(irawHisto==3) sumADCZPA = hdata->GetMean();
547               else if(irawHisto==6) adcQZNC = hdata->GetMean();
548               else if(irawHisto==7) adcQZNA = hdata->GetMean();
549               else if(irawHisto==8) adcQZPC = hdata->GetMean();
550               else if(irawHisto==9) adcQZPA = hdata->GetMean();
551               else if(irawHisto==10) adcCZNC = hdata->GetMean();
552               else if(irawHisto==11) adcCZNA = hdata->GetMean();
553               else if(irawHisto==12) adcCZPC = hdata->GetMean();
554               else if(irawHisto==13) adcCZPA = hdata->GetMean();
555             }
556             //
557             // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
558             // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
559             if(irawHisto==3){
560               if(TMath::Abs(sumADCZNC)>1.e-10 && TMath::Abs(sumADCZNA)>1.e-10){
561                 if((2*TMath::Abs(sumADCZNC-sumADCZNA)/(sumADCZNA+sumADCZNC))<percentageDiff) 
562                   res=1.;
563                 else 
564                   res=.5;
565                 test[specie] += res;
566                 count++;
567               }
568               if(TMath::Abs(sumADCZPC)>1.e-10 && TMath::Abs(sumADCZPA)>1.e-10){
569                 if((TMath::Abs(sumADCZPC-sumADCZPA)/(sumADCZPA+sumADCZPC))<percentageDiff) 
570                   res=1.;
571                 else 
572                   res=.5;
573                 test[specie] += res;
574                 count++;
575               }
576             }
577             // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
578             if(irawHisto==13){
579               if(TMath::Abs(sumADCZNC)>1.e-10){
580                 if((TMath::Abs(adcQZNC-adcCZNC)/adcCZNC)<percentageDiff) 
581                   res=1.;
582                 else 
583                   res=.5;
584                 test[specie] += res;
585                 count++;
586               }
587               if(TMath::Abs(sumADCZNA)>1.e-10){
588                 if((TMath::Abs(adcQZNA-adcCZNA)/adcCZNA)<percentageDiff) 
589                   res=1.;
590                 else 
591                   res=.5;
592                 test[specie] += res;
593                 count++;
594               }
595               if(TMath::Abs(sumADCZPC)>1.e-10){
596                 if((TMath::Abs(adcQZPC-adcCZPC)/adcCZPC)<percentageDiff) 
597                   res=1.;
598                 else 
599                   res=.5;
600                 test[specie] += res;
601                 count++;
602               }
603               if(TMath::Abs(sumADCZPA)>1.e-10){
604                 if((TMath::Abs(adcQZPA-adcCZPA)/adcCZPA)<percentageDiff) 
605                   res=1.;
606                 else 
607                   res=.5;
608                 test[specie] += res;
609                 count++;
610               }
611             }
612             irawHisto++;         
613           }   
614           // -------------------------------------------------------------------
615           else if(index == AliQAv1::kREC){
616             //
617             // Check RAW HIGH GAIN CHAIN histos
618             if(hdata->GetEntries()>0){
619               if(irecHisto==0)       meanZNC = hdata->GetMean();
620               else if(irecHisto==1)  meanZNA = hdata->GetMean();
621               else if(irecHisto==2)  meanZPC = hdata->GetMean();
622               else if(irecHisto==3)  meanZPA = hdata->GetMean();
623               else if(irecHisto==4)  pmQZNC = hdata->GetMean();
624               else if(irecHisto==5)  pmQZNA = hdata->GetMean();
625               else if(irecHisto==6)  pmQZPC = hdata->GetMean();
626               else if(irecHisto==7)  pmQZPA = hdata->GetMean();
627               else if(irecHisto==8)  pmCZNC = hdata->GetMean();
628               else if(irecHisto==9)  pmCZNA = hdata->GetMean();
629               else if(irecHisto==10) pmCZPC = hdata->GetMean();
630               else if(irecHisto==11) pmCZPA = hdata->GetMean();
631             }
632             //
633             // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
634             // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
635             if(irecHisto==3){
636               if(TMath::Abs(meanZNC)>1.e-10 && TMath::Abs(meanZNA)>1.e-10){
637                 if((2*TMath::Abs(meanZNC-meanZNA)/(meanZNA+meanZNC))<percentageDiff) 
638                   res=1.;
639                 else 
640                   res=.5;
641                 test[specie] += res;
642                 count++;
643               }
644               if(TMath::Abs(meanZPC)>1.e-10 && TMath::Abs(meanZPA)>1.e-10){
645                 if((TMath::Abs(meanZPC-meanZPA)/(meanZPA+meanZPC))<percentageDiff) 
646                   res=1.;
647                 else 
648                   res=.5;
649                 test[specie] += res;
650                 count++;
651               }
652             }
653             // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
654             if(irecHisto==11){
655               if(TMath::Abs(meanZNC)>1.e-10){
656                 if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff) 
657                   res=1.;
658                 else 
659                   res=.5;
660                 test[specie] += res;
661                 count++;
662               }
663               if(TMath::Abs(meanZNA)>1.e-10){
664                 if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff) 
665                   res=1.;
666                 else 
667                   res=.5;
668                 test[specie] += res;
669                 count++;
670               }
671               if(TMath::Abs(meanZPC)>1.e-10){
672                 if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff) 
673                   res=1.;
674                 else 
675                   res=.5;
676                 test[specie] += res;
677                 count++;
678               }
679               if(TMath::Abs(meanZPA)>1.e-10){
680                 if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff) 
681                   res=1.;
682                 else 
683                   res=.5;
684                 test[specie] += res;
685                 count++;
686               }
687             }
688             irecHisto++;         
689           }   
690           // -------------------------------------------------------------------
691           else if(index == AliQAv1::kESD){
692             //
693             // Check ESD HIGH GAIN CHAIN histos
694             if(hdata->GetEntries()>0){
695               if(esdInd==2)      sumADCZNC = hdata->GetMean();
696               else if(esdInd==3) sumADCZNA = hdata->GetMean();
697               else if(esdInd==4) sumADCZPC = hdata->GetMean();
698               else if(esdInd==5) sumADCZPA = hdata->GetMean();
699               else if(esdInd==8) pmQZNC = hdata->GetMean();
700               else if(esdInd==9) pmQZNA = hdata->GetMean();
701               else if(esdInd==10) pmQZPC = hdata->GetMean();
702               else if(esdInd==11) pmQZPA = hdata->GetMean();
703               else if(esdInd==12) pmCZNC = hdata->GetMean();
704               else if(esdInd==13) pmCZNA = hdata->GetMean();
705               else if(esdInd==14) pmCZPC = hdata->GetMean();
706               else if(esdInd==15) pmCZPA = hdata->GetMean();
707             }
708             //
709             // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
710             // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
711             if(esdInd==5){
712               if(TMath::Abs(sumADCZNC)>1.e-10 && TMath::Abs(sumADCZNA)>1.e-10){
713                 if((2*TMath::Abs(sumADCZNC-sumADCZNA)/(sumADCZNA+sumADCZNC))<percentageDiff) 
714                   res=1.;
715                 else 
716                   res=.5;
717                 test[specie] += res;
718                 count++;
719               }
720               if(TMath::Abs(sumADCZPC)>1.e-10 && TMath::Abs(sumADCZPA)>1.e-10){
721                 if((TMath::Abs(sumADCZPC-sumADCZPA)/(sumADCZPA+sumADCZPC))<percentageDiff) 
722                   res=1.;
723                 else 
724                   res=.5;
725                 test[specie] += res;
726                 count++;
727               }
728             }
729             // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
730             if(esdInd==15){
731               if(TMath::Abs(sumADCZNC)>1.e-10){
732                 if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff) 
733                   res=1.;
734                 else 
735                   res=.5;
736                 test[specie] += res;
737                 count++;
738               }
739               if(TMath::Abs(sumADCZNA)>1.e-10){
740                 if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff) 
741                   res=1.;
742                 else 
743                   res=.5;
744                 test[specie] += res;
745                 count++;
746               }
747               if(TMath::Abs(sumADCZPC)>1.e-10){
748                 if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff) 
749                   res=1.;
750                 else 
751                   res=.5;
752                 test[specie] += res;
753                 count++;
754               }
755               if(TMath::Abs(sumADCZPA)>1.e-10){
756                 if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff) 
757                   res=1.;
758                 else 
759                   res=.5;
760                 test[specie] += res;
761                 count++;
762               }
763             }
764             esdInd++;
765           }  
766           else {
767             AliWarning(Form("\n\t No ZDC QA for %s task\n",taskName)); 
768             return ;
769           } 
770         }//if(hdata) 
771         else AliError("\t  No histos found for ZDC!!!\n");
772       }
773     } // HighMult (Pb-Pb) 
774     // ====================================================================
775     //  Checks for Calibration events
776     // ====================================================================
777     else if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCalib) {
778       AliWarning(Form("\n\t No check implemented in ZDC QA for %s task\n",taskName)); 
779       return ;
780     } // Calibration
781     // ====================================================================
782     //  Checks for cosmic events
783     // ====================================================================
784     else if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCosmic) {
785       AliWarning(Form("\n\t No check implemented in ZDC QA for %s task\n",taskName)); 
786       return ; 
787     } // Cosmic
788     if(TMath::Abs(count)>1.e-10) test[specie] = test[specie]/count;
789     AliDebug(AliQAv1::GetQADebugLevel(), Form("\n\t ZDC QA check result = %1.2f\n",test[specie]));
790   } // Loop on species
791 }