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