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