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