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 ---
31 #include <TObjArray.h>
33 // --- Standard library ---
35 // --- AliRoot header files ---
36 #include "AliCDBPath.h"
37 #include "AliCDBEntry.h"
38 #include "AliDetectorRecoParam.h"
39 #include "AliCDBManager.h"
42 #include "AliQADataMakerRec.h"
43 #include "AliESDEvent.h"
44 #include "AliRawReader.h"
46 ClassImp(AliQADataMakerRec)
48 //____________________________________________________________________________
49 AliQADataMakerRec::AliQADataMakerRec(const char * name, const char * title) :
50 AliQADataMaker(name, title),
53 fRecPointsQAList(NULL),
58 fDetectorDirName = GetName() ;
61 //____________________________________________________________________________
62 AliQADataMakerRec::AliQADataMakerRec(const AliQADataMakerRec& qadm) :
63 AliQADataMaker(qadm.GetName(), qadm.GetTitle()),
64 fESDsQAList(qadm.fESDsQAList),
65 fRawsQAList(qadm.fRawsQAList),
66 fRecPointsQAList(qadm.fRecPointsQAList),
67 fCorrNt(qadm.fCorrNt),
68 fRecoParam(qadm.fRecoParam)
71 SetName(qadm.GetName()) ;
72 SetTitle(qadm.GetTitle()) ;
73 fDetectorDirName = GetName() ;
76 //____________________________________________________________________________
77 AliQADataMakerRec::~AliQADataMakerRec()
79 //dtor: delete the TObjArray and thei content
81 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
82 if ( fESDsQAList[specie] ) {
83 if ( fESDsQAList[specie]->IsOwner() )
84 fESDsQAList[specie]->Delete() ;
87 delete[] fESDsQAList ;
90 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
91 if ( fRawsQAList[specie] ) {
92 if ( fRawsQAList[specie]->IsOwner() )
93 fRawsQAList[specie]->Delete() ;
96 delete[] fRawsQAList ;
98 if ( fRecPointsQAList ) {
99 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
100 if ( fRecPointsQAList[specie] ) {
101 if ( fRecPointsQAList[specie]->IsOwner() )
102 fRecPointsQAList[specie]->Delete() ;
105 delete[] fRecPointsQAList ;
109 //__________________________________________________________________
110 AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm )
112 // Assignment operator.
113 this->~AliQADataMakerRec();
114 new(this) AliQADataMakerRec(qadm);
118 //____________________________________________________________________________
119 void AliQADataMakerRec::EndOfCycle()
121 // Finishes a cycle of QA for all the tasks
122 EndOfCycle(AliQAv1::kRAWS) ;
123 EndOfCycle(AliQAv1::kRECPOINTS) ;
124 EndOfCycle(AliQAv1::kESDS) ;
128 //____________________________________________________________________________
129 void AliQADataMakerRec::EndOfCycle(AliQAv1::TASKINDEX_t task)
131 // Finishes a cycle of QA
133 TObjArray ** list = NULL ;
135 if ( task == AliQAv1::kRAWS )
137 else if ( task == AliQAv1::kRECPOINTS )
138 list = fRecPointsQAList ;
139 else if ( task == AliQAv1::kESDS )
143 if ( ! list && ! fCorrNt )
145 //DefaultEndOfDetectorCycle(task) ;
146 EndOfDetectorCycle(task, list) ;
147 TDirectory * subDir = NULL ;
149 subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
152 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
153 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
154 if (eventSpecieDir) {
155 eventSpecieDir->cd() ;
157 TIter next(list[specie]) ;
159 while( (obj = next()) ) {
160 if (!obj->TestBit(AliQAv1::GetExpertBit()))
164 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
165 if ( expertDir ) { // Write only if requested
168 while( (obj = next()) ) {
169 if (!obj->TestBit(AliQAv1::GetExpertBit()))
178 if (fCorrNt[specie] && AliQAv1::GetDetIndex(GetName()) == AliQAv1::kCORR) {
179 eventSpecieDir->cd() ;
180 fCorrNt[specie]->Write() ;
186 if ( AliDebugLevel() == AliQAv1::GetQADebugLevel() )
190 //____________________________________________________________________________
191 void AliQADataMakerRec::MakeImage(AliQAv1::TASKINDEX_t task)
193 // create a drawing of detetor defined histograms
194 TObjArray ** list = NULL ;
201 case AliQAv1::kSDIGITS:
203 case AliQAv1::kDIGITS:
205 case AliQAv1::kRECPOINTS:
206 list = fRecPointsQAList ;
208 case AliQAv1::kTRACKSEGMENTS:
210 case AliQAv1::kRECPARTICLES:
215 case AliQAv1::kNTASKINDEX:
221 AliError("data not initialized, call AliQADataMaker::Init");
224 TIter next(list[0]) ;
227 while ( (hdata=dynamic_cast<TH1 *>(next())) ) {
228 if ( hdata->TestBit(AliQAv1::GetImageBit()) )
231 if ( nImages == 0 ) {
232 AliWarning(Form("No histogram will be plotted for %s %s\n", GetName(), AliQAv1::GetTaskName(task).Data())) ;
234 AliDebug(AliQAv1::GetQADebugLevel(), Form("%d histograms will be plotted for %s %s\n", nImages, GetName(), AliQAv1::GetTaskName(task).Data())) ;
237 for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
238 TCanvas * canvasQA = new TCanvas(Form("QA_%s_%s_%s",
240 AliQAv1::GetTaskName(task).Data(),
241 AliRecoParam::GetEventSpecieName(esIndex)),
242 Form("QA control plots for det=%s task=%s eventspecie=%s",
244 AliQAv1::GetTaskName(task).Data(),
245 AliRecoParam::GetEventSpecieName(esIndex)),
247 canvasQA->SetWindowSize(w + (w - canvasQA->GetWw()), h + (h - canvasQA->GetWh())) ;
248 Int_t nx = TMath::Sqrt(nImages) ;
250 if ( nx < TMath::Sqrt(nImages))
252 canvasQA->Divide(nx, ny) ;
253 TIter nexthist(list[esIndex]) ;
257 while ( (hist=dynamic_cast<TH1*>(nexthist())) ) {
258 if(hist->TestBit(AliQAv1::GetImageBit())) {
260 canvasQA->cd(++npad) ;
268 //____________________________________________________________________________
269 void AliQADataMakerRec::Exec(AliQAv1::TASKINDEX_t task, TObject * data)
271 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
273 if ( task == AliQAv1::kRAWS ) {
274 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Raws QA") ;
275 AliRawReader * rawReader = dynamic_cast<AliRawReader *>(data) ;
277 MakeRaws(rawReader) ;
279 AliDebug(AliQAv1::GetQADebugLevel(), "Raw data are not processed") ;
280 } else if ( task == AliQAv1::kRECPOINTS ) {
281 AliDebug(AliQAv1::GetQADebugLevel(), "Processing RecPoints QA") ;
282 TTree * tree = dynamic_cast<TTree *>(data) ;
284 MakeRecPoints(tree) ;
286 AliWarning("data are not a TTree") ;
288 } else if ( task == AliQAv1::kESDS ) {
289 AliDebug(AliQAv1::GetQADebugLevel(), "Processing ESDs QA") ;
290 AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ;
294 AliError("Wrong type of esd container") ;
298 //____________________________________________________________________________
299 TObjArray ** AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
301 // general intialisation
303 TObjArray ** rv = NULL ;
308 if ( task == AliQAv1::kRAWS ) {
309 if (! fRawsQAList ) {
310 fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
311 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
312 fRawsQAList[specie] = new TObjArray(100) ;
313 fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
318 } else if ( task == AliQAv1::kRECPOINTS ) {
319 if ( ! fRecPointsQAList ) {
320 fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
321 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
322 fRecPointsQAList[specie] = new TObjArray(100) ;
323 fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
327 rv = fRecPointsQAList ;
328 } else if ( task == AliQAv1::kESDS ) {
329 if ( ! fESDsQAList ) {
330 fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
331 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
332 fESDsQAList[specie] = new TObjArray(100) ;
333 fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
342 //____________________________________________________________________________
343 void AliQADataMakerRec::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
345 // Intialisation by passing the list of QA data booked elsewhere
352 if ( task == AliQAv1::kRAWS ) {
354 } else if ( task == AliQAv1::kRECPOINTS ) {
355 fRecPointsQAList = list ;
356 } else if ( task == AliQAv1::kESDS ) {
361 //____________________________________________________________________________
362 void AliQADataMakerRec::InitRecoParams()
365 AliDebug(AliQAv1::GetQADebugLevel(), Form("Loading reconstruction parameter objects for detector %s", GetName()));
366 AliCDBPath path(GetName(),"Calib","RecoParam");
367 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
370 AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",GetName()));
373 TObject * recoParamObj = entry->GetObject() ;
374 if (dynamic_cast<TObjArray*>(recoParamObj)) {
375 // The detector has only one set of reco parameters
376 AliDebug(AliQAv1::GetQADebugLevel(), Form("Array of reconstruction parameters found for detector %s",GetName()));
377 TObjArray *recoParamArray = dynamic_cast<TObjArray*>(recoParamObj) ;
378 for (Int_t iRP=0; iRP<recoParamArray->GetEntriesFast(); iRP++) {
379 fRecoParam = dynamic_cast<AliDetectorRecoParam*>(recoParamArray->At(iRP)) ;
380 if (fRecoParam->IsDefault()) break;
383 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
384 // The detector has only onse set of reco parameters
385 // Registering it in AliRecoParam
386 AliDebug(AliQAv1::GetQADebugLevel(), Form("Single set of reconstruction parameters found for detector %s",GetName()));
387 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
388 fRecoParam = dynamic_cast<AliDetectorRecoParam*>(recoParamObj) ;
390 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",GetName()));
393 AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
397 //____________________________________________________________________________
398 void AliQADataMakerRec::StartOfCycle(Int_t run)
400 // Finishes a cycle of QA for all the tasks
401 Bool_t samecycle = kFALSE ;
402 StartOfCycle(AliQAv1::kRAWS, run, samecycle) ;
404 StartOfCycle(AliQAv1::kRECPOINTS, run, samecycle) ;
405 StartOfCycle(AliQAv1::kESDS, run, samecycle) ;
408 //____________________________________________________________________________
409 void AliQADataMakerRec::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
411 // Finishes a cycle of QA data acquistion
414 if ( !sameCycle || fCurrentCycle == -1) {
418 fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;
420 AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s",
421 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
423 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
425 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
427 TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
429 subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
431 for ( Int_t specie = AliRecoParam::kDefault ; specie < AliRecoParam::kNSpecies ; specie++ ) {
432 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
434 eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
435 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
437 expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
439 StartOfDetectorCycle() ;