]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROQAChecker.cxx
Updates
[u/mrichter/AliRoot.git] / VZERO / AliVZEROQAChecker.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 /*
18   Checks the quality assurance. Under construction. 
19   By comparing with reference data
20
21 */
22
23 // --- ROOT system ---
24 #include <TClass.h>
25 #include <TH1F.h> 
26 #include <TH1I.h> 
27 #include <TIterator.h> 
28 #include <TKey.h> 
29 #include <TFile.h> 
30
31 // --- Standard library ---
32
33 // --- AliRoot header files ---
34 #include "AliLog.h"
35 #include "AliQAv1.h"
36 #include "AliQAChecker.h"
37 #include "AliVZEROQAChecker.h"
38 #include "AliVZEROQADataMakerRec.h"
39
40 ClassImp(AliVZEROQAChecker)
41
42 //__________________________________________________________________
43 AliVZEROQAChecker::AliVZEROQAChecker() : AliQACheckerBase("VZERO","VZERO Quality Assurance Data Checker"),
44   fLowEventCut(1000),
45   fORvsANDCut(0.2),
46   fBGvsBBCut(0.2)
47 {
48   // Default constructor
49   // Nothing else here
50 }
51
52 //__________________________________________________________________
53 void AliVZEROQAChecker::Check(Double_t * check, AliQAv1::ALITASK_t index, TObjArray ** list, const AliDetectorRecoParam * /*recoParam*/) 
54 {
55   // Main check function: Depending on the TASK, different checks will be applied
56   // Check for missing channels and check on the trigger type for raw data
57   // Check for missing disk or rings for esd (to be redone)
58
59   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
60     check[specie] = 1.0;
61     // no check on cosmic or calibration events
62     if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCosmic || AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCalib)
63       continue;
64     if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) 
65       continue;
66     if (index == AliQAv1::kRAW) {
67       check[specie] =  CheckRaws(list[specie]);
68     } else if (index == AliQAv1::kESD) {
69       // Check for one disk missing (FATAL) or one ring missing (ERROR) in ESDs (to be redone)
70       check[specie] =  CheckEsds(list[specie]);
71     } 
72   }
73 }
74
75 //_________________________________________________________________
76 Double_t AliVZEROQAChecker::CheckRaws(TObjArray * list) const
77 {
78
79   //  Check on the QA histograms on the raw-data input list:
80   //  Two things are checked: the presence of data in all channels and
81   //  the ratio between different trigger types
82
83   Double_t test = 1.0;
84   if (list->GetEntries() == 0){  
85     AliWarning("There are no histograms to be checked");
86   } else {
87     TH1F *hTriggers  = (TH1F*)list->At(AliVZEROQADataMakerRec::kTriggers);
88     if (!hTriggers) {
89       AliWarning("Trigger type histogram is not found");
90     }
91     else if (hTriggers->GetEntries() < fLowEventCut) {
92       AliInfo("Not enough events to perform QA checks");
93     }
94     else {
95       Double_t nANDs = hTriggers->GetBinContent(hTriggers->FindBin(0));
96       Double_t nORs = hTriggers->GetBinContent(hTriggers->FindBin(1));
97       Double_t nBGAs = hTriggers->GetBinContent(hTriggers->FindBin(2));
98       Double_t nBGCs = hTriggers->GetBinContent(hTriggers->FindBin(3));
99       if ((nORs - nANDs) > fORvsANDCut*nANDs) test = 0.001;
100       if ((nBGAs + nBGCs) > fBGvsBBCut*nANDs) test = 0.002;
101     }
102     TH1F *hBBflags = (TH1F*)list->At(AliVZEROQADataMakerRec::kBBFlagsPerChannel);
103     if (!hBBflags) {
104       AliWarning("BB-flags per channel histogram is not found");
105     }
106     else if (hBBflags->GetEntries() < fLowEventCut) {
107       AliInfo("Not enough events to perform QA checks");
108     }
109     else {
110       for(Int_t iBin = 1; iBin <= 64; ++iBin) {
111         if (hBBflags->GetBinContent(iBin) < 1.0) test = -1.0;
112       }
113     }
114   }
115   return test ; 
116 }  
117
118 //_________________________________________________________________
119 Double_t AliVZEROQAChecker::CheckEsds(TObjArray * list) const
120 {
121   
122 //  check the ESDs for missing disk or ring
123 //  printf(" Number of entries in ESD list = %d\n", list->GetEntries()); 
124 //  list->Print();
125
126   Double_t test     = 1.0;     // initialisation to OK
127   Int_t    histonb =   0; 
128   Double_t multV0A = 0.0;
129   Double_t multV0C = 0.0;
130   Double_t v0ABBRing[4], v0CBBRing[4];
131   Double_t v0ABGRing[4], v0CBGRing[4];
132   for (Int_t i=0; i<4; i++) { 
133        v0ABBRing[i]= v0CBBRing[i]= 0.0;
134        v0ABGRing[i]= v0CBGRing[i]= 0.0;
135   }  
136   TIter next(list) ; 
137   TH1 * hdata ;
138   
139   while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
140           if (hdata) {
141                   switch (histonb) {
142                   case AliVZEROQADataMakerRec::kCellMultiV0A:
143                           multV0A  = hdata->GetMean();
144                           break;
145                   case AliVZEROQADataMakerRec::kCellMultiV0C:
146                           multV0C  = hdata->GetMean();
147                           break;
148                   case AliVZEROQADataMakerRec::kBBFlag:
149                   for (Int_t i=0; i<8; i++) {         
150                                   if(i<4) v0CBBRing[i]  = hdata->Integral((i*8)+1, (i*8) +8);
151                                   else v0ABBRing[i-4]  = hdata->Integral((i*8)+1, (i*8) +8);
152                           }           
153                           break;
154                   case AliVZEROQADataMakerRec::kBGFlag:
155                   for (Int_t i=0; i<8; i++) {         
156                                   if(i<4) v0CBGRing[i]  = hdata->Integral((i*8)+1, (i*8) +8);
157                                   else v0ABGRing[i-4]  = hdata->Integral((i*8)+1, (i*8) +8);
158                           }           
159                           break;
160                   }
161           }
162           histonb++;
163   }
164   
165   if(multV0A == 0.0 || multV0C == 0.0) {
166      AliWarning(Form("One of the two disks is missing !") );
167      test = 0.0; // bit FATAL set
168   }
169   if( v0ABBRing[0]+v0ABGRing[0] == 0.0 || 
170       v0ABBRing[1]+v0ABGRing[1] == 0.0 || 
171       v0ABBRing[2]+v0ABGRing[2] == 0.0 || 
172       v0ABBRing[3]+v0ABGRing[3] == 0.0 || 
173       v0CBBRing[0]+v0CBGRing[0] == 0.0 || 
174       v0CBBRing[1]+v0CBGRing[1] == 0.0 || 
175       v0CBBRing[2]+v0CBGRing[2] == 0.0 || 
176       v0CBBRing[3]+v0CBGRing[3] == 0.0  ){    
177       AliWarning(Form("One ring is missing !") );
178       test = 0.1;   // bit ERROR set
179   }
180
181   return test ; 
182
183
184 //______________________________________________________________________________
185 void AliVZEROQAChecker::Init(const AliQAv1::DETECTORINDEX_t det) 
186 {
187   // intialises QA and QA checker settings
188   AliQAv1::Instance(det) ; 
189   Float_t * hiValue = new Float_t[AliQAv1::kNBIT] ; 
190   Float_t * lowValue = new Float_t[AliQAv1::kNBIT] ;
191   lowValue[AliQAv1::kINFO]      = 0.5   ; 
192   hiValue[AliQAv1::kINFO]       = 1.0 ; 
193   lowValue[AliQAv1::kWARNING]   = 0.2 ; 
194   hiValue[AliQAv1::kWARNING]    = 0.5 ; 
195   lowValue[AliQAv1::kERROR]     = 0.0   ; 
196   hiValue[AliQAv1::kERROR]      = 0.2 ; 
197   lowValue[AliQAv1::kFATAL]     = -1.0   ; 
198   hiValue[AliQAv1::kFATAL]      = 0.0 ; 
199   SetHiLo(hiValue, lowValue) ; 
200   delete [] hiValue;
201   delete [] lowValue;
202 }
203
204 //______________________________________________________________________________
205 void AliVZEROQAChecker::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const
206 {
207 // sets the QA word according to return value of the Check
208   AliQAv1 * qa = AliQAv1::Instance(index);
209   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
210     qa->UnSet(AliQAv1::kFATAL, specie);
211     qa->UnSet(AliQAv1::kWARNING, specie);
212     qa->UnSet(AliQAv1::kERROR, specie);
213     qa->UnSet(AliQAv1::kINFO, specie);
214     if ( ! value ) { // No checker is implemented, set all QA to Fatal
215       qa->Set(AliQAv1::kFATAL, specie) ; 
216     } else {
217       if ( value[specie] >= fLowTestValue[AliQAv1::kFATAL] && value[specie] < fUpTestValue[AliQAv1::kFATAL] ) 
218         qa->Set(AliQAv1::kFATAL, specie) ; 
219       else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && value[specie] <= fUpTestValue[AliQAv1::kERROR]  )
220         qa->Set(AliQAv1::kERROR, specie) ; 
221       else if ( value[specie] > fLowTestValue[AliQAv1::kWARNING] && value[specie] <= fUpTestValue[AliQAv1::kWARNING]  )
222         qa->Set(AliQAv1::kWARNING, specie) ;
223       else if ( value[specie] > fLowTestValue[AliQAv1::kINFO] && value[specie] <= fUpTestValue[AliQAv1::kINFO] ) 
224         qa->Set(AliQAv1::kINFO, specie) ;       
225     }
226   }
227 }
228