]>
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), | |
42 | fDigitsQAList(0x0), | |
43 | fHitsQAList(0x0), | |
44 | fSDigitsQAList(0x0) | |
45 | { | |
46 | // ctor | |
47 | fDetectorDirName = GetName() ; | |
48 | } | |
49 | ||
50 | //____________________________________________________________________________ | |
51 | AliQADataMakerSim::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 | //____________________________________________________________________________ |
62 | AliQADataMakerSim::~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 | //__________________________________________________________________ |
89 | AliQADataMakerSim& AliQADataMakerSim::operator = (const AliQADataMakerSim& qadm ) | |
90 | { | |
91 | // Assignment operator. | |
92 | this->~AliQADataMakerSim(); | |
93 | new(this) AliQADataMakerSim(qadm); | |
94 | return *this; | |
95 | } | |
96 | ||
930e6e3e | 97 | //____________________________________________________________________________ |
98 | void AliQADataMakerSim::EndOfCycle() | |
99 | { | |
100 | // Finishes a cycle of QA for all tasks | |
101 | EndOfCycle(AliQA::kHITS) ; | |
102 | EndOfCycle(AliQA::kSDIGITS) ; | |
103 | EndOfCycle(AliQA::kDIGITS) ; | |
104 | ResetCycle() ; | |
105 | } | |
106 | ||
04236e67 | 107 | //____________________________________________________________________________ |
96d67a8d | 108 | void AliQADataMakerSim::EndOfCycle(AliQA::TASKINDEX_t task) |
04236e67 | 109 | { |
110 | // Finishes a cycle of QA data acquistion | |
57acd2d2 | 111 | TObjArray ** list = NULL ; |
04236e67 | 112 | |
113 | if ( task == AliQA::kHITS ) | |
114 | list = fHitsQAList ; | |
115 | else if ( task == AliQA::kSDIGITS ) | |
116 | list = fSDigitsQAList ; | |
117 | else if ( task == AliQA::kDIGITS ) | |
118 | list = fDigitsQAList ; | |
930e6e3e | 119 | |
120 | if ( ! list ) | |
121 | return ; | |
04236e67 | 122 | EndOfDetectorCycle(task, list) ; |
6294b9a7 | 123 | TDirectory * subDir = NULL ; |
124 | if (fDetectorDir) | |
125 | subDir = fDetectorDir->GetDirectory(AliQA::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()) ) { | |
6294b9a7 | 135 | if (!obj->TestBit(AliQA::GetExpertBit())) |
57acd2d2 | 136 | obj->Write() ; |
137 | } | |
138 | if (WriteExpert()) { | |
139 | TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQA::GetExpert()) ; | |
140 | if ( expertDir ) { | |
141 | expertDir->cd() ; | |
142 | next.Reset() ; | |
143 | while ( (obj = next()) ) { | |
144 | if (!obj->TestBit(AliQA::GetExpertBit())) | |
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 | //____________________________________________________________________________ | |
96d67a8d | 158 | void AliQADataMakerSim::Exec(AliQA::TASKINDEX_t task, TObject * data) |
04236e67 | 159 | { |
160 | // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs) | |
161 | ||
162 | if ( task == AliQA::kHITS ) { | |
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 | } | |
175 | } else if ( task == AliQA::kSDIGITS ) { | |
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 | } | |
188 | } else if ( task == AliQA::kDIGITS ) { | |
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 | //____________________________________________________________________________ | |
57acd2d2 | 205 | TObjArray ** AliQADataMakerSim::Init(AliQA::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 ; |
04236e67 | 212 | if ( task == AliQA::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) ; | |
217 | fHitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; | |
218 | } | |
63c6f8ae | 219 | InitHits() ; |
220 | } | |
04236e67 | 221 | rv = fHitsQAList ; |
222 | } else if ( task == AliQA::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) ; | |
227 | fSDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; | |
228 | } | |
229 | InitSDigits() ; | |
63c6f8ae | 230 | } |
04236e67 | 231 | rv = fSDigitsQAList ; |
232 | } else if ( task == AliQA::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) ; | |
237 | fDigitsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; | |
238 | } | |
63c6f8ae | 239 | InitDigits() ; |
240 | } | |
04236e67 | 241 | rv = fDigitsQAList ; |
242 | } | |
243 | ||
244 | return rv ; | |
245 | } | |
246 | ||
247 | //____________________________________________________________________________ | |
57acd2d2 | 248 | void AliQADataMakerSim::Init(AliQA::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 | ||
256 | if ( task == AliQA::kHITS ) { | |
257 | fHitsQAList = list ; | |
258 | } else if ( task == AliQA::kSDIGITS) { | |
259 | fSDigitsQAList = list ; | |
260 | } else if ( task == AliQA::kDIGITS ) { | |
261 | fDigitsQAList = list ; | |
262 | } | |
263 | } | |
264 | ||
265 | //____________________________________________________________________________ | |
930e6e3e | 266 | void AliQADataMakerSim::StartOfCycle(Int_t run) |
267 | { | |
268 | // Finishes a cycle of QA for all tasks | |
269 | Bool_t samecycle = kFALSE ; | |
270 | StartOfCycle(AliQA::kHITS, run, samecycle) ; | |
271 | samecycle = kTRUE ; | |
272 | StartOfCycle(AliQA::kSDIGITS, run, samecycle) ; | |
273 | StartOfCycle(AliQA::kDIGITS, run, samecycle) ; | |
274 | } | |
275 | ||
276 | //____________________________________________________________________________ | |
277 | void AliQADataMakerSim::StartOfCycle(AliQA::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() ; | |
930e6e3e | 286 | fOutput = AliQA::GetQADataFile(GetName(), fRun) ; |
04236e67 | 287 | } |
288 | ||
289 | AliInfo(Form(" Run %d Cycle %d task %s file %s", | |
290 | fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ; | |
291 | ||
292 | fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; | |
293 | if (!fDetectorDir) | |
294 | fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; | |
295 | ||
296 | TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ; | |
297 | if (!subDir) | |
298 | subDir = fDetectorDir->mkdir(AliQA::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)) ; | |
304 | TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQA::GetExpert()) ; | |
305 | if (!expertDir) | |
306 | expertDir = eventSpecieDir->mkdir(AliQA::GetExpert()) ; | |
307 | } | |
04236e67 | 308 | StartOfDetectorCycle() ; |
309 | } |