]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCQAChecker.cxx
accomodate 'x' for missing DCS point in DDL status string (MakeDeadMap)
[u/mrichter/AliRoot.git] / TPC / AliTPCQAChecker.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2007, 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 /* $Id: $ */
17
18 /*
19   Checks implemented a la AliMUONQAChecker.
20   Checks the quality assurance by realzed checks on histogram content.
21   P. Christiansen, Lund, September 2009.
22
23   Based on AliPHOSQAChecker.
24   Checks the quality assurance by comparing with reference data.
25   P. Christiansen, Lund, January 2008.
26 */
27
28 // --- ROOT header files ---
29 #include <TH1.h>
30
31 // --- AliRoot header files ---
32 #include "AliTPCQAChecker.h"
33 #include "AliTPCQADataMakerRec.h"
34
35 ClassImp(AliTPCQAChecker)
36
37 //__________________________________________________________________
38 Double_t *
39 AliTPCQAChecker::Check(AliQAv1::ALITASK_t index, TObjArray ** list, 
40                        const AliDetectorRecoParam * /*recoParam*/)
41 {
42   /* It is important to understand the destinction between indexed tasks (AliQAv1::TASKINDEX_t) which are used in the DataMaker classes and indexed tasks (AliQAv1::ALITASK_t) whihc are used in the checker class.
43
44      From the AliQAChecker::Run() methods we have:
45      AliQAv1::kRAW
46      - AliQAv1::kRAWS 
47      
48      AliQAv1::kSIM 
49      - AliQAv1::kHITS
50      - AliQAv1::kSDIGITS
51      - AliQAv1::kDIGITS
52      
53      AliQAv1::kREC
54      - AliQAv1::kDIGITSR 
55      - AliQAv1::kRECPOINTS
56      - AliQAv1::kTRACKSEGMENTS 
57      - AliQAv1::kRECPARTICLES
58      
59      AliQAv1::kESD ; 
60      -AliQAv1::kESDS
61
62      This means that for each group of tasks the Check will be called
63      one or more times.  This also mean that we cannot know what
64      histograms will be or not be there in a single call... And we
65      also do not know the position in the list of the histogram.
66   */
67   
68   /// Check objects in list
69   if(fDebug>0)
70     AliInfo("In AliTPCQAChecker::Check");
71   
72   if (index!=AliQAv1::kRAW&&index!=AliQAv1::kSIM&&index!=AliQAv1::kREC&&index!=AliQAv1::kESD) {
73     
74     AliWarning(Form("Checker for task %d not implement for the moment",index));
75     return NULL;
76   }
77   
78   Double_t * rv = new Double_t[AliRecoParam::kNSpecies] ; 
79   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
80     rv[specie] = 1.0; // All is fine 
81   
82   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
83     
84     if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) 
85       continue ; 
86     
87     if (index == AliQAv1::kRAW)
88       rv[specie] = CheckRAW(specie, list[specie]);
89     if (index == AliQAv1::kSIM)
90       rv[specie] = CheckSIM(specie, list[specie]);
91     if (index == AliQAv1::kREC)
92       rv[specie] = CheckREC(specie, list[specie]);
93     if (index == AliQAv1::kESD)
94       rv[specie] = CheckESD(specie, list[specie]);
95
96     if(fDebug>3)
97       AliInfo(Form("Specie: %s. Task: %s. Value: %f",  
98                    AliRecoParam::GetEventSpecieName(specie),
99                    AliQAv1::GetAliTaskName(index),
100                    rv[specie]));
101   }
102   
103   return rv;
104 }
105
106 //______________________________________________________________________________
107 Double_t AliTPCQAChecker::CheckRAW(Int_t specie, TObjArray* list)
108 {
109   /// Check ESD
110   if(fDebug>0)
111     AliInfo("In AliTPCQAChecker::CheckRAW");
112   
113   if(fDebug>2)
114     list->Print();
115
116   Char_t specieName[256];
117   sprintf(specieName, AliRecoParam::GetEventSpecieName(specie));
118
119   TH1* hRawsOccupancyVsSector = static_cast<TH1*>
120     (list->FindObject(Form("%s_hRawsOccupancyVsSector",specieName)));
121   TH1* hRawsQmaxVsSector = static_cast<TH1*>
122     (list->FindObject(Form("%s_hRawsQmaxVsSector",specieName)));
123   TH1* hRawsOccupancyVsEvent = static_cast<TH1*>
124     (list->FindObject(Form("%s_hRawsOccupancyVsEvent",specieName)));
125   TH1* hRawsNclustersVsEvent = static_cast<TH1*>
126     (list->FindObject(Form("%s_hRawsNclustersVsEvent",specieName)));
127   
128   if (!hRawsOccupancyVsSector || !hRawsQmaxVsSector ||
129       !hRawsOccupancyVsEvent  || !hRawsNclustersVsEvent) 
130     return -0.5; // fatal
131   
132   if(hRawsOccupancyVsSector->GetEntries()==0) {
133     return 0.25; // error - No TPC data!
134   }
135   
136   Int_t nBinsX = hRawsOccupancyVsSector->GetNbinsX();
137   for(Int_t i = 1; i <= nBinsX; i++) {
138     
139     if(hRawsOccupancyVsSector->GetBinContent(i)==0)
140       return 0.75; // warning - no TPC data for at least one sector
141   }
142   
143   return 1.0; // ok
144 }
145
146 //______________________________________________________________________________
147 Double_t AliTPCQAChecker::CheckSIM(Int_t specie, TObjArray* list)
148 {
149   // This method checks the QA histograms associated with simulation
150   //
151   // For TPC this is:
152   // Digits : 
153   // The digit histogram gives the ADC distribution for all sigbnals
154   // above threshold. The check is just that there are digits.
155   // Hits : The hit histograms are checked to see that they are not
156   // empty. They contain a lot of detailed information on the
157   // energyloss model (they were used to debug the AliRoot TPC use of
158   // FLUKA).
159   //
160   // The check methods are simple:
161   // We do not know if it is bad that histograms are missing because
162   // this will always be the case for summable digits. So this check
163   // is not possible here.
164   // If digit histogram is empty (set error)
165   // If one of the hit histograms are empty (set error)
166   if(fDebug>0)
167     AliInfo("In AliTPCQAChecker::CheckSIM");
168   
169   if(fDebug>2)
170     list->Print();
171
172   Char_t specieName[256];
173   sprintf(specieName, AliRecoParam::GetEventSpecieName(specie));
174
175   TH1* hDigits = static_cast<TH1*>
176     (list->FindObject(Form("%s_hDigitsADC",specieName)));
177   TH1* hHitsNhits = static_cast<TH1*> 
178     (list->FindObject(Form("%s_hHitsNhits",specieName)));
179   TH1* hHitsElectrons         = static_cast<TH1*> 
180     (list->FindObject(Form("%s_hHitsElectrons",specieName)));
181   TH1* hHitsRadius        = static_cast<TH1*> 
182     (list->FindObject(Form("%s_hHitsRadius",specieName)));
183   TH1* histHitsPrimPerCm          = static_cast<TH1*> 
184     (list->FindObject(Form("%s_histHitsPrimPerCm",specieName)));
185   TH1* histHitsElectronsPerCm          = static_cast<TH1*> 
186     (list->FindObject(Form("%s_histHitsElectronsPerCm",specieName)));
187   
188 //   if (!(hDigits) ||                                             // digit hists
189 //       !(hHitsNhits && hHitsElectrons && hHitsRadius && histHitsPrimPerCm && histHitsElectronsPerCm)) // hit hists
190 //     return -0.5; // fatal
191   
192   if (hDigits) {
193     if(hDigits->GetEntries()==0) 
194       return 0.25; // error
195   }
196
197   if (hHitsNhits && hHitsElectrons && hHitsRadius && 
198       histHitsPrimPerCm && histHitsElectronsPerCm) {
199     if (hHitsNhits->GetEntries()==0 || hHitsElectrons->GetEntries()==0 ||
200         hHitsRadius->GetEntries()==0 || histHitsPrimPerCm->GetEntries()==0 ||
201         histHitsElectronsPerCm->GetEntries()==0) 
202       return 0.25; // error
203   }
204
205   return 1; // ok
206 }
207
208 //______________________________________________________________________________
209 Double_t AliTPCQAChecker::CheckREC(Int_t specie, TObjArray* list)
210 {
211   // This method checks the QA histograms associated with reconstruction
212   //
213   // For TPC this is:
214   // DigitsR : 
215   // The digit histogram gives the ADC distribution for all sigbnals
216   // above threshold. The check is just that there are digits.
217   // RecPoints : 
218   // The cluster histograms are meant to give an idea about the gain
219   // from the cluster charge and to indicate iof there are rows with
220   // noise clusters, i.e., they are very visual.
221   //
222   // The check methods are simple:
223   // If there are no histogram at all (set fatal)
224   // If digit histogram is there, but there are no digits (set error)
225   // If cluster histogram is there but there are less than 1000 
226   //    clusters (set warning)
227   // If there are more than 1000 clusters but no clusters for either short, 
228   // medium, or long pads (set error)
229   if(fDebug>0)
230     AliInfo("In AliTPCQAChecker::CheckREC");
231   
232   if(fDebug>2)
233     list->Print();
234
235   Char_t specieName[256];
236   sprintf(specieName, AliRecoParam::GetEventSpecieName(specie));
237
238   TH1* hDigits = static_cast<TH1*>
239     (list->FindObject(Form("%s_hDigitsADC",specieName)));
240   TH1* hNclustersVsRow = static_cast<TH1*> 
241     (list->FindObject(Form("%s_hRecPointsRow",specieName)));
242   TH1* hQshort         = static_cast<TH1*> 
243     (list->FindObject(Form("%s_hRecPointsQShort",specieName)));
244   TH1* hQmedium        = static_cast<TH1*> 
245     (list->FindObject(Form("%s_hRecPointsQMedium",specieName)));
246   TH1* hQlong          = static_cast<TH1*> 
247     (list->FindObject(Form("%s_hRecPointsQLong",specieName)));
248   // The Qmax histograms are for now ignored
249
250   if (!hDigits &&                                             // digits missing
251       (!hNclustersVsRow || !hQshort || !hQmedium || !hQlong)) // 1 recpoint hist missing
252     return -0.5; // fatal
253
254   if (hDigits && hDigits->GetEntries()==0) 
255     return 0.25; // error
256   
257   if (hNclustersVsRow && hNclustersVsRow->GetEntries() < 1000) {
258     return 0.75; // warning
259   } else { 
260     if (!hQshort || !hQlong || !hQlong)
261       return -0.5;// fatal - they should be there if the cluster vs row hist is there
262     if (hQshort->GetEntries()==0 || hQmedium->GetEntries()==0 ||
263         hQlong->GetEntries()==0) 
264       return 0.25; // error
265   }
266   return 1; // ok
267 }
268
269 //______________________________________________________________________________
270 Double_t AliTPCQAChecker::CheckESD(Int_t specie, TObjArray* list)
271 {
272   // This method checks the QA histograms associated with ESDs
273   // (Note that there is aslo a globalQA which is running on all
274   //  the ESD information so for now this is just a few basic
275   //  histograms)
276   //
277   // The check methods are simple:
278   // If there are no histogram at all (set fatal)
279   // 
280   if(fDebug>0)
281     AliInfo("In AliTPCQAChecker::CheckESD");
282
283   if(fDebug>2)
284     list->Print();
285
286   Char_t specieName[256];
287   sprintf(specieName, AliRecoParam::GetEventSpecieName(specie));
288
289   TH1* hESDclusters = static_cast<TH1*>
290     (list->FindObject(Form("%s_hESDclusters",specieName)));
291   TH1* hESDratio = static_cast<TH1*>
292     (list->FindObject(Form("%s_hESDratio",specieName)));
293   TH1* hESDpt = static_cast<TH1*>
294     (list->FindObject(Form("%s_hESDpt",specieName)));
295   
296   if (!hESDclusters || !hESDratio || !hESDpt) 
297     return -0.5; // fatal
298
299   return 1.0; // ok
300 }
301
302 //______________________________________________________________________________
303 void AliTPCQAChecker::Init(const AliQAv1::DETECTORINDEX_t det) 
304 {
305   /// intialises QA and QA checker settings
306   if(fDebug>0)
307     AliInfo("In AliTPCQAChecker::Init");
308   AliQAv1::Instance(det) ; 
309   Float_t hiValue[AliQAv1::kNBIT] ; 
310   Float_t lowValue[AliQAv1::kNBIT] ;
311   hiValue[AliQAv1::kINFO]       = 1.00; 
312   lowValue[AliQAv1::kINFO]      = 0.99; 
313   hiValue[AliQAv1::kWARNING]    = 0.99; 
314   lowValue[AliQAv1::kWARNING]   = 0.50; 
315   hiValue[AliQAv1::kERROR]      = 0.50; 
316   lowValue[AliQAv1::kERROR]     = 0.00; 
317   hiValue[AliQAv1::kFATAL]      = 0.00; 
318   lowValue[AliQAv1::kFATAL]     =-1.00; 
319   //  SetHiLo(&hiValue[0], &lowValue[0]) ; 
320   SetHiLo(hiValue, lowValue) ; 
321 }
322
323 //______________________________________________________________________________
324 void 
325 AliTPCQAChecker::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const
326 {
327   /// sets the QA according the return value of the Check
328
329   if(fDebug>0)
330     AliInfo("In AliTPCQAChecker::SetQA");
331
332   AliQAv1 * qa = AliQAv1::Instance(index);
333   
334   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
335
336     if (value==NULL) { // No checker is implemented, set all QA to Fatal
337       
338       if(fDebug>1)
339         AliInfo(Form("Fatal QA. Task: %s. Specie: %s", 
340                      AliQAv1::GetAliTaskName(index), 
341                      AliRecoParam::GetEventSpecieName(specie)));
342       qa->Set(AliQAv1::kFATAL, specie) ; 
343     } else {
344       
345       if ( value[specie] >= fLowTestValue[AliQAv1::kFATAL] && 
346            value[specie] < fUpTestValue[AliQAv1::kFATAL] ) {
347         
348         if(fDebug>1)
349           AliInfo(Form("QA-Fatal. Task: %s. Specie: %s", 
350                        AliQAv1::GetAliTaskName(index), 
351                        AliRecoParam::GetEventSpecieName(specie)));
352         qa->Set(AliQAv1::kFATAL, specie) ; 
353       } else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && 
354                   value[specie] <= fUpTestValue[AliQAv1::kERROR]  ) {
355         
356         if(fDebug>1)
357           AliInfo(Form("QA-Error. Task: %s. Specie: %s", 
358                        AliQAv1::GetAliTaskName(index), 
359                        AliRecoParam::GetEventSpecieName(specie)));
360         qa->Set(AliQAv1::kERROR, specie) ; 
361       } else if (value[specie] > fLowTestValue[AliQAv1::kWARNING] && 
362                  value[specie] <= fUpTestValue[AliQAv1::kWARNING]) {
363         
364         if(fDebug>1)
365           AliInfo(Form("QA-Warning. Task: %s. Specie: %s", 
366                        AliQAv1::GetAliTaskName(index), 
367                        AliRecoParam::GetEventSpecieName(specie)));
368         qa->Set(AliQAv1::kWARNING, specie) ;
369       } else if (value[specie] > fLowTestValue[AliQAv1::kINFO] && 
370                  value[specie] <= fUpTestValue[AliQAv1::kINFO] ) { 
371         
372         if(fDebug>1)
373           AliInfo(Form("QA-Info. Task: %s. Specie: %s", 
374                        AliQAv1::GetAliTaskName(index), 
375                        AliRecoParam::GetEventSpecieName(specie)));
376         qa->Set(AliQAv1::kINFO, specie) ;       
377       }
378     }
379   }
380 }