]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCQAChecker.cxx
coding conventions
[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 void
39 AliTPCQAChecker::Check(Double_t * rv, 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;
76   }
77   
78   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
79     rv[specie] = 1.0; // All is fine 
80   
81   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
82     
83     if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) 
84       continue ; 
85     
86     if (index == AliQAv1::kRAW)
87       rv[specie] = CheckRAW(specie, list[specie]);
88     if (index == AliQAv1::kSIM)
89       rv[specie] = CheckSIM(specie, list[specie]);
90     if (index == AliQAv1::kREC)
91       rv[specie] = CheckREC(specie, list[specie]);
92     if (index == AliQAv1::kESD)
93       rv[specie] = CheckESD(specie, list[specie]);
94
95     if(fDebug>3)
96       AliInfo(Form("Specie: %s. Task: %s. Value: %f",  
97                    AliRecoParam::GetEventSpecieName(specie),
98                    AliQAv1::GetAliTaskName(index),
99                    rv[specie]));
100   }
101 }
102
103 //______________________________________________________________________________
104 Double_t AliTPCQAChecker::CheckRAW(Int_t specie, TObjArray* list)
105 {
106   /// Check ESD
107   if(fDebug>0)
108     AliInfo("In AliTPCQAChecker::CheckRAW");
109   
110   if(fDebug>2)
111     list->Print();
112
113   Char_t specieName[256];
114   sprintf(specieName, AliRecoParam::GetEventSpecieName(specie));
115
116   TH1* hRawsOccupancyVsSector = static_cast<TH1*>
117     (list->FindObject(Form("%s_hRawsOccupancyVsSector",specieName)));
118   TH1* hRawsQmaxVsSector = static_cast<TH1*>
119     (list->FindObject(Form("%s_hRawsQmaxVsSector",specieName)));
120   TH1* hRawsOccupancyVsEvent = static_cast<TH1*>
121     (list->FindObject(Form("%s_hRawsOccupancyVsEvent",specieName)));
122   TH1* hRawsNclustersVsEvent = static_cast<TH1*>
123     (list->FindObject(Form("%s_hRawsNclustersVsEvent",specieName)));
124   
125   if (!hRawsOccupancyVsSector || !hRawsQmaxVsSector ||
126       !hRawsOccupancyVsEvent  || !hRawsNclustersVsEvent) 
127     return -0.5; // fatal
128   
129   if(hRawsOccupancyVsSector->GetEntries()==0) {
130     return 0.25; // error - No TPC data!
131   }
132   
133   Int_t nBinsX = hRawsOccupancyVsSector->GetNbinsX();
134   for(Int_t i = 1; i <= nBinsX; i++) {
135     
136     if(hRawsOccupancyVsSector->GetBinContent(i)==0)
137       return 0.75; // warning - no TPC data for at least one sector
138   }
139   
140   return 1.0; // ok
141 }
142
143 //______________________________________________________________________________
144 Double_t AliTPCQAChecker::CheckSIM(Int_t specie, TObjArray* list)
145 {
146   // This method checks the QA histograms associated with simulation
147   //
148   // For TPC this is:
149   // Digits : 
150   // The digit histogram gives the ADC distribution for all sigbnals
151   // above threshold. The check is just that there are digits.
152   // Hits : The hit histograms are checked to see that they are not
153   // empty. They contain a lot of detailed information on the
154   // energyloss model (they were used to debug the AliRoot TPC use of
155   // FLUKA).
156   //
157   // The check methods are simple:
158   // We do not know if it is bad that histograms are missing because
159   // this will always be the case for summable digits. So this check
160   // is not possible here.
161   // If digit histogram is empty (set error)
162   // If one of the hit histograms are empty (set error)
163   if(fDebug>0)
164     AliInfo("In AliTPCQAChecker::CheckSIM");
165   
166   if(fDebug>2)
167     list->Print();
168
169   Char_t specieName[256];
170   sprintf(specieName, AliRecoParam::GetEventSpecieName(specie));
171
172   TH1* hDigits = static_cast<TH1*>
173     (list->FindObject(Form("%s_hDigitsADC",specieName)));
174   TH1* hHitsNhits = static_cast<TH1*> 
175     (list->FindObject(Form("%s_hHitsNhits",specieName)));
176   TH1* hHitsElectrons         = static_cast<TH1*> 
177     (list->FindObject(Form("%s_hHitsElectrons",specieName)));
178   TH1* hHitsRadius        = static_cast<TH1*> 
179     (list->FindObject(Form("%s_hHitsRadius",specieName)));
180   TH1* histHitsPrimPerCm          = static_cast<TH1*> 
181     (list->FindObject(Form("%s_histHitsPrimPerCm",specieName)));
182   TH1* histHitsElectronsPerCm          = static_cast<TH1*> 
183     (list->FindObject(Form("%s_histHitsElectronsPerCm",specieName)));
184   
185 //   if (!(hDigits) ||                                             // digit hists
186 //       !(hHitsNhits && hHitsElectrons && hHitsRadius && histHitsPrimPerCm && histHitsElectronsPerCm)) // hit hists
187 //     return -0.5; // fatal
188   
189   if (hDigits) {
190     if(hDigits->GetEntries()==0) 
191       return 0.25; // error
192   }
193
194   if (hHitsNhits && hHitsElectrons && hHitsRadius && 
195       histHitsPrimPerCm && histHitsElectronsPerCm) {
196     if (hHitsNhits->GetEntries()==0 || hHitsElectrons->GetEntries()==0 ||
197         hHitsRadius->GetEntries()==0 || histHitsPrimPerCm->GetEntries()==0 ||
198         histHitsElectronsPerCm->GetEntries()==0) 
199       return 0.25; // error
200   }
201
202   return 1; // ok
203 }
204
205 //______________________________________________________________________________
206 Double_t AliTPCQAChecker::CheckREC(Int_t specie, TObjArray* list)
207 {
208   // This method checks the QA histograms associated with reconstruction
209   //
210   // For TPC this is:
211   // DigitsR : 
212   // The digit histogram gives the ADC distribution for all sigbnals
213   // above threshold. The check is just that there are digits.
214   // RecPoints : 
215   // The cluster histograms are meant to give an idea about the gain
216   // from the cluster charge and to indicate iof there are rows with
217   // noise clusters, i.e., they are very visual.
218   //
219   // The check methods are simple:
220   // If there are no histogram at all (set fatal)
221   // If digit histogram is there, but there are no digits (set error)
222   // If cluster histogram is there but there are less than 1000 
223   //    clusters (set warning)
224   // If there are more than 1000 clusters but no clusters for either short, 
225   // medium, or long pads (set error)
226   if(fDebug>0)
227     AliInfo("In AliTPCQAChecker::CheckREC");
228   
229   if(fDebug>2)
230     list->Print();
231
232   Char_t specieName[256];
233   sprintf(specieName, AliRecoParam::GetEventSpecieName(specie));
234
235   TH1* hDigits = static_cast<TH1*>
236     (list->FindObject(Form("%s_hDigitsADC",specieName)));
237   TH1* hNclustersVsRow = static_cast<TH1*> 
238     (list->FindObject(Form("%s_hRecPointsRow",specieName)));
239   TH1* hQshort         = static_cast<TH1*> 
240     (list->FindObject(Form("%s_hRecPointsQShort",specieName)));
241   TH1* hQmedium        = static_cast<TH1*> 
242     (list->FindObject(Form("%s_hRecPointsQMedium",specieName)));
243   TH1* hQlong          = static_cast<TH1*> 
244     (list->FindObject(Form("%s_hRecPointsQLong",specieName)));
245   // The Qmax histograms are for now ignored
246
247   if (!hDigits &&                                             // digits missing
248       (!hNclustersVsRow || !hQshort || !hQmedium || !hQlong)) // 1 recpoint hist missing
249     return -0.5; // fatal
250
251   if (hDigits && hDigits->GetEntries()==0) 
252     return 0.25; // error
253   
254   if (hNclustersVsRow && hNclustersVsRow->GetEntries() < 1000) {
255     return 0.75; // warning
256   } else { 
257     if (!hQshort || !hQlong || !hQlong)
258       return -0.5;// fatal - they should be there if the cluster vs row hist is there
259     if (hQshort->GetEntries()==0 || hQmedium->GetEntries()==0 ||
260         hQlong->GetEntries()==0) 
261       return 0.25; // error
262   }
263   return 1; // ok
264 }
265
266 //______________________________________________________________________________
267 Double_t AliTPCQAChecker::CheckESD(Int_t specie, TObjArray* list)
268 {
269   // This method checks the QA histograms associated with ESDs
270   // (Note that there is aslo a globalQA which is running on all
271   //  the ESD information so for now this is just a few basic
272   //  histograms)
273   //
274   // The check methods are simple:
275   // If there are no histogram at all (set fatal)
276   // 
277   if(fDebug>0)
278     AliInfo("In AliTPCQAChecker::CheckESD");
279
280   if(fDebug>2)
281     list->Print();
282
283   Char_t specieName[256];
284   sprintf(specieName, AliRecoParam::GetEventSpecieName(specie));
285
286   TH1* hESDclusters = static_cast<TH1*>
287     (list->FindObject(Form("%s_hESDclusters",specieName)));
288   TH1* hESDratio = static_cast<TH1*>
289     (list->FindObject(Form("%s_hESDratio",specieName)));
290   TH1* hESDpt = static_cast<TH1*>
291     (list->FindObject(Form("%s_hESDpt",specieName)));
292   
293   if (!hESDclusters || !hESDratio || !hESDpt) 
294     return -0.5; // fatal
295
296   return 1.0; // ok
297 }
298
299 //______________________________________________________________________________
300 void AliTPCQAChecker::Init(const AliQAv1::DETECTORINDEX_t det) 
301 {
302   /// intialises QA and QA checker settings
303   if(fDebug>0)
304     AliInfo("In AliTPCQAChecker::Init");
305   AliQAv1::Instance(det) ; 
306   Float_t hiValue[AliQAv1::kNBIT] ; 
307   Float_t lowValue[AliQAv1::kNBIT] ;
308   hiValue[AliQAv1::kINFO]       = 1.00; 
309   lowValue[AliQAv1::kINFO]      = 0.99; 
310   hiValue[AliQAv1::kWARNING]    = 0.99; 
311   lowValue[AliQAv1::kWARNING]   = 0.50; 
312   hiValue[AliQAv1::kERROR]      = 0.50; 
313   lowValue[AliQAv1::kERROR]     = 0.00; 
314   hiValue[AliQAv1::kFATAL]      = 0.00; 
315   lowValue[AliQAv1::kFATAL]     =-1.00; 
316   //  SetHiLo(&hiValue[0], &lowValue[0]) ; 
317   SetHiLo(hiValue, lowValue) ; 
318 }
319
320 //______________________________________________________________________________
321 void 
322 AliTPCQAChecker::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const
323 {
324   /// sets the QA according the return value of the Check
325
326   if(fDebug>0)
327     AliInfo("In AliTPCQAChecker::SetQA");
328
329   AliQAv1 * qa = AliQAv1::Instance(index);
330   
331   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
332
333     if (value==NULL) { // No checker is implemented, set all QA to Fatal
334       
335       if(fDebug>1)
336         AliInfo(Form("Fatal QA. Task: %s. Specie: %s", 
337                      AliQAv1::GetAliTaskName(index), 
338                      AliRecoParam::GetEventSpecieName(specie)));
339       qa->Set(AliQAv1::kFATAL, specie) ; 
340     } else {
341       
342       if ( value[specie] >= fLowTestValue[AliQAv1::kFATAL] && 
343            value[specie] < fUpTestValue[AliQAv1::kFATAL] ) {
344         
345         if(fDebug>1)
346           AliInfo(Form("QA-Fatal. Task: %s. Specie: %s", 
347                        AliQAv1::GetAliTaskName(index), 
348                        AliRecoParam::GetEventSpecieName(specie)));
349         qa->Set(AliQAv1::kFATAL, specie) ; 
350       } else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && 
351                   value[specie] <= fUpTestValue[AliQAv1::kERROR]  ) {
352         
353         if(fDebug>1)
354           AliInfo(Form("QA-Error. Task: %s. Specie: %s", 
355                        AliQAv1::GetAliTaskName(index), 
356                        AliRecoParam::GetEventSpecieName(specie)));
357         qa->Set(AliQAv1::kERROR, specie) ; 
358       } else if (value[specie] > fLowTestValue[AliQAv1::kWARNING] && 
359                  value[specie] <= fUpTestValue[AliQAv1::kWARNING]) {
360         
361         if(fDebug>1)
362           AliInfo(Form("QA-Warning. Task: %s. Specie: %s", 
363                        AliQAv1::GetAliTaskName(index), 
364                        AliRecoParam::GetEventSpecieName(specie)));
365         qa->Set(AliQAv1::kWARNING, specie) ;
366       } else if (value[specie] > fLowTestValue[AliQAv1::kINFO] && 
367                  value[specie] <= fUpTestValue[AliQAv1::kINFO] ) { 
368         
369         if(fDebug>1)
370           AliInfo(Form("QA-Info. Task: %s. Specie: %s", 
371                        AliQAv1::GetAliTaskName(index), 
372                        AliRecoParam::GetEventSpecieName(specie)));
373         qa->Set(AliQAv1::kINFO, specie) ;       
374       }
375     }
376   }
377 }