added EOL
[u/mrichter/AliRoot.git] / STEER / AliQADataMakerSim.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 *
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 **************************************************************************/
15
16
17/* $Id$ */
18
202374b1 19//
20// Base Class
21// Produces the data needed to calculate the quality assurance.
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>
29#include <TClonesArray.h>
30
31// --- Standard library ---
32
33// --- AliRoot header files ---
34#include "AliLog.h"
35#include "AliQADataMakerSim.h"
04236e67 36
37ClassImp(AliQADataMakerSim)
38
39//____________________________________________________________________________
40AliQADataMakerSim::AliQADataMakerSim(const char * name, const char * title) :
41 AliQADataMaker(name, title),
42 fDigitsQAList(0x0),
43 fHitsQAList(0x0),
44 fSDigitsQAList(0x0)
45{
46 // ctor
47 fDetectorDirName = GetName() ;
48}
49
50//____________________________________________________________________________
51AliQADataMakerSim::AliQADataMakerSim(const AliQADataMakerSim& qadm) :
52 AliQADataMaker(qadm.GetName(), qadm.GetTitle()),
53 fDigitsQAList(qadm.fDigitsQAList),
54 fHitsQAList(qadm.fHitsQAList),
55 fSDigitsQAList(qadm.fSDigitsQAList)
56{
57 //copy ctor
58 fDetectorDirName = GetName() ;
59}
60
63c6f8ae 61//____________________________________________________________________________
62AliQADataMakerSim::~AliQADataMakerSim()
63{
64 //dtor: delete the TObjArray and thei content
7ff8385d 65 if ( fDigitsQAList ) {
57acd2d2 66 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
67 if ( fDigitsQAList[specie]->IsOwner() )
68 fDigitsQAList[specie]->Delete() ;
69 }
70 delete[] fDigitsQAList ;
7ff8385d 71 }
72 if ( fHitsQAList ) {
57acd2d2 73 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
74 if ( fHitsQAList[specie]->IsOwner() )
75 fHitsQAList[specie]->Delete() ;
76 }
77 delete[] fHitsQAList ;
7ff8385d 78 }
79 if ( fSDigitsQAList ) {
57acd2d2 80 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
81 if ( fSDigitsQAList[specie]->IsOwner() )
82 fSDigitsQAList[specie]->Delete() ;
83 }
84 delete[] fSDigitsQAList ;
7ff8385d 85 }
63c6f8ae 86}
87
04236e67 88//__________________________________________________________________
89AliQADataMakerSim& AliQADataMakerSim::operator = (const AliQADataMakerSim& qadm )
90{
91 // Assignment operator.
92 this->~AliQADataMakerSim();
93 new(this) AliQADataMakerSim(qadm);
94 return *this;
95}
96
97//____________________________________________________________________________
930e6e3e 98void AliQADataMakerSim::EndOfCycle()
99{
100 // Finishes a cycle of QA for all tasks
4e25ac79 101 EndOfCycle(AliQAv1::kHITS) ;
102 EndOfCycle(AliQAv1::kSDIGITS) ;
103 EndOfCycle(AliQAv1::kDIGITS) ;
930e6e3e 104 ResetCycle() ;
105}
106
107//____________________________________________________________________________
4e25ac79 108void AliQADataMakerSim::EndOfCycle(AliQAv1::TASKINDEX_t task)
04236e67 109{
110 // Finishes a cycle of QA data acquistion
57acd2d2 111 TObjArray ** list = NULL ;
04236e67 112
4e25ac79 113 if ( task == AliQAv1::kHITS )
04236e67 114 list = fHitsQAList ;
4e25ac79 115 else if ( task == AliQAv1::kSDIGITS )
04236e67 116 list = fSDigitsQAList ;
4e25ac79 117 else if ( task == AliQAv1::kDIGITS )
04236e67 118 list = fDigitsQAList ;
930e6e3e 119
120 if ( ! list )
121 return ;
04236e67 122 EndOfDetectorCycle(task, list) ;
6294b9a7 123 TDirectory * subDir = NULL ;
124 if (fDetectorDir)
4e25ac79 125 subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
ccbf0759 126 if (subDir) {
127 subDir->cd() ;
57acd2d2 128 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
129 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ;
130 if (eventSpecieDir) {
131 eventSpecieDir->cd() ;
132 TIter next(list[specie]) ;
133 TObject * obj ;
134 while ( (obj = next()) ) {
4e25ac79 135 if (!obj->TestBit(AliQAv1::GetExpertBit()))
57acd2d2 136 obj->Write() ;
137 }
138 if (WriteExpert()) {
4e25ac79 139 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
57acd2d2 140 if ( expertDir ) {
141 expertDir->cd() ;
142 next.Reset() ;
143 while ( (obj = next()) ) {
4e25ac79 144 if (!obj->TestBit(AliQAv1::GetExpertBit()))
57acd2d2 145 continue ;
146 obj->Write() ;
147 }
148 }
149 }
b1af1125 150 }
6e65319c 151 }
57acd2d2 152 fOutput->Save() ;
6e65319c 153 }
930e6e3e 154 ResetCycle() ;
04236e67 155}
156
157//____________________________________________________________________________
4e25ac79 158void AliQADataMakerSim::Exec(AliQAv1::TASKINDEX_t task, TObject * data)
04236e67 159{
160 // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs)
161
4e25ac79 162 if ( task == AliQAv1::kHITS ) {
04236e67 163 AliDebug(1, "Processing Hits QA") ;
164 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
165 if (arr) {
166 MakeHits(arr) ;
167 } else {
168 TTree * tree = dynamic_cast<TTree *>(data) ;
169 if (tree) {
170 MakeHits(tree) ;
171 } else {
172 AliWarning("data are neither a TClonesArray nor a TTree") ;
173 }
174 }
4e25ac79 175 } else if ( task == AliQAv1::kSDIGITS ) {
04236e67 176 AliDebug(1, "Processing SDigits QA") ;
177 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
178 if (arr) {
179 MakeSDigits(arr) ;
180 } else {
181 TTree * tree = dynamic_cast<TTree *>(data) ;
182 if (tree) {
183 MakeSDigits(tree) ;
184 } else {
185 AliWarning("data are neither a TClonesArray nor a TTree") ;
186 }
187 }
4e25ac79 188 } else if ( task == AliQAv1::kDIGITS ) {
04236e67 189 AliDebug(1, "Processing Digits QA") ;
190 TClonesArray * arr = dynamic_cast<TClonesArray *>(data) ;
191 if (arr) {
192 MakeDigits(arr) ;
193 } else {
194 TTree * tree = dynamic_cast<TTree *>(data) ;
195 if (tree) {
196 MakeDigits(tree) ;
197 } else {
198 AliWarning("data are neither a TClonesArray nor a TTree") ;
199 }
200 }
201 }
202}
203
204//____________________________________________________________________________
4e25ac79 205TObjArray ** AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, Int_t cycles)
04236e67 206{
207 // general intialisation
208
04236e67 209 if (cycles > 0)
210 SetCycle(cycles) ;
57acd2d2 211 TObjArray ** rv = NULL ;
4e25ac79 212 if ( task == AliQAv1::kHITS ) {
63c6f8ae 213 if ( ! fHitsQAList ) {
57acd2d2 214 fHitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
215 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
216 fHitsQAList[specie] = new TObjArray(100) ;
4e25ac79 217 fHitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 218 }
63c6f8ae 219 InitHits() ;
220 }
04236e67 221 rv = fHitsQAList ;
4e25ac79 222 } else if ( task == AliQAv1::kSDIGITS ) {
63c6f8ae 223 if ( ! fSDigitsQAList ) {
57acd2d2 224 fSDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
225 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
226 fSDigitsQAList[specie] = new TObjArray(100) ;
4e25ac79 227 fSDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 228 }
229 InitSDigits() ;
63c6f8ae 230 }
04236e67 231 rv = fSDigitsQAList ;
4e25ac79 232 } else if ( task == AliQAv1::kDIGITS ) {
63c6f8ae 233 if ( ! fDigitsQAList ) {
57acd2d2 234 fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ;
235 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
236 fDigitsQAList[specie] = new TObjArray(100) ;
4e25ac79 237 fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ;
57acd2d2 238 }
63c6f8ae 239 InitDigits() ;
240 }
04236e67 241 rv = fDigitsQAList ;
242 }
243
244 return rv ;
245}
246
247//____________________________________________________________________________
4e25ac79 248void AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles)
04236e67 249{
250 // Intialisation by passing the list of QA data booked elsewhere
251
252 fRun = run ;
253 if (cycles > 0)
254 SetCycle(cycles) ;
255
4e25ac79 256 if ( task == AliQAv1::kHITS ) {
04236e67 257 fHitsQAList = list ;
4e25ac79 258 } else if ( task == AliQAv1::kSDIGITS) {
04236e67 259 fSDigitsQAList = list ;
4e25ac79 260 } else if ( task == AliQAv1::kDIGITS ) {
04236e67 261 fDigitsQAList = list ;
262 }
263}
264
265//____________________________________________________________________________
930e6e3e 266void AliQADataMakerSim::StartOfCycle(Int_t run)
267{
268 // Finishes a cycle of QA for all tasks
269 Bool_t samecycle = kFALSE ;
4e25ac79 270 StartOfCycle(AliQAv1::kHITS, run, samecycle) ;
930e6e3e 271 samecycle = kTRUE ;
4e25ac79 272 StartOfCycle(AliQAv1::kSDIGITS, run, samecycle) ;
273 StartOfCycle(AliQAv1::kDIGITS, run, samecycle) ;
930e6e3e 274}
275
276//____________________________________________________________________________
4e25ac79 277void AliQADataMakerSim::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle)
04236e67 278{
279 // Finishes a cycle of QA data acquistion
930e6e3e 280 if ( run > 0 )
281 fRun = run ;
04236e67 282 if ( !sameCycle || fCurrentCycle == -1) {
283 ResetCycle() ;
284 if (fOutput)
285 fOutput->Close() ;
4e25ac79 286 fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ;
04236e67 287 }
288
289 AliInfo(Form(" Run %d Cycle %d task %s file %s",
4e25ac79 290 fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ;
04236e67 291
292 fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ;
293 if (!fDetectorDir)
294 fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ;
295
4e25ac79 296 TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ;
04236e67 297 if (!subDir)
4e25ac79 298 subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ;
6e65319c 299
57acd2d2 300 for ( Int_t index = AliRecoParam::kDefault ; index < AliRecoParam::kNSpecies ; index++ ) {
301 TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(index)) ;
302 if (!eventSpecieDir)
303 eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(index)) ;
4e25ac79 304 TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ;
57acd2d2 305 if (!expertDir)
4e25ac79 306 expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ;
57acd2d2 307 }
04236e67 308 StartOfDetectorCycle() ;
309}