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