]>
Commit | Line | Data |
---|---|---|
312e6f8d | 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 | /* $Id$ */ | |
202374b1 | 17 | /////////////////////////////////////////////////////////////////////////////// |
18 | // // | |
19 | // class for running the QA makers // | |
20 | // // | |
21 | // AliQADataMakerSteer qas; // | |
22 | // qas.Run(AliQA::kRAWS, rawROOTFileName); // | |
23 | // qas.Run(AliQA::kHITS); // | |
24 | // qas.Run(AliQA::kSDIGITS); // | |
25 | // qas.Run(AliQA::kDIGITS); // | |
26 | // qas.Run(AliQA::kRECPOINTS); // | |
27 | // qas.Run(AliQA::kESDS); // | |
28 | // // | |
29 | /////////////////////////////////////////////////////////////////////////////// | |
312e6f8d | 30 | |
4edbc5bc | 31 | #include <TKey.h> |
312e6f8d | 32 | #include <TFile.h> |
567d83d9 | 33 | #include <TFileMerger.h> |
312e6f8d | 34 | #include <TPluginManager.h> |
35 | #include <TROOT.h> | |
36 | #include <TString.h> | |
37 | #include <TSystem.h> | |
38 | ||
4edbc5bc | 39 | #include "AliCDBManager.h" |
40 | #include "AliCDBEntry.h" | |
41 | #include "AliCDBId.h" | |
42 | #include "AliCDBMetaData.h" | |
940d8e5f | 43 | #include "AliCodeTimer.h" |
a2b64fbd | 44 | #include "AliCorrQADataMakerRec.h" |
0233bebf | 45 | #include "AliDetectorRecoParam.h" |
312e6f8d | 46 | #include "AliESDEvent.h" |
f451171e | 47 | #include "AliGeomManager.h" |
30bbd491 | 48 | #include "AliGlobalQADataMaker.h" |
6441b07a | 49 | #include "AliHeader.h" |
312e6f8d | 50 | #include "AliLog.h" |
007fcebb | 51 | #include "AliModule.h" |
312e6f8d | 52 | #include "AliQA.h" |
04236e67 | 53 | #include "AliQADataMakerRec.h" |
54 | #include "AliQADataMakerSim.h" | |
312e6f8d | 55 | #include "AliQADataMakerSteer.h" |
4ecde5fc | 56 | #include "AliRawReaderDate.h" |
57 | #include "AliRawReaderFile.h" | |
312e6f8d | 58 | #include "AliRawReaderRoot.h" |
59 | #include "AliRun.h" | |
60 | #include "AliRunLoader.h" | |
61 | ||
62 | ClassImp(AliQADataMakerSteer) | |
63 | ||
64 | //_____________________________________________________________________________ | |
30bbd491 | 65 | AliQADataMakerSteer::AliQADataMakerSteer(char * mode, const char* gAliceFilename, const char * name, const char * title) : |
312e6f8d | 66 | TNamed(name, title), |
018c2b09 | 67 | fCurrentEvent(0), |
c65c502a | 68 | fCycleSame(kFALSE), |
fff5167b | 69 | fDetectors("ALL"), |
70 | fDetectorsW("ALL"), | |
312e6f8d | 71 | fESD(NULL), |
72 | fESDTree(NULL), | |
312e6f8d | 73 | fGAliceFileName(gAliceFilename), |
e30aef00 | 74 | fFirstEvent(0), |
30bbd491 | 75 | fMaxEvents(0), |
76 | fMode(mode), | |
774ac967 | 77 | fNumberOfEvents(999999), |
940d8e5f | 78 | fRecoParam(), |
30bbd491 | 79 | fRunNumber(0), |
312e6f8d | 80 | fRawReader(NULL), |
6441b07a | 81 | fRawReaderDelete(kTRUE), |
940d8e5f | 82 | fRunLoader(NULL), |
a2b64fbd | 83 | fTasks("") |
312e6f8d | 84 | { |
85 | // default ctor | |
f0c6fb4b | 86 | fMaxEvents = fNumberOfEvents ; |
312e6f8d | 87 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
4d52736b | 88 | if (IsSelected(AliQA::GetDetName(iDet))) { |
89 | fLoader[iDet] = NULL ; | |
90 | fQADataMaker[iDet] = NULL ; | |
91 | fQACycles[iDet] = 999999 ; | |
252f8aa8 | 92 | fQAWriteExpert[iDet] = kFALSE ; |
4d52736b | 93 | } |
312e6f8d | 94 | } |
95 | } | |
96 | ||
97 | //_____________________________________________________________________________ | |
98 | AliQADataMakerSteer::AliQADataMakerSteer(const AliQADataMakerSteer & qas) : | |
99 | TNamed(qas), | |
018c2b09 | 100 | fCurrentEvent(qas.fCurrentEvent), |
c65c502a | 101 | fCycleSame(kFALSE), |
fff5167b | 102 | fDetectors(qas.fDetectors), |
103 | fDetectorsW(qas.fDetectorsW), | |
312e6f8d | 104 | fESD(NULL), |
105 | fESDTree(NULL), | |
312e6f8d | 106 | fGAliceFileName(qas.fGAliceFileName), |
e30aef00 | 107 | fFirstEvent(qas.fFirstEvent), |
30bbd491 | 108 | fMaxEvents(qas.fMaxEvents), |
109 | fMode(qas.fMode), | |
312e6f8d | 110 | fNumberOfEvents(qas.fNumberOfEvents), |
940d8e5f | 111 | fRecoParam(), |
112 | fRunNumber(qas.fRunNumber), | |
312e6f8d | 113 | fRawReader(NULL), |
6441b07a | 114 | fRawReaderDelete(kTRUE), |
940d8e5f | 115 | fRunLoader(NULL), |
a2b64fbd | 116 | fTasks(qas.fTasks) |
312e6f8d | 117 | { |
118 | // cpy ctor | |
119 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
252f8aa8 | 120 | fLoader[iDet] = qas.fLoader[iDet] ; |
121 | fQADataMaker[iDet] = qas.fQADataMaker[iDet] ; | |
122 | fQACycles[iDet] = qas.fQACycles[iDet] ; | |
123 | fQAWriteExpert[iDet] = qas.fQAWriteExpert[iDet] ; | |
312e6f8d | 124 | } |
125 | } | |
126 | ||
127 | //_____________________________________________________________________________ | |
128 | AliQADataMakerSteer & AliQADataMakerSteer::operator = (const AliQADataMakerSteer & qas) | |
129 | { | |
130 | // assignment operator | |
131 | this->~AliQADataMakerSteer() ; | |
132 | new(this) AliQADataMakerSteer(qas) ; | |
133 | return *this ; | |
134 | } | |
135 | ||
136 | //_____________________________________________________________________________ | |
137 | AliQADataMakerSteer::~AliQADataMakerSteer() | |
138 | { | |
139 | // dtor | |
57e8b77b | 140 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
141 | if (IsSelected(AliQA::GetDetName(iDet))) { | |
4d52736b | 142 | fLoader[iDet] = NULL; |
143 | if (fQADataMaker[iDet]) { | |
144 | (fQADataMaker[iDet])->Finish() ; | |
fa18368b | 145 | delete fQADataMaker[iDet] ; |
4d52736b | 146 | } |
57e8b77b | 147 | } |
148 | } | |
57e8b77b | 149 | if (fRawReaderDelete) { |
150 | fRunLoader = NULL ; | |
151 | delete fRawReader ; | |
152 | fRawReader = NULL ; | |
153 | } | |
312e6f8d | 154 | } |
155 | ||
4d52736b | 156 | //_____________________________________________________________________________ |
30bbd491 | 157 | Bool_t AliQADataMakerSteer::DoIt(const AliQA::TASKINDEX_t taskIndex) |
4d52736b | 158 | { |
159 | // Runs all the QA data Maker for every detector | |
95932286 | 160 | |
4d52736b | 161 | Bool_t rv = kFALSE ; |
4d52736b | 162 | // Fill QA data in event loop |
95932286 | 163 | for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) { |
018c2b09 | 164 | fCurrentEvent++ ; |
4d52736b | 165 | // Get the event |
a6f6970e | 166 | if ( iEvent%10 == 0 ) |
167 | AliInfo(Form("processing event %d", iEvent)); | |
4d52736b | 168 | if ( taskIndex == AliQA::kRAWS ) { |
169 | if ( !fRawReader->NextEvent() ) | |
170 | break ; | |
171 | } else if ( taskIndex == AliQA::kESDS ) { | |
774ac967 | 172 | if ( fESDTree->GetEntry(iEvent) == 0 ) |
173 | break ; | |
4d52736b | 174 | } else { |
774ac967 | 175 | if ( fRunLoader->GetEvent(iEvent) != 0 ) |
176 | break ; | |
4d52736b | 177 | } |
56f4f5f4 | 178 | // loop over active loaders |
30bbd491 | 179 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
180 | if (IsSelected(AliQA::GetDetName(iDet))) { | |
181 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; | |
d15bbee6 | 182 | if (!qadm) continue; // This detector doesn't have any QA (for example, HLT) |
30bbd491 | 183 | if ( qadm->IsCycleDone() ) { |
930e6e3e | 184 | qadm->EndOfCycle(taskIndex) ; |
30bbd491 | 185 | } |
c5595529 | 186 | TTree * data = NULL ; |
30bbd491 | 187 | AliLoader* loader = GetLoader(qadm->GetUniqueID()); |
188 | switch (taskIndex) { | |
940d8e5f | 189 | case AliQA::kNULLTASKINDEX : |
190 | break ; | |
30bbd491 | 191 | case AliQA::kRAWS : |
192 | qadm->Exec(taskIndex, fRawReader) ; | |
193 | break ; | |
194 | case AliQA::kHITS : | |
c5595529 | 195 | if( loader ) { |
196 | loader->LoadHits() ; | |
197 | data = loader->TreeH() ; | |
198 | if ( ! data ) { | |
199 | AliWarning(Form(" Hit Tree not found for %s", AliQA::GetDetName(iDet))) ; | |
200 | break ; | |
201 | } | |
202 | } | |
203 | qadm->Exec(taskIndex, data) ; | |
30bbd491 | 204 | break ; |
205 | case AliQA::kSDIGITS : | |
c5595529 | 206 | if( loader ) { |
207 | loader->LoadSDigits() ; | |
208 | data = loader->TreeS() ; | |
209 | if ( ! data ) { | |
210 | AliWarning(Form(" SDigit Tree not found for %s", AliQA::GetDetName(iDet))) ; | |
211 | break ; | |
212 | } | |
213 | } | |
214 | qadm->Exec(taskIndex, data) ; | |
30bbd491 | 215 | break; |
216 | case AliQA::kDIGITS : | |
c5595529 | 217 | if( loader ) { |
218 | loader->LoadDigits() ; | |
219 | data = loader->TreeD() ; | |
220 | if ( ! data ) { | |
221 | AliWarning(Form(" Digit Tree not found for %s", AliQA::GetDetName(iDet))) ; | |
222 | break ; | |
223 | } | |
224 | } | |
225 | qadm->Exec(taskIndex, data) ; | |
30bbd491 | 226 | break; |
227 | case AliQA::kRECPOINTS : | |
c5595529 | 228 | if( loader ) { |
229 | loader->LoadRecPoints() ; | |
230 | data = loader->TreeR() ; | |
231 | if (!data) { | |
232 | AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ; | |
233 | break ; | |
234 | } | |
235 | } | |
236 | qadm->Exec(taskIndex, data) ; | |
237 | break; | |
30bbd491 | 238 | case AliQA::kTRACKSEGMENTS : |
239 | break; | |
240 | case AliQA::kRECPARTICLES : | |
241 | break; | |
242 | case AliQA::kESDS : | |
243 | qadm->Exec(taskIndex, fESD) ; | |
244 | break; | |
245 | case AliQA::kNTASKINDEX : | |
246 | break; | |
247 | } //task switch | |
248 | } | |
4d52736b | 249 | } // detector loop |
930e6e3e | 250 | Increment() ; |
4d52736b | 251 | } // event loop |
30bbd491 | 252 | // Save QA data for all detectors |
253 | rv = Finish(taskIndex) ; | |
54b7165d | 254 | |
255 | if ( taskIndex == AliQA::kRAWS ) | |
256 | fRawReader->RewindEvents() ; | |
fff5167b | 257 | |
4d52736b | 258 | return rv ; |
259 | } | |
260 | ||
4edbc5bc | 261 | //_____________________________________________________________________________ |
30bbd491 | 262 | Bool_t AliQADataMakerSteer::Finish(const AliQA::TASKINDEX_t taskIndex) |
4edbc5bc | 263 | { |
264 | // write output to file for all detectors | |
30bbd491 | 265 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
266 | if (IsSelected(AliQA::GetDetName(iDet))) { | |
267 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; | |
d15bbee6 | 268 | if (qadm) qadm->EndOfCycle(taskIndex) ; |
30bbd491 | 269 | } |
270 | } | |
4edbc5bc | 271 | return kTRUE ; |
272 | } | |
273 | ||
274 | //_____________________________________________________________________________ | |
96d67a8d | 275 | TObjArray * AliQADataMakerSteer::GetFromOCDB(AliQA::DETECTORINDEX_t det, AliQA::TASKINDEX_t task, const char * year) const |
4edbc5bc | 276 | { |
277 | // Retrieve the list of QA data for a given detector and a given task | |
f73f556a | 278 | TObjArray * rv = NULL ; |
605cb8bb | 279 | if ( !strlen(AliQA::GetQARefStorage()) ) { |
f73f556a | 280 | AliError("No storage defined, use AliQA::SetQARefStorage") ; |
281 | return NULL ; | |
282 | } | |
4edbc5bc | 283 | AliCDBManager* man = AliCDBManager::Instance() ; |
f73f556a | 284 | if ( ! man->IsDefaultStorageSet() ) { |
11032e1d | 285 | TString tmp(AliQA::GetQARefDefaultStorage()) ; |
286 | tmp.Append(year) ; | |
287 | tmp.Append("/") ; | |
288 | man->SetDefaultStorage(tmp.Data()) ; | |
96d67a8d | 289 | man->SetSpecificStorage(Form("%s/*", AliQA::GetQAName()), AliQA::GetQARefStorage()) ; |
f73f556a | 290 | } |
614a7f99 | 291 | TString detOCDBDir(Form("%s/%s/%s", AliQA::GetQAName(), AliQA::GetDetName((Int_t)det), AliQA::GetRefOCDBDirName())) ; |
292 | AliInfo(Form("Retrieving reference data from %s/%s for %s", AliQA::GetQARefStorage(), detOCDBDir.Data(), AliQA::GetTaskName(task).Data())) ; | |
293 | AliCDBEntry* entry = man->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number | |
4edbc5bc | 294 | TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ; |
295 | if ( listDetQAD ) | |
f73f556a | 296 | rv = dynamic_cast<TObjArray *>(listDetQAD->FindObject(AliQA::GetTaskName(task))) ; |
4edbc5bc | 297 | return rv ; |
298 | } | |
299 | ||
312e6f8d | 300 | //_____________________________________________________________________________ |
301 | AliLoader * AliQADataMakerSteer::GetLoader(Int_t iDet) | |
302 | { | |
303 | // get the loader for a detector | |
56f4f5f4 | 304 | |
c5595529 | 305 | if ( !fRunLoader || iDet == AliQA::kCORR) |
56f4f5f4 | 306 | return NULL ; |
312e6f8d | 307 | |
308 | TString detName = AliQA::GetDetName(iDet) ; | |
309 | fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader"); | |
310 | if (fLoader[iDet]) | |
311 | return fLoader[iDet] ; | |
312 | ||
313 | // load the QA data maker object | |
314 | TPluginManager* pluginManager = gROOT->GetPluginManager() ; | |
315 | TString loaderName = "Ali" + detName + "Loader" ; | |
316 | ||
317 | AliLoader * loader = NULL ; | |
318 | // first check if a plugin is defined for the quality assurance data maker | |
319 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ; | |
320 | // if not, add a plugin for it | |
321 | if (!pluginHandler) { | |
322 | AliDebug(1, Form("defining plugin for %s", loaderName.Data())) ; | |
323 | TString libs = gSystem->GetLibraries() ; | |
324 | if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) { | |
325 | pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ; | |
326 | } else { | |
327 | pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ; | |
328 | } | |
329 | pluginHandler = pluginManager->FindHandler("AliLoader", detName) ; | |
330 | } | |
331 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
332 | loader = (AliLoader *) pluginHandler->ExecPlugin(0) ; | |
333 | } | |
334 | if (loader) | |
335 | fLoader[iDet] = loader ; | |
336 | return loader ; | |
337 | } | |
338 | ||
339 | //_____________________________________________________________________________ | |
30bbd491 | 340 | AliQADataMaker * AliQADataMakerSteer::GetQADataMaker(const Int_t iDet) |
312e6f8d | 341 | { |
342 | // get the quality assurance data maker for a detector | |
343 | ||
344 | if (fQADataMaker[iDet]) | |
345 | return fQADataMaker[iDet] ; | |
346 | ||
347 | AliQADataMaker * qadm = NULL ; | |
348 | ||
30bbd491 | 349 | if (iDet == AliQA::kGLOBAL) { //Global QA |
350 | qadm = new AliGlobalQADataMaker(); | |
7c37c363 | 351 | qadm->SetName(AliQA::GetDetName(iDet)); |
352 | qadm->SetUniqueID(iDet); | |
30bbd491 | 353 | fQADataMaker[iDet] = qadm; |
354 | return qadm; | |
355 | } | |
356 | ||
a2b64fbd | 357 | if (iDet == AliQA::kCORR) { //the data maker for correlations among detectors |
358 | qadm = new AliCorrQADataMakerRec(fQADataMaker) ; | |
359 | qadm->SetName(AliQA::GetDetName(iDet)); | |
360 | qadm->SetUniqueID(iDet); | |
361 | fQADataMaker[iDet] = qadm; | |
362 | return qadm; | |
363 | } | |
364 | ||
30bbd491 | 365 | // load the QA data maker object |
366 | TPluginManager* pluginManager = gROOT->GetPluginManager() ; | |
367 | TString detName = AliQA::GetDetName(iDet) ; | |
368 | TString tmp(fMode) ; | |
369 | if (tmp.Contains("sim")) | |
370 | tmp.ReplaceAll("s", "S") ; | |
371 | else if (tmp.Contains("rec")) | |
372 | tmp.ReplaceAll("r", "R") ; | |
373 | ||
374 | TString qadmName = "Ali" + detName + "QADataMaker" + tmp ; | |
375 | ||
376 | // first check if a plugin is defined for the quality assurance data maker | |
377 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ; | |
378 | // if not, add a plugin for it | |
379 | if (!pluginHandler) { | |
380 | AliDebug(1, Form("defining plugin for %s", qadmName.Data())) ; | |
381 | TString libs = gSystem->GetLibraries() ; | |
382 | if (libs.Contains("lib" + detName + fMode + ".so") || (gSystem->Load("lib" + detName + fMode + ".so") >= 0)) { | |
383 | pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ; | |
384 | } else { | |
385 | pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ; | |
312e6f8d | 386 | } |
30bbd491 | 387 | pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ; |
388 | } | |
389 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
390 | qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ; | |
312e6f8d | 391 | } |
940d8e5f | 392 | if (qadm) { |
940d8e5f | 393 | qadm->SetName(AliQA::GetDetName(iDet)); |
394 | qadm->SetUniqueID(iDet); | |
7c37c363 | 395 | fQADataMaker[iDet] = qadm ; |
940d8e5f | 396 | } |
397 | ||
30bbd491 | 398 | return qadm ; |
312e6f8d | 399 | } |
400 | ||
940d8e5f | 401 | //_____________________________________________________________________________ |
402 | void AliQADataMakerSteer::EndOfCycle(TObjArray * detArray) | |
403 | { | |
404 | // End of cycle QADataMakers | |
405 | ||
406 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { | |
407 | if (IsSelected(AliQA::GetDetName(iDet))) { | |
408 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; | |
409 | if (!qadm) | |
410 | continue ; | |
411 | // skip non active detectors | |
412 | if (detArray) { | |
413 | AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ; | |
414 | if (!det || !det->IsActive()) | |
415 | continue ; | |
416 | } | |
417 | for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) { | |
418 | if ( fTasks.Contains(Form("%d", taskIndex)) ) | |
419 | qadm->EndOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex))) ; | |
420 | } | |
421 | qadm->Finish(); | |
422 | } | |
423 | } | |
424 | } | |
425 | ||
930e6e3e | 426 | //_____________________________________________________________________________ |
427 | void AliQADataMakerSteer::Increment() | |
428 | { | |
429 | // Increments the cycle counter for all QA Data Makers | |
430 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { | |
431 | if (IsSelected(AliQA::GetDetName(iDet))) { | |
432 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; | |
433 | if (qadm) | |
434 | qadm->Increment() ; | |
435 | } | |
436 | } | |
437 | } | |
438 | ||
312e6f8d | 439 | //_____________________________________________________________________________ |
30bbd491 | 440 | Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX_t taskIndex, const char * input ) |
312e6f8d | 441 | { |
442 | // Initialize the event source and QA data makers | |
443 | ||
194bc923 | 444 | //fTasks = AliQA::GetTaskName(taskIndex) ; |
940d8e5f | 445 | |
6441b07a | 446 | if (taskIndex == AliQA::kRAWS) { |
447 | if (!fRawReader) { | |
e64fcb90 | 448 | fRawReader = AliRawReader::Create(input); |
4ecde5fc | 449 | } |
940d8e5f | 450 | if ( ! fRawReader ) |
312e6f8d | 451 | return kFALSE ; |
fff5167b | 452 | fRawReaderDelete = kTRUE ; |
312e6f8d | 453 | fRawReader->NextEvent() ; |
454 | fRunNumber = fRawReader->GetRunNumber() ; | |
04236e67 | 455 | AliCDBManager::Instance()->SetRun(fRunNumber) ; |
312e6f8d | 456 | fRawReader->RewindEvents(); |
457 | fNumberOfEvents = 999999 ; | |
f0c6fb4b | 458 | if ( fMaxEvents < 0 ) |
459 | fMaxEvents = fNumberOfEvents ; | |
460 | } else if (taskIndex == AliQA::kESDS) { | |
940d8e5f | 461 | fTasks = AliQA::GetTaskName(AliQA::kESDS) ; |
ad265f3e | 462 | if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists |
463 | TFile * esdFile = TFile::Open("AliESDs.root") ; | |
464 | fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ; | |
04236e67 | 465 | if ( !fESDTree ) { |
466 | AliError("esdTree not found") ; | |
467 | return kFALSE ; | |
468 | } else { | |
469 | fESD = new AliESDEvent() ; | |
470 | fESD->ReadFromTree(fESDTree) ; | |
471 | fESDTree->GetEntry(0) ; | |
472 | fRunNumber = fESD->GetRunNumber() ; | |
473 | fNumberOfEvents = fESDTree->GetEntries() ; | |
f0c6fb4b | 474 | if ( fMaxEvents < 0 ) |
475 | fMaxEvents = fNumberOfEvents ; | |
04236e67 | 476 | } |
ad265f3e | 477 | } else { |
478 | AliError("AliESDs.root not found") ; | |
479 | return kFALSE ; | |
480 | } | |
b37ee1e8 | 481 | } else { |
774ac967 | 482 | if ( !InitRunLoader() ) { |
483 | AliWarning("No Run Loader not found") ; | |
312e6f8d | 484 | } else { |
312e6f8d | 485 | fNumberOfEvents = fRunLoader->GetNumberOfEvents() ; |
f0c6fb4b | 486 | if ( fMaxEvents < 0 ) |
487 | fMaxEvents = fNumberOfEvents ; | |
312e6f8d | 488 | } |
ad265f3e | 489 | } |
fff5167b | 490 | |
56f4f5f4 | 491 | // Get Detectors |
492 | TObjArray* detArray = NULL ; | |
493 | if (fRunLoader) // check if RunLoader exists | |
b37ee1e8 | 494 | if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root |
56f4f5f4 | 495 | detArray = fRunLoader->GetAliRun()->Detectors() ; |
b37ee1e8 | 496 | fRunNumber = fRunLoader->GetHeader()->GetRun() ; |
497 | } | |
30bbd491 | 498 | |
499 | // Initialize all QA data makers for all detectors | |
500 | fRunNumber = AliCDBManager::Instance()->GetRun() ; | |
501 | if ( ! AliGeomManager::GetGeometry() ) | |
502 | AliGeomManager::LoadGeometry() ; | |
503 | ||
930e6e3e | 504 | InitQADataMaker(fRunNumber, fRecoParam, detArray) ; //, fCycleSame, kTRUE, detArray) ; |
940d8e5f | 505 | return kTRUE ; |
506 | } | |
507 | ||
508 | //_____________________________________________________________________________ | |
930e6e3e | 509 | void AliQADataMakerSteer::InitQADataMaker(UInt_t run, const AliRecoParam & par, TObjArray * detArray) |
940d8e5f | 510 | { |
511 | // Initializes The QADataMaker for all active detectors and for all active tasks | |
512 | ||
56f4f5f4 | 513 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
4d52736b | 514 | if (IsSelected(AliQA::GetDetName(iDet))) { |
30bbd491 | 515 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; |
252f8aa8 | 516 | if (fQAWriteExpert[iDet]) |
517 | qadm->SetWriteExpert() ; | |
4d52736b | 518 | if (!qadm) { |
fff5167b | 519 | AliError(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ; |
520 | fDetectorsW.ReplaceAll(AliQA::GetDetName(iDet), "") ; | |
4d52736b | 521 | } else { |
fff5167b | 522 | AliDebug(1, Form("Data Maker found for %s", qadm->GetName())) ; |
56f4f5f4 | 523 | // skip non active detectors |
524 | if (detArray) { | |
525 | AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ; | |
526 | if (!det || !det->IsActive()) | |
527 | continue ; | |
528 | } | |
940d8e5f | 529 | // Set default reco params |
530 | qadm->SetRecoParam(par.GetDetRecoParam(iDet)); | |
930e6e3e | 531 | Bool_t sameCycle = kFALSE ; |
940d8e5f | 532 | for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) { |
533 | if ( fTasks.Contains(Form("%d", taskIndex)) ) { | |
930e6e3e | 534 | qadm->StartOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), run, sameCycle) ; |
535 | qadm->Init(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ; | |
536 | sameCycle = kTRUE ; | |
940d8e5f | 537 | } |
538 | } | |
4d52736b | 539 | } |
312e6f8d | 540 | } |
940d8e5f | 541 | } |
312e6f8d | 542 | } |
543 | ||
a2b64fbd | 544 | |
312e6f8d | 545 | //_____________________________________________________________________________ |
546 | Bool_t AliQADataMakerSteer::InitRunLoader() | |
547 | { | |
548 | // get or create the run loader | |
549 | if (fRunLoader) { | |
c65c502a | 550 | fCycleSame = kTRUE ; |
e4a998ed | 551 | } else { |
552 | if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists | |
553 | // load all base libraries to get the loader classes | |
554 | TString libs = gSystem->GetLibraries() ; | |
555 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
556 | if (!IsSelected(AliQA::GetDetName(iDet))) | |
557 | continue ; | |
558 | TString detName = AliQA::GetDetName(iDet) ; | |
559 | if (detName == "HLT") | |
560 | continue; | |
561 | if (libs.Contains("lib" + detName + "base.so")) | |
562 | continue; | |
563 | gSystem->Load("lib" + detName + "base.so"); | |
564 | } | |
565 | fRunLoader = AliRunLoader::Open(fGAliceFileName.Data()); | |
566 | if (!fRunLoader) { | |
567 | AliError(Form("no run loader found in file %s", fGAliceFileName.Data())); | |
568 | return kFALSE; | |
569 | } | |
570 | fRunLoader->CdGAFile(); | |
571 | if (fRunLoader->LoadgAlice() == 0) { | |
572 | gAlice = fRunLoader->GetAliRun(); | |
573 | } | |
574 | ||
575 | if (!gAlice) { | |
576 | AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data())); | |
577 | return kFALSE; | |
578 | } | |
4d52736b | 579 | |
e4a998ed | 580 | } else { // galice.root does not exist |
581 | AliError(Form("the file %s does not exist", fGAliceFileName.Data())); | |
312e6f8d | 582 | return kFALSE; |
583 | } | |
e4a998ed | 584 | } |
312e6f8d | 585 | |
e4a998ed | 586 | if (!fRunNumber) { |
587 | fRunLoader->LoadHeader(); | |
588 | fRunNumber = fRunLoader->GetHeader()->GetRun() ; | |
589 | } | |
590 | return kTRUE; | |
312e6f8d | 591 | } |
592 | ||
04236e67 | 593 | //_____________________________________________________________________________ |
594 | Bool_t AliQADataMakerSteer::IsSelected(const char * det) | |
595 | { | |
596 | // check whether detName is contained in detectors | |
597 | // if yes, it is removed from detectors | |
598 | ||
56f4f5f4 | 599 | Bool_t rv = kFALSE; |
04236e67 | 600 | const TString detName(det) ; |
a2b64fbd | 601 | // always activates Correlation |
602 | if ( detName.Contains(AliQA::GetDetName(AliQA::kCORR))) { | |
603 | rv = kTRUE ; | |
604 | } else { | |
605 | // check if all detectors are selected | |
606 | if (fDetectors.Contains("ALL")) { | |
607 | fDetectors = "ALL"; | |
608 | rv = kTRUE; | |
609 | } else if ((fDetectors.CompareTo(detName) == 0) || | |
610 | fDetectors.BeginsWith(detName+" ") || | |
611 | fDetectors.EndsWith(" "+detName) || | |
612 | fDetectors.Contains(" "+detName+" ")) { | |
613 | rv = kTRUE; | |
614 | } | |
615 | } | |
04236e67 | 616 | return rv ; |
617 | } | |
618 | ||
312e6f8d | 619 | //_____________________________________________________________________________ |
4edbc5bc | 620 | Bool_t AliQADataMakerSteer::Merge(const Int_t runNumber) const |
f5464b75 | 621 | { |
622 | // Merge data from all the cycles from all detectors in one single file per run | |
623 | // Merge the QA results from all the data chunks in one run | |
624 | Bool_t rv = MergeData(runNumber) ; | |
625 | rv *= MergeResults(runNumber) ; | |
626 | return rv ; | |
627 | } | |
628 | ||
629 | ||
630 | //_____________________________________________________________________________ | |
631 | Bool_t AliQADataMakerSteer::MergeData(const Int_t runNumber) const | |
315bba70 | 632 | { |
567d83d9 | 633 | // Merge all the cycles from all detectors in one single file per run |
614a7f99 | 634 | TString cmd ; |
f5464b75 | 635 | if (runNumber == -1) |
147c1c84 | 636 | cmd = Form(".! ls *%s*.%d.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ; |
f5464b75 | 637 | else |
147c1c84 | 638 | cmd = Form(".! ls *%s*.*.root > tempo.txt", AliQA::GetQADataFileName()) ; |
614a7f99 | 639 | gROOT->ProcessLine(cmd.Data()) ; |
567d83d9 | 640 | ifstream in("tempo.txt") ; |
641 | const Int_t runMax = 10 ; | |
642 | TString file[AliQA::kNDET*runMax] ; | |
567d83d9 | 643 | |
644 | Int_t index = 0 ; | |
645 | while ( 1 ) { | |
4edbc5bc | 646 | in >> file[index] ; |
567d83d9 | 647 | if ( !in.good() ) |
648 | break ; | |
e5dedfe2 | 649 | AliInfo(Form("index = %d file = %s", index, (file[index]).Data())) ; |
650 | index++ ; | |
4edbc5bc | 651 | } |
652 | ||
653 | if ( index == 0 ) { | |
654 | AliError(Form("run number %d not found", runNumber)) ; | |
655 | return kFALSE ; | |
567d83d9 | 656 | } |
147c1c84 | 657 | |
658 | TFileMerger merger ; | |
659 | TString outFileName(Form("Merged.%s.Data.%d.root",AliQA::GetQADataFileName(),runNumber)); | |
660 | merger.OutputFile(outFileName.Data()) ; | |
661 | for (Int_t ifile = 0 ; ifile < index-1 ; ifile++) { | |
662 | TString pattern(Form("%s.%d.", AliQA::GetQADataFileName(), runNumber)); | |
663 | TString tmp(file[ifile]) ; | |
664 | if (tmp.Contains(pattern)) { | |
665 | merger.AddFile(tmp) ; | |
666 | } | |
567d83d9 | 667 | } |
147c1c84 | 668 | merger.Merge() ; |
567d83d9 | 669 | return kTRUE ; |
315bba70 | 670 | } |
671 | ||
f5464b75 | 672 | //_____________________________________________________________________________ |
673 | Bool_t AliQADataMakerSteer::MergeResults(const Int_t runNumber) const | |
674 | { | |
675 | // Merge the QA result from all the data chunks in a run | |
676 | TString cmd ; | |
677 | cmd = Form(".! ls %s*.root > tempo.txt", AliQA::GetQADataFileName()) ; | |
678 | gROOT->ProcessLine(cmd.Data()) ; | |
679 | ifstream in("tempo.txt") ; | |
680 | const Int_t chunkMax = 100 ; | |
681 | TString fileList[chunkMax] ; | |
682 | ||
683 | Int_t index = 0 ; | |
684 | while ( 1 ) { | |
685 | TString file ; | |
686 | in >> fileList[index] ; | |
687 | if ( !in.good() ) | |
688 | break ; | |
689 | AliInfo(Form("index = %d file = %s", index, (fileList[index].Data()))) ; | |
690 | index++ ; | |
691 | } | |
692 | ||
693 | if ( index == 0 ) { | |
694 | AliError("No QA Result File found") ; | |
695 | return kFALSE ; | |
696 | } | |
697 | ||
698 | TFileMerger merger ; | |
699 | TString outFileName(Form("Merged.%s.Result.%d.root", AliQA::GetQADataFileName(), runNumber)); | |
700 | merger.OutputFile(outFileName.Data()) ; | |
701 | for (Int_t ifile = 0 ; ifile < index ; ifile++) { | |
702 | TString file = fileList[ifile] ; | |
703 | merger.AddFile(file) ; | |
704 | } | |
705 | merger.Merge() ; | |
706 | ||
707 | return kTRUE ; | |
708 | } | |
709 | ||
c65c502a | 710 | //_____________________________________________________________________________ |
fff5167b | 711 | void AliQADataMakerSteer::Reset(const Bool_t sameCycle) |
c65c502a | 712 | { |
713 | // Reset the default data members | |
c65c502a | 714 | |
30bbd491 | 715 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
716 | if (IsSelected(AliQA::GetDetName(iDet))) { | |
717 | AliQADataMaker * qadm = GetQADataMaker(iDet); | |
930e6e3e | 718 | qadm->Reset(); |
30bbd491 | 719 | } |
56f4f5f4 | 720 | } |
6441b07a | 721 | if (fRawReaderDelete) { |
722 | delete fRawReader ; | |
723 | fRawReader = NULL ; | |
724 | } | |
c65c502a | 725 | |
fff5167b | 726 | fCycleSame = sameCycle ; |
c65c502a | 727 | fESD = NULL ; |
728 | fESDTree = NULL ; | |
30bbd491 | 729 | //fFirst = kTRUE ; |
774ac967 | 730 | fNumberOfEvents = 999999 ; |
c65c502a | 731 | } |
732 | ||
6441b07a | 733 | //_____________________________________________________________________________ |
7c002d48 | 734 | TString AliQADataMakerSteer::Run(const char * detectors, AliRawReader * rawReader, const Bool_t sameCycle) |
6441b07a | 735 | { |
736 | //Runs all the QA data Maker for Raws only | |
7c002d48 | 737 | |
738 | fCycleSame = sameCycle ; | |
739 | fRawReader = rawReader ; | |
4d52736b | 740 | fDetectors = detectors ; |
7c002d48 | 741 | fDetectorsW = detectors ; |
742 | ||
95932286 | 743 | AliCDBManager* man = AliCDBManager::Instance() ; |
7930d770 | 744 | |
95932286 | 745 | if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data |
95932286 | 746 | rawReader->NextEvent() ; |
747 | man->SetRun(fRawReader->GetRunNumber()) ; | |
748 | rawReader->RewindEvents() ; | |
749 | } | |
750 | ||
30bbd491 | 751 | if ( !Init(AliQA::kRAWS) ) |
ea9ce23f | 752 | return kFALSE ; |
753 | fRawReaderDelete = kFALSE ; | |
754 | ||
30bbd491 | 755 | DoIt(AliQA::kRAWS) ; |
e5dedfe2 | 756 | return fDetectorsW ; |
04236e67 | 757 | } |
758 | ||
759 | //_____________________________________________________________________________ | |
7c002d48 | 760 | TString AliQADataMakerSteer::Run(const char * detectors, const char * fileName, const Bool_t sameCycle) |
04236e67 | 761 | { |
762 | //Runs all the QA data Maker for Raws only | |
7c002d48 | 763 | |
764 | fCycleSame = sameCycle ; | |
04236e67 | 765 | fDetectors = detectors ; |
e5dedfe2 | 766 | fDetectorsW = detectors ; |
04236e67 | 767 | |
95932286 | 768 | AliCDBManager* man = AliCDBManager::Instance() ; |
95932286 | 769 | if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun |
770 | AliRunLoader * rl = AliRunLoader::Open("galice.root") ; | |
771 | if ( ! rl ) { | |
772 | AliFatal("galice.root file not found in current directory") ; | |
773 | } else { | |
774 | rl->CdGAFile() ; | |
775 | rl->LoadgAlice() ; | |
776 | if ( ! rl->GetAliRun() ) { | |
777 | AliFatal("AliRun not found in galice.root") ; | |
778 | } else { | |
779 | rl->LoadHeader() ; | |
780 | man->SetRun(rl->GetHeader()->GetRun()); | |
781 | } | |
782 | } | |
783 | } | |
784 | ||
30bbd491 | 785 | if ( !Init(AliQA::kRAWS, fileName) ) |
ea9ce23f | 786 | return kFALSE ; |
787 | ||
30bbd491 | 788 | DoIt(AliQA::kRAWS) ; |
fff5167b | 789 | return fDetectorsW ; |
6441b07a | 790 | } |
791 | ||
312e6f8d | 792 | //_____________________________________________________________________________ |
7c002d48 | 793 | TString AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX_t taskIndex, Bool_t const sameCycle, const char * fileName ) |
312e6f8d | 794 | { |
795 | // Runs all the QA data Maker for every detector | |
7c002d48 | 796 | |
797 | fCycleSame = sameCycle ; | |
798 | fDetectors = detectors ; | |
799 | fDetectorsW = detectors ; | |
800 | ||
65c771ca | 801 | AliCDBManager* man = AliCDBManager::Instance() ; |
95932286 | 802 | if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun |
803 | AliRunLoader * rl = AliRunLoader::Open("galice.root") ; | |
804 | if ( ! rl ) { | |
805 | AliFatal("galice.root file not found in current directory") ; | |
806 | } else { | |
807 | rl->CdGAFile() ; | |
808 | rl->LoadgAlice() ; | |
809 | if ( ! rl->GetAliRun() ) { | |
efb37e8e | 810 | AliInfo("AliRun not found in galice.root") ; |
95932286 | 811 | } else { |
812 | rl->LoadHeader() ; | |
813 | man->SetRun(rl->GetHeader()->GetRun()) ; | |
814 | } | |
815 | } | |
816 | } | |
817 | ||
ea9ce23f | 818 | |
940d8e5f | 819 | if ( taskIndex == AliQA::kNULLTASKINDEX) { |
194bc923 | 820 | for (UInt_t task = 0; task < AliQA::kNTASKINDEX; task++) { |
821 | if ( fTasks.Contains(Form("%d", task)) ) { | |
822 | if ( !Init(AliQA::GetTaskIndex(AliQA::GetTaskName(task)), fileName) ) | |
823 | return kFALSE ; | |
940d8e5f | 824 | DoIt(AliQA::GetTaskIndex(AliQA::GetTaskName(task))) ; |
194bc923 | 825 | } |
826 | } | |
827 | } else { | |
828 | if ( !Init(taskIndex, fileName) ) | |
829 | return kFALSE ; | |
830 | DoIt(taskIndex) ; | |
831 | } | |
4d52736b | 832 | |
e5dedfe2 | 833 | return fDetectorsW ; |
6441b07a | 834 | |
14e1eccc | 835 | } |
4edbc5bc | 836 | |
940d8e5f | 837 | //_____________________________________________________________________________ |
838 | void AliQADataMakerSteer::RunOneEvent(AliRawReader * rawReader) | |
839 | { | |
840 | //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method) | |
930e6e3e | 841 | if ( ! rawReader ) |
842 | return ; | |
940d8e5f | 843 | AliCodeTimerAuto("") ; |
a2b64fbd | 844 | if (fTasks.Contains(Form("%d", AliQA::kRAWS))){ |
845 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
846 | if (!IsSelected(AliQA::GetDetName(iDet))) | |
847 | continue; | |
848 | AliQADataMaker *qadm = GetQADataMaker(iDet); | |
849 | if (!qadm) | |
850 | continue; | |
930e6e3e | 851 | if ( qadm->IsCycleDone() ) { |
852 | qadm->EndOfCycle() ; | |
853 | } | |
a2b64fbd | 854 | AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet))); |
940d8e5f | 855 | qadm->Exec(AliQA::kRAWS, rawReader) ; |
a2b64fbd | 856 | AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet))); |
940d8e5f | 857 | } |
a2b64fbd | 858 | } |
940d8e5f | 859 | } |
860 | ||
861 | //_____________________________________________________________________________ | |
862 | void AliQADataMakerSteer::RunOneEvent(AliESDEvent *& esd) | |
863 | { | |
864 | //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method) | |
865 | ||
866 | AliCodeTimerAuto("") ; | |
a2b64fbd | 867 | if (fTasks.Contains(Form("%d", AliQA::kESDS))) { |
868 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
869 | if (!IsSelected(AliQA::GetDetName(iDet))) | |
870 | continue; | |
871 | AliQADataMaker *qadm = GetQADataMaker(iDet); | |
872 | if (!qadm) | |
873 | continue; | |
930e6e3e | 874 | if ( qadm->IsCycleDone() ) { |
875 | qadm->EndOfCycle() ; | |
876 | } | |
a2b64fbd | 877 | AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet))); |
940d8e5f | 878 | qadm->Exec(AliQA::kESDS, esd) ; |
a2b64fbd | 879 | AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet))); |
940d8e5f | 880 | } |
881 | } | |
882 | } | |
883 | ||
884 | //_____________________________________________________________________________ | |
885 | void AliQADataMakerSteer::RunOneEventInOneDetector(Int_t det, TTree * tree) | |
886 | { | |
887 | // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method) | |
888 | AliCodeTimerAuto("") ; | |
a2b64fbd | 889 | if (fTasks.Contains(Form("%d", AliQA::kRECPOINTS))) { |
930e6e3e | 890 | if (IsSelected(AliQA::GetDetName(det))) { |
a2b64fbd | 891 | AliQADataMaker *qadm = GetQADataMaker(det); |
892 | if (qadm) { | |
930e6e3e | 893 | if ( qadm->IsCycleDone() ) { |
894 | qadm->EndOfCycle() ; | |
895 | } | |
a2b64fbd | 896 | AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det))); |
897 | qadm->Exec(AliQA::kRECPOINTS, tree) ; | |
930e6e3e | 898 | AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det))); |
899 | } | |
900 | } | |
901 | } | |
940d8e5f | 902 | } |
903 | ||
4edbc5bc | 904 | //_____________________________________________________________________________ |
147c1c84 | 905 | Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, const char * year, const char * detectors) const |
4edbc5bc | 906 | { |
907 | // take the locasl QA data merge into a single file and save in OCDB | |
908 | Bool_t rv = kTRUE ; | |
909 | TString tmp(AliQA::GetQARefStorage()) ; | |
910 | if ( tmp.IsNull() ) { | |
911 | AliError("No storage defined, use AliQA::SetQARefStorage") ; | |
912 | return kFALSE ; | |
913 | } | |
914 | if ( !(tmp.Contains(AliQA::GetLabLocalOCDB()) || tmp.Contains(AliQA::GetLabAliEnOCDB())) ) { | |
915 | AliError(Form("%s is a wrong storage, use %s or %s", AliQA::GetQARefStorage(), AliQA::GetLabLocalOCDB().Data(), AliQA::GetLabAliEnOCDB().Data())) ; | |
916 | return kFALSE ; | |
917 | } | |
918 | TString sdet(detectors) ; | |
919 | sdet.ToUpper() ; | |
920 | TFile * inputFile ; | |
921 | if ( sdet.Contains("ALL") ) { | |
922 | rv = Merge(runNumber) ; | |
923 | if ( ! rv ) | |
924 | return kFALSE ; | |
147c1c84 | 925 | TString inputFileName(Form("Merged.%s.Data.%d.root", AliQA::GetQADataFileName(), runNumber)) ; |
614a7f99 | 926 | inputFile = TFile::Open(inputFileName.Data()) ; |
11032e1d | 927 | rv = SaveIt2OCDB(runNumber, inputFile, year) ; |
4edbc5bc | 928 | } else { |
929 | for (Int_t index = 0; index < AliQA::kNDET; index++) { | |
930 | if (sdet.Contains(AliQA::GetDetName(index))) { | |
147c1c84 | 931 | TString inputFileName(Form("%s.%s.%d.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber)) ; |
614a7f99 | 932 | inputFile = TFile::Open(inputFileName.Data()) ; |
11032e1d | 933 | rv *= SaveIt2OCDB(runNumber, inputFile, year) ; |
4edbc5bc | 934 | } |
935 | } | |
936 | } | |
937 | return rv ; | |
938 | } | |
939 | ||
940 | //_____________________________________________________________________________ | |
11032e1d | 941 | Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const char * year) const |
4edbc5bc | 942 | { |
943 | // reads the TH1 from file and adds it to appropriate list before saving to OCDB | |
944 | Bool_t rv = kTRUE ; | |
945 | AliInfo(Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQA::GetQARefStorage())) ; | |
946 | AliCDBManager* man = AliCDBManager::Instance() ; | |
f73f556a | 947 | if ( ! man->IsDefaultStorageSet() ) { |
a681ca96 | 948 | TString tmp( AliQA::GetQARefStorage() ) ; |
949 | if ( tmp.Contains(AliQA::GetLabLocalOCDB()) ) | |
950 | man->SetDefaultStorage(AliQA::GetQARefStorage()) ; | |
951 | else { | |
605cb8bb | 952 | TString tmp1(AliQA::GetQARefDefaultStorage()) ; |
953 | tmp1.Append(year) ; | |
954 | tmp1.Append("?user=alidaq") ; | |
955 | man->SetDefaultStorage(tmp1.Data()) ; | |
a681ca96 | 956 | } |
f73f556a | 957 | } |
a681ca96 | 958 | man->SetSpecificStorage("*", AliQA::GetQARefStorage()) ; |
04236e67 | 959 | if(man->GetRun() < 0) |
960 | man->SetRun(runNumber); | |
961 | ||
11032e1d | 962 | AliCDBMetaData mdr ; |
963 | mdr.SetResponsible("yves schutz"); | |
964 | ||
4edbc5bc | 965 | for ( Int_t detIndex = 0 ; detIndex < AliQA::kNDET ; detIndex++) { |
966 | TDirectory * detDir = inputFile->GetDirectory(AliQA::GetDetName(detIndex)) ; | |
967 | if ( detDir ) { | |
968 | AliInfo(Form("Entering %s", detDir->GetName())) ; | |
614a7f99 | 969 | TString detOCDBDir(Form("%s/%s/%s", AliQA::GetDetName(detIndex), AliQA::GetRefOCDBDirName(), AliQA::GetRefDataDirName())) ; |
147c1c84 | 970 | printf("SSSSSSSSSSSSSSSSSSSSS %s\n", detOCDBDir.Data()) ; |
614a7f99 | 971 | AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ; |
4edbc5bc | 972 | TList * listDetQAD = new TList() ; |
614a7f99 | 973 | TString listName(Form("%s QA data Reference", AliQA::GetDetName(detIndex))) ; |
11032e1d | 974 | mdr.SetComment("HMPID QA stuff"); |
4edbc5bc | 975 | listDetQAD->SetName(listName) ; |
976 | TList * taskList = detDir->GetListOfKeys() ; | |
977 | TIter nextTask(taskList) ; | |
978 | TKey * taskKey ; | |
979 | while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) { | |
980 | TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ; | |
981 | AliInfo(Form("Saving %s", taskDir->GetName())) ; | |
f73f556a | 982 | TObjArray * listTaskQAD = new TObjArray(100) ; |
4edbc5bc | 983 | listTaskQAD->SetName(taskKey->GetName()) ; |
984 | listDetQAD->Add(listTaskQAD) ; | |
985 | TList * histList = taskDir->GetListOfKeys() ; | |
986 | TIter nextHist(histList) ; | |
987 | TKey * histKey ; | |
988 | while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) { | |
989 | TObject * odata = taskDir->Get(histKey->GetName()) ; | |
a681ca96 | 990 | if ( !odata ) { |
991 | AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ; | |
992 | } else { | |
4edbc5bc | 993 | AliInfo(Form("Adding %s", histKey->GetName())) ; |
a681ca96 | 994 | if ( odata->IsA()->InheritsFrom("TH1") ) { |
995 | AliInfo(Form("Adding %s", histKey->GetName())) ; | |
996 | TH1 * hdata = static_cast<TH1*>(odata) ; | |
997 | listTaskQAD->Add(hdata) ; | |
998 | } | |
4edbc5bc | 999 | } |
1000 | } | |
1001 | } | |
4edbc5bc | 1002 | man->Put(listDetQAD, idr, &mdr) ; |
1003 | } | |
1004 | } | |
1005 | return rv ; | |
1006 | } | |
a6f6970e | 1007 | |
940d8e5f | 1008 | //_____________________________________________________________________________ |
1009 | void AliQADataMakerSteer::SetRecoParam(const char* detector, AliDetectorRecoParam *par) | |
1010 | { | |
1011 | // Set custom reconstruction parameters for a given detector | |
1012 | // Single set of parameters for all the events | |
194bc923 | 1013 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
940d8e5f | 1014 | if(!strcmp(detector, AliQA::GetDetName(iDet))) { |
1015 | par->SetAsDefault(); | |
1016 | fRecoParam.AddDetRecoParam(iDet,par); | |
1017 | break; | |
1018 | } | |
1019 | } | |
1020 | } | |
1021 | ||
1022 |