]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/AliZDCQAChecker.cxx
Modified file access mode
[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 const Double_t AliZDCQAChecker::Check(AliQA::ALITASK_t index, TObjArray * list) 
32 {
33   // Checks the QA histograms on the input list: 
34   //
35   Double_t test=0.;
36   Int_t count=0, ntests=0; 
37   const char* taskName = AliQA::GetAliTaskName(index);
38   
39   // -------------------------------------------------------------------
40   if(index == AliQA::kSIM){
41   
42     if(list->GetEntries()==0){  
43       AliWarning("\tAliZDCQAChecker->The list to be checked is empty!");
44       test = 1.; // nothing to check
45       return test;
46     }
47     printf("\n\tAliZDCQAChecker-> checking QA histograms for task %s\n\n",taskName);
48     
49     TIter next(list); 
50     TH1 * hdata;          
51     Double_t meanX=0., meanY=0.;
52     Double_t meanZNA=0., rmsZNA=0., meanZNC=0.;
53     Double_t meanZPA=0., rmsZPA=0., meanZPC=0.;
54     Double_t pmCZNA=0., pmCZNC=0., pmCZPA=0., pmCZPC=0.;
55     Double_t pmQZNA=0., pmQZNC=0., pmQZPA=0., pmQZPC=0.;
56     Float_t  res=0.;
57     Int_t    digInd=0, testgood=0;
58     //
59     count = ntests = 0; 
60     //
61     while((hdata = dynamic_cast<TH1 *>(next()))){
62       if(hdata){ 
63         //printf("\tAliZDCQAChecker-> checking histo %s",hdata->GetName());
64         // Check HITS histos
65         if(!(strncmp(hdata->GetName(),"hZNCh",5))){ 
66           // hits histos
67           meanX = hdata->GetMean(1);
68           meanY = hdata->GetMean(2);
69           // check if the spot is centered
70           if((TMath::Abs(meanX)<0.2) && (TMath::Abs(meanY)<0.2)) res=1.;
71           else res=0.5;
72           test += res;
73           ntests++;
74           // 
75           //printf("\t %d performed tests, results %1.2f\n",ntests,test/ntests);
76         }
77         // Check DIGITS histos
78         else{
79           // [1] check response of ZNC vs. ZNA
80           if(digInd==0 || digInd==1){
81              if(digInd==0){
82                if(hdata->GetEntries() != 0.){
83                  testgood=1;
84                  meanZNA = hdata->GetMean();
85                  rmsZNA = hdata->GetRMS();
86                }
87              }
88              else{
89                if(hdata->GetEntries() != 0.){
90                  testgood=1;
91                  meanZNC = hdata->GetMean();
92                }
93                else testgood=0;
94                // check if the response m.v. of ZNA and ZNC are equal (@ 1sigma level)
95                if(testgood==1){
96                  if(TMath::Abs(meanZNA-meanZNC)<rmsZNA) res=1.;
97                  else res=.5;
98                  testgood=0;
99                  test += res;
100                  ntests++;
101                  // 
102                  //printf("\t %d performed tests, results %1.2f\n",ntests,test/ntests);
103                }
104                else res=0.;
105              }
106           }
107           // [2] check response of ZPC vs. ZPA
108           else if(digInd==2 || digInd==3){
109              if(digInd==2){
110                if(hdata->GetEntries() != 0.){
111                  testgood=1;
112                  meanZPA = hdata->GetMean();
113                  rmsZPA = hdata->GetRMS();
114                }
115              }
116              else{
117                if(hdata->GetEntries() != 0.){
118                  testgood=1;
119                  meanZPC = hdata->GetMean();
120                }
121                // check if the response m.v. of ZPA and ZPC are equal (@ 3sigma level)
122                if(testgood==1){
123                  if(TMath::Abs(meanZPA-meanZPC)<(3.*rmsZPA)) res=1.;
124                  else res=.5;
125                  test += res;
126                  ntests++;
127                  testgood=0;
128                  // 
129                  //printf("\t %d performed tests, results %1.2f\n",ntests,test/ntests);
130                }
131                else res=0.;
132              }
133           }
134           // [2] check PMC responses vs. summed PMQ responses
135           else if(digInd>3 && digInd<12){
136             if(digInd==4) pmQZNC = hdata->GetMean();
137             else if(digInd==5) pmQZNA = hdata->GetMean();
138             else if(digInd==6) pmQZPC = hdata->GetMean();
139             else if(digInd==7) pmQZPA = hdata->GetMean();
140             else if(digInd==8){
141               pmCZNC = hdata->GetMean();
142               if(TMath::Abs(pmQZNC-pmCZNC)<(0.1*(pmQZNC+pmCZNC)/2)) res=1.;
143               else res=0.5;
144               test += res;
145               ntests++;
146               // 
147               //printf("\t %d performed tests, results %1.2f\n",ntests,test/ntests);
148             }
149             else if(digInd==9){
150               pmCZNA = hdata->GetMean();
151               if(TMath::Abs(pmQZNA-pmCZNA)<(0.1*(pmQZNA+pmCZNA)/2)) res=1.;
152               else res=0.5;
153               test += res;
154               ntests++;
155               // 
156               //printf("\t %d performed tests, results %1.2f\n",ntests,test/ntests);
157             }
158             else if(digInd==10){
159               pmCZPC = hdata->GetMean();
160               if(TMath::Abs(pmQZPC-pmCZPC)<(0.1*(pmQZPC+pmCZPC)/2)) res=1.;
161               else res=0.5;
162               test += res;
163               ntests++;
164               // 
165               //printf("\t %d performed tests, results %1.2f\n",ntests,test/ntests);
166             }
167             else if(digInd==11){
168               pmCZPA = hdata->GetMean();
169               if(TMath::Abs(pmQZPA-pmCZPA)<(0.1*(pmQZPA+pmCZPA)/2)) res=1.;
170               else res=0.5;
171               test += res;
172               ntests++;
173               // 
174               //printf("\t %d performed tests, results %1.2f\n",ntests,test/ntests);
175             }
176           }
177           //
178           digInd++;
179         }
180         //
181         count++;
182       }
183       else{
184         AliError("AliZDCQAChecker-> No histos!!!\n");
185       }
186     }
187     if(ntests!=0) test = test/ntests;
188     printf("\n\tAliZDCQAChecker-> QA check result = %1.2f\n",test);
189   }
190   
191   // -------------------------------------------------------------------
192   else if(index == AliQA::kRAW){
193   
194     if(list->GetEntries()==0){  
195       AliWarning("\tAliZDCQAChecker->The list to be checked is empty!");
196       test = 1.; // nothing to check
197       return test;
198     }
199     printf("\n\tAliZDCQAChecker-> checking QA histograms for task %s\n\n",taskName);
200     
201     TIter next(list); 
202     TH1 * hdata;
203     Double_t meanZNA=0., rmsZNA=0., meanZNC=0.;
204     Double_t meanZPA=0., rmsZPA=0., meanZPC=0.;
205     Double_t pmCZNA=0., pmCZNC=0., pmCZPA=0., pmCZPC=0.;
206     Double_t pmQZNA=0., pmQZNC=0., pmQZPA=0., pmQZPC=0.;
207     Float_t  res=0.;
208     Int_t    rawInd=0, testgood=0;
209     count = ntests = 0; 
210     //
211     while((hdata = dynamic_cast<TH1 *>(next()))){
212       if(hdata){
213           // [1] check response of ZNC vs. ZNA
214           if(rawInd==0 || rawInd==1){
215              if(rawInd==0){
216                if(hdata->GetEntries() != 0.){
217                  testgood=1;
218                  meanZNA = hdata->GetMean();
219                  rmsZNA = hdata->GetRMS();
220                }
221              }
222              else{
223                if(hdata->GetEntries() != 0.){
224                  testgood=1;
225                  meanZNC = hdata->GetMean();
226                }
227                else testgood=0;
228                // check if the response m.v. of ZNA and ZNC are equal (@ 1sigma level)
229                if(testgood==1){
230                  if(TMath::Abs(meanZNA-meanZNC)<rmsZNA) res=1.;
231                  else res=.5;
232                  test += res;
233                  ntests++;
234                  testgood=0;
235                }
236                else res=0.;
237              }
238           }
239           // [2] check response of ZPC vs. ZPA
240           else if(rawInd==2 || rawInd==3){
241              if(rawInd==2){
242                if(hdata->GetEntries() != 0.){
243                  testgood=1;
244                  meanZPA = hdata->GetMean();
245                  rmsZPA = hdata->GetRMS();
246                }
247              }
248              else{
249                if(hdata->GetEntries() != 0.){
250                  testgood=1;
251                  meanZPC = hdata->GetMean();
252                }
253                // check if the response m.v. of ZPA and ZPC are equal (@ 3sigma level)
254                if(testgood==1){
255                  if(TMath::Abs(meanZPA-meanZPC)<(3.*rmsZPA)) res=1.;
256                  else res=.5;
257                  test += res;
258                  ntests++;
259                  testgood=0;
260                }
261                else res=0.;
262              }
263           }
264           // [2] check PMC responses vs. summed PMQ responses
265           else if(rawInd>3 && rawInd<12){
266             if(rawInd==4) pmQZNC = hdata->GetMean();
267             else if(rawInd==5) pmQZNA = hdata->GetMean();
268             else if(rawInd==6) pmQZPC = hdata->GetMean();
269             else if(rawInd==7) pmQZPA = hdata->GetMean();
270             else if(rawInd==8){
271               pmCZNC = hdata->GetMean();
272               if(TMath::Abs(pmQZNC-pmCZNC)<(0.1*(pmQZNC+pmCZNC)/2)) res=1.;
273               else res=0.5;
274               test += res;
275               ntests++;
276             }
277             else if(rawInd==9){
278               pmCZNA = hdata->GetMean();
279               if(TMath::Abs(pmQZNA-pmCZNA)<(0.1*(pmQZNA+pmCZNA)/2)) res=1.;
280               else res=0.5;
281               test += res;
282               ntests++;
283             }
284             else if(rawInd==10){
285               pmCZPC = hdata->GetMean();
286               if(TMath::Abs(pmQZPC-pmCZPC)<(0.1*(pmQZPC+pmCZPC)/2)) res=1.;
287               else res=0.5;
288               test += res;
289               ntests++;
290             }
291             else if(rawInd==11){
292               pmCZPA = hdata->GetMean();
293               if(TMath::Abs(pmQZPA-pmCZPA)<(0.1*(pmQZPA+pmCZPA)/2)) res=1.;
294               else res=0.5;
295               test += res;
296               ntests++;
297             }
298           }
299           //
300           rawInd++;
301           count++;
302       }
303       // 
304       //printf("\t %d performed tests, results %1.2f\n",ntests,test/ntests);
305       else{
306         AliError("\t AliZDCQAChecker->No histos!!!\n");
307       }
308     }
309     if(ntests!=0) test = test/ntests;
310     printf("\n\tAliZDCQAChecker-> QA check result = %1.2f\n",test);
311   }
312
313   // -------------------------------------------------------------------
314   else if(index == AliQA::kESD){
315   
316     if(list->GetEntries()==0){  
317       AliWarning("\tAliZDCQAChecker->The list to be checked is empty!");
318       test = 1.; // nothing to check
319       return test;
320     }
321     printf("\n\tAliZDCQAChecker-> checking QA histograms for task %s\n\n",taskName);
322     
323     TIter next(list); 
324     TH1 * hdata;
325     Double_t meanX=0., meanY=0.;
326     Double_t meanZNA=0., rmsZNA=0., meanZNC=0.;
327     Double_t meanZPA=0., rmsZPA=0., meanZPC=0.;
328     Double_t eneCZNA=0., eneCZNC=0., eneCZPA=0., eneCZPC=0.;
329     Double_t eneQZNA=0., eneQZNC=0., eneQZPA=0., eneQZPC=0.;
330     Float_t  res=0.;
331     Int_t    esdInd=0, testgood=0;
332     //
333     count = ntests = 0; 
334     //
335     while((hdata = dynamic_cast<TH1 *>(next()))){
336       if(hdata){ 
337         //printf("\tAliZDCQAChecker-> checking histo %s",hdata->GetName());
338         if(esdInd<2){
339           // hits histos
340           meanX = hdata->GetMean(1);
341           meanY = hdata->GetMean(2);
342           // check if the spot is centered
343           if((TMath::Abs(meanX)<0.2) && (TMath::Abs(meanY)<0.2)) res=1.;
344           else res=0.5;
345           test += res;
346           ntests++;
347         }
348         //
349         else{
350           // [1] check response of ZNC vs. ZNA
351           if(esdInd==0 || esdInd==1){
352              if(esdInd==0){
353                if(hdata->GetEntries() != 0.){
354                  testgood=1;
355                  meanZNA = hdata->GetMean();
356                  rmsZNA = hdata->GetRMS();
357                }
358              }
359              else{
360                if(hdata->GetEntries() != 0.){
361                  testgood=1;
362                  meanZNC = hdata->GetMean();
363                }
364                else testgood=0;
365                // check if the response m.v. of ZNA and ZNC are equal (@ 1sigma level)
366                if(testgood==1){
367                  if(TMath::Abs(meanZNA-meanZNC)<rmsZNA) res=1.;
368                  else res=.5;
369                  testgood=0;
370                  test += res;
371                  ntests++;
372                }
373                else res=0.;
374              }
375           }
376           // [2] check response of ZPC vs. ZPA
377           else if(esdInd==2 || esdInd==3){
378              if(esdInd==2){
379                if(hdata->GetEntries() != 0.){
380                  testgood=1;
381                  meanZPA = hdata->GetMean();
382                  rmsZPA = hdata->GetRMS();
383                }
384              }
385              else{
386                if(hdata->GetEntries() != 0.){
387                  testgood=1;
388                  meanZPC = hdata->GetMean();
389                }
390                // check if the response m.v. of ZPA and ZPC are equal (@ 3sigma level)
391                if(testgood==1){
392                  if(TMath::Abs(meanZPA-meanZPC)<(3.*rmsZPA)) res=1.;
393                  else res=.5;
394                  test += res;
395                  ntests++;
396                  testgood=0;
397                }
398                else res=0.;
399              }
400           }
401           // [2] check eneC responses vs. summed eneQ responses
402           else if(esdInd>3 && esdInd<12){
403             if(esdInd==4) eneQZNC = hdata->GetMean();
404             else if(esdInd==5) eneQZNA = hdata->GetMean();
405             else if(esdInd==6) eneQZPC = hdata->GetMean();
406             else if(esdInd==7) eneQZPA = hdata->GetMean();
407             else if(esdInd==8){
408               eneCZNC = hdata->GetMean();
409               if(TMath::Abs(eneQZNC-eneCZNC)<(0.1*(eneQZNC+eneCZNC)/2)) res=1.;
410               else res=0.5;
411               test += res;
412               ntests++;
413             }
414             else if(esdInd==9){
415               eneCZNA = hdata->GetMean();
416               if(TMath::Abs(eneQZNA-eneCZNA)<(0.1*(eneQZNA+eneCZNA)/2)) res=1.;
417               else res=0.5;
418               test += res;
419               ntests++;
420             }
421             else if(esdInd==10){
422               eneCZPC = hdata->GetMean();
423               if(TMath::Abs(eneQZPC-eneCZPC)<(0.1*(eneQZPC+eneCZPC)/2)) res=1.;
424               else res=0.5;
425               test += res;
426               ntests++;
427             }
428             else if(esdInd==11){
429               eneCZPA = hdata->GetMean();
430               if(TMath::Abs(eneQZPA-eneCZPA)<(0.1*(eneQZPA+eneCZPA)/2)) res=1.;
431               else res=0.5;
432               test += res;
433               ntests++;
434             }
435           }
436           //
437           esdInd++;
438         }
439         // 
440         //printf("\t %d performed tests, results %1.2f\n",ntests,test/ntests);
441         //
442         count++;
443       }
444       else{
445         AliError("AliZDCQAChecker-> No histos!!!\n");
446       }
447     }
448     if(ntests!=0) test = test/ntests;
449     printf("\n\tAliZDCQAChecker-> QA check result = %1.2f\n\n",test);
450   }
451   else{
452     AliWarning(Form("\n\t No ZDC QA for %s task\n",taskName)); 
453     return 1.;
454   }
455   
456   AliInfo(Form("Test Result = %f", test)); 
457   return test; 
458 }