]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliPreprocessor.cxx
Fix for Savannah bug report 59287
[u/mrichter/AliRoot.git] / STEER / AliPreprocessor.cxx
CommitLineData
57459306 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/*
17$Log$
bba57327 18Revision 1.17 2007/08/28 16:03:30 acolla
19Restored to v1.14:
20
21
22Function Bool_t GetHLTStatus() added to preprocessor interface. It will return
23the status of HLT read from the run logbook.
24
a53c3f59 25Revision 1.16 2007/08/22 09:20:50 hristov
26Updated QA classes (Yves)
27
03b6e5e2 28Revision 1.14 2007/05/30 06:35:21 jgrosseo
29Adding functionality to the Shuttle/TestShuttle:
30o) Function to retrieve list of sources from a given system (GetFileSources with id=0)
31o) Function to retrieve list of IDs for a given source (GetFileIDs)
32These functions are needed for dealing with the tag files that are saved for the GRP preprocessor
33Example code has been added to the TestProcessor in TestShuttle
34
4a33bdd9 35Revision 1.13 2007/04/12 08:26:33 jgrosseo
36updated commment
37
7a6c91b3 38Revision 1.12 2007/04/05 08:05:55 acolla
39Conversion from online to offline detector name in StoreReferenceFile
40
36a9f79d 41Revision 1.11 2007/04/04 10:29:18 jgrosseo
421) Storing of files to the Grid is now done _after_ your preprocessors succeeded. This is transparent, which means that you can still use the same functions (Store, StoreReferenceData) to store files to the Grid. However, the Shuttle first stores them locally and transfers them after the preprocessor finished. The return code of these two functions has changed from UInt_t to Bool_t which gives you the success of the storing.
43In case of an error with the Grid, the Shuttle will retry the storing later, the preprocessor does not need to be run again.
44
452) The meaning of the return code of the preprocessor has changed. 0 is now success and any other value means failure. This value is stored in the log and you can use it to keep details about the error condition.
46
473) New function StoreReferenceFile to _directly_ store a file (without opening it) to the reference storage.
48
494) The memory usage of the preprocessor is monitored. If it exceeds 2 GB it is terminated.
50
515) New function AliPreprocessor::ProcessDCS(). If you do not need to have DCS data in all cases, you can skip the processing by implemting this function and returning kFALSE under certain conditions. E.g. if there is a certain run type.
52If you always need DCS data (like before), you do not need to implement it.
53
546) The run type has been added to the monitoring page
55
eb4a4f5c 56Revision 1.9 2007/02/28 10:42:58 acolla
57Run type field added in SHUTTLE framework. Run type is read from "run type" logbook and retrieved by
58AliPreprocessor::GetRunType() function.
59
4426d64a 60Revision 1.7 2006/11/06 14:24:21 jgrosseo
61reading of run parameters from the logbook
62online offline naming conversion
63
1b82b32d 64Revision 1.6 2006/10/02 12:57:48 jgrosseo
65Small interface change of function StoreReferenceData in Shuttle
66
3c78eaa5 67Revision 1.5 2006/09/04 17:42:34 hristov
68Changes required by Effective C++
69
fe12e09c 70Revision 1.4 2006/08/08 14:20:49 jgrosseo
71Update to shuttle classes (Alberto)
72
73- Possibility to set the full object's path in the Preprocessor's and
74Shuttle's Store functions
75- Possibility to extend the object's run validity in the same classes
76("startValidity" and "validityInfinite" parameters)
77- Implementation of the StoreReferenceData function to store reference
78data in a dedicated CDB storage.
79
84090f85 80Revision 1.3 2006/07/11 12:42:43 jgrosseo
81adding parameters for extended validity range of data produced by preprocessor
82
17111222 83Revision 1.2 2006/06/06 16:36:49 jgrosseo
84minor changes in AliShuttleInterface and AliPreprocessor
85
b88146b7 86Revision 1.1 2006/06/02 14:14:36 hristov
87Separate library for CDB (Jan)
88
57459306 89Revision 1.2 2006/03/07 07:52:34 hristov
90New version (B.Yordanov)
91
92Revision 1.3 2005/11/17 17:47:34 byordano
93TList changed to TObjArray
94
95Revision 1.2 2005/11/17 14:43:22 byordano
96import to local CVS
97
98Revision 1.1.1.1 2005/10/28 07:33:58 hristov
99Initial import as subdirectory in AliRoot
100
101Revision 1.1.1.1 2005/09/12 22:11:40 byordano
102SHUTTLE package
103
104Revision 1.2 2005/08/29 21:15:47 byordano
105some docs added
106
107*/
108
109// Description:
110// This class is the CDBPreProcessor interface,
111// supposed to be implemented by any detector
112// interested in immediate processing of data
113// which is retrieved from DCS.
114// For every particular run set of aliases and
115// their corespoding value sets are returned.
116// Usage schema:
117// 1) virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
118// This method is called at the begining of data retrieval.
119// run: run number
120// startTime: when the run started
121// endTime: when the run finished
122//
123// 2) virtual void Process()
124//
125// This method is called and passed a list of retrieved values from DCS
126//
127//
128
129
130#include "AliPreprocessor.h"
131
132#include <TString.h>
57459306 133#include <TMap.h>
a0dbe362 134#include <TObjString.h>
57459306 135
136#include "AliLog.h"
137#include "AliCDBMetaData.h"
138#include "AliCDBStorage.h"
139#include "AliCDBId.h"
140#include "AliCDBPath.h"
4426d64a 141#include "AliCDBEntry.h"
57459306 142#include "AliShuttleInterface.h"
143
144ClassImp(AliPreprocessor)
145
84090f85 146//______________________________________________________________________________________________
57459306 147AliPreprocessor::AliPreprocessor(const char* detector, AliShuttleInterface* shuttle) :
148 TNamed(detector, ""),
fe12e09c 149 fRun(-1),
150 fStartTime(0),
151 fEndTime(0),
a0dbe362 152 fShuttle(shuttle),
153 fRunTypes()
57459306 154{
155 SetTitle(Form("AliPreprocessor for %s subdetector.", detector));
156
157 if (!fShuttle)
b88146b7 158 {
57459306 159 AliFatal("Initialized without Shuttle instance.");
b88146b7 160 return;
161 }
162
163 fShuttle->RegisterPreprocessor(this);
a0dbe362 164
165 fRunTypes.SetOwner(kTRUE);
57459306 166}
167
84090f85 168//______________________________________________________________________________________________
57459306 169AliPreprocessor::~AliPreprocessor()
170{
171}
172
84090f85 173//______________________________________________________________________________________________
57459306 174void AliPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
175{
176 // Sets the information of the run which is currently processed
177 // can be overriden for special behaviour, make sure that you call base class
178 // function
179
180 fRun = run;
181 fStartTime = startTime;
182 fEndTime = endTime;
183}
184
84090f85 185//______________________________________________________________________________________________
eb4a4f5c 186Bool_t AliPreprocessor::Store(const char* pathLevel2, const char* pathLevel3, TObject* object,
84090f85 187 AliCDBMetaData* metaData, Int_t validityStart, Bool_t validityInfinite)
188{
189 // Stores a CDB object in the storage for offline reconstruction. Objects that are not needed for
190 // offline reconstruction, but should be stored anyway (e.g. for debugging) should NOT be stored
191 // using this function. Use StoreReferenceData instead!
192 //
193 // This function should be called at the end of the preprocessor cycle
194 //
195 // The parameters are
196 // 1, 2) the 2nd and 3rd level of the object's path. The first level is the detector name which is provided
1b82b32d 197 // by the Preprocessor and converted to the Offline name. Thus the object's path is "DET/level2/level3"
84090f85 198 // 3) the object to be stored
199 // 4) the metaData to be associated with the object
200 // 5) the validity start run number w.r.t. the current run,
201 // if the data is valid only for this run leave the default 0
202 // 6) specifies if the calibration data is valid for infinity (this means until updated),
203 // typical for calibration runs, the default is kFALSE
204 //
205 // The call is delegated to AliShuttleInterface
206
1b82b32d 207 const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
208 if(!offlineDetName) return 0;
209
210 return fShuttle->Store(AliCDBPath(offlineDetName, pathLevel2, pathLevel3), object,
84090f85 211 metaData, validityStart, validityInfinite);
212}
213
214//______________________________________________________________________________________________
eb4a4f5c 215Bool_t AliPreprocessor::StoreReferenceData(const char* pathLevel2, const char* pathLevel3, TObject* object,
3c78eaa5 216 AliCDBMetaData* metaData)
57459306 217{
84090f85 218 // Stores a CDB object in the storage for reference data. This objects will not be available during
219 // offline reconstrunction. Use this function for reference data only!
220 //
57459306 221 // This function should be called at the end of the preprocessor cycle
222 //
17111222 223 // The parameters are
84090f85 224 // 1, 2) the 2nd and 3rd level of the object's path. The first level is the detector name which is provided
1b82b32d 225 // by the Preprocessor and converted to the Offline name. Thus the object's path is "DET/level2/level3"
84090f85 226 // 3) the object to be stored
227 // 4) the metaData to be associated with the object
17111222 228 //
57459306 229 // The call is delegated to AliShuttleInterface
230
1b82b32d 231 const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
232 if(!offlineDetName) return 0;
233
234 return fShuttle->StoreReferenceData(AliCDBPath(offlineDetName, pathLevel2, pathLevel3), object,
3c78eaa5 235 metaData);
57459306 236}
9827400b 237
238//______________________________________________________________________________________________
239Bool_t AliPreprocessor::StoreReferenceFile(const char* localFile, const char* gridFileName)
240{
241 //
242 // Stores a file directly (without opening it) in the reference storage in the Grid
243 //
7a6c91b3 244 // The file is stored under the following location:
245 // <base folder of reference storage>/<DET>/<RUN#>_<gridFileName>
246 // where <gridFileName> is the second parameter given to the function
247 //
9827400b 248 // The call is delegated to AliShuttleInterface
249
36a9f79d 250 const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
251 if(!offlineDetName) return 0;
9827400b 252 return fShuttle->StoreReferenceFile(GetName(), localFile, gridFileName);
253}
bba57327 254
255//______________________________________________________________________________________________
256Bool_t AliPreprocessor::StoreRunMetadataFile(const char* localFile, const char* gridFileName)
257{
258 //
259 // Stores Run metadata file to the Grid, in the run folder
260 //
261 // Only GRP can call this function.
262
263 TString detName(GetName());
264 if (detName != "GRP")
265 {
ca8ea066 266 Log("StoreRunMetadataFile - Only GRP can call this function.");
bba57327 267 return kFALSE;
268 }
269 return fShuttle->StoreRunMetadataFile(localFile, gridFileName);
270}
57459306 271
84090f85 272//______________________________________________________________________________________________
57459306 273const char* AliPreprocessor::GetFile(Int_t system, const char* id, const char* source)
274{
275 // This function retrieves a file from the given system (kDAQ, kDCS, kHLT) with the given file id
276 // and from the given source in the system.
277 // The function returnes the path to the local file.
278 //
279 // The call is delegated to AliShuttleInterface
280
281 return fShuttle->GetFile(system, GetName(), id, source);
282}
283
84090f85 284//______________________________________________________________________________________________
57459306 285TList* AliPreprocessor::GetFileSources(Int_t system, const char* id)
286{
287 // Returns a list of sources in a given system that saved a file with the given id
4a33bdd9 288 // if id is not given all sources are returned
57459306 289 //
290 // The call is delegated to AliShuttleInterface
291
292 return fShuttle->GetFileSources(system, GetName(), id);
293}
294
4a33bdd9 295//______________________________________________________________________________________________
296TList* AliPreprocessor::GetFileIDs(Int_t system, const char* source)
297{
298 // Returns a list of ids in a given system that saved a file with the given source
299 //
300 // The call is delegated to AliShuttleInterface
301
302 return fShuttle->GetFileIDs(system, GetName(), source);
303}
304
84090f85 305//______________________________________________________________________________________________
57459306 306void AliPreprocessor::Log(const char* message)
307{
308 // Adds a log message to the Shuttle log of this preprocessor
309 //
310 // The call is delegated to AliShuttleInterface
311
312 fShuttle->Log(GetName(), message);
313}
1b82b32d 314
315//______________________________________________________________________________________________
316const char* AliPreprocessor::GetRunParameter(const char* param)
317{
318 // Return run parameter read from run logbook
319 //
320 // The call is delegated to AliShuttleInterface
321
322 return fShuttle->GetRunParameter(param);
323}
4426d64a 324
325//______________________________________________________________________________________________
326AliCDBEntry* AliPreprocessor::GetFromOCDB(const char* pathLevel2, const char* pathLevel3)
327{
328 // Return object from OCDB valid for current run
329 //
330 // The call is delegated to AliShuttleInterface
331
332 const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
333 if (!offlineDetName) return 0;
334
335 return dynamic_cast<AliCDBEntry*>
9827400b 336 (fShuttle->GetFromOCDB(GetName(), AliCDBPath(offlineDetName, pathLevel2, pathLevel3)));
4426d64a 337}
5c957e4a 338
339//______________________________________________________________________________________________
340const char* AliPreprocessor::GetRunType()
341{
342 // Return run type string read from "run type" logbook
343 //
344 // The call is delegated to AliShuttleInterface
345
9827400b 346 return fShuttle->GetRunType();
5c957e4a 347}
a53c3f59 348
349//______________________________________________________________________________________________
350Bool_t AliPreprocessor::GetHLTStatus()
351{
352 // Return HLT status (ON or OFF)
353 // Converts the HLT status from the status string read in the run logbook (not just a bool)
354 // The call is delegated to AliShuttleInterface
355
356 return fShuttle->GetHLTStatus();
357
358}
a0dbe362 359
ca8ea066 360//______________________________________________________________________________________________
361const char* AliPreprocessor::GetTriggerConfiguration()
362{
363 // Returns the trigger configuration which is read from a table in the DAQ logbook
364 // The call is delegated to AliShuttleInterface
365 // Only GRP can call this function.
366
367 TString detName(GetName());
368 if (detName != "GRP")
369 {
370 Log("GetTriggerConfiguration - Only GRP can call this function.");
371 return 0;
372 }
373
374 return fShuttle->GetTriggerConfiguration();
375}
b48d2542 376//______________________________________________________________________________________________
2c5f9d06 377const char* AliPreprocessor::GetCTPTimeParams()
378{
379 // Returns the CTP timing parameters read from a table in the DAQ logbook
380 // The call is delegated to AliShuttleInterface
381 // Only GRP can call this function.
382
383 TString detName(GetName());
384 if (detName != "GRP")
385 {
386 Log("GetCTPTimeParams - Only GRP can call this function.");
387 return 0;
388 }
389
390 return fShuttle->GetCTPTimeParams();
391}
392//______________________________________________________________________________________________
b48d2542 393const char* AliPreprocessor::GetTriggerDetectorMask()
394{
395 // Returns the trigger detector mask which is read from a table in the DAQ logbook
396 // The call is delegated to AliShuttleInterface
397 // Only TRI can call this function.
398
399 TString detName(GetName());
400 if (detName != "TRI")
401 {
402 Log("GetTriggerDetectorMask - Only TRI can call this function.");
403 return 0;
404 }
405
406 return fShuttle->GetTriggerDetectorMask();
407}
ca8ea066 408
a0dbe362 409//______________________________________________________________________________________________
410void AliPreprocessor::AddRunType(const char* runType)
411{
412 // adds the given run type to the list of run types that are processed
413 // this function should be called in the constructor of the derived preprocessor
414
415 if (!runType)
416 return;
417
418 fRunTypes.Add(new TObjString(runType));
419}
420
421//______________________________________________________________________________________________
422Bool_t AliPreprocessor::AliPreprocessor::ProcessRunType()
423{
424 // searches for the current run type in the list of run types that are processed by this
425 // preprocessor. The list is populated by AddRunType
426
427 const char* runType = GetRunType();
428
429 Log(Form("Checking if run type %s is in the list of run types to be processed by this preprocessor...", runType));
430
431 if (fRunTypes.GetEntries() == 0)
432 Log("WARNING! There are no run types defined. This preprocessor will never run.");
433
434 if (fRunTypes.FindObject(runType))
435 {
436 Log("Run type found. Processing this run.");
437 return kTRUE;
438 }
439
440 Log("Run type not found. Skipping this run.");
441 return kFALSE;
442}
2eb98462 443//______________________________________________________________________________________________
f12d42ce 444UInt_t AliPreprocessor::GetStartTimeDCSQuery()
2eb98462 445{
446 // Return Start Time for the DCS query
447 //
448 // The call is delegated to AliShuttleInterface
449
450 return fShuttle->GetStartTimeDCSQuery();
451}
452//______________________________________________________________________________________________
f12d42ce 453UInt_t AliPreprocessor::GetEndTimeDCSQuery()
2eb98462 454{
455 // Return End Time for the DCS query
456 //
457 // The call is delegated to AliShuttleInterface
458
459 return fShuttle->GetEndTimeDCSQuery();
460}
461