Update for Ds
[u/mrichter/AliRoot.git] / ITS / AliITSQADataMakerSim.cxx
CommitLineData
04236e67 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// contained in a DB
22// -------------------------------------------------------------
8dc34e37 23// W. Ferrarese + P. Cerello Feb 2008
04236e67 24// INFN Torino
25
26// --- ROOT system ---
04236e67 27#include <TTree.h>
57acd2d2 28#include <TMath.h>
04236e67 29// --- Standard library ---
30
31// --- AliRoot header files ---
32#include "AliITSQADataMakerSim.h"
8dc34e37 33#include "AliITSQASPDDataMakerSim.h"
34#include "AliITSQASDDDataMakerSim.h"
35#include "AliITSQASSDDataMakerSim.h"
04236e67 36#include "AliLog.h"
4e25ac79 37#include "AliQAv1.h"
04236e67 38#include "AliQAChecker.h"
5dfa9b71 39#include "AliITSQAChecker.h"
8dc34e37 40#include "AliRawReader.h"
04236e67 41
42ClassImp(AliITSQADataMakerSim)
43
44//____________________________________________________________________________
8dc34e37 45AliITSQADataMakerSim::AliITSQADataMakerSim(Short_t subDet) :
4e25ac79 46AliQADataMakerSim(AliQAv1::GetDetName(AliQAv1::kITS), "ITS Quality Assurance Data Maker"),
8dc34e37 47fSubDetector(subDet),
48fSPDDataMaker(NULL),
49fSDDDataMaker(NULL),
50fSSDDataMaker(NULL)
51{
52 //ctor used to discriminate OnLine-Offline analysis
53 if(fSubDetector < 0 || fSubDetector > 3) {
54 AliError("Error: fSubDetector number out of range; return\n");
55 }
56
80b9610c 57 // Initialization for each subdetector
8dc34e37 58 if(fSubDetector == 0 || fSubDetector == 1) {
5379c4a3 59 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Create SPD DataMakerSim\n");
8dc34e37 60 fSPDDataMaker = new AliITSQASPDDataMakerSim(this);
61 }
62 if(fSubDetector == 0 || fSubDetector == 2) {
5379c4a3 63 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Create SDD DataMakerSim\n");
8dc34e37 64 //printf("AliITSQADM::Create SDD DataMakerSim\n");
65 fSDDDataMaker = new AliITSQASDDDataMakerSim(this);
66 }
67 if(fSubDetector == 0 || fSubDetector == 3) {
5379c4a3 68 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Create SSD DataMakerSim\n");
8dc34e37 69 fSSDDataMaker = new AliITSQASSDDataMakerSim(this);
70 }
04236e67 71}
72
73//____________________________________________________________________________
8dc34e37 74AliITSQADataMakerSim::~AliITSQADataMakerSim(){
75 // destructor
76 if(fSPDDataMaker)delete fSPDDataMaker;
77 if(fSDDDataMaker)delete fSDDDataMaker;
78 if(fSSDDataMaker)delete fSSDDataMaker;
04236e67 79}
80
81//____________________________________________________________________________
82AliITSQADataMakerSim::AliITSQADataMakerSim(const AliITSQADataMakerSim& qadm) :
8dc34e37 83AliQADataMakerSim(),
84fSubDetector(qadm.fSubDetector),
85fSPDDataMaker(NULL),
86fSDDDataMaker(NULL),
87fSSDDataMaker(NULL)
04236e67 88{
89 //copy ctor
90 SetName((const char*)qadm.GetName()) ;
8dc34e37 91 SetTitle((const char*)qadm.GetTitle());
04236e67 92}
93
94//__________________________________________________________________
95AliITSQADataMakerSim& AliITSQADataMakerSim::operator = (const AliITSQADataMakerSim& qac )
96{
97 // Equal operator.
98 this->~AliITSQADataMakerSim();
99 new(this) AliITSQADataMakerSim(qac);
100 return *this;
101}
102
103//____________________________________________________________________________
85f5e9c2 104void AliITSQADataMakerSim::StartOfDetectorCycle()
04236e67 105{
106 //Detector specific actions at start of cycle
5379c4a3 107 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Start of ITS Cycle\n");
8dc34e37 108
109 if(fSubDetector == 0 || fSubDetector == 1) fSPDDataMaker->StartOfDetectorCycle();
8dc34e37 110 if(fSubDetector == 0 || fSubDetector == 2) fSDDDataMaker->StartOfDetectorCycle();
111 if(fSubDetector == 0 || fSubDetector == 3) fSSDDataMaker->StartOfDetectorCycle();
04236e67 112}
113
114//____________________________________________________________________________
4e25ac79 115void AliITSQADataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray** list)
04236e67 116{
80b9610c 117
118 AliInfo(Form("End of Dedetctor Cycle called for %s\n",AliQAv1::GetTaskName(task).Data() ));
119
04236e67 120 // launch the QA checking
57acd2d2 121 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
80b9610c 122 if (! IsValidEventSpecie(specie, list) ){
6252ceeb 123 continue ;
614c7e17 124 }
80b9610c 125 else{
126 Int_t idnumber=list[specie]->GetUniqueID();
127 //printf("specie %s \t id number == %d\n",AliRecoParam::GetEventSpecieName(specie),idnumber);
128 if(idnumber==0)
129 {
130 //AliInfo(Form("No check for %s\n",AliQAv1::GetTaskName(task).Data() ))
131 continue;
132 } //skip kDigitsR and not filled TobjArray specie
133 else{
134 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSDM instantiates checker with Run(AliQAv1::kITS, task, list)\n");
135 if(fSubDetector == 0 || fSubDetector == 1) fSPDDataMaker->EndOfDetectorCycle(task, list[specie]);
136 if(fSubDetector == 0 || fSubDetector == 2) fSDDDataMaker->EndOfDetectorCycle(task, list[specie]);
137 if(fSubDetector == 0 || fSubDetector == 3) fSSDDataMaker->EndOfDetectorCycle(task, list[specie]);
138
139
140 AliQAChecker *qac = AliQAChecker::Instance();
141 AliITSQAChecker *qacb = (AliITSQAChecker *) qac->GetDetQAChecker(0);
142 Int_t subdet=GetSubDet();
143 qacb->SetSubDet(subdet);
144
145 if(subdet== 0 ){
146 qacb->SetTaskOffset(fSPDDataMaker->GetOffset(task,specie),fSDDDataMaker->GetOffset(task,specie),fSSDDataMaker->GetOffset(task,specie)); //Setting the offset for the QAChecker list
147 qacb->SetHisto(fSPDDataMaker->GetTaskHisto(task), fSDDDataMaker->GetTaskHisto(task), fSSDDataMaker->GetTaskHisto(task));
148 }
149 else
150 if(subdet!=0){
151 Int_t offset=GetDetTaskOffset(subdet, task);
152 qacb->SetDetTaskOffset(subdet,offset);
153 Int_t histo=GetDetTaskHisto(subdet, task);
154 qacb->SetDetHisto(subdet,histo);
155 }
156 qac->Run( AliQAv1::kITS , task, list);
157 }//end else unique id
158 }//end else event specie
159 }//end for
04236e67 160}
161
8dc34e37 162//____________________________________________________________________________
163void AliITSQADataMakerSim::InitDigits()
164{
80b9610c 165
9b94f977 166 // Initialization for Digits data
80b9610c 167 fDigitsQAList[AliRecoParam::AConvert(fEventSpecie)]->SetUniqueID(60);
9b94f977 168 if(fSubDetector == 0 || fSubDetector == 1) {
169 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM:: SPD InitDigits\n");
170
171 fSPDDataMaker->InitDigits();
172 }
173 if(fSubDetector == 0 || fSubDetector == 2) {
174 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM:: SDD InitDigits\n");
175
176 fSDDDataMaker->SetOffset(AliQAv1::kDIGITS, fDigitsQAList[AliRecoParam::AConvert(fEventSpecie)]->GetEntries(),AliRecoParam::AConvert(fEventSpecie));
177 fSDDDataMaker->InitDigits();
178 }
179 if(fSubDetector == 0 || fSubDetector == 3) {
180 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM:: SSD InitDigits\n");
181
182 fSSDDataMaker->SetOffset(AliQAv1::kDIGITS, fDigitsQAList[AliRecoParam::AConvert(fEventSpecie)]->GetEntries(),AliRecoParam::AConvert(fEventSpecie));
183 fSSDDataMaker->InitDigits();
184 }
8dc34e37 185}
186
187//____________________________________________________________________________
6252ceeb 188void AliITSQADataMakerSim::MakeDigits()
8dc34e37 189{
eca4fa66 190 // Fill QA for digits
4a903927 191 if(fSubDetector == 0 || fSubDetector == 1)
192 fSPDDataMaker->MakeDigits() ;
193
eca4fa66 194
4a903927 195 if(fSubDetector == 0 || fSubDetector == 2)
196 fSDDDataMaker->MakeDigits() ;
eca4fa66 197
6252ceeb 198 if(fSubDetector == 0 || fSubDetector == 3) fSSDDataMaker->MakeDigits();
8dc34e37 199}
200
201//____________________________________________________________________________
202void AliITSQADataMakerSim::MakeDigits(TTree * digits)
203{
eca4fa66 204 // Fill QA for digits
4a903927 205 if(fSubDetector == 0 || fSubDetector == 1)
206 fSPDDataMaker->MakeDigits(digits) ;
207
208 if(fSubDetector == 0 || fSubDetector == 2)
209 fSDDDataMaker->MakeDigits(digits) ;
eca4fa66 210
8dc34e37 211 if(fSubDetector == 0 || fSubDetector == 3) fSSDDataMaker->MakeDigits(digits);
212}
213
214//____________________________________________________________________________
215void AliITSQADataMakerSim::InitSDigits()
216{
9b94f977 217 // Initialization for SDigits
80b9610c 218 fSDigitsQAList[AliRecoParam::AConvert(fEventSpecie)]->SetUniqueID(70);
8dc34e37 219 if(fSubDetector == 0 || fSubDetector == 1) {
5379c4a3 220 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM:: SPD InitSDigits\n");
4a903927 221
8dc34e37 222 fSPDDataMaker->InitSDigits();
223 }
4a903927 224 if(fSubDetector == 0 || fSubDetector == 2){
5379c4a3 225 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM:: SDD InitSDigits\n");
4a903927 226
227 fSDDDataMaker->SetOffset(AliQAv1::kSDIGITS, fSDigitsQAList [AliRecoParam::AConvert(fEventSpecie)]->GetEntries(),AliRecoParam::AConvert(fEventSpecie));
228 fSDDDataMaker->InitSDigits();
8dc34e37 229 }
230 if(fSubDetector == 0 || fSubDetector == 3) {
5379c4a3 231 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM:: SSD InitSDigits\n");
4a903927 232
233 fSSDDataMaker->SetOffset(AliQAv1::kSDIGITS, fSDigitsQAList [AliRecoParam::AConvert(fEventSpecie)]->GetEntries(),AliRecoParam::AConvert(fEventSpecie));
234 fSSDDataMaker->InitSDigits();
8dc34e37 235 }
236}
237
238//____________________________________________________________________________
6252ceeb 239void AliITSQADataMakerSim::MakeSDigits()
8dc34e37 240{
9b94f977 241 // Fill QA for sdigits
4a903927 242 if(fSubDetector == 0 || fSubDetector == 1)
243 fSPDDataMaker->MakeSDigits() ;
244
eca4fa66 245
4a903927 246 if(fSubDetector == 0 || fSubDetector == 2)
247 fSDDDataMaker->MakeSDigits() ;
248
eca4fa66 249
6252ceeb 250 if(fSubDetector == 0 || fSubDetector == 3) fSSDDataMaker->MakeSDigits();
8dc34e37 251}
252
253//____________________________________________________________________________
254void AliITSQADataMakerSim::MakeSDigits(TTree * sdigits)
255{
256 // Fill QA for recpoints
eca4fa66 257 if(fSubDetector == 0 || fSubDetector == 1){
4a903927 258 fSPDDataMaker->MakeSDigits(sdigits) ;
259 }
eca4fa66 260
261 if(fSubDetector == 0 || fSubDetector == 2){
4a903927 262 fSDDDataMaker->MakeSDigits(sdigits) ;
eca4fa66 263 }
264
8dc34e37 265 if(fSubDetector == 0 || fSubDetector == 3) fSSDDataMaker->MakeSDigits(sdigits);
266}
267
268//____________________________________________________________________________
269void AliITSQADataMakerSim::InitHits()
270{
eca4fa66 271 // Initialization for hits
9b94f977 272 fHitsQAList[AliRecoParam::AConvert(fEventSpecie)]->SetUniqueID(50);
8dc34e37 273 if(fSubDetector == 0 || fSubDetector == 1) {
5379c4a3 274 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM:: SPD InitHits\n");
8dc34e37 275 fSPDDataMaker->InitHits();
276 }
277 if(fSubDetector == 0 || fSubDetector == 2) {
5379c4a3 278 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM:: SDD InitHits\n");
4a903927 279
280 fSDDDataMaker->SetOffset(AliQAv1::kHITS, fHitsQAList[AliRecoParam::AConvert(fEventSpecie)]->GetEntries(),AliRecoParam::AConvert(fEventSpecie));
281 fSDDDataMaker->InitHits();
8dc34e37 282 }
283 if(fSubDetector == 0 || fSubDetector == 3) {
5379c4a3 284 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM:: SSD InitHits\n");
4a903927 285
286 fSSDDataMaker->SetOffset(AliQAv1::kHITS, fHitsQAList[AliRecoParam::AConvert(fEventSpecie)]->GetEntries(),AliRecoParam::AConvert(fEventSpecie));
287 fSSDDataMaker->InitHits();
8dc34e37 288 }
289}
290
291//____________________________________________________________________________
6252ceeb 292void AliITSQADataMakerSim::MakeHits()
8dc34e37 293{
eca4fa66 294 // Fill QA for hits
295 if(fSubDetector == 0 || fSubDetector == 1) {
4a903927 296 fSPDDataMaker->MakeHits() ;
297 }
eca4fa66 298
299 if(fSubDetector == 0 || fSubDetector == 2) {
4a903927 300 fSDDDataMaker->MakeHits() ;
eca4fa66 301 }
302
6252ceeb 303 if(fSubDetector == 0 || fSubDetector == 3) fSSDDataMaker->MakeHits();
8dc34e37 304}
305
306//____________________________________________________________________________
307void AliITSQADataMakerSim::MakeHits(TTree * hits)
308{
eca4fa66 309 // Fill QA for hits
310 if(fSubDetector == 0 || fSubDetector == 1) {
4a903927 311 fSPDDataMaker->MakeHits(hits) ;
312 }
eca4fa66 313 if(fSubDetector == 0 || fSubDetector == 2) {
4a903927 314 fSDDDataMaker->MakeHits(hits) ;
eca4fa66 315 }
316
8dc34e37 317 if(fSubDetector == 0 || fSubDetector == 3) fSSDDataMaker->MakeHits(hits);
318}
614c7e17 319
320//_________________________________________________________________
4e25ac79 321Int_t AliITSQADataMakerSim::GetDetTaskOffset(Int_t subdet,AliQAv1::TASKINDEX_t task)
614c7e17 322{
9b94f977 323
324 //return the offset for each subdetector
614c7e17 325 switch(subdet)
326 {
327
328 Int_t offset;
329 case 1:
330 offset=fSPDDataMaker->GetOffset(task);
331 return offset;
332 break;
333 case 2:
334 offset=fSDDDataMaker->GetOffset(task);
335 return offset;
336 break;
337 case 3:
338 offset=fSSDDataMaker->GetOffset(task);
339 return offset;
340 break;
341 default:
342 AliWarning("No specific subdetector (SPD, SDD, SSD) selected!! Offset set to zero \n");
343 offset=0;
344 return offset;
345 break;
346 }
347 //return offset;
348}
80b9610c 349
350//_________________________________________________________________
351Int_t AliITSQADataMakerSim::GetDetTaskHisto(Int_t subdet,AliQAv1::TASKINDEX_t task)
352{
9b94f977 353 //return of the number of histograms for each task and for each sub detector
80b9610c 354 switch(subdet)
355 {
356
357 Int_t histo;
358 case 1:
359 histo=fSPDDataMaker->GetOffset(task);
360 return histo;
361 break;
362 case 2:
363 histo=fSDDDataMaker->GetOffset(task);
364 return histo;
365 break;
366 case 3:
367 histo=fSSDDataMaker->GetOffset(task);
368 return histo;
369 break;
370 default:
371 AliWarning("No specific subdetector (SPD, SDD, SSD) selected!! Offset set to zero \n");
372 histo=0;
373 return histo;
374 break;
375 }
376 //return offset;
377}