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