]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSQASDDChecker.cxx
Adding TDC channel delays to the calib object.
[u/mrichter/AliRoot.git] / ITS / AliITSQASDDChecker.cxx
CommitLineData
5b716935 1/**************************************************************************
2 * Copyright(c) 2007-2009, 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 the quality assurance
20// by comparing with reference data
21// P. Cerello Apr 2008
22// INFN Torino
23
24// --- ROOT system ---
3647765c 25#include "TH1.h"
80b9610c 26#include <TH1D.h>
27#include <TH2.h>
5b716935 28// --- AliRoot header files ---
f09c0b42 29#include "AliITSQADataMakerRec.h"
5b716935 30#include "AliITSQASDDChecker.h"
c71529b0 31#include "AliLog.h"
3647765c 32#include "AliCDBEntry.h"
f09c0b42 33#include "AliCDBManager.h"
34//#include "AliQAManager.h"
35//#include "AliQACheckerBase.h"
36//#include "TSystem.h"
80b9610c 37#include "AliITSCalibrationSDD.h"
38#include "AliITSgeomTGeo.h"
f09c0b42 39//#include "AliITSQAChecker.h"
40
5b716935 41
3647765c 42ClassImp(AliITSQASDDChecker)
5b716935 43//__________________________________________________________________
44AliITSQASDDChecker& AliITSQASDDChecker::operator = (const AliITSQASDDChecker& qac )
45{
46 // Equal operator.
47 this->~AliITSQASDDChecker();
48 new(this) AliITSQASDDChecker(qac);
49 return *this;
50}
51
80b9610c 52AliITSQASDDChecker::~AliITSQASDDChecker()
53{
f09c0b42 54
55 //destructor
80b9610c 56 if(fStepBitSDD)
57 {
58 delete[] fStepBitSDD ;
59 fStepBitSDD = NULL;
60 }
61 if(fLowSDDValue)
62 {
63 delete[]fLowSDDValue;
64 fLowSDDValue=NULL;
65 }
66 if(fHighSDDValue)
67 {
68 delete[]fHighSDDValue;
69 fHighSDDValue=NULL;
70 }
71 if(fCalibration)
72 {
73 delete fCalibration;
74 fCalibration=NULL;
75 }
76} // dtor
77
5b716935 78//__________________________________________________________________
f09c0b42 79Double_t AliITSQASDDChecker::Check(AliQAv1::ALITASK_t index, const TObjArray * list, const AliDetectorRecoParam * /*recoparam*/)
80{
81 //check histograms of the different lists
80b9610c 82 AliInfo(Form("AliITSQASDDChecker called with offset: %d\n", fSubDetOffset) );
83
3647765c 84 AliDebug(1,Form("AliITSQASDDChecker called with offset: %d\n", fSubDetOffset));
3647765c 85
80b9610c 86 Double_t test = 0.;
87 TH1 *hdata=NULL;
88 Double_t entries=0.;
89 Double_t entries2[2];
90 for(Int_t i=0;i<2;i++)entries2[i]=0.;
80118b05 91
92 if(!fCalibration){
93 AliCDBEntry *calibSDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
94 Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
95 if(!calibSDD)
96 {
97 AliError("Calibration object retrieval failed! SDD will not be processed");
98 fCalibration = NULL;
99 test= fHighSDDValue[AliQAv1::kWARNING];
100 }
101 fCalibration = (TObjArray *)calibSDD->GetObject();
102
103 if(!cacheStatus)calibSDD->SetObject(NULL);
104 calibSDD->SetOwner(kTRUE);
105 if(!cacheStatus)
106 {
107 delete calibSDD;
108 }
109 }
110
111 AliInfo("Calib SDD Created\n ");
112
80b9610c 113 switch(index)
114 {
3647765c 115
80b9610c 116 case AliQAv1::kRAW:
117 AliInfo(Form("Check on %s\n",AliQAv1::GetAliTaskName(index)));
80b9610c 118
f09c0b42 119 if (list->GetEntries() == 0){ //check if the list is empty
80b9610c 120 //printf("test = %f \t value %f\n",test,fHighSDDValue[AliQAv1::kFATAL]);
121 test=test+fHighSDDValue[AliQAv1::kFATAL];
122 break;
123 }//end if getentries
124 else{
125 TIter next(list);
126 Int_t offset = 0;
127 for(offset =0;offset < fSubDetOffset; offset++){hdata = dynamic_cast<TH1*>(next());}//end for
128 Int_t emptymodules[2];
129 Int_t filledmodules[2];
130 Int_t emptyladders[2];
131 Int_t filledladders[2];
132 for(Int_t i=0;i<2;i++){
133 emptymodules[i]=0;
134 filledmodules[i]=0;
135 emptyladders[i]=0;
136 filledladders[i]=0;
3647765c 137 }
80b9610c 138 TH1 *hmodule=NULL;
139 TH2 *hlayer[2];
140 for(Int_t i=0;i<2;i++)hlayer[i]=NULL;
ef0526f3 141 while( (hdata = dynamic_cast<TH1* >(next())) ){
80b9610c 142 if (hdata){
143 TString hname=hdata->GetName();
144 if(hname.Contains("SDDchargeMap"))continue;
145 if(hname.Contains("SDDModPattern")){
3f90b3dc 146 if(hname.Contains("NORM")) continue;
80b9610c 147 else{
3f90b3dc 148 hmodule=hdata;
149 entries= hdata->GetEntries();
f09c0b42 150 if(AliITSQADataMakerRec::AreEqual(entries,0.)){
3f90b3dc 151 AliWarning(Form("===================>>>>>> No entries in %s \n",hname.Data()));
152 //printf("test = %f \t value %f\n",test,fHighSDDValue[AliQAv1::kFATAL]);
153 test=test+fStepBitSDD[AliQAv1::kFATAL];
154 }//endif entries
155 else{
156 int modmax=hdata->GetNbinsX();
157 Int_t empty=0;
158 Int_t filled=0;
159 Double_t content=0;
160 for(Int_t i=1;i<=modmax;i++){
161 content=hdata->GetBinContent(i);
f09c0b42 162 if(AliITSQADataMakerRec::AreEqual(content,0.)){empty++;}
163 else if((AliITSQADataMakerRec::AreEqual(content,0.)==kFALSE)){filled++;}
3f90b3dc 164 }//end for
165 AliInfo(Form(" %s : empty modules %i \t filled modules %i",hname.Data(), empty, filled));
166 }//end else pattern entries !=0
167 }//end if norm
80b9610c 168 }//end if modpattern
169 else if(hname.Contains("SDDphizL3")||hname.Contains("SDDphizL4")){
3f90b3dc 170 if(hname.Contains("NORM")) continue;
80b9610c 171 else{
3f90b3dc 172 Int_t layer=0;
173 if(hname.Contains("3"))layer=0;
174 else if(hname.Contains("4"))layer=1;
175 entries2[layer]=hdata->GetEntries();
176 if(entries2[layer]==0){
177 AliWarning(Form("===================>>>>>> No entries in %s \n",hname.Data()));
178 //printf("test = %f \t value %f\n",test,fStepBitSDD[AliQAv1::kFATAL]);
179 test=test+fStepBitSDD[AliQAv1::kFATAL];
f09c0b42 180 if(AliITSQADataMakerRec::AreEqual(entries,0.)){
3f90b3dc 181 //return test;
182 //break;
183 }
184 }//end if getentries
185 else{
186 Int_t layer1=0;
187 if(hname.Contains("3"))layer1=0;
188 else if(hname.Contains("4"))layer1=1;
189 TH2* htemp=dynamic_cast<TH2*>(hdata);
190 hlayer[layer1]=(TH2*)htemp->Clone();
191 char newname[50];
192 sprintf(newname,"%s_copy",hname.Data());
193 hlayer[layer1]->SetName(newname);
194 hlayer[layer1]->RebinX(2);
195 int modmay=hlayer[layer1]->GetNbinsY();
196 TH1D* hproj= hlayer[layer1]->ProjectionY();
197 Double_t ladcontent=0;
198 for(Int_t i=1;i<=modmay;i++) {//loop on the ladders
199 ladcontent=hproj->GetBinContent(i);
f09c0b42 200 if(AliITSQADataMakerRec::AreEqual(ladcontent,0.)){emptyladders[layer1]++;}
201 else {filledladders[layer1]++;}
3f90b3dc 202 }//end for
203 AliInfo(Form(" %s : empty ladders %i \t filled ladders %i\n",hname.Data(), emptyladders[layer], filledladders[layer]));//end else layer 3
204 delete hproj;
205 hproj=NULL;
206 //delete htemp;
207 //htemp=NULL;
208 }//end else entries !=0
209 }//end check on norm
80b9610c 210 }//end if layer 3
211 }//end if hdata
212 }//end while
f09c0b42 213 if(AliITSQADataMakerRec::AreEqual(entries,0.)&&AliITSQADataMakerRec::AreEqual(entries2[0],0.)&&AliITSQADataMakerRec::AreEqual(entries2[1],0.)) break;
3647765c 214 else{
80b9610c 215 if(hmodule||(hlayer[0]&&hlayer[1])){
216 Int_t excluded=0;
217 Int_t active=0;
218 Int_t exactive=0;//excluded but taking data
219 //AliITSCalibrationSDD *cal;
220 for(Int_t imod=0;imod<fgknSDDmodules;imod++){
221 Int_t lay=0;
222 Int_t lad=0;
223 Int_t det=0;
224 Int_t module=0;
225 module=imod+fgkmodoffset;
226 AliITSCalibrationSDD * cal=(AliITSCalibrationSDD*)fCalibration->At(imod);
227 if(cal==0) { delete cal; continue;}
228 AliITSgeomTGeo::GetModuleId(module,lay,lad,det);
229 if (cal->IsBad()){
230 excluded++;
231 Double_t content=0.;
232 Double_t contentlayer[2];
233 for(Int_t i=0;i<2;i++)contentlayer[i]=0.;
234 if(hmodule)content=hmodule->GetBinContent(imod+1);//if expert bit is active the histogram has been created
235 contentlayer[lay-3]=hlayer[lay-3]->GetBinContent(det,lad);
f09c0b42 236 if(AliITSQADataMakerRec::AreEqual(content,0.)==kFALSE||AliITSQADataMakerRec::AreEqual(contentlayer[lay-3],0.)==kFALSE)
80b9610c 237 {
238 filledmodules[lay-3]++;
239 AliWarning(Form("The module %d (layer %i, ladder %i det %i ) excluded from the acquisition, took data \n ",module,lay,lad,det));
240 exactive++;
241 }
f09c0b42 242 else if(AliITSQADataMakerRec::AreEqual(content,0.)&&AliITSQADataMakerRec::AreEqual(contentlayer[lay-3],0.))emptymodules[lay-3]++;
80b9610c 243 //AliInfo(Form("The module %d (layer %i, ladder %i det %i ) is bad, content %f content layer %f filled modules position %d ",module,lay,lad,det,contentlayer[lay-3],content,lay-3) );
244 }//end if bad
245 else
246 {
247 Double_t contentgood=0.;
248 active++;
249 //printf("lay: %i\t det %i \t lad %i \n",lay,det,lad );
250 contentgood=hlayer[lay-3]->GetBinContent(det,lad);
f09c0b42 251 if(AliITSQADataMakerRec::AreEqual(contentgood,0.)){emptymodules[lay-3]++;}
252 else {filledmodules[lay-3]++;}
80b9610c 253 }
254
255 //delete cal;
256 //cal=NULL;
257 }//end for
80118b05 258 for(Int_t i=0;i<2;i++){AliInfo(Form("Layer %i \tempty modules %i \t filled modules %i\n", i+3,emptymodules[i], filledmodules[i]));}//end else layers
80b9610c 259 if(exactive==0){
260 AliInfo(Form("All the active modules (%i) are in acquisition. The number of excluded modules are %i \n",active,excluded));
261 test=fHighSDDValue[AliQAv1::kINFO];}
262 if(exactive!=0){
263 AliWarning(Form("%i modules excluded from the acquisition took data. Active modules%i \n ",exactive,active));
264 test=fHighSDDValue[AliQAv1::kWARNING];
265 }
266 if(excluded==exactive){
267 AliWarning(Form("All the modules exluded from the acquisition (%d) took data! Active modules %i\n",excluded,active));
268 test=fHighSDDValue[AliQAv1::kWARNING];
269 }
270 if(active==0){
271 AliWarning(Form("No modules took data: excluded %i \t exactive %i \n", excluded, exactive));
272 test=fHighSDDValue[AliQAv1::kFATAL];
273 }
80118b05 274 for(Int_t i=0;i<2;i++)
275 {
276 delete hlayer[i];
277 hlayer[i]=NULL;
278 }
279 }//end else
3647765c 280 }
80b9610c 281 }//end getentries !=0
282 //delete calSDD;
283
80b9610c 284 //delete calibSDD;
285 //delete calSDD;
286
287 break;
288 case AliQAv1::kNULLTASK:
289 AliInfo(Form("No Check on %s\n",AliQAv1::GetAliTaskName(index)));
290 test=1.;
291 break;
80b9610c 292 case AliQAv1::kREC:
80118b05 293 /*
80b9610c 294 AliInfo(Form("Check on %s\n",AliQAv1::GetAliTaskName(index)));
80118b05 295 //TH1*hdata=NULL;
296 if(list->GetUniqueID()==40){
f09c0b42 297 if (list->GetEntries() == 0){ //check if the list is empty
80118b05 298 //printf("test = %f \t value %f\n",test,fHighSDDValue[AliQAv1::kFATAL]);
299 test=fHighSDDValue[AliQAv1::kFATAL];
300
301 }//end if getentries
302 else{
303
304 TIter next(list);
305
306 while( hdata = dynamic_cast<TH1* >(next()) ){
307 if (hdata){
f09c0b42 308 if(AliITSQADataMakerRec::AreEqual(hdata->GetEntries(),0.))test=test+fStepBitSDD[AliQAv1::kFATAL];
80118b05 309 else
310 {
311 TString hname=hdata->GetName();
312 if(hname.Contains("FSE"))continue;
313 else if(hname.Contains("SDDLay3TotCh")||hname.Contains("SDDLay4TotCh")){
314 Double_t meancharge=hdata->GetMean();
315 Double_t rmscharge=hdata->GetRMS();
316 AliInfo(Form("%s : Mean value:%f RMS value%f \n ",hname.Data(),meancharge,rmscharge));
317 test=test+fStepBitSDD[AliQAv1::kINFO];
318 }//end if name charge
319 else if(hname.Contains("SDDGlobalCoordDistribYX" ))
320 {
321 test=test+fStepBitSDD[AliQAv1::kINFO];
322 }//end xy
323 else if(hname.Contains("SDDGlobalCoordDistribRZ"))
324 {
325
326 test=test+fStepBitSDD[AliQAv1::kINFO];
327 } //end rz
328 else if(hname.Contains("SDDGlobalCoordDistribL3PHIZ" )||hname.Contains("SDDGlobalCoordDistribL3PHIZ"))
329 {
330
331 }//end phiz
332 else if(hname.Contains("SDDModPatternRP"))
333 {
334
335 //to do :se raws
336
337 }//modpattern
338 else if(hname.Contains("SDDModPatternL3RP")||hname.Contains("SDDModPatternL4RP") )
339 {
340 //to do: see raws
341 }//end ladpattern
342 else if(hname.Contains("SDDLocalCoordDistrib"))
343 {
344 test=test+fStepBitSDD[AliQAv1::kINFO];
345 }//end local coord
346 else if(hname.Contains("SDDrdistrib_Layer3")||hname.Contains("SDDrdistrib_Layer4"))
347 {
348
349 }//end r distribution
350 else if(hname.Contains("SDDphidistrib_Layer3")||hname.Contains("SDDphidistrib_Layer4"))
351 {
352
353 }//end phi distribution
354 else if(hname.Contains("SDDdrifttime_Layer3")||hname.Contains("SDDdrifttime_Layer4"))
355 {
356
357 }//end drift time
358 }
359 }//end if hdata
360
361 }//end while
362 }//end else geentries
363 }//end uniqueid
364 */
80b9610c 365 test=1.;
366 break;
367 case AliQAv1::kANA:
80118b05 368 AliInfo(Form("===================> No Check on %s\n",AliQAv1::GetAliTaskName(index)));
80b9610c 369 test=1.;
370 break;
371 case AliQAv1::kESD:
80118b05 372 AliInfo(Form("==================> No Check on %s\n",AliQAv1::GetAliTaskName(index)));
80b9610c 373 test=1.;
374 break;
375 case AliQAv1::kNTASK:
80118b05 376 AliInfo(Form("==================> No Check on %s\n",AliQAv1::GetAliTaskName(index)));
377 test=1.;
378 break;
379 case AliQAv1::kSIM:
380 AliInfo(Form("Check on %s\n",AliQAv1::GetAliTaskName(index)));
381 Int_t uid=list->GetUniqueID();
382 if(uid==60)
383 {
384 //digits
f09c0b42 385 if (list->GetEntries() == 0){ //check if the list is empty
80118b05 386 //printf("test = %f \t value %f\n",test,fHighSDDValue[AliQAv1::kFATAL]);
387 test=fHighSDDValue[AliQAv1::kFATAL];
388
389 }//end if getentries
390 else{
391
392 TIter next(list);
393
ef0526f3 394 while( (hdata = dynamic_cast<TH1* >(next())) ){
80118b05 395 if (hdata){
396 if(hdata->GetEntries()==0)test=test+fStepBitSDD[AliQAv1::kFATAL];
397 else
398 {
399 TString hname=hdata->GetName();
400 if(hname.Contains("SDDDIGITSModulePattern"))
401 {
402 //see raws
403
404 test=test+fStepBitSDD[AliQAv1::kINFO];
405 }//end modpattern
406 else if(hname.Contains("SDDAnodeDistribution"))
407 {
408
409 test=test+fStepBitSDD[AliQAv1::kINFO];
410 }//end anode distribution
411 else if(hname.Contains("SDDTbinDistribution"))
412 {
413
414 //to do as rp
415 test=test+fStepBitSDD[AliQAv1::kINFO];
416 }//end timebindistribution
417 else if(hname.Contains("SDDADCCountsDistribution"))
418 {
419 test=test+fStepBitSDD[AliQAv1::kINFO];
420 }//end adc counts
421
422 }//end entries !=0
423 }//end hdata
424 }//end while
425 }//end else
426 }//end digits
427 else if(uid==50)
428 {
429 //hits
f09c0b42 430 if (list->GetEntries() == 0){ //check if the list is empty
80118b05 431 //printf("test = %f \t value %f\n",test,fHighSDDValue[AliQAv1::kFATAL]);
432 test=fHighSDDValue[AliQAv1::kFATAL];
433
434 }//end if getentries
435 else{
436
437 TIter next(list);
438
ef0526f3 439 while( (hdata = dynamic_cast<TH1* >(next())) ){
80118b05 440 if (hdata){
441 if(hdata->GetEntries()==0)test=test+fStepBitSDD[AliQAv1::kFATAL];
442 else
443 {
444 TString hname=hdata->GetName();
445 if(hname.Contains("SDDHITSModulePattern"))
446 {
447 //to do as raws
448 test=test+fStepBitSDD[AliQAv1::kINFO];
449 }//end modpattern
450 else if(hname.Contains("SDDHITlenghtalonglocalYCoord"))
451 {
452 test=test+fStepBitSDD[AliQAv1::kINFO];
453 }//end hit lenght
454 else if(hname.Contains("SDDHITlenghtalonglocalYCoordZoom"))
455 {
456 test=test+fStepBitSDD[AliQAv1::kINFO];
457 }//end hit lenght
458 else if(hname.Contains("SDDDepositedEnergyDistribution"))
459 {
460 test=test+fStepBitSDD[AliQAv1::kINFO];
461 }//end deposited energy
462
463 }//end entries !=0
464 }//end hdata
465 }//end while
466 }//end else
467 }//end hits
468 else if(uid==70)
469 {
470 //sdigits
f09c0b42 471 if (list->GetEntries() == 0){ //check if the list is empty
80118b05 472 //printf("test = %f \t value %f\n",test,fHighSDDValue[AliQAv1::kFATAL]);
473 test=fHighSDDValue[AliQAv1::kFATAL];
474
475 }//end if getentries
476 else{
477
478 TIter next(list);
479
ef0526f3 480 while( (hdata = dynamic_cast<TH1* >(next())) ){
80118b05 481 if (hdata){
482 if(hdata->GetEntries()==0)test=test+fStepBitSDD[AliQAv1::kFATAL];
483 else
484 {
485 TString hname=hdata->GetName();
486 if(hname.Contains("SDDSDIGITSModulePattern"))
487 {
488 //to do as raws
489 test=test+fStepBitSDD[AliQAv1::kINFO];
490 }//end modpattern
491 else if(hname.Contains("SDDAnodeDistribution"))
492 {
493 test=test+fStepBitSDD[AliQAv1::kINFO];
494 }//end anode bindistribution
495 else if(hname.Contains("SDDTbinDistribution"))
496 {
497 //to do as rp
498 test=test+fStepBitSDD[AliQAv1::kINFO];
499 }//end timebindistribution
500 else if(hname.Contains("SDDADCCountsDistribution"))
501 {
502 test=test+fStepBitSDD[AliQAv1::kINFO];
503 }//end adc counts bindistribution
504
505 }//end entries !=0
506 }//end hdata
507 }//end while
508 }//end else
509 }//end sdigits
80b9610c 510 test=1.;
511 break;
512
513 }//end switch
80118b05 514
515 fCalibration=NULL;
80b9610c 516 delete hdata;
3647765c 517 return test;
5b716935 518}
519
3647765c 520//__________________________________________________________________
80b9610c 521void AliITSQASDDChecker::SetTaskOffset(Int_t taskoffset)
522{
f09c0b42 523 //set the number of the histograms already present in the list before the SDD histograms
80b9610c 524 fSubDetOffset = taskoffset;
525}
526
527
528//__________________________________________________________________
f09c0b42 529void AliITSQASDDChecker::SetStepBit(const Double_t *steprange)
80b9610c 530{
f09c0b42 531 //set the values of the step bit for each QA bit range calculated in the AliITSQAChecker class
80b9610c 532 fStepBitSDD = new Double_t[AliQAv1::kNBIT];
533 for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
534 {
535 fStepBitSDD[bit]=steprange[bit];
536 }
537}
538
539//__________________________________________________________________
f09c0b42 540void AliITSQASDDChecker::SetSDDLimits(const Float_t *lowvalue, const Float_t * highvalue)
3647765c 541{
f09c0b42 542 //set the low and high values in for each QA bit range calculated in the AliITSQAChecker class
80b9610c 543 fLowSDDValue = new Float_t[AliQAv1::kNBIT];
544 fHighSDDValue= new Float_t[AliQAv1::kNBIT];
545
546 for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
547 {
548 fLowSDDValue[bit]=lowvalue[bit];
549 fHighSDDValue[bit]= highvalue[bit];
550 }
551
3647765c 552}
80b9610c 553
554