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