]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliQADataMakerRec.cxx
technical 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 ---
7d297381 27#include <TCanvas.h>
04236e67 28#include <TFile.h>
04236e67 29#include <TTree.h>
57acd2d2 30#include <TNtupleD.h>
fb6e511e 31#include <TObjArray.h>
04236e67 32
33// --- Standard library ---
34
35// --- AliRoot header files ---
fb6e511e 36#include "AliCDBPath.h"
37#include "AliCDBEntry.h"
38#include "AliDetectorRecoParam.h"
39#include "AliCDBManager.h"
40
04236e67 41#include "AliLog.h"
42#include "AliQADataMakerRec.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) ;
eca4fa66 167 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
168 if (!fDetectorDir)
169 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
170 TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
171 if (!subDir)
172 subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
173 subDir->cd() ;
6252ceeb 174 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { // skip Default
175 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)) || AliRecoParam::ConvertIndex(specie) == AliRecoParam::kDefault)
eca4fa66 176 continue ;
177 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
178 if (!eventSpecieDir)
179 eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
180 eventSpecieDir->cd() ;
181 if (list[specie]) {
182 TIter next(list[specie]) ;
183 TObject * obj ;
184 while( (obj = next()) ) {
185 if (!obj->TestBit(AliQAv1::GetExpertBit()))
186 obj->Write() ;
6e65319c 187 }
eca4fa66 188 if (WriteExpert()) {
189 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
190 if (!expertDir)
191 expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
192 expertDir->cd() ;
193 next.Reset() ;
194 while( (obj = next()) ) {
195 if (!obj->TestBit(AliQAv1::GetExpertBit()))
196 continue ;
197 obj->Write() ;
198 }
199 }
200 }
201 if ( !fCorrNt )
202 continue ;
203 if (fCorrNt[specie] && AliQAv1::GetDetIndex(GetName()) == AliQAv1::kCORR) {
204 eventSpecieDir->cd() ;
205 fCorrNt[specie]->Write() ;
6e65319c 206 }
a595ac34 207 fOutput->Save() ;
eca4fa66 208 }
209 MakeImage(task) ;
04236e67 210}
7d297381 211
212//____________________________________________________________________________
213void AliQADataMakerRec::MakeImage(AliQAv1::TASKINDEX_t task)
214{
215 // create a drawing of detetor defined histograms
216 TObjArray ** list = NULL ;
217 switch (task) {
218 case AliQAv1::kRAWS:
219 list = fRawsQAList ;
220 break;
221 case AliQAv1::kHITS:
222 break;
223 case AliQAv1::kSDIGITS:
224 break;
225 case AliQAv1::kDIGITS:
226 break;
44ed7a66 227 case AliQAv1::kDIGITSR:
228 list = fDigitsQAList ;
229 break;
7d297381 230 case AliQAv1::kRECPOINTS:
231 list = fRecPointsQAList ;
232 break;
233 case AliQAv1::kTRACKSEGMENTS:
234 break;
235 case AliQAv1::kRECPARTICLES:
236 break;
237 case AliQAv1::kESDS:
238 list = fESDsQAList ;
239 break;
240 case AliQAv1::kNTASKINDEX:
241 break;
242 default:
243 break;
244 }
245 if ( !list) {
246 AliError("data not initialized, call AliQADataMaker::Init");
247 return ;
248 }
fec0891b 249 MakeTheImage(list, task, "Rec") ;
7d297381 250}
251
04236e67 252//____________________________________________________________________________
4e25ac79 253void AliQADataMakerRec::Exec(AliQAv1::TASKINDEX_t task, TObject * data)
04236e67 254{
255 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
256
4e25ac79 257 if ( task == AliQAv1::kRAWS ) {
5379c4a3 258 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Raws QA") ;
eca4fa66 259 AliRawReader * rawReader = static_cast<AliRawReader *>(data) ;
04236e67 260 if (rawReader)
261 MakeRaws(rawReader) ;
262 else
5379c4a3 263 AliDebug(AliQAv1::GetQADebugLevel(), "Raw data are not processed") ;
44ed7a66 264 } else if ( task == AliQAv1::kDIGITSR ) {
265 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ;
eca4fa66 266 TTree * tree = static_cast<TTree *>(data) ;
267 if (strcmp(tree->ClassName(), "TTree") == 0) {
44ed7a66 268 MakeDigits(tree) ;
269 } else {
270 AliWarning("data are not a TTree") ;
271 }
4e25ac79 272 } else if ( task == AliQAv1::kRECPOINTS ) {
5379c4a3 273 AliDebug(AliQAv1::GetQADebugLevel(), "Processing RecPoints QA") ;
eca4fa66 274 TTree * tree = static_cast<TTree *>(data) ;
275 if (strcmp(tree->ClassName(), "TTree") == 0) {
04236e67 276 MakeRecPoints(tree) ;
277 } else {
278 AliWarning("data are not a TTree") ;
279 }
4e25ac79 280 } else if ( task == AliQAv1::kESDS ) {
5379c4a3 281 AliDebug(AliQAv1::GetQADebugLevel(), "Processing ESDs QA") ;
eca4fa66 282 AliESDEvent * esd = static_cast<AliESDEvent *>(data) ;
283 if (strcmp(esd->ClassName(), "AliESDEvent") == 0)
04236e67 284 MakeESDs(esd) ;
285 else
286 AliError("Wrong type of esd container") ;
287 }
288}
289
290//____________________________________________________________________________
4e25ac79 291TObjArray ** AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
04236e67 292{
293 // general intialisation
fb6e511e 294 InitRecoParams() ;
57acd2d2 295 TObjArray ** rv = NULL ;
04236e67 296
04236e67 297 if (cycles > 0)
298 SetCycle(cycles) ;
299
4e25ac79 300 if ( task == AliQAv1::kRAWS ) {
63c6f8ae 301 if (! fRawsQAList ) {
57acd2d2 302 fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
303 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
49466ea2 304 fRawsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
4e25ac79 305 fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 306 }
63c6f8ae 307 }
04236e67 308 rv = fRawsQAList ;
44ed7a66 309 } else if ( task == AliQAv1::kDIGITSR ) {
310 if ( ! fDigitsQAList ) {
311 fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
312 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
49466ea2 313 fDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
44ed7a66 314 fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
315 }
44ed7a66 316 }
317 rv = fDigitsQAList ;
4e25ac79 318 } else if ( task == AliQAv1::kRECPOINTS ) {
63c6f8ae 319 if ( ! fRecPointsQAList ) {
57acd2d2 320 fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
321 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
49466ea2 322 fRecPointsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
4e25ac79 323 fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 324 }
eca4fa66 325 }
04236e67 326 rv = fRecPointsQAList ;
4e25ac79 327 } else if ( task == AliQAv1::kESDS ) {
63c6f8ae 328 if ( ! fESDsQAList ) {
57acd2d2 329 fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
330 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
49466ea2 331 fESDsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
4e25ac79 332 fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 333 }
63c6f8ae 334 }
04236e67 335 rv = fESDsQAList ;
336 }
04236e67 337 return rv ;
338}
339
340//____________________________________________________________________________
4e25ac79 341void AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
04236e67 342{
343 // Intialisation by passing the list of QA data booked elsewhere
344
fb6e511e 345 InitRecoParams() ;
346 fRun = run ;
04236e67 347 if (cycles > 0)
348 SetCycle(cycles) ;
349
4e25ac79 350 if ( task == AliQAv1::kRAWS ) {
04236e67 351 fRawsQAList = list ;
44ed7a66 352 } else if ( task == AliQAv1::kDIGITSR ) {
353 fDigitsQAList = list ;
4e25ac79 354 } else if ( task == AliQAv1::kRECPOINTS ) {
04236e67 355 fRecPointsQAList = list ;
4e25ac79 356 } else if ( task == AliQAv1::kESDS ) {
04236e67 357 fESDsQAList = list ;
358 }
359}
360
fb6e511e 361//____________________________________________________________________________
362void AliQADataMakerRec::InitRecoParams()
363{
364 if (!fRecoParam) {
5379c4a3 365 AliDebug(AliQAv1::GetQADebugLevel(), Form("Loading reconstruction parameter objects for detector %s", GetName()));
fb6e511e 366 AliCDBPath path(GetName(),"Calib","RecoParam");
367 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
368 if(!entry) {
369 fRecoParam = NULL ;
55e356ec 370 AliDebug(AliQAv1::GetQADebugLevel(), Form("Couldn't find RecoParam entry in OCDB for detector %s",GetName()));
fb6e511e 371 }
372 else {
373 TObject * recoParamObj = entry->GetObject() ;
eca4fa66 374 if ( strcmp(recoParamObj->ClassName(), "TObjArray") == 0 ) {
42383dda 375 // The detector has only one set of reco parameters
5379c4a3 376 AliDebug(AliQAv1::GetQADebugLevel(), Form("Array of reconstruction parameters found for detector %s",GetName()));
eca4fa66 377 TObjArray *recoParamArray = static_cast<TObjArray*>(recoParamObj) ;
42383dda 378 for (Int_t iRP=0; iRP<recoParamArray->GetEntriesFast(); iRP++) {
eca4fa66 379 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamArray->At(iRP)) ;
380 if (!fRecoParam)
381 break ;
382 else if (fRecoParam->IsDefault())
383 break ;
42383dda 384 }
385 }
eca4fa66 386 else if (recoParamObj->InheritsFrom("AliDetectorRecoParam")) {
387 // The detector has only one set of reco parameters
fb6e511e 388 // Registering it in AliRecoParam
5379c4a3 389 AliDebug(AliQAv1::GetQADebugLevel(), Form("Single set of reconstruction parameters found for detector %s",GetName()));
eca4fa66 390 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamObj) ;
391 static_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
fb6e511e 392 } else {
393 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",GetName()));
394 }
395 }
42383dda 396 AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
fb6e511e 397 }
398}
399
04236e67 400//____________________________________________________________________________
930e6e3e 401void AliQADataMakerRec::StartOfCycle(Int_t run)
402{
403 // Finishes a cycle of QA for all the tasks
404 Bool_t samecycle = kFALSE ;
4e25ac79 405 StartOfCycle(AliQAv1::kRAWS, run, samecycle) ;
930e6e3e 406 samecycle = kTRUE ;
44ed7a66 407 StartOfCycle(AliQAv1::kDIGITSR, run, samecycle) ;
4e25ac79 408 StartOfCycle(AliQAv1::kRECPOINTS, run, samecycle) ;
409 StartOfCycle(AliQAv1::kESDS, run, samecycle) ;
930e6e3e 410}
411
412//____________________________________________________________________________
4e25ac79 413void AliQADataMakerRec::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
04236e67 414{
415 // Finishes a cycle of QA data acquistion
930e6e3e 416 if ( run > 0 )
417 fRun = run ;
04236e67 418 if ( !sameCycle || fCurrentCycle == -1) {
419 ResetCycle() ;
420 if (fOutput)
421 fOutput->Close() ;
4e25ac79 422 fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;
04236e67 423 }
5379c4a3 424 AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s",
4e25ac79 425 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
04236e67 426
eca4fa66 427// fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
428// if (!fDetectorDir)
429// fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
430//
431// TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
432// if (!subDir)
433// subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
434//
435// for ( Int_t specie = AliRecoParam::kDefault ; specie < AliRecoParam::kNSpecies ; specie++ ) {
436// TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
437// if (!eventSpecieDir)
438// eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
439// TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
440// if (!expertDir)
441// expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
442// }
04236e67 443 StartOfDetectorCycle() ;
444}