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.12 2007/04/05 08:05:55 acolla
19 Conversion from online to offline detector name in StoreReferenceFile
21 Revision 1.11 2007/04/04 10:29:18 jgrosseo
22 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.
23 In case of an error with the Grid, the Shuttle will retry the storing later, the preprocessor does not need to be run again.
25 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.
27 3) New function StoreReferenceFile to _directly_ store a file (without opening it) to the reference storage.
29 4) The memory usage of the preprocessor is monitored. If it exceeds 2 GB it is terminated.
31 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.
32 If you always need DCS data (like before), you do not need to implement it.
34 6) The run type has been added to the monitoring page
36 Revision 1.9 2007/02/28 10:42:58 acolla
37 Run type field added in SHUTTLE framework. Run type is read from "run type" logbook and retrieved by
38 AliPreprocessor::GetRunType() function.
40 Revision 1.7 2006/11/06 14:24:21 jgrosseo
41 reading of run parameters from the logbook
42 online offline naming conversion
44 Revision 1.6 2006/10/02 12:57:48 jgrosseo
45 Small interface change of function StoreReferenceData in Shuttle
47 Revision 1.5 2006/09/04 17:42:34 hristov
48 Changes required by Effective C++
50 Revision 1.4 2006/08/08 14:20:49 jgrosseo
51 Update to shuttle classes (Alberto)
53 - Possibility to set the full object's path in the Preprocessor's and
54 Shuttle's Store functions
55 - Possibility to extend the object's run validity in the same classes
56 ("startValidity" and "validityInfinite" parameters)
57 - Implementation of the StoreReferenceData function to store reference
58 data in a dedicated CDB storage.
60 Revision 1.3 2006/07/11 12:42:43 jgrosseo
61 adding parameters for extended validity range of data produced by preprocessor
63 Revision 1.2 2006/06/06 16:36:49 jgrosseo
64 minor changes in AliShuttleInterface and AliPreprocessor
66 Revision 1.1 2006/06/02 14:14:36 hristov
67 Separate library for CDB (Jan)
69 Revision 1.2 2006/03/07 07:52:34 hristov
70 New version (B.Yordanov)
72 Revision 1.3 2005/11/17 17:47:34 byordano
73 TList changed to TObjArray
75 Revision 1.2 2005/11/17 14:43:22 byordano
78 Revision 1.1.1.1 2005/10/28 07:33:58 hristov
79 Initial import as subdirectory in AliRoot
81 Revision 1.1.1.1 2005/09/12 22:11:40 byordano
84 Revision 1.2 2005/08/29 21:15:47 byordano
90 // This class is the CDBPreProcessor interface,
91 // supposed to be implemented by any detector
92 // interested in immediate processing of data
93 // which is retrieved from DCS.
94 // For every particular run set of aliases and
95 // their corespoding value sets are returned.
97 // 1) virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
98 // This method is called at the begining of data retrieval.
100 // startTime: when the run started
101 // endTime: when the run finished
103 // 2) virtual void Process()
105 // This method is called and passed a list of retrieved values from DCS
110 #include "AliPreprocessor.h"
117 #include "AliCDBMetaData.h"
118 #include "AliCDBStorage.h"
119 #include "AliCDBId.h"
120 #include "AliCDBPath.h"
121 #include "AliCDBEntry.h"
122 #include "AliShuttleInterface.h"
124 ClassImp(AliPreprocessor)
126 //______________________________________________________________________________________________
127 AliPreprocessor::AliPreprocessor(const char* detector, AliShuttleInterface* shuttle) :
128 TNamed(detector, ""),
134 SetTitle(Form("AliPreprocessor for %s subdetector.", detector));
138 AliFatal("Initialized without Shuttle instance.");
142 fShuttle->RegisterPreprocessor(this);
145 //______________________________________________________________________________________________
146 AliPreprocessor::~AliPreprocessor()
150 //______________________________________________________________________________________________
151 void AliPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
153 // Sets the information of the run which is currently processed
154 // can be overriden for special behaviour, make sure that you call base class
158 fStartTime = startTime;
162 //______________________________________________________________________________________________
163 Bool_t AliPreprocessor::Store(const char* pathLevel2, const char* pathLevel3, TObject* object,
164 AliCDBMetaData* metaData, Int_t validityStart, Bool_t validityInfinite)
166 // Stores a CDB object in the storage for offline reconstruction. Objects that are not needed for
167 // offline reconstruction, but should be stored anyway (e.g. for debugging) should NOT be stored
168 // using this function. Use StoreReferenceData instead!
170 // This function should be called at the end of the preprocessor cycle
172 // The parameters are
173 // 1, 2) the 2nd and 3rd level of the object's path. The first level is the detector name which is provided
174 // by the Preprocessor and converted to the Offline name. Thus the object's path is "DET/level2/level3"
175 // 3) the object to be stored
176 // 4) the metaData to be associated with the object
177 // 5) the validity start run number w.r.t. the current run,
178 // if the data is valid only for this run leave the default 0
179 // 6) specifies if the calibration data is valid for infinity (this means until updated),
180 // typical for calibration runs, the default is kFALSE
182 // The call is delegated to AliShuttleInterface
184 const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
185 if(!offlineDetName) return 0;
187 return fShuttle->Store(AliCDBPath(offlineDetName, pathLevel2, pathLevel3), object,
188 metaData, validityStart, validityInfinite);
191 //______________________________________________________________________________________________
192 Bool_t AliPreprocessor::StoreReferenceData(const char* pathLevel2, const char* pathLevel3, TObject* object,
193 AliCDBMetaData* metaData)
195 // Stores a CDB object in the storage for reference data. This objects will not be available during
196 // offline reconstrunction. Use this function for reference data only!
198 // This function should be called at the end of the preprocessor cycle
200 // The parameters are
201 // 1, 2) the 2nd and 3rd level of the object's path. The first level is the detector name which is provided
202 // by the Preprocessor and converted to the Offline name. Thus the object's path is "DET/level2/level3"
203 // 3) the object to be stored
204 // 4) the metaData to be associated with the object
206 // The call is delegated to AliShuttleInterface
208 const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
209 if(!offlineDetName) return 0;
211 return fShuttle->StoreReferenceData(AliCDBPath(offlineDetName, pathLevel2, pathLevel3), object,
215 //______________________________________________________________________________________________
216 Bool_t AliPreprocessor::StoreReferenceFile(const char* localFile, const char* gridFileName)
219 // Stores a file directly (without opening it) in the reference storage in the Grid
221 // The file is stored under the following location:
222 // <base folder of reference storage>/<DET>/<RUN#>_<gridFileName>
223 // where <gridFileName> is the second parameter given to the function
225 // The call is delegated to AliShuttleInterface
227 const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
228 if(!offlineDetName) return 0;
229 return fShuttle->StoreReferenceFile(GetName(), localFile, gridFileName);
232 //______________________________________________________________________________________________
233 const char* AliPreprocessor::GetFile(Int_t system, const char* id, const char* source)
235 // This function retrieves a file from the given system (kDAQ, kDCS, kHLT) with the given file id
236 // and from the given source in the system.
237 // The function returnes the path to the local file.
239 // The call is delegated to AliShuttleInterface
241 return fShuttle->GetFile(system, GetName(), id, source);
244 //______________________________________________________________________________________________
245 TList* AliPreprocessor::GetFileSources(Int_t system, const char* id)
247 // Returns a list of sources in a given system that saved a file with the given id
249 // The call is delegated to AliShuttleInterface
251 return fShuttle->GetFileSources(system, GetName(), id);
254 //______________________________________________________________________________________________
255 void AliPreprocessor::Log(const char* message)
257 // Adds a log message to the Shuttle log of this preprocessor
259 // The call is delegated to AliShuttleInterface
261 fShuttle->Log(GetName(), message);
264 //______________________________________________________________________________________________
265 const char* AliPreprocessor::GetRunParameter(const char* param)
267 // Return run parameter read from run logbook
269 // The call is delegated to AliShuttleInterface
271 return fShuttle->GetRunParameter(param);
274 //______________________________________________________________________________________________
275 AliCDBEntry* AliPreprocessor::GetFromOCDB(const char* pathLevel2, const char* pathLevel3)
277 // Return object from OCDB valid for current run
279 // The call is delegated to AliShuttleInterface
281 const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
282 if (!offlineDetName) return 0;
284 return dynamic_cast<AliCDBEntry*>
285 (fShuttle->GetFromOCDB(GetName(), AliCDBPath(offlineDetName, pathLevel2, pathLevel3)));
288 //______________________________________________________________________________________________
289 const char* AliPreprocessor::GetRunType()
291 // Return run type string read from "run type" logbook
293 // The call is delegated to AliShuttleInterface
295 return fShuttle->GetRunType();