]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliQADataMakerRec.cxx
The description of changes:
[u/mrichter/AliRoot.git] / STEER / AliQADataMakerRec.cxx
CommitLineData
04236e67 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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 *
940d8e5f 10 * copies and that both the copyright notice and this permission notifce *
04236e67 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
17/* $Id$ */
18
202374b1 19//
20// Base Class
21// Produces the data needed to calculate the quality assurance for Reconstruction
22// All data must be mergeable objects.
23// Y. Schutz CERN July 2007
24//
04236e67 25
26// --- ROOT system ---
04236e67 27#include <TFile.h>
04236e67 28#include <TTree.h>
57acd2d2 29#include <TNtupleD.h>
fb6e511e 30#include <TObjArray.h>
04236e67 31
32// --- Standard library ---
33
34// --- AliRoot header files ---
fb6e511e 35#include "AliCDBPath.h"
36#include "AliCDBEntry.h"
37#include "AliDetectorRecoParam.h"
38#include "AliCDBManager.h"
39
04236e67 40#include "AliLog.h"
41#include "AliQADataMakerRec.h"
50dee02c 42#include "AliQAManager.h"
04236e67 43#include "AliESDEvent.h"
44#include "AliRawReader.h"
45
46ClassImp(AliQADataMakerRec)
47
48//____________________________________________________________________________
49AliQADataMakerRec::AliQADataMakerRec(const char * name, const char * title) :
50 AliQADataMaker(name, title),
71f27f1f 51 fDigitsQAList(NULL),
a2b64fbd 52 fESDsQAList(NULL),
53 fRawsQAList(NULL),
54 fRecPointsQAList(NULL),
57acd2d2 55 fCorrNt(NULL),
6252ceeb 56 fRecoParam(NULL),
57 fRecPointsArray(NULL)
04236e67 58{
59 // ctor
60 fDetectorDirName = GetName() ;
61}
62
63//____________________________________________________________________________
64AliQADataMakerRec::AliQADataMakerRec(const AliQADataMakerRec& qadm) :
b8bd1ab8 65 AliQADataMaker(qadm.GetName(), qadm.GetTitle()),
71f27f1f 66 fDigitsQAList(qadm.fDigitsQAList),
b8bd1ab8 67 fESDsQAList(qadm.fESDsQAList),
68 fRawsQAList(qadm.fRawsQAList),
69 fRecPointsQAList(qadm.fRecPointsQAList),
57acd2d2 70 fCorrNt(qadm.fCorrNt),
6252ceeb 71 fRecoParam(qadm.fRecoParam),
72 fRecPointsArray(NULL)
04236e67 73{
74 //copy ctor
75 SetName(qadm.GetName()) ;
76 SetTitle(qadm.GetTitle()) ;
77 fDetectorDirName = GetName() ;
78}
79
63c6f8ae 80//____________________________________________________________________________
81AliQADataMakerRec::~AliQADataMakerRec()
82{
83 //dtor: delete the TObjArray and thei content
7ff8385d 84 if ( fESDsQAList ) {
57acd2d2 85 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
86 if ( fESDsQAList[specie] ) {
87 if ( fESDsQAList[specie]->IsOwner() )
88 fESDsQAList[specie]->Delete() ;
89 }
90 }
91 delete[] fESDsQAList ;
7ff8385d 92 }
93 if ( fRawsQAList ) {
57acd2d2 94 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
95 if ( fRawsQAList[specie] ) {
96 if ( fRawsQAList[specie]->IsOwner() )
97 fRawsQAList[specie]->Delete() ;
98 }
99 }
100 delete[] fRawsQAList ;
44ed7a66 101 }
102 if ( fDigitsQAList ) {
103 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
104 if ( fDigitsQAList[specie] ) {
105 if ( fDigitsQAList[specie]->IsOwner() )
106 fDigitsQAList[specie]->Delete() ;
107 }
108 }
109 delete[] fDigitsQAList ;
57acd2d2 110 }
7ff8385d 111 if ( fRecPointsQAList ) {
57acd2d2 112 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
113 if ( fRecPointsQAList[specie] ) {
114 if ( fRecPointsQAList[specie]->IsOwner() )
115 fRecPointsQAList[specie]->Delete() ;
116 }
117 }
118 delete[] fRecPointsQAList ;
eca4fa66 119 }
6252ceeb 120 if (fRecPointsArray) {
121 fRecPointsArray->Clear() ;
122 delete fRecPointsArray ;
123 }
63c6f8ae 124}
125
04236e67 126//__________________________________________________________________
127AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm )
128{
129 // Assignment operator.
130 this->~AliQADataMakerRec();
131 new(this) AliQADataMakerRec(qadm);
132 return *this;
133}
134
930e6e3e 135//____________________________________________________________________________
136void AliQADataMakerRec::EndOfCycle()
137{
138 // Finishes a cycle of QA for all the tasks
4e25ac79 139 EndOfCycle(AliQAv1::kRAWS) ;
44ed7a66 140 EndOfCycle(AliQAv1::kDIGITSR) ;
4e25ac79 141 EndOfCycle(AliQAv1::kRECPOINTS) ;
142 EndOfCycle(AliQAv1::kESDS) ;
930e6e3e 143 ResetCycle() ;
144}
145
04236e67 146//____________________________________________________________________________
4e25ac79 147void AliQADataMakerRec::EndOfCycle(AliQAv1::TASKINDEX_t task)
04236e67 148{
930e6e3e 149 // Finishes a cycle of QA
04236e67 150
ea5df941 151
152 TObjArray ** list = NULL ;
04236e67 153
4e25ac79 154 if ( task == AliQAv1::kRAWS )
04236e67 155 list = fRawsQAList ;
44ed7a66 156 else if ( task == AliQAv1::kDIGITSR )
157 list = fDigitsQAList ;
4e25ac79 158 else if ( task == AliQAv1::kRECPOINTS )
04236e67 159 list = fRecPointsQAList ;
4e25ac79 160 else if ( task == AliQAv1::kESDS )
04236e67 161 list = fESDsQAList ;
7c002d48 162
930e6e3e 163
57acd2d2 164 if ( ! list && ! fCorrNt )
930e6e3e 165 return ;
166 //DefaultEndOfDetectorCycle(task) ;
0774e4a4 167 EndOfDetectorCycle(task, list) ;
50dee02c 168
ea5df941 169 if (! AliQAManager::QAManager(AliQAv1::kRECMODE)->IsSaveData())
170 return ;
171
eca4fa66 172 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
173 if (!fDetectorDir)
174 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
175 TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
176 if (!subDir)
177 subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
178 subDir->cd() ;
6252ceeb 179 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { // skip Default
180 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)) || AliRecoParam::ConvertIndex(specie) == AliRecoParam::kDefault)
eca4fa66 181 continue ;
7822bb76 182 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
183 if (!eventSpecieDir)
184 eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
185 eventSpecieDir->cd() ;
af65f4c8 186 if (list) {
187 if (list[specie]) {
188 TIter next(list[specie]) ;
189 TObject * obj ;
eca4fa66 190 while( (obj = next()) ) {
191 if (!obj->TestBit(AliQAv1::GetExpertBit()))
af65f4c8 192 obj->Write() ;
193 }
194 if (WriteExpert()) {
195 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
196 if (!expertDir)
197 expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
198 expertDir->cd() ;
199 next.Reset() ;
200 while( (obj = next()) ) {
201 if (!obj->TestBit(AliQAv1::GetExpertBit()))
202 continue ;
203 obj->Write() ;
204 }
205 }
eca4fa66 206 }
af65f4c8 207 }
208 else if ( fCorrNt ) {
209 if (fCorrNt[specie] && AliQAv1::GetDetIndex(GetName()) == AliQAv1::kCORR) {
210 eventSpecieDir->cd() ;
211 fCorrNt[specie]->Write() ;
212 }
213 fOutput->Save() ;
7822bb76 214 }
eca4fa66 215 }
7d297381 216}
217
04236e67 218//____________________________________________________________________________
4e25ac79 219void AliQADataMakerRec::Exec(AliQAv1::TASKINDEX_t task, TObject * data)
04236e67 220{
221 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
222
4e25ac79 223 if ( task == AliQAv1::kRAWS ) {
5379c4a3 224 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Raws QA") ;
eca4fa66 225 AliRawReader * rawReader = static_cast<AliRawReader *>(data) ;
04236e67 226 if (rawReader)
227 MakeRaws(rawReader) ;
228 else
5379c4a3 229 AliDebug(AliQAv1::GetQADebugLevel(), "Raw data are not processed") ;
44ed7a66 230 } else if ( task == AliQAv1::kDIGITSR ) {
231 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ;
eca4fa66 232 TTree * tree = static_cast<TTree *>(data) ;
233 if (strcmp(tree->ClassName(), "TTree") == 0) {
44ed7a66 234 MakeDigits(tree) ;
235 } else {
236 AliWarning("data are not a TTree") ;
237 }
4e25ac79 238 } else if ( task == AliQAv1::kRECPOINTS ) {
5379c4a3 239 AliDebug(AliQAv1::GetQADebugLevel(), "Processing RecPoints QA") ;
eca4fa66 240 TTree * tree = static_cast<TTree *>(data) ;
241 if (strcmp(tree->ClassName(), "TTree") == 0) {
04236e67 242 MakeRecPoints(tree) ;
243 } else {
244 AliWarning("data are not a TTree") ;
245 }
4e25ac79 246 } else if ( task == AliQAv1::kESDS ) {
5379c4a3 247 AliDebug(AliQAv1::GetQADebugLevel(), "Processing ESDs QA") ;
eca4fa66 248 AliESDEvent * esd = static_cast<AliESDEvent *>(data) ;
249 if (strcmp(esd->ClassName(), "AliESDEvent") == 0)
04236e67 250 MakeESDs(esd) ;
251 else
252 AliError("Wrong type of esd container") ;
253 }
254}
255
256//____________________________________________________________________________
4e25ac79 257TObjArray ** AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
04236e67 258{
259 // general intialisation
fb6e511e 260 InitRecoParams() ;
57acd2d2 261 TObjArray ** rv = NULL ;
04236e67 262
04236e67 263 if (cycles > 0)
264 SetCycle(cycles) ;
265
4e25ac79 266 if ( task == AliQAv1::kRAWS ) {
63c6f8ae 267 if (! fRawsQAList ) {
57acd2d2 268 fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
269 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
49466ea2 270 fRawsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
4e25ac79 271 fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 272 }
63c6f8ae 273 }
04236e67 274 rv = fRawsQAList ;
44ed7a66 275 } else if ( task == AliQAv1::kDIGITSR ) {
276 if ( ! fDigitsQAList ) {
277 fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
278 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
49466ea2 279 fDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
44ed7a66 280 fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
281 }
44ed7a66 282 }
283 rv = fDigitsQAList ;
4e25ac79 284 } else if ( task == AliQAv1::kRECPOINTS ) {
63c6f8ae 285 if ( ! fRecPointsQAList ) {
57acd2d2 286 fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
287 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
49466ea2 288 fRecPointsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
4e25ac79 289 fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 290 }
eca4fa66 291 }
04236e67 292 rv = fRecPointsQAList ;
4e25ac79 293 } else if ( task == AliQAv1::kESDS ) {
63c6f8ae 294 if ( ! fESDsQAList ) {
57acd2d2 295 fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
296 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
49466ea2 297 fESDsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
4e25ac79 298 fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 299 }
63c6f8ae 300 }
04236e67 301 rv = fESDsQAList ;
302 }
04236e67 303 return rv ;
304}
305
306//____________________________________________________________________________
4e25ac79 307void AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
04236e67 308{
309 // Intialisation by passing the list of QA data booked elsewhere
310
fb6e511e 311 InitRecoParams() ;
312 fRun = run ;
04236e67 313 if (cycles > 0)
314 SetCycle(cycles) ;
315
4e25ac79 316 if ( task == AliQAv1::kRAWS ) {
04236e67 317 fRawsQAList = list ;
44ed7a66 318 } else if ( task == AliQAv1::kDIGITSR ) {
319 fDigitsQAList = list ;
4e25ac79 320 } else if ( task == AliQAv1::kRECPOINTS ) {
04236e67 321 fRecPointsQAList = list ;
4e25ac79 322 } else if ( task == AliQAv1::kESDS ) {
04236e67 323 fESDsQAList = list ;
324 }
325}
326
fb6e511e 327//____________________________________________________________________________
328void AliQADataMakerRec::InitRecoParams()
329{
330 if (!fRecoParam) {
5379c4a3 331 AliDebug(AliQAv1::GetQADebugLevel(), Form("Loading reconstruction parameter objects for detector %s", GetName()));
fb6e511e 332 AliCDBPath path(GetName(),"Calib","RecoParam");
333 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
334 if(!entry) {
335 fRecoParam = NULL ;
55e356ec 336 AliDebug(AliQAv1::GetQADebugLevel(), Form("Couldn't find RecoParam entry in OCDB for detector %s",GetName()));
fb6e511e 337 }
338 else {
339 TObject * recoParamObj = entry->GetObject() ;
eca4fa66 340 if ( strcmp(recoParamObj->ClassName(), "TObjArray") == 0 ) {
42383dda 341 // The detector has only one set of reco parameters
5379c4a3 342 AliDebug(AliQAv1::GetQADebugLevel(), Form("Array of reconstruction parameters found for detector %s",GetName()));
eca4fa66 343 TObjArray *recoParamArray = static_cast<TObjArray*>(recoParamObj) ;
42383dda 344 for (Int_t iRP=0; iRP<recoParamArray->GetEntriesFast(); iRP++) {
eca4fa66 345 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamArray->At(iRP)) ;
346 if (!fRecoParam)
347 break ;
348 else if (fRecoParam->IsDefault())
349 break ;
42383dda 350 }
351 }
eca4fa66 352 else if (recoParamObj->InheritsFrom("AliDetectorRecoParam")) {
353 // The detector has only one set of reco parameters
fb6e511e 354 // Registering it in AliRecoParam
5379c4a3 355 AliDebug(AliQAv1::GetQADebugLevel(), Form("Single set of reconstruction parameters found for detector %s",GetName()));
eca4fa66 356 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamObj) ;
357 static_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
fb6e511e 358 } else {
359 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",GetName()));
360 }
361 }
362 }
363}
364
9ac91920 365//____________________________________________________________________________
366void AliQADataMakerRec::ResetDetector(AliQAv1::TASKINDEX_t task)
367{
368 // default reset that resets all the QA objects.
369 // to be overloaded by detectors, if necessary
370
371 TObjArray ** list = NULL ;
372 if ( task == AliQAv1::kRAWS ) {
373 list = fRawsQAList ;
374 } else if ( task == AliQAv1::kDIGITSR ) {
375 list = fDigitsQAList ;
376 } else if ( task == AliQAv1::kRECPOINTS ) {
377 list = fRecPointsQAList ;
378 } else if ( task == AliQAv1::kESDS ) {
379 list = fESDsQAList ;
380 }
381 //list was not initialized, skip
382 if (!list)
383 return ;
384
385 for (int spec = 0; spec < AliRecoParam::kNSpecies; spec++) {
386 if (!AliQAv1::Instance()->IsEventSpecieSet(AliRecoParam::ConvertIndex(spec)))
387 continue;
388 TIter next(list[spec]) ;
389 TH1 * histo = NULL ;
390 while ( (histo = dynamic_cast<TH1*> (next())) ) {
391 histo->Reset() ;
392 }
393 }
394}
395
04236e67 396//____________________________________________________________________________
930e6e3e 397void AliQADataMakerRec::StartOfCycle(Int_t run)
398{
399 // Finishes a cycle of QA for all the tasks
400 Bool_t samecycle = kFALSE ;
4e25ac79 401 StartOfCycle(AliQAv1::kRAWS, run, samecycle) ;
930e6e3e 402 samecycle = kTRUE ;
44ed7a66 403 StartOfCycle(AliQAv1::kDIGITSR, run, samecycle) ;
4e25ac79 404 StartOfCycle(AliQAv1::kRECPOINTS, run, samecycle) ;
405 StartOfCycle(AliQAv1::kESDS, run, samecycle) ;
930e6e3e 406}
407
408//____________________________________________________________________________
4e25ac79 409void AliQADataMakerRec::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
04236e67 410{
411 // Finishes a cycle of QA data acquistion
930e6e3e 412 if ( run > 0 )
413 fRun = run ;
04236e67 414 if ( !sameCycle || fCurrentCycle == -1) {
415 ResetCycle() ;
416 if (fOutput)
417 fOutput->Close() ;
50dee02c 418 if (AliQAManager::QAManager(AliQAv1::kRECMODE)->IsSaveData())
419 fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;
04236e67 420 }
5379c4a3 421 AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s",
4e25ac79 422 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
04236e67 423
eca4fa66 424// fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
425// if (!fDetectorDir)
426// fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
427//
428// TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
429// if (!subDir)
430// subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
431//
432// for ( Int_t specie = AliRecoParam::kDefault ; specie < AliRecoParam::kNSpecies ; specie++ ) {
433// TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
434// if (!eventSpecieDir)
435// eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
436// TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
437// if (!expertDir)
438// expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
439// }
04236e67 440 StartOfDetectorCycle() ;
441}