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