]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliQADataMakerRec.cxx
added the option to save or not the QA data objects
[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
57acd2d2 151 TObjArray ** list = NULL ;
04236e67 152
4e25ac79 153 if ( task == AliQAv1::kRAWS )
04236e67 154 list = fRawsQAList ;
44ed7a66 155 else if ( task == AliQAv1::kDIGITSR )
156 list = fDigitsQAList ;
4e25ac79 157 else if ( task == AliQAv1::kRECPOINTS )
04236e67 158 list = fRecPointsQAList ;
4e25ac79 159 else if ( task == AliQAv1::kESDS )
04236e67 160 list = fESDsQAList ;
7c002d48 161
930e6e3e 162
57acd2d2 163 if ( ! list && ! fCorrNt )
930e6e3e 164 return ;
165 //DefaultEndOfDetectorCycle(task) ;
0774e4a4 166 EndOfDetectorCycle(task, list) ;
50dee02c 167
eca4fa66 168 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
169 if (!fDetectorDir)
170 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
171 TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
172 if (!subDir)
173 subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
174 subDir->cd() ;
6252ceeb 175 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { // skip Default
176 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)) || AliRecoParam::ConvertIndex(specie) == AliRecoParam::kDefault)
eca4fa66 177 continue ;
7822bb76 178 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
179 if (!eventSpecieDir)
180 eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
181 eventSpecieDir->cd() ;
af65f4c8 182 if (list) {
183 if (list[specie]) {
184 TIter next(list[specie]) ;
185 TObject * obj ;
eca4fa66 186 while( (obj = next()) ) {
187 if (!obj->TestBit(AliQAv1::GetExpertBit()))
af65f4c8 188 obj->Write() ;
189 }
190 if (WriteExpert()) {
191 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
192 if (!expertDir)
193 expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
194 expertDir->cd() ;
195 next.Reset() ;
196 while( (obj = next()) ) {
197 if (!obj->TestBit(AliQAv1::GetExpertBit()))
198 continue ;
199 obj->Write() ;
200 }
201 }
eca4fa66 202 }
af65f4c8 203 }
204 else if ( fCorrNt ) {
205 if (fCorrNt[specie] && AliQAv1::GetDetIndex(GetName()) == AliQAv1::kCORR) {
206 eventSpecieDir->cd() ;
207 fCorrNt[specie]->Write() ;
208 }
209 fOutput->Save() ;
7822bb76 210 }
eca4fa66 211 }
7d297381 212}
213
04236e67 214//____________________________________________________________________________
4e25ac79 215void AliQADataMakerRec::Exec(AliQAv1::TASKINDEX_t task, TObject * data)
04236e67 216{
217 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
218
4e25ac79 219 if ( task == AliQAv1::kRAWS ) {
5379c4a3 220 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Raws QA") ;
eca4fa66 221 AliRawReader * rawReader = static_cast<AliRawReader *>(data) ;
04236e67 222 if (rawReader)
223 MakeRaws(rawReader) ;
224 else
5379c4a3 225 AliDebug(AliQAv1::GetQADebugLevel(), "Raw data are not processed") ;
44ed7a66 226 } else if ( task == AliQAv1::kDIGITSR ) {
227 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ;
eca4fa66 228 TTree * tree = static_cast<TTree *>(data) ;
229 if (strcmp(tree->ClassName(), "TTree") == 0) {
44ed7a66 230 MakeDigits(tree) ;
231 } else {
232 AliWarning("data are not a TTree") ;
233 }
4e25ac79 234 } else if ( task == AliQAv1::kRECPOINTS ) {
5379c4a3 235 AliDebug(AliQAv1::GetQADebugLevel(), "Processing RecPoints QA") ;
eca4fa66 236 TTree * tree = static_cast<TTree *>(data) ;
237 if (strcmp(tree->ClassName(), "TTree") == 0) {
04236e67 238 MakeRecPoints(tree) ;
239 } else {
240 AliWarning("data are not a TTree") ;
241 }
4e25ac79 242 } else if ( task == AliQAv1::kESDS ) {
5379c4a3 243 AliDebug(AliQAv1::GetQADebugLevel(), "Processing ESDs QA") ;
eca4fa66 244 AliESDEvent * esd = static_cast<AliESDEvent *>(data) ;
245 if (strcmp(esd->ClassName(), "AliESDEvent") == 0)
04236e67 246 MakeESDs(esd) ;
247 else
248 AliError("Wrong type of esd container") ;
249 }
250}
251
252//____________________________________________________________________________
4e25ac79 253TObjArray ** AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
04236e67 254{
255 // general intialisation
fb6e511e 256 InitRecoParams() ;
57acd2d2 257 TObjArray ** rv = NULL ;
04236e67 258
04236e67 259 if (cycles > 0)
260 SetCycle(cycles) ;
261
4e25ac79 262 if ( task == AliQAv1::kRAWS ) {
63c6f8ae 263 if (! fRawsQAList ) {
57acd2d2 264 fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
265 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
49466ea2 266 fRawsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
4e25ac79 267 fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 268 }
63c6f8ae 269 }
04236e67 270 rv = fRawsQAList ;
44ed7a66 271 } else if ( task == AliQAv1::kDIGITSR ) {
272 if ( ! fDigitsQAList ) {
273 fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
274 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
49466ea2 275 fDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
44ed7a66 276 fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
277 }
44ed7a66 278 }
279 rv = fDigitsQAList ;
4e25ac79 280 } else if ( task == AliQAv1::kRECPOINTS ) {
63c6f8ae 281 if ( ! fRecPointsQAList ) {
57acd2d2 282 fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
283 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
49466ea2 284 fRecPointsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
4e25ac79 285 fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 286 }
eca4fa66 287 }
04236e67 288 rv = fRecPointsQAList ;
4e25ac79 289 } else if ( task == AliQAv1::kESDS ) {
63c6f8ae 290 if ( ! fESDsQAList ) {
57acd2d2 291 fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
292 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
49466ea2 293 fESDsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
4e25ac79 294 fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 295 }
63c6f8ae 296 }
04236e67 297 rv = fESDsQAList ;
298 }
04236e67 299 return rv ;
300}
301
302//____________________________________________________________________________
4e25ac79 303void AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
04236e67 304{
305 // Intialisation by passing the list of QA data booked elsewhere
306
fb6e511e 307 InitRecoParams() ;
308 fRun = run ;
04236e67 309 if (cycles > 0)
310 SetCycle(cycles) ;
311
4e25ac79 312 if ( task == AliQAv1::kRAWS ) {
04236e67 313 fRawsQAList = list ;
44ed7a66 314 } else if ( task == AliQAv1::kDIGITSR ) {
315 fDigitsQAList = list ;
4e25ac79 316 } else if ( task == AliQAv1::kRECPOINTS ) {
04236e67 317 fRecPointsQAList = list ;
4e25ac79 318 } else if ( task == AliQAv1::kESDS ) {
04236e67 319 fESDsQAList = list ;
320 }
321}
322
fb6e511e 323//____________________________________________________________________________
324void AliQADataMakerRec::InitRecoParams()
325{
326 if (!fRecoParam) {
5379c4a3 327 AliDebug(AliQAv1::GetQADebugLevel(), Form("Loading reconstruction parameter objects for detector %s", GetName()));
fb6e511e 328 AliCDBPath path(GetName(),"Calib","RecoParam");
329 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
330 if(!entry) {
331 fRecoParam = NULL ;
55e356ec 332 AliDebug(AliQAv1::GetQADebugLevel(), Form("Couldn't find RecoParam entry in OCDB for detector %s",GetName()));
fb6e511e 333 }
334 else {
335 TObject * recoParamObj = entry->GetObject() ;
eca4fa66 336 if ( strcmp(recoParamObj->ClassName(), "TObjArray") == 0 ) {
42383dda 337 // The detector has only one set of reco parameters
5379c4a3 338 AliDebug(AliQAv1::GetQADebugLevel(), Form("Array of reconstruction parameters found for detector %s",GetName()));
eca4fa66 339 TObjArray *recoParamArray = static_cast<TObjArray*>(recoParamObj) ;
42383dda 340 for (Int_t iRP=0; iRP<recoParamArray->GetEntriesFast(); iRP++) {
eca4fa66 341 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamArray->At(iRP)) ;
342 if (!fRecoParam)
343 break ;
344 else if (fRecoParam->IsDefault())
345 break ;
42383dda 346 }
347 }
eca4fa66 348 else if (recoParamObj->InheritsFrom("AliDetectorRecoParam")) {
349 // The detector has only one set of reco parameters
fb6e511e 350 // Registering it in AliRecoParam
5379c4a3 351 AliDebug(AliQAv1::GetQADebugLevel(), Form("Single set of reconstruction parameters found for detector %s",GetName()));
eca4fa66 352 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamObj) ;
353 static_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
fb6e511e 354 } else {
355 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",GetName()));
356 }
357 }
358 }
359}
360
04236e67 361//____________________________________________________________________________
930e6e3e 362void AliQADataMakerRec::StartOfCycle(Int_t run)
363{
364 // Finishes a cycle of QA for all the tasks
365 Bool_t samecycle = kFALSE ;
4e25ac79 366 StartOfCycle(AliQAv1::kRAWS, run, samecycle) ;
930e6e3e 367 samecycle = kTRUE ;
44ed7a66 368 StartOfCycle(AliQAv1::kDIGITSR, run, samecycle) ;
4e25ac79 369 StartOfCycle(AliQAv1::kRECPOINTS, run, samecycle) ;
370 StartOfCycle(AliQAv1::kESDS, run, samecycle) ;
930e6e3e 371}
372
373//____________________________________________________________________________
4e25ac79 374void AliQADataMakerRec::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
04236e67 375{
376 // Finishes a cycle of QA data acquistion
930e6e3e 377 if ( run > 0 )
378 fRun = run ;
04236e67 379 if ( !sameCycle || fCurrentCycle == -1) {
380 ResetCycle() ;
381 if (fOutput)
382 fOutput->Close() ;
50dee02c 383 if (AliQAManager::QAManager(AliQAv1::kRECMODE)->IsSaveData())
384 fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;
04236e67 385 }
5379c4a3 386 AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s",
4e25ac79 387 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
04236e67 388
eca4fa66 389// fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
390// if (!fDetectorDir)
391// fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
392//
393// TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
394// if (!subDir)
395// subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
396//
397// for ( Int_t specie = AliRecoParam::kDefault ; specie < AliRecoParam::kNSpecies ; specie++ ) {
398// TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
399// if (!eventSpecieDir)
400// eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
401// TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
402// if (!expertDir)
403// expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
404// }
04236e67 405 StartOfDetectorCycle() ;
406}