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 notice *
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.
22 // All data must be mergeable objects.
23 // Y. Schutz CERN July 2007
26 // --- ROOT system ---
29 #include <TClonesArray.h>
31 // --- Standard library ---
33 // --- AliRoot header files ---
35 #include "AliQADataMakerSim.h"
37 ClassImp(AliQADataMakerSim)
39 //____________________________________________________________________________
40 AliQADataMakerSim::AliQADataMakerSim(const char * name, const char * title) :
41 AliQADataMaker(name, title),
49 fDetectorDirName = GetName() ;
52 //____________________________________________________________________________
53 AliQADataMakerSim::AliQADataMakerSim(const AliQADataMakerSim& qadm) :
54 AliQADataMaker(qadm.GetName(), qadm.GetTitle()),
55 fDigitsQAList(qadm.fDigitsQAList),
56 fHitsQAList(qadm.fHitsQAList),
57 fSDigitsQAList(qadm.fSDigitsQAList),
62 fDetectorDirName = GetName() ;
65 //____________________________________________________________________________
66 AliQADataMakerSim::~AliQADataMakerSim()
68 //dtor: delete the TObjArray and thei content
69 if ( fDigitsQAList ) {
70 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
71 fDigitsQAList[specie]->Delete() ;
73 delete[] fDigitsQAList ;
76 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
77 fHitsQAList[specie]->Delete() ;
79 delete[] fHitsQAList ;
81 if ( fSDigitsQAList ) {
82 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
83 fSDigitsQAList[specie]->Delete() ;
85 delete[] fSDigitsQAList ;
92 fSDigitsArray->Clear() ;
93 delete fSDigitsArray ;
97 //__________________________________________________________________
98 AliQADataMakerSim& AliQADataMakerSim::operator = (const AliQADataMakerSim& qadm )
100 // Assignment operator.
101 this->~AliQADataMakerSim();
102 new(this) AliQADataMakerSim(qadm);
106 //____________________________________________________________________________
107 void AliQADataMakerSim::EndOfCycle()
109 // Finishes a cycle of QA for all tasks
110 EndOfCycle(AliQAv1::kHITS) ;
111 EndOfCycle(AliQAv1::kSDIGITS) ;
112 EndOfCycle(AliQAv1::kDIGITS) ;
116 //____________________________________________________________________________
117 void AliQADataMakerSim::EndOfCycle(AliQAv1::TASKINDEX_t task)
119 // Finishes a cycle of QA data acquistion
120 TObjArray ** list = NULL ;
122 if ( task == AliQAv1::kHITS )
124 else if ( task == AliQAv1::kSDIGITS )
125 list = fSDigitsQAList ;
126 else if ( task == AliQAv1::kDIGITS )
127 list = fDigitsQAList ;
131 EndOfDetectorCycle(task, list) ;
132 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
134 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
135 TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
137 subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
139 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
140 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)) )
142 if (list[specie]->GetEntries() != 0 ) {
143 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
145 eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ;
146 eventSpecieDir->cd() ;
147 TIter next(list[specie]) ;
149 while ( (obj = next()) ) {
150 if (!obj->TestBit(AliQAv1::GetExpertBit()))
154 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
156 expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
159 while ( (obj = next()) ) {
160 if (!obj->TestBit(AliQAv1::GetExpertBit()))
170 //____________________________________________________________________________
171 void AliQADataMakerSim::Exec(AliQAv1::TASKINDEX_t task, TObject * data)
173 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
175 if ( task == AliQAv1::kHITS ) {
176 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Hits QA") ;
177 if (strcmp(data->ClassName(), "TClonesArray") == 0) {
178 fHitsArray = static_cast<TClonesArray *>(data) ;
180 } else if (strcmp(data->ClassName(), "TTree") == 0) {
181 TTree * tree = static_cast<TTree *>(data) ;
184 AliWarning("data are neither a TClonesArray nor a TTree") ;
186 } else if ( task == AliQAv1::kSDIGITS ) {
187 AliDebug(AliQAv1::GetQADebugLevel(), "Processing SDigits QA") ;
188 if (strcmp(data->ClassName(), "TClonesArray") == 0) {
189 fSDigitsArray = static_cast<TClonesArray *>(data) ;
191 } else if (strcmp(data->ClassName(), "TTree") == 0) {
192 TTree * tree = static_cast<TTree *>(data) ;
195 AliWarning("data are neither a TClonesArray nor a TTree") ;
197 } else if ( task == AliQAv1::kDIGITS ) {
198 AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ;
199 if (strcmp(data->ClassName(), "TClonesArray") == 0) {
200 fDigitsArray = static_cast<TClonesArray *>(data) ;
202 } else if (strcmp(data->ClassName(), "TTree") == 0) {
203 TTree * tree = static_cast<TTree *>(data) ;
206 AliWarning("data are neither a TClonesArray nor a TTree") ;
211 //____________________________________________________________________________
212 TObjArray ** AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
214 // general intialisation
218 TObjArray ** rv = NULL ;
219 if ( task == AliQAv1::kHITS ) {
220 if ( ! fHitsQAList ) {
221 fHitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
222 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
223 fHitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
224 fHitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
228 } else if ( task == AliQAv1::kSDIGITS ) {
229 if ( ! fSDigitsQAList ) {
230 fSDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
231 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
232 fSDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
233 fSDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
236 rv = fSDigitsQAList ;
237 } else if ( task == AliQAv1::kDIGITS ) {
238 if ( ! fDigitsQAList ) {
239 fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
240 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
241 fDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ;
242 fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
251 //____________________________________________________________________________
252 void AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
254 // Intialisation by passing the list of QA data booked elsewhere
260 if ( task == AliQAv1::kHITS ) {
262 } else if ( task == AliQAv1::kSDIGITS) {
263 fSDigitsQAList = list ;
264 } else if ( task == AliQAv1::kDIGITS ) {
265 fDigitsQAList = list ;
269 //____________________________________________________________________________
270 void AliQADataMakerSim::ResetDetector(AliQAv1::TASKINDEX_t task)
272 // default reset that resets all the QA objects.
273 // to be overloaded by detectors, if necessary
275 TObjArray ** list = NULL ;
276 if ( task == AliQAv1::kHITS ) {
278 } else if ( task == AliQAv1::kSDIGITS ) {
279 list = fSDigitsQAList ;
280 } else if ( task == AliQAv1::kDIGITS ) {
281 list = fDigitsQAList ;
283 //list was not initialized, skip
287 for (int spec = 0; spec < AliRecoParam::kNSpecies; spec++) {
288 if (!AliQAv1::Instance()->IsEventSpecieSet(AliRecoParam::ConvertIndex(spec)))
290 TIter next(list[spec]) ;
292 while ( (histo = dynamic_cast<TH1*> (next())) ) {
298 //____________________________________________________________________________
299 void AliQADataMakerSim::StartOfCycle(Int_t run)
301 // Finishes a cycle of QA for all tasks
302 Bool_t samecycle = kFALSE ;
303 StartOfCycle(AliQAv1::kHITS, run, samecycle) ;
305 StartOfCycle(AliQAv1::kSDIGITS, run, samecycle) ;
306 StartOfCycle(AliQAv1::kDIGITS, run, samecycle) ;
309 //____________________________________________________________________________
310 void AliQADataMakerSim::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
312 // Finishes a cycle of QA data acquistion
315 if ( !sameCycle || fCurrentCycle == -1) {
319 fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;
322 AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s",
323 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
325 //fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
326 // if (!fDetectorDir)
327 // fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
329 // TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
331 // subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
333 // for ( Int_t index = AliRecoParam::kDefault ; index < AliRecoParam::kNSpecies ; index++ ) {
334 // TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(index)) ;
335 // if (!eventSpecieDir)
336 // eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(index)) ;
337 // TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
339 // expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
341 StartOfDetectorCycle() ;
345 //____________________________________________________________________________
346 void AliQADataMakerSim::ClonePerTrigClass(AliQAv1::TASKINDEX_t task)
348 // clone the histos of the array corresponding to task
351 case AliQAv1::kHITS : ClonePerTrigClassL(fHitsQAList, task); break;
352 case AliQAv1::kSDIGITS : ClonePerTrigClassL(fSDigitsQAList, task); break;
353 case AliQAv1::kDIGITS : ClonePerTrigClassL(fDigitsQAList, task); break;
354 default : AliError(Form("Task %s is invalid in this context", AliQAv1::GetTaskName(task).Data() )); break;