]>
Commit | Line | Data |
---|---|---|
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 | |
37 | ClassImp(AliQADataMakerSim) | |
38 | ||
39 | //____________________________________________________________________________ | |
40 | AliQADataMakerSim::AliQADataMakerSim(const char * name, const char * title) : | |
41 | AliQADataMaker(name, title), | |
eca4fa66 | 42 | fDigitsQAList(NULL), |
43 | fHitsQAList(NULL), | |
6252ceeb | 44 | fSDigitsQAList(NULL), |
45 | fHitsArray(NULL), | |
46 | fSDigitsArray(NULL) | |
04236e67 | 47 | { |
48 | // ctor | |
49 | fDetectorDirName = GetName() ; | |
50 | } | |
51 | ||
52 | //____________________________________________________________________________ | |
53 | AliQADataMakerSim::AliQADataMakerSim(const AliQADataMakerSim& qadm) : | |
54 | AliQADataMaker(qadm.GetName(), qadm.GetTitle()), | |
55 | fDigitsQAList(qadm.fDigitsQAList), | |
56 | fHitsQAList(qadm.fHitsQAList), | |
6252ceeb | 57 | fSDigitsQAList(qadm.fSDigitsQAList), |
58 | fHitsArray(NULL), | |
59 | fSDigitsArray(NULL) | |
04236e67 | 60 | { |
61 | //copy ctor | |
62 | fDetectorDirName = GetName() ; | |
63 | } | |
64 | ||
63c6f8ae | 65 | //____________________________________________________________________________ |
66 | AliQADataMakerSim::~AliQADataMakerSim() | |
67 | { | |
68 | //dtor: delete the TObjArray and thei content | |
7ff8385d | 69 | if ( fDigitsQAList ) { |
57acd2d2 | 70 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { |
71 | if ( fDigitsQAList[specie]->IsOwner() ) | |
72 | fDigitsQAList[specie]->Delete() ; | |
73 | } | |
eca4fa66 | 74 | delete[] fDigitsQAList ; |
75 | } | |
7ff8385d | 76 | if ( fHitsQAList ) { |
57acd2d2 | 77 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { |
78 | if ( fHitsQAList[specie]->IsOwner() ) | |
79 | fHitsQAList[specie]->Delete() ; | |
80 | } | |
eca4fa66 | 81 | delete[] fHitsQAList ; |
82 | } | |
7ff8385d | 83 | if ( fSDigitsQAList ) { |
57acd2d2 | 84 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { |
85 | if ( fSDigitsQAList[specie]->IsOwner() ) | |
86 | fSDigitsQAList[specie]->Delete() ; | |
87 | } | |
eca4fa66 | 88 | delete[] fSDigitsQAList ; |
89 | } | |
6252ceeb | 90 | if (fHitsArray) { |
91 | fHitsArray->Clear() ; | |
92 | delete fHitsArray ; | |
93 | } | |
94 | if (fSDigitsArray) { | |
95 | fSDigitsArray->Clear() ; | |
96 | delete fSDigitsArray ; | |
97 | } | |
63c6f8ae | 98 | } |
99 | ||
04236e67 | 100 | //__________________________________________________________________ |
101 | AliQADataMakerSim& AliQADataMakerSim::operator = (const AliQADataMakerSim& qadm ) | |
102 | { | |
103 | // Assignment operator. | |
104 | this->~AliQADataMakerSim(); | |
105 | new(this) AliQADataMakerSim(qadm); | |
106 | return *this; | |
107 | } | |
108 | ||
930e6e3e | 109 | //____________________________________________________________________________ |
110 | void AliQADataMakerSim::EndOfCycle() | |
111 | { | |
112 | // Finishes a cycle of QA for all tasks | |
4e25ac79 | 113 | EndOfCycle(AliQAv1::kHITS) ; |
114 | EndOfCycle(AliQAv1::kSDIGITS) ; | |
115 | EndOfCycle(AliQAv1::kDIGITS) ; | |
930e6e3e | 116 | ResetCycle() ; |
117 | } | |
118 | ||
04236e67 | 119 | //____________________________________________________________________________ |
4e25ac79 | 120 | void AliQADataMakerSim::EndOfCycle(AliQAv1::TASKINDEX_t task) |
04236e67 | 121 | { |
122 | // Finishes a cycle of QA data acquistion | |
57acd2d2 | 123 | TObjArray ** list = NULL ; |
04236e67 | 124 | |
4e25ac79 | 125 | if ( task == AliQAv1::kHITS ) |
04236e67 | 126 | list = fHitsQAList ; |
4e25ac79 | 127 | else if ( task == AliQAv1::kSDIGITS ) |
04236e67 | 128 | list = fSDigitsQAList ; |
4e25ac79 | 129 | else if ( task == AliQAv1::kDIGITS ) |
04236e67 | 130 | list = fDigitsQAList ; |
930e6e3e | 131 | |
132 | if ( ! list ) | |
133 | return ; | |
04236e67 | 134 | EndOfDetectorCycle(task, list) ; |
eca4fa66 | 135 | fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; |
136 | if (!fDetectorDir) | |
137 | fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; | |
138 | TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ; | |
139 | if (!subDir) | |
140 | subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ; | |
141 | subDir->cd() ; | |
142 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { | |
143 | if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)) ) | |
144 | continue ; | |
4851e489 | 145 | if (list[specie]->GetEntries() != 0 ) { |
146 | TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ; | |
147 | if (!eventSpecieDir) | |
148 | eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ; | |
149 | eventSpecieDir->cd() ; | |
150 | TIter next(list[specie]) ; | |
151 | TObject * obj ; | |
152 | while ( (obj = next()) ) { | |
eca4fa66 | 153 | if (!obj->TestBit(AliQAv1::GetExpertBit())) |
4851e489 | 154 | obj->Write() ; |
155 | } | |
156 | if (WriteExpert()) { | |
157 | TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ; | |
158 | if (!expertDir) | |
159 | expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ; | |
160 | expertDir->cd() ; | |
161 | next.Reset() ; | |
162 | while ( (obj = next()) ) { | |
163 | if (!obj->TestBit(AliQAv1::GetExpertBit())) | |
164 | continue ; | |
165 | obj->Write() ; | |
166 | } | |
167 | } | |
6e65319c | 168 | } |
57acd2d2 | 169 | fOutput->Save() ; |
6e65319c | 170 | } |
04236e67 | 171 | } |
eca4fa66 | 172 | |
04236e67 | 173 | //____________________________________________________________________________ |
4e25ac79 | 174 | void AliQADataMakerSim::Exec(AliQAv1::TASKINDEX_t task, TObject * data) |
04236e67 | 175 | { |
176 | // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs) | |
eca4fa66 | 177 | |
4e25ac79 | 178 | if ( task == AliQAv1::kHITS ) { |
5379c4a3 | 179 | AliDebug(AliQAv1::GetQADebugLevel(), "Processing Hits QA") ; |
eca4fa66 | 180 | if (strcmp(data->ClassName(), "TClonesArray") == 0) { |
6252ceeb | 181 | fHitsArray = static_cast<TClonesArray *>(data) ; |
182 | MakeHits() ; | |
eca4fa66 | 183 | } else if (strcmp(data->ClassName(), "TTree") == 0) { |
184 | TTree * tree = static_cast<TTree *>(data) ; | |
185 | MakeHits(tree) ; | |
186 | } else { | |
187 | AliWarning("data are neither a TClonesArray nor a TTree") ; | |
188 | } | |
4e25ac79 | 189 | } else if ( task == AliQAv1::kSDIGITS ) { |
5379c4a3 | 190 | AliDebug(AliQAv1::GetQADebugLevel(), "Processing SDigits QA") ; |
eca4fa66 | 191 | if (strcmp(data->ClassName(), "TClonesArray") == 0) { |
6252ceeb | 192 | fSDigitsArray = static_cast<TClonesArray *>(data) ; |
193 | MakeSDigits() ; | |
eca4fa66 | 194 | } else if (strcmp(data->ClassName(), "TTree") == 0) { |
195 | TTree * tree = static_cast<TTree *>(data) ; | |
196 | MakeSDigits(tree) ; | |
197 | } else { | |
198 | AliWarning("data are neither a TClonesArray nor a TTree") ; | |
199 | } | |
200 | } else if ( task == AliQAv1::kDIGITS ) { | |
5379c4a3 | 201 | AliDebug(AliQAv1::GetQADebugLevel(), "Processing Digits QA") ; |
eca4fa66 | 202 | if (strcmp(data->ClassName(), "TClonesArray") == 0) { |
6252ceeb | 203 | fDigitsArray = static_cast<TClonesArray *>(data) ; |
204 | MakeDigits() ; | |
eca4fa66 | 205 | } else if (strcmp(data->ClassName(), "TTree") == 0) { |
206 | TTree * tree = static_cast<TTree *>(data) ; | |
207 | MakeDigits(tree) ; | |
208 | } else { | |
209 | AliWarning("data are neither a TClonesArray nor a TTree") ; | |
210 | } | |
211 | } | |
04236e67 | 212 | } |
213 | ||
214 | //____________________________________________________________________________ | |
4e25ac79 | 215 | TObjArray ** AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, Int_t cycles) |
04236e67 | 216 | { |
217 | // general intialisation | |
218 | ||
04236e67 | 219 | if (cycles > 0) |
220 | SetCycle(cycles) ; | |
57acd2d2 | 221 | TObjArray ** rv = NULL ; |
4e25ac79 | 222 | if ( task == AliQAv1::kHITS ) { |
63c6f8ae | 223 | if ( ! fHitsQAList ) { |
57acd2d2 | 224 | fHitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; |
225 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { | |
49466ea2 | 226 | fHitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ; |
4e25ac79 | 227 | fHitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; |
57acd2d2 | 228 | } |
63c6f8ae | 229 | } |
04236e67 | 230 | rv = fHitsQAList ; |
4e25ac79 | 231 | } else if ( task == AliQAv1::kSDIGITS ) { |
63c6f8ae | 232 | if ( ! fSDigitsQAList ) { |
57acd2d2 | 233 | fSDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; |
234 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { | |
49466ea2 | 235 | fSDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ; |
4e25ac79 | 236 | fSDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; |
57acd2d2 | 237 | } |
63c6f8ae | 238 | } |
04236e67 | 239 | rv = fSDigitsQAList ; |
4e25ac79 | 240 | } else if ( task == AliQAv1::kDIGITS ) { |
63c6f8ae | 241 | if ( ! fDigitsQAList ) { |
57acd2d2 | 242 | fDigitsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; |
243 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { | |
49466ea2 | 244 | fDigitsQAList[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ; |
4e25ac79 | 245 | fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; |
57acd2d2 | 246 | } |
63c6f8ae | 247 | } |
04236e67 | 248 | rv = fDigitsQAList ; |
249 | } | |
250 | ||
251 | return rv ; | |
eca4fa66 | 252 | } |
04236e67 | 253 | |
254 | //____________________________________________________________________________ | |
4e25ac79 | 255 | void AliQADataMakerSim::Init(AliQAv1::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles) |
04236e67 | 256 | { |
257 | // Intialisation by passing the list of QA data booked elsewhere | |
258 | ||
259 | fRun = run ; | |
260 | if (cycles > 0) | |
261 | SetCycle(cycles) ; | |
262 | ||
4e25ac79 | 263 | if ( task == AliQAv1::kHITS ) { |
04236e67 | 264 | fHitsQAList = list ; |
4e25ac79 | 265 | } else if ( task == AliQAv1::kSDIGITS) { |
04236e67 | 266 | fSDigitsQAList = list ; |
4e25ac79 | 267 | } else if ( task == AliQAv1::kDIGITS ) { |
04236e67 | 268 | fDigitsQAList = list ; |
269 | } | |
270 | } | |
271 | ||
9ac91920 | 272 | //____________________________________________________________________________ |
273 | void AliQADataMakerSim::ResetDetector(AliQAv1::TASKINDEX_t task) | |
274 | { | |
275 | // default reset that resets all the QA objects. | |
276 | // to be overloaded by detectors, if necessary | |
277 | ||
278 | TObjArray ** list = NULL ; | |
279 | if ( task == AliQAv1::kHITS ) { | |
280 | list = fHitsQAList ; | |
281 | } else if ( task == AliQAv1::kSDIGITS ) { | |
282 | list = fSDigitsQAList ; | |
283 | } else if ( task == AliQAv1::kDIGITS ) { | |
284 | list = fDigitsQAList ; | |
285 | } | |
286 | //list was not initialized, skip | |
287 | if (!list) | |
288 | return ; | |
289 | ||
290 | for (int spec = 0; spec < AliRecoParam::kNSpecies; spec++) { | |
291 | if (!AliQAv1::Instance()->IsEventSpecieSet(AliRecoParam::ConvertIndex(spec))) | |
292 | continue; | |
293 | TIter next(list[spec]) ; | |
294 | TH1 * histo = NULL ; | |
295 | while ( (histo = dynamic_cast<TH1*> (next())) ) { | |
296 | histo->Reset() ; | |
297 | } | |
298 | } | |
299 | } | |
300 | ||
04236e67 | 301 | //____________________________________________________________________________ |
930e6e3e | 302 | void AliQADataMakerSim::StartOfCycle(Int_t run) |
303 | { | |
304 | // Finishes a cycle of QA for all tasks | |
305 | Bool_t samecycle = kFALSE ; | |
4e25ac79 | 306 | StartOfCycle(AliQAv1::kHITS, run, samecycle) ; |
930e6e3e | 307 | samecycle = kTRUE ; |
4e25ac79 | 308 | StartOfCycle(AliQAv1::kSDIGITS, run, samecycle) ; |
309 | StartOfCycle(AliQAv1::kDIGITS, run, samecycle) ; | |
930e6e3e | 310 | } |
311 | ||
312 | //____________________________________________________________________________ | |
4e25ac79 | 313 | void AliQADataMakerSim::StartOfCycle(AliQAv1::TASKINDEX_t task, Int_t run, const Bool_t sameCycle) |
04236e67 | 314 | { |
315 | // Finishes a cycle of QA data acquistion | |
930e6e3e | 316 | if ( run > 0 ) |
317 | fRun = run ; | |
04236e67 | 318 | if ( !sameCycle || fCurrentCycle == -1) { |
319 | ResetCycle() ; | |
320 | if (fOutput) | |
321 | fOutput->Close() ; | |
4e25ac79 | 322 | fOutput = AliQAv1::GetQADataFile(GetName(), fRun) ; |
04236e67 | 323 | } |
324 | ||
5379c4a3 | 325 | AliDebug(AliQAv1::GetQADebugLevel(), Form(" Run %d Cycle %d task %s file %s", |
4e25ac79 | 326 | fRun, fCurrentCycle, AliQAv1::GetTaskName(task).Data(), fOutput->GetName() )) ; |
04236e67 | 327 | |
eca4fa66 | 328 | //fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; |
329 | // if (!fDetectorDir) | |
330 | // fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; | |
331 | // | |
332 | // TDirectory * subDir = fDetectorDir->GetDirectory(AliQAv1::GetTaskName(task)) ; | |
333 | // if (!subDir) | |
334 | // subDir = fDetectorDir->mkdir(AliQAv1::GetTaskName(task)) ; | |
335 | // | |
336 | // for ( Int_t index = AliRecoParam::kDefault ; index < AliRecoParam::kNSpecies ; index++ ) { | |
337 | // TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(index)) ; | |
338 | // if (!eventSpecieDir) | |
339 | // eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(index)) ; | |
340 | // TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQAv1::GetExpert()) ; | |
341 | // if (!expertDir) | |
342 | // expertDir = eventSpecieDir->mkdir(AliQAv1::GetExpert()) ; | |
343 | // } | |
04236e67 | 344 | StartOfDetectorCycle() ; |
345 | } |