1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.14 2007/05/30 06:35:21 jgrosseo
19 Adding functionality to the Shuttle/TestShuttle:
20 o) Function to retrieve list of sources from a given system (GetFileSources with id=0)
21 o) Function to retrieve list of IDs for a given source (GetFileIDs)
22 These functions are needed for dealing with the tag files that are saved for the GRP preprocessor
23 Example code has been added to the TestProcessor in TestShuttle
25 Revision 1.13 2007/04/12 08:26:33 jgrosseo
28 Revision 1.12 2007/04/05 08:05:55 acolla
29 Conversion from online to offline detector name in StoreReferenceFile
31 Revision 1.11 2007/04/04 10:29:18 jgrosseo
32 1) 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.
33 In case of an error with the Grid, the Shuttle will retry the storing later, the preprocessor does not need to be run again.
35 2) 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.
37 3) New function StoreReferenceFile to _directly_ store a file (without opening it) to the reference storage.
39 4) The memory usage of the preprocessor is monitored. If it exceeds 2 GB it is terminated.
41 5) 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.
42 If you always need DCS data (like before), you do not need to implement it.
44 6) The run type has been added to the monitoring page
46 Revision 1.9 2007/02/28 10:42:58 acolla
47 Run type field added in SHUTTLE framework. Run type is read from "run type" logbook and retrieved by
48 AliPreprocessor::GetRunType() function.
50 Revision 1.7 2006/11/06 14:24:21 jgrosseo
51 reading of run parameters from the logbook
52 online offline naming conversion
54 Revision 1.6 2006/10/02 12:57:48 jgrosseo
55 Small interface change of function StoreReferenceData in Shuttle
57 Revision 1.5 2006/09/04 17:42:34 hristov
58 Changes required by Effective C++
60 Revision 1.4 2006/08/08 14:20:49 jgrosseo
61 Update to shuttle classes (Alberto)
63 - Possibility to set the full object's path in the Preprocessor's and
64 Shuttle's Store functions
65 - Possibility to extend the object's run validity in the same classes
66 ("startValidity" and "validityInfinite" parameters)
67 - Implementation of the StoreReferenceData function to store reference
68 data in a dedicated CDB storage.
70 Revision 1.3 2006/07/11 12:42:43 jgrosseo
71 adding parameters for extended validity range of data produced by preprocessor
73 Revision 1.2 2006/06/06 16:36:49 jgrosseo
74 minor changes in AliShuttleInterface and AliPreprocessor
76 Revision 1.1 2006/06/02 14:14:36 hristov
77 Separate library for CDB (Jan)
79 Revision 1.2 2006/03/07 07:52:34 hristov
80 New version (B.Yordanov)
82 Revision 1.3 2005/11/17 17:47:34 byordano
83 TList changed to TObjArray
85 Revision 1.2 2005/11/17 14:43:22 byordano
88 Revision 1.1.1.1 2005/10/28 07:33:58 hristov
89 Initial import as subdirectory in AliRoot
91 Revision 1.1.1.1 2005/09/12 22:11:40 byordano
94 Revision 1.2 2005/08/29 21:15:47 byordano
100 // This class is the CDBPreProcessor interface,
101 // supposed to be implemented by any detector
102 // interested in immediate processing of data
103 // which is retrieved from DCS.
104 // For every particular run set of aliases and
105 // their corespoding value sets are returned.
107 // 1) virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
108 // This method is called at the begining of data retrieval.
110 // startTime: when the run started
111 // endTime: when the run finished
113 // 2) virtual void Process()
115 // This method is called and passed a list of retrieved values from DCS
120 #include "AliPreprocessor.h"
127 #include "AliCDBMetaData.h"
128 #include "AliCDBStorage.h"
129 #include "AliCDBId.h"
130 #include "AliCDBPath.h"
131 #include "AliCDBEntry.h"
132 #include "AliShuttleInterface.h"
134 ClassImp(AliPreprocessor)
136 //______________________________________________________________________________________________
137 AliPreprocessor::AliPreprocessor(const char* detector, AliShuttleInterface* shuttle) :
138 TNamed(detector, ""),
144 SetTitle(Form("AliPreprocessor for %s subdetector.", detector));
148 AliFatal("Initialized without Shuttle instance.");
152 fShuttle->RegisterPreprocessor(this);
155 //______________________________________________________________________________________________
156 AliPreprocessor::~AliPreprocessor()
160 //______________________________________________________________________________________________
161 void AliPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
163 // Sets the information of the run which is currently processed
164 // can be overriden for special behaviour, make sure that you call base class
168 fStartTime = startTime;
172 //______________________________________________________________________________________________
173 Bool_t AliPreprocessor::Store(const char* pathLevel2, const char* pathLevel3, TObject* object,
174 AliCDBMetaData* metaData, Int_t validityStart, Bool_t validityInfinite)
176 // Stores a CDB object in the storage for offline reconstruction. Objects that are not needed for
177 // offline reconstruction, but should be stored anyway (e.g. for debugging) should NOT be stored
178 // using this function. Use StoreReferenceData instead!
180 // This function should be called at the end of the preprocessor cycle
182 // The parameters are
183 // 1, 2) the 2nd and 3rd level of the object's path. The first level is the detector name which is provided
184 // by the Preprocessor and converted to the Offline name. Thus the object's path is "DET/level2/level3"
185 // 3) the object to be stored
186 // 4) the metaData to be associated with the object
187 // 5) the validity start run number w.r.t. the current run,
188 // if the data is valid only for this run leave the default 0
189 // 6) specifies if the calibration data is valid for infinity (this means until updated),
190 // typical for calibration runs, the default is kFALSE
192 // The call is delegated to AliShuttleInterface
194 const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
195 if(!offlineDetName) return 0;
197 return fShuttle->Store(AliCDBPath(offlineDetName, pathLevel2, pathLevel3), object,
198 metaData, validityStart, validityInfinite);
201 //______________________________________________________________________________________________
202 Bool_t AliPreprocessor::StoreReferenceData(const char* pathLevel2, const char* pathLevel3, TObject* object,
203 AliCDBMetaData* metaData)
205 // Stores a CDB object in the storage for reference data. This objects will not be available during
206 // offline reconstrunction. Use this function for reference data only!
208 // This function should be called at the end of the preprocessor cycle
210 // The parameters are
211 // 1, 2) the 2nd and 3rd level of the object's path. The first level is the detector name which is provided
212 // by the Preprocessor and converted to the Offline name. Thus the object's path is "DET/level2/level3"
213 // 3) the object to be stored
214 // 4) the metaData to be associated with the object
216 // The call is delegated to AliShuttleInterface
218 const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
219 if(!offlineDetName) return 0;
221 return fShuttle->StoreReferenceData(AliCDBPath(offlineDetName, pathLevel2, pathLevel3), object,
225 //______________________________________________________________________________________________
226 Bool_t AliPreprocessor::StoreReferenceFile(const char* localFile, const char* gridFileName)
229 // Stores a file directly (without opening it) in the reference storage in the Grid
231 // The file is stored under the following location:
232 // <base folder of reference storage>/<DET>/<RUN#>_<gridFileName>
233 // where <gridFileName> is the second parameter given to the function
235 // The call is delegated to AliShuttleInterface
237 const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
238 if(!offlineDetName) return 0;
239 return fShuttle->StoreReferenceFile(GetName(), localFile, gridFileName);
242 //______________________________________________________________________________________________
243 const char* AliPreprocessor::GetFile(Int_t system, const char* id, const char* source)
245 // This function retrieves a file from the given system (kDAQ, kDCS, kHLT) with the given file id
246 // and from the given source in the system.
247 // The function returnes the path to the local file.
249 // The call is delegated to AliShuttleInterface
251 return fShuttle->GetFile(system, GetName(), id, source);
254 //______________________________________________________________________________________________
255 TList* AliPreprocessor::GetFileSources(Int_t system, const char* id)
257 // Returns a list of sources in a given system that saved a file with the given id
258 // if id is not given all sources are returned
260 // The call is delegated to AliShuttleInterface
262 return fShuttle->GetFileSources(system, GetName(), id);
265 //______________________________________________________________________________________________
266 TList* AliPreprocessor::GetFileIDs(Int_t system, const char* source)
268 // Returns a list of ids in a given system that saved a file with the given source
270 // The call is delegated to AliShuttleInterface
272 return fShuttle->GetFileIDs(system, GetName(), source);
275 //______________________________________________________________________________________________
276 void AliPreprocessor::Log(const char* message)
278 // Adds a log message to the Shuttle log of this preprocessor
280 // The call is delegated to AliShuttleInterface
282 fShuttle->Log(GetName(), message);
285 //______________________________________________________________________________________________
286 const char* AliPreprocessor::GetRunParameter(const char* param)
288 // Return run parameter read from run logbook
290 // The call is delegated to AliShuttleInterface
292 return fShuttle->GetRunParameter(param);
295 //______________________________________________________________________________________________
296 AliCDBEntry* AliPreprocessor::GetFromOCDB(const char* pathLevel2, const char* pathLevel3)
298 // Return object from OCDB valid for current run
300 // The call is delegated to AliShuttleInterface
302 const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
303 if (!offlineDetName) return 0;
305 return dynamic_cast<AliCDBEntry*>
306 (fShuttle->GetFromOCDB(GetName(), AliCDBPath(offlineDetName, pathLevel2, pathLevel3)));
309 //______________________________________________________________________________________________
310 const char* AliPreprocessor::GetRunType()
312 // Return run type string read from "run type" logbook
314 // The call is delegated to AliShuttleInterface
316 return fShuttle->GetRunType();