1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 *
10 * copies and that both the copyright notice and this permission notifce *
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 **************************************************************************/
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
26 // --- ROOT system ---
30 #include <TObjArray.h>
32 // --- Standard library ---
34 // --- AliRoot header files ---
35 #include "AliCDBPath.h"
36 #include "AliCDBEntry.h"
37 #include "AliDetectorRecoParam.h"
38 #include "AliCDBManager.h"
41 #include "AliQADataMakerRec.h"
42 #include "AliESDEvent.h"
43 #include "AliRawReader.h"
45 ClassImp(AliQADataMakerRec)
47 //____________________________________________________________________________
48 AliQADataMakerRec::AliQADataMakerRec(const char * name, const char * title) :
49 AliQADataMaker(name, title),
53 fRecPointsQAList(NULL),
59 fDetectorDirName = GetName() ;
62 //____________________________________________________________________________
63 AliQADataMakerRec::AliQADataMakerRec(const AliQADataMakerRec& qadm) :
64 AliQADataMaker(qadm.GetName(), qadm.GetTitle()),
65 fDigitsQAList(qadm.fDigitsQAList),
66 fESDsQAList(qadm.fESDsQAList),
67 fRawsQAList(qadm.fRawsQAList),
68 fRecPointsQAList(qadm.fRecPointsQAList),
69 fCorrNt(qadm.fCorrNt),
70 fRecoParam(qadm.fRecoParam),
74 SetName(qadm.GetName()) ;
75 SetTitle(qadm.GetTitle()) ;
76 fDetectorDirName = GetName() ;
79 //____________________________________________________________________________
80 AliQADataMakerRec::~AliQADataMakerRec()
82 //dtor: delete the TObjArray and thei content
84 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
85 if ( fESDsQAList[specie] ) {
86 if ( fESDsQAList[specie]->IsOwner() )
87 fESDsQAList[specie]->Delete() ;
90 delete[] fESDsQAList ;
93 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
94 if ( fRawsQAList[specie] ) {
95 if ( fRawsQAList[specie]->IsOwner() )
96 fRawsQAList[specie]->Delete() ;
99 delete[] fRawsQAList ;
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() ;
108 delete[] fDigitsQAList ;
110 if ( fRecPointsQAList ) {
111 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
112 if ( fRecPointsQAList[specie] ) {
113 if ( fRecPointsQAList[specie]->IsOwner() )
114 fRecPointsQAList[specie]->Delete() ;
117 delete[] fRecPointsQAList ;
119 if (fRecPointsArray) {
120 fRecPointsArray->Clear() ;
121 delete fRecPointsArray ;
125 //__________________________________________________________________
126 AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm )
128 // Assignment operator.
129 this->~AliQADataMakerRec();
130 new(this) AliQADataMakerRec(qadm);
134 //____________________________________________________________________________
135 void AliQADataMakerRec::EndOfCycle()
137 // Finishes a cycle of QA for all the tasks
138 EndOfCycle(AliQAv1::kRAWS) ;
139 EndOfCycle(AliQAv1::kDIGITSR) ;
140 EndOfCycle(AliQAv1::kRECPOINTS) ;
141 EndOfCycle(AliQAv1::kESDS) ;
145 //____________________________________________________________________________
146 void AliQADataMakerRec::EndOfCycle(AliQAv1::TASKINDEX_t task)
148 // Finishes a cycle of QA
150 TObjArray ** list = NULL ;
152 if ( task == AliQAv1::kRAWS )
154 else if ( task == AliQAv1::kDIGITSR )
155 list = fDigitsQAList ;
156 else if ( task == AliQAv1::kRECPOINTS )
157 list = fRecPointsQAList ;
158 else if ( task == AliQAv1::kESDS )
162 if ( ! list && ! fCorrNt )
164 //DefaultEndOfDetectorCycle(task) ;
165 EndOfDetectorCycle(task, list) ;
166 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
168 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
169 TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
171 subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
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)
176 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
178 eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
179 eventSpecieDir->cd() ;
181 TIter next(list[specie]) ;
183 while( (obj = next()) ) {
184 if (!obj->TestBit(AliQAv1::GetExpertBit()))
188 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
190 expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
193 while( (obj = next()) ) {
194 if (!obj->TestBit(AliQAv1::GetExpertBit()))
202 if (fCorrNt[specie] && AliQAv1::GetDetIndex(GetName()) == AliQAv1::kCORR) {
203 eventSpecieDir->cd() ;
204 fCorrNt[specie]->Write() ;
210 //____________________________________________________________________________
211 void AliQADataMakerRec::Exec(AliQAv1::TASKINDEX_t task, TObject * data)
213 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
215 if ( task == AliQAv1::kRAWS ) {
216 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Raws QA") ;
217 AliRawReader * rawReader = static_cast<AliRawReader *>(data) ;
219 MakeRaws(rawReader) ;
221 AliDebug(AliQAv1::GetQADebugLevel(), "Raw data are not processed") ;
222 } else if ( task == AliQAv1::kDIGITSR ) {
223 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ;
224 TTree * tree = static_cast<TTree *>(data) ;
225 if (strcmp(tree->ClassName(), "TTree") == 0) {
228 AliWarning("data are not a TTree") ;
230 } else if ( task == AliQAv1::kRECPOINTS ) {
231 AliDebug(AliQAv1::GetQADebugLevel(), "Processing RecPoints QA") ;
232 TTree * tree = static_cast<TTree *>(data) ;
233 if (strcmp(tree->ClassName(), "TTree") == 0) {
234 MakeRecPoints(tree) ;
236 AliWarning("data are not a TTree") ;
238 } else if ( task == AliQAv1::kESDS ) {
239 AliDebug(AliQAv1::GetQADebugLevel(), "Processing ESDs QA") ;
240 AliESDEvent * esd = static_cast<AliESDEvent *>(data) ;
241 if (strcmp(esd->ClassName(), "AliESDEvent") == 0)
244 AliError("Wrong type of esd container") ;
248 //____________________________________________________________________________
249 TObjArray ** AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
251 // general intialisation
253 TObjArray ** rv = NULL ;
258 if ( task == AliQAv1::kRAWS ) {
259 if (! fRawsQAList ) {
260 fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
261 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
262 fRawsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
263 fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
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++) {
271 fDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
272 fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
276 } else if ( task == AliQAv1::kRECPOINTS ) {
277 if ( ! fRecPointsQAList ) {
278 fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
279 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
280 fRecPointsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
281 fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
284 rv = fRecPointsQAList ;
285 } else if ( task == AliQAv1::kESDS ) {
286 if ( ! fESDsQAList ) {
287 fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
288 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
289 fESDsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
290 fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
298 //____________________________________________________________________________
299 void AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
301 // Intialisation by passing the list of QA data booked elsewhere
308 if ( task == AliQAv1::kRAWS ) {
310 } else if ( task == AliQAv1::kDIGITSR ) {
311 fDigitsQAList = list ;
312 } else if ( task == AliQAv1::kRECPOINTS ) {
313 fRecPointsQAList = list ;
314 } else if ( task == AliQAv1::kESDS ) {
319 //____________________________________________________________________________
320 void AliQADataMakerRec::InitRecoParams()
323 AliDebug(AliQAv1::GetQADebugLevel(), Form("Loading reconstruction parameter objects for detector %s", GetName()));
324 AliCDBPath path(GetName(),"Calib","RecoParam");
325 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
328 AliDebug(AliQAv1::GetQADebugLevel(), Form("Couldn't find RecoParam entry in OCDB for detector %s",GetName()));
331 TObject * recoParamObj = entry->GetObject() ;
332 if ( strcmp(recoParamObj->ClassName(), "TObjArray") == 0 ) {
333 // The detector has only one set of reco parameters
334 AliDebug(AliQAv1::GetQADebugLevel(), Form("Array of reconstruction parameters found for detector %s",GetName()));
335 TObjArray *recoParamArray = static_cast<TObjArray*>(recoParamObj) ;
336 for (Int_t iRP=0; iRP<recoParamArray->GetEntriesFast(); iRP++) {
337 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamArray->At(iRP)) ;
340 else if (fRecoParam->IsDefault())
344 else if (recoParamObj->InheritsFrom("AliDetectorRecoParam")) {
345 // The detector has only one set of reco parameters
346 // Registering it in AliRecoParam
347 AliDebug(AliQAv1::GetQADebugLevel(), Form("Single set of reconstruction parameters found for detector %s",GetName()));
348 fRecoParam = static_cast<AliDetectorRecoParam*>(recoParamObj) ;
349 static_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
351 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",GetName()));
354 AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
358 //____________________________________________________________________________
359 void AliQADataMakerRec::StartOfCycle(Int_t run)
361 // Finishes a cycle of QA for all the tasks
362 Bool_t samecycle = kFALSE ;
363 StartOfCycle(AliQAv1::kRAWS, run, samecycle) ;
365 StartOfCycle(AliQAv1::kDIGITSR, run, samecycle) ;
366 StartOfCycle(AliQAv1::kRECPOINTS, run, samecycle) ;
367 StartOfCycle(AliQAv1::kESDS, run, samecycle) ;
370 //____________________________________________________________________________
371 void AliQADataMakerRec::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
373 // Finishes a cycle of QA data acquistion
376 if ( !sameCycle || fCurrentCycle == -1) {
380 fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;
382 AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s",
383 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
385 // fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
386 // if (!fDetectorDir)
387 // fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
389 // TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
391 // subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
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()) ;
399 // expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
401 StartOfDetectorCycle() ;