]>
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 * | |
940d8e5f | 10 | * copies and that both the copyright notice and this permission notifce * |
04236e67 | 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 for Reconstruction | |
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> |
57acd2d2 | 29 | #include <TNtupleD.h> |
fb6e511e | 30 | #include <TObjArray.h> |
04236e67 | 31 | |
32 | // --- Standard library --- | |
33 | ||
34 | // --- AliRoot header files --- | |
fb6e511e | 35 | #include "AliCDBPath.h" |
36 | #include "AliCDBEntry.h" | |
37 | #include "AliDetectorRecoParam.h" | |
38 | #include "AliCDBManager.h" | |
39 | ||
04236e67 | 40 | #include "AliLog.h" |
41 | #include "AliQADataMakerRec.h" | |
04236e67 | 42 | #include "AliESDEvent.h" |
43 | #include "AliRawReader.h" | |
44 | ||
45 | ClassImp(AliQADataMakerRec) | |
46 | ||
47 | //____________________________________________________________________________ | |
48 | AliQADataMakerRec::AliQADataMakerRec(const char * name, const char * title) : | |
49 | AliQADataMaker(name, title), | |
a2b64fbd | 50 | fESDsQAList(NULL), |
51 | fRawsQAList(NULL), | |
52 | fRecPointsQAList(NULL), | |
57acd2d2 | 53 | fCorrNt(NULL), |
a2b64fbd | 54 | fRecoParam(NULL) |
04236e67 | 55 | { |
56 | // ctor | |
57 | fDetectorDirName = GetName() ; | |
58 | } | |
59 | ||
60 | //____________________________________________________________________________ | |
61 | AliQADataMakerRec::AliQADataMakerRec(const AliQADataMakerRec& qadm) : | |
b8bd1ab8 | 62 | AliQADataMaker(qadm.GetName(), qadm.GetTitle()), |
63 | fESDsQAList(qadm.fESDsQAList), | |
64 | fRawsQAList(qadm.fRawsQAList), | |
65 | fRecPointsQAList(qadm.fRecPointsQAList), | |
57acd2d2 | 66 | fCorrNt(qadm.fCorrNt), |
a2b64fbd | 67 | fRecoParam(qadm.fRecoParam) |
04236e67 | 68 | { |
69 | //copy ctor | |
70 | SetName(qadm.GetName()) ; | |
71 | SetTitle(qadm.GetTitle()) ; | |
72 | fDetectorDirName = GetName() ; | |
73 | } | |
74 | ||
63c6f8ae | 75 | //____________________________________________________________________________ |
76 | AliQADataMakerRec::~AliQADataMakerRec() | |
77 | { | |
78 | //dtor: delete the TObjArray and thei content | |
7ff8385d | 79 | if ( fESDsQAList ) { |
57acd2d2 | 80 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { |
81 | if ( fESDsQAList[specie] ) { | |
82 | if ( fESDsQAList[specie]->IsOwner() ) | |
83 | fESDsQAList[specie]->Delete() ; | |
84 | } | |
85 | } | |
86 | delete[] fESDsQAList ; | |
7ff8385d | 87 | } |
88 | if ( fRawsQAList ) { | |
57acd2d2 | 89 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { |
90 | if ( fRawsQAList[specie] ) { | |
91 | if ( fRawsQAList[specie]->IsOwner() ) | |
92 | fRawsQAList[specie]->Delete() ; | |
93 | } | |
94 | } | |
95 | delete[] fRawsQAList ; | |
96 | } | |
7ff8385d | 97 | if ( fRecPointsQAList ) { |
57acd2d2 | 98 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { |
99 | if ( fRecPointsQAList[specie] ) { | |
100 | if ( fRecPointsQAList[specie]->IsOwner() ) | |
101 | fRecPointsQAList[specie]->Delete() ; | |
102 | } | |
103 | } | |
104 | delete[] fRecPointsQAList ; | |
7ff8385d | 105 | } |
63c6f8ae | 106 | } |
107 | ||
04236e67 | 108 | //__________________________________________________________________ |
109 | AliQADataMakerRec& AliQADataMakerRec::operator = (const AliQADataMakerRec& qadm ) | |
110 | { | |
111 | // Assignment operator. | |
112 | this->~AliQADataMakerRec(); | |
113 | new(this) AliQADataMakerRec(qadm); | |
114 | return *this; | |
115 | } | |
116 | ||
930e6e3e | 117 | //____________________________________________________________________________ |
118 | void AliQADataMakerRec::EndOfCycle() | |
119 | { | |
120 | // Finishes a cycle of QA for all the tasks | |
121 | EndOfCycle(AliQA::kRAWS) ; | |
122 | EndOfCycle(AliQA::kRECPOINTS) ; | |
123 | EndOfCycle(AliQA::kESDS) ; | |
124 | ResetCycle() ; | |
125 | } | |
126 | ||
04236e67 | 127 | //____________________________________________________________________________ |
92a357bf | 128 | void AliQADataMakerRec::EndOfCycle(AliQA::TASKINDEX_t task) |
04236e67 | 129 | { |
930e6e3e | 130 | // Finishes a cycle of QA |
04236e67 | 131 | |
57acd2d2 | 132 | TObjArray ** list = NULL ; |
04236e67 | 133 | |
134 | if ( task == AliQA::kRAWS ) | |
135 | list = fRawsQAList ; | |
136 | else if ( task == AliQA::kRECPOINTS ) | |
137 | list = fRecPointsQAList ; | |
138 | else if ( task == AliQA::kESDS ) | |
139 | list = fESDsQAList ; | |
7c002d48 | 140 | |
930e6e3e | 141 | |
57acd2d2 | 142 | if ( ! list && ! fCorrNt ) |
930e6e3e | 143 | return ; |
144 | //DefaultEndOfDetectorCycle(task) ; | |
0774e4a4 | 145 | EndOfDetectorCycle(task, list) ; |
a2b64fbd | 146 | TDirectory * subDir = NULL ; |
7c002d48 | 147 | if (fDetectorDir) |
148 | subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ; | |
45c5be2d | 149 | if ( subDir ) { |
eecc22a3 | 150 | subDir->cd() ; |
57acd2d2 | 151 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { |
152 | TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ; | |
153 | if (eventSpecieDir) { | |
154 | eventSpecieDir->cd() ; | |
155 | if (list[specie]) { | |
156 | TIter next(list[specie]) ; | |
157 | TObject * obj ; | |
750730d8 | 158 | while( (obj = next()) ) { |
159 | if (!obj->TestBit(AliQA::GetExpertBit())) | |
57acd2d2 | 160 | obj->Write() ; |
161 | } | |
162 | if (WriteExpert()) { | |
163 | TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQA::GetExpert()) ; | |
164 | if ( expertDir ) { // Write only if requested | |
165 | expertDir->cd() ; | |
166 | next.Reset() ; | |
167 | while( (obj = next()) ) { | |
168 | if (!obj->TestBit(AliQA::GetExpertBit())) | |
169 | continue ; | |
170 | obj->Write() ; | |
171 | } | |
172 | } | |
173 | } | |
174 | } | |
175 | if ( !fCorrNt ) | |
176 | continue ; | |
177 | if (fCorrNt[specie] && AliQA::GetDetIndex(GetName()) == AliQA::kCORR) { | |
178 | eventSpecieDir->cd() ; | |
179 | fCorrNt[specie]->Write() ; | |
b1af1125 | 180 | } |
6e65319c | 181 | } |
182 | } | |
a595ac34 | 183 | fOutput->Save() ; |
eecc22a3 | 184 | } |
04236e67 | 185 | } |
186 | ||
187 | //____________________________________________________________________________ | |
92a357bf | 188 | void AliQADataMakerRec::Exec(AliQA::TASKINDEX_t task, TObject * data) |
04236e67 | 189 | { |
190 | // creates the quality assurance data for the various tasks (Hits, SDigits, Digits, ESDs) | |
191 | ||
192 | if ( task == AliQA::kRAWS ) { | |
193 | AliDebug(1, "Processing Raws QA") ; | |
194 | AliRawReader * rawReader = dynamic_cast<AliRawReader *>(data) ; | |
195 | if (rawReader) | |
196 | MakeRaws(rawReader) ; | |
197 | else | |
930e6e3e | 198 | AliInfo("Raw data are not processed") ; |
04236e67 | 199 | } else if ( task == AliQA::kRECPOINTS ) { |
200 | AliDebug(1, "Processing RecPoints QA") ; | |
201 | TTree * tree = dynamic_cast<TTree *>(data) ; | |
202 | if (tree) { | |
203 | MakeRecPoints(tree) ; | |
204 | } else { | |
205 | AliWarning("data are not a TTree") ; | |
206 | } | |
207 | } else if ( task == AliQA::kESDS ) { | |
208 | AliDebug(1, "Processing ESDs QA") ; | |
209 | AliESDEvent * esd = dynamic_cast<AliESDEvent *>(data) ; | |
210 | if (esd) | |
211 | MakeESDs(esd) ; | |
212 | else | |
213 | AliError("Wrong type of esd container") ; | |
214 | } | |
215 | } | |
216 | ||
217 | //____________________________________________________________________________ | |
57acd2d2 | 218 | TObjArray ** AliQADataMakerRec::Init(AliQA::TASKINDEX_t task, Int_t cycles) |
04236e67 | 219 | { |
220 | // general intialisation | |
fb6e511e | 221 | InitRecoParams() ; |
57acd2d2 | 222 | TObjArray ** rv = NULL ; |
04236e67 | 223 | |
04236e67 | 224 | if (cycles > 0) |
225 | SetCycle(cycles) ; | |
226 | ||
227 | if ( task == AliQA::kRAWS ) { | |
63c6f8ae | 228 | if (! fRawsQAList ) { |
57acd2d2 | 229 | fRawsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; |
230 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { | |
231 | fRawsQAList[specie] = new TObjArray(100) ; | |
232 | fRawsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; | |
233 | } | |
63c6f8ae | 234 | InitRaws() ; |
235 | } | |
04236e67 | 236 | rv = fRawsQAList ; |
237 | } else if ( task == AliQA::kRECPOINTS ) { | |
63c6f8ae | 238 | if ( ! fRecPointsQAList ) { |
57acd2d2 | 239 | fRecPointsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; |
240 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { | |
241 | fRecPointsQAList[specie] = new TObjArray(100) ; | |
242 | fRecPointsQAList[specie]->SetName(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; | |
243 | } | |
244 | InitRecPoints() ; | |
63c6f8ae | 245 | } |
04236e67 | 246 | rv = fRecPointsQAList ; |
247 | } else if ( task == AliQA::kESDS ) { | |
63c6f8ae | 248 | if ( ! fESDsQAList ) { |
57acd2d2 | 249 | fESDsQAList = new TObjArray *[AliRecoParam::kNSpecies] ; |
250 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { | |
251 | fESDsQAList[specie] = new TObjArray(100) ; | |
252 | fESDsQAList[specie]->SetName(Form("%s_%s", GetName(), AliQA::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(specie))) ; | |
253 | } | |
63c6f8ae | 254 | InitESDs() ; |
255 | } | |
04236e67 | 256 | rv = fESDsQAList ; |
257 | } | |
04236e67 | 258 | return rv ; |
259 | } | |
260 | ||
261 | //____________________________________________________________________________ | |
57acd2d2 | 262 | void AliQADataMakerRec::Init(AliQA::TASKINDEX_t task, TObjArray ** list, Int_t run, Int_t cycles) |
04236e67 | 263 | { |
264 | // Intialisation by passing the list of QA data booked elsewhere | |
265 | ||
fb6e511e | 266 | InitRecoParams() ; |
267 | fRun = run ; | |
04236e67 | 268 | if (cycles > 0) |
269 | SetCycle(cycles) ; | |
270 | ||
271 | if ( task == AliQA::kRAWS ) { | |
272 | fRawsQAList = list ; | |
273 | } else if ( task == AliQA::kRECPOINTS ) { | |
274 | fRecPointsQAList = list ; | |
275 | } else if ( task == AliQA::kESDS ) { | |
276 | fESDsQAList = list ; | |
277 | } | |
278 | } | |
279 | ||
fb6e511e | 280 | //____________________________________________________________________________ |
281 | void AliQADataMakerRec::InitRecoParams() | |
282 | { | |
283 | if (!fRecoParam) { | |
284 | AliInfo(Form("Loading reconstruction parameter objects for detector %s", GetName())); | |
285 | AliCDBPath path(GetName(),"Calib","RecoParam"); | |
286 | AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath()); | |
287 | if(!entry) { | |
288 | fRecoParam = NULL ; | |
289 | AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",GetName())); | |
290 | } | |
291 | else { | |
292 | TObject * recoParamObj = entry->GetObject() ; | |
293 | if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) { | |
294 | // The detector has only onse set of reco parameters | |
295 | // Registering it in AliRecoParam | |
296 | AliInfo(Form("Single set of reconstruction parameters found for detector %s",GetName())); | |
297 | dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault(); | |
298 | fRecoParam = dynamic_cast<AliDetectorRecoParam*>(recoParamObj) ; | |
299 | } else { | |
300 | AliError(Form("No valid RecoParam object found in the OCDB for detector %s",GetName())); | |
301 | } | |
302 | } | |
303 | } | |
304 | } | |
305 | ||
04236e67 | 306 | //____________________________________________________________________________ |
930e6e3e | 307 | void AliQADataMakerRec::StartOfCycle(Int_t run) |
308 | { | |
309 | // Finishes a cycle of QA for all the tasks | |
310 | Bool_t samecycle = kFALSE ; | |
311 | StartOfCycle(AliQA::kRAWS, run, samecycle) ; | |
312 | samecycle = kTRUE ; | |
313 | StartOfCycle(AliQA::kRECPOINTS, run, samecycle) ; | |
314 | StartOfCycle(AliQA::kESDS, run, samecycle) ; | |
315 | } | |
316 | ||
317 | //____________________________________________________________________________ | |
318 | void AliQADataMakerRec::StartOfCycle(AliQA::TASKINDEX_t task, Int_t run, const Bool_t sameCycle) | |
04236e67 | 319 | { |
320 | // Finishes a cycle of QA data acquistion | |
930e6e3e | 321 | if ( run > 0 ) |
322 | fRun = run ; | |
04236e67 | 323 | if ( !sameCycle || fCurrentCycle == -1) { |
324 | ResetCycle() ; | |
325 | if (fOutput) | |
326 | fOutput->Close() ; | |
930e6e3e | 327 | fOutput = AliQA::GetQADataFile(GetName(), fRun) ; |
04236e67 | 328 | } |
7c002d48 | 329 | AliInfo(Form(" Run %d Cycle %d task %s file %s", |
04236e67 | 330 | fRun, fCurrentCycle, AliQA::GetTaskName(task).Data(), fOutput->GetName() )) ; |
331 | ||
332 | fDetectorDir = fOutput->GetDirectory(GetDetectorDirName()) ; | |
333 | if (!fDetectorDir) | |
334 | fDetectorDir = fOutput->mkdir(GetDetectorDirName()) ; | |
335 | ||
336 | TDirectory * subDir = fDetectorDir->GetDirectory(AliQA::GetTaskName(task)) ; | |
337 | if (!subDir) | |
338 | subDir = fDetectorDir->mkdir(AliQA::GetTaskName(task)) ; | |
6e65319c | 339 | |
57acd2d2 | 340 | for ( Int_t specie = AliRecoParam::kDefault ; specie < AliRecoParam::kNSpecies ; specie++ ) { |
341 | TDirectory * eventSpecieDir = subDir->GetDirectory(AliRecoParam::GetEventSpecieName(specie)) ; | |
342 | if (!eventSpecieDir) | |
343 | eventSpecieDir = subDir->mkdir(AliRecoParam::GetEventSpecieName(specie)) ; | |
344 | TDirectory * expertDir = eventSpecieDir->GetDirectory(AliQA::GetExpert()) ; | |
345 | if (!expertDir) | |
346 | expertDir = eventSpecieDir->mkdir(AliQA::GetExpert()) ; | |
347 | } | |
04236e67 | 348 | StartOfDetectorCycle() ; |
349 | } |