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.13 2007/04/12 08:26:33 jgrosseo
21 Revision 1.12 2007/04/05 08:05:55 acolla
22 Conversion from online to offline detector name in StoreReferenceFile
24 Revision 1.11 2007/04/04 10:29:18 jgrosseo
25 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.
26 In case of an error with the Grid, the Shuttle will retry the storing later, the preprocessor does not need to be run again.
28 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.
30 3) New function StoreReferenceFile to _directly_ store a file (without opening it) to the reference storage.
32 4) The memory usage of the preprocessor is monitored. If it exceeds 2 GB it is terminated.
34 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.
35 If you always need DCS data (like before), you do not need to implement it.
37 6) The run type has been added to the monitoring page
39 Revision 1.9 2007/02/28 10:42:58 acolla
40 Run type field added in SHUTTLE framework. Run type is read from "run type" logbook and retrieved by
41 AliPreprocessor::GetRunType() function.
43 Revision 1.7 2006/11/06 14:24:21 jgrosseo
44 reading of run parameters from the logbook
45 online offline naming conversion
47 Revision 1.6 2006/10/02 12:57:48 jgrosseo
48 Small interface change of function StoreReferenceData in Shuttle
50 Revision 1.5 2006/09/04 17:42:34 hristov
51 Changes required by Effective C++
53 Revision 1.4 2006/08/08 14:20:49 jgrosseo
54 Update to shuttle classes (Alberto)
56 - Possibility to set the full object's path in the Preprocessor's and
57 Shuttle's Store functions
58 - Possibility to extend the object's run validity in the same classes
59 ("startValidity" and "validityInfinite" parameters)
60 - Implementation of the StoreReferenceData function to store reference
61 data in a dedicated CDB storage.
63 Revision 1.3 2006/07/11 12:42:43 jgrosseo
64 adding parameters for extended validity range of data produced by preprocessor
66 Revision 1.2 2006/06/06 16:36:49 jgrosseo
67 minor changes in AliShuttleInterface and AliPreprocessor
69 Revision 1.1 2006/06/02 14:14:36 hristov
70 Separate library for CDB (Jan)
72 Revision 1.2 2006/03/07 07:52:34 hristov
73 New version (B.Yordanov)
75 Revision 1.3 2005/11/17 17:47:34 byordano
76 TList changed to TObjArray
78 Revision 1.2 2005/11/17 14:43:22 byordano
81 Revision 1.1.1.1 2005/10/28 07:33:58 hristov
82 Initial import as subdirectory in AliRoot
84 Revision 1.1.1.1 2005/09/12 22:11:40 byordano
87 Revision 1.2 2005/08/29 21:15:47 byordano
93 // This class is the CDBPreProcessor interface,
94 // supposed to be implemented by any detector
95 // interested in immediate processing of data
96 // which is retrieved from DCS.
97 // For every particular run set of aliases and
98 // their corespoding value sets are returned.
100 // 1) virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
101 // This method is called at the begining of data retrieval.
103 // startTime: when the run started
104 // endTime: when the run finished
106 // 2) virtual void Process()
108 // This method is called and passed a list of retrieved values from DCS
113 #include "AliPreprocessor.h"
120 #include "AliCDBMetaData.h"
121 #include "AliCDBStorage.h"
122 #include "AliCDBId.h"
123 #include "AliCDBPath.h"
124 #include "AliCDBEntry.h"
125 #include "AliShuttleInterface.h"
127 ClassImp(AliPreprocessor)
129 //______________________________________________________________________________________________
130 AliPreprocessor::AliPreprocessor(const char* detector, AliShuttleInterface* shuttle) :
131 TNamed(detector, ""),
137 SetTitle(Form("AliPreprocessor for %s subdetector.", detector));
141 AliFatal("Initialized without Shuttle instance.");
145 fShuttle->RegisterPreprocessor(this);
148 //______________________________________________________________________________________________
149 AliPreprocessor::~AliPreprocessor()
153 //______________________________________________________________________________________________
154 void AliPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
156 // Sets the information of the run which is currently processed
157 // can be overriden for special behaviour, make sure that you call base class
161 fStartTime = startTime;
165 //______________________________________________________________________________________________
166 Bool_t AliPreprocessor::Store(const char* pathLevel2, const char* pathLevel3, TObject* object,
167 AliCDBMetaData* metaData, Int_t validityStart, Bool_t validityInfinite)
169 // Stores a CDB object in the storage for offline reconstruction. Objects that are not needed for
170 // offline reconstruction, but should be stored anyway (e.g. for debugging) should NOT be stored
171 // using this function. Use StoreReferenceData instead!
173 // This function should be called at the end of the preprocessor cycle
175 // The parameters are
176 // 1, 2) the 2nd and 3rd level of the object's path. The first level is the detector name which is provided
177 // by the Preprocessor and converted to the Offline name. Thus the object's path is "DET/level2/level3"
178 // 3) the object to be stored
179 // 4) the metaData to be associated with the object
180 // 5) the validity start run number w.r.t. the current run,
181 // if the data is valid only for this run leave the default 0
182 // 6) specifies if the calibration data is valid for infinity (this means until updated),
183 // typical for calibration runs, the default is kFALSE
185 // The call is delegated to AliShuttleInterface
187 const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
188 if(!offlineDetName) return 0;
190 return fShuttle->Store(AliCDBPath(offlineDetName, pathLevel2, pathLevel3), object,
191 metaData, validityStart, validityInfinite);
194 //______________________________________________________________________________________________
195 Bool_t AliPreprocessor::StoreReferenceData(const char* pathLevel2, const char* pathLevel3, TObject* object,
196 AliCDBMetaData* metaData)
198 // Stores a CDB object in the storage for reference data. This objects will not be available during
199 // offline reconstrunction. Use this function for reference data only!
201 // This function should be called at the end of the preprocessor cycle
203 // The parameters are
204 // 1, 2) the 2nd and 3rd level of the object's path. The first level is the detector name which is provided
205 // by the Preprocessor and converted to the Offline name. Thus the object's path is "DET/level2/level3"
206 // 3) the object to be stored
207 // 4) the metaData to be associated with the object
209 // The call is delegated to AliShuttleInterface
211 const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
212 if(!offlineDetName) return 0;
214 return fShuttle->StoreReferenceData(AliCDBPath(offlineDetName, pathLevel2, pathLevel3), object,
218 //______________________________________________________________________________________________
219 Bool_t AliPreprocessor::StoreReferenceFile(const char* localFile, const char* gridFileName)
222 // Stores a file directly (without opening it) in the reference storage in the Grid
224 // The file is stored under the following location:
225 // <base folder of reference storage>/<DET>/<RUN#>_<gridFileName>
226 // where <gridFileName> is the second parameter given to the function
228 // The call is delegated to AliShuttleInterface
230 const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
231 if(!offlineDetName) return 0;
232 return fShuttle->StoreReferenceFile(GetName(), localFile, gridFileName);
235 //______________________________________________________________________________________________
236 const char* AliPreprocessor::GetFile(Int_t system, const char* id, const char* source)
238 // This function retrieves a file from the given system (kDAQ, kDCS, kHLT) with the given file id
239 // and from the given source in the system.
240 // The function returnes the path to the local file.
242 // The call is delegated to AliShuttleInterface
244 return fShuttle->GetFile(system, GetName(), id, source);
247 //______________________________________________________________________________________________
248 TList* AliPreprocessor::GetFileSources(Int_t system, const char* id)
250 // Returns a list of sources in a given system that saved a file with the given id
251 // if id is not given all sources are returned
253 // The call is delegated to AliShuttleInterface
255 return fShuttle->GetFileSources(system, GetName(), id);
258 //______________________________________________________________________________________________
259 TList* AliPreprocessor::GetFileIDs(Int_t system, const char* source)
261 // Returns a list of ids in a given system that saved a file with the given source
263 // The call is delegated to AliShuttleInterface
265 return fShuttle->GetFileIDs(system, GetName(), source);
268 //______________________________________________________________________________________________
269 void AliPreprocessor::Log(const char* message)
271 // Adds a log message to the Shuttle log of this preprocessor
273 // The call is delegated to AliShuttleInterface
275 fShuttle->Log(GetName(), message);
278 //______________________________________________________________________________________________
279 const char* AliPreprocessor::GetRunParameter(const char* param)
281 // Return run parameter read from run logbook
283 // The call is delegated to AliShuttleInterface
285 return fShuttle->GetRunParameter(param);
288 //______________________________________________________________________________________________
289 AliCDBEntry* AliPreprocessor::GetFromOCDB(const char* pathLevel2, const char* pathLevel3)
291 // Return object from OCDB valid for current run
293 // The call is delegated to AliShuttleInterface
295 const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
296 if (!offlineDetName) return 0;
298 return dynamic_cast<AliCDBEntry*>
299 (fShuttle->GetFromOCDB(GetName(), AliCDBPath(offlineDetName, pathLevel2, pathLevel3)));
302 //______________________________________________________________________________________________
303 const char* AliPreprocessor::GetRunType()
305 // Return run type string read from "run type" logbook
307 // The call is delegated to AliShuttleInterface
309 return fShuttle->GetRunType();