]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliPreprocessor.cxx
Misalignment according survey data
[u/mrichter/AliRoot.git] / STEER / AliPreprocessor.cxx
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$
18 Revision 1.16  2007/08/22 09:20:50  hristov
19 Updated QA classes (Yves)
20
21 Revision 1.14  2007/05/30 06:35:21  jgrosseo
22 Adding functionality to the Shuttle/TestShuttle:
23 o) Function to retrieve list of sources from a given system (GetFileSources with id=0)
24 o) Function to retrieve list of IDs for a given source      (GetFileIDs)
25 These functions are needed for dealing with the tag files that are saved for the GRP preprocessor
26 Example code has been added to the TestProcessor in TestShuttle
27
28 Revision 1.13  2007/04/12 08:26:33  jgrosseo
29 updated commment
30
31 Revision 1.12  2007/04/05 08:05:55  acolla
32 Conversion from online to offline detector name in StoreReferenceFile
33
34 Revision 1.11  2007/04/04 10:29:18  jgrosseo
35 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.
36 In case of an error with the Grid, the Shuttle will retry the storing later, the preprocessor does not need to be run again.
37
38 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.
39
40 3) New function StoreReferenceFile to _directly_ store a file (without opening it) to the reference storage.
41
42 4) The memory usage of the preprocessor is monitored. If it exceeds 2 GB it is terminated.
43
44 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.
45 If you always need DCS data (like before), you do not need to implement it.
46
47 6) The run type has been added to the monitoring page
48
49 Revision 1.9  2007/02/28 10:42:58  acolla
50 Run type field added in SHUTTLE framework. Run type is read from "run type" logbook and retrieved by
51 AliPreprocessor::GetRunType() function.
52
53 Revision 1.7  2006/11/06 14:24:21  jgrosseo
54 reading of run parameters from the logbook
55 online offline naming conversion
56
57 Revision 1.6  2006/10/02 12:57:48  jgrosseo
58 Small interface change of function StoreReferenceData in Shuttle
59
60 Revision 1.5  2006/09/04 17:42:34  hristov
61 Changes required by Effective C++
62
63 Revision 1.4  2006/08/08 14:20:49  jgrosseo
64 Update to shuttle classes (Alberto)
65
66 - Possibility to set the full object's path in the Preprocessor's and
67 Shuttle's  Store functions
68 - Possibility to extend the object's run validity in the same classes
69 ("startValidity" and "validityInfinite" parameters)
70 - Implementation of the StoreReferenceData function to store reference
71 data in a dedicated CDB storage.
72
73 Revision 1.3  2006/07/11 12:42:43  jgrosseo
74 adding parameters for extended validity range of data produced by preprocessor
75
76 Revision 1.2  2006/06/06 16:36:49  jgrosseo
77 minor changes in AliShuttleInterface and AliPreprocessor
78
79 Revision 1.1  2006/06/02 14:14:36  hristov
80 Separate library for CDB (Jan)
81
82 Revision 1.2  2006/03/07 07:52:34  hristov
83 New version (B.Yordanov)
84
85 Revision 1.3  2005/11/17 17:47:34  byordano
86 TList changed to TObjArray
87
88 Revision 1.2  2005/11/17 14:43:22  byordano
89 import to local CVS
90
91 Revision 1.1.1.1  2005/10/28 07:33:58  hristov
92 Initial import as subdirectory in AliRoot
93
94 Revision 1.1.1.1  2005/09/12 22:11:40  byordano
95 SHUTTLE package
96
97 Revision 1.2  2005/08/29 21:15:47  byordano
98 some docs added
99
100 */
101
102 // Description:
103 // This class is the CDBPreProcessor interface,
104 // supposed to be implemented by any detector
105 // interested in immediate processing of data 
106 // which is retrieved from DCS.
107 // For every particular run set of aliases and
108 // their corespoding value sets are returned.
109 // Usage schema:
110 //      1) virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime) 
111 //      This method is called at the begining of data retrieval.
112 //      run: run number
113 //      startTime: when the run started
114 //      endTime: when the run finished  
115 //
116 //      2) virtual void Process()
117 //
118 //      This method is called and passed a list of retrieved values from DCS
119 //
120 //
121
122
123 #include "AliPreprocessor.h"
124
125 #include <TString.h>
126 #include <TList.h>
127 #include <TMap.h>
128
129 #include "AliLog.h"
130 #include "AliCDBMetaData.h"
131 #include "AliCDBStorage.h"
132 #include "AliCDBId.h"
133 #include "AliCDBPath.h"
134 #include "AliCDBEntry.h"
135 #include "AliShuttleInterface.h"
136
137 ClassImp(AliPreprocessor)
138
139 //______________________________________________________________________________________________
140 AliPreprocessor::AliPreprocessor(const char* detector, AliShuttleInterface* shuttle) :
141   TNamed(detector, ""),
142   fRun(-1),
143   fStartTime(0),
144   fEndTime(0),
145   fShuttle(shuttle)
146 {
147         SetTitle(Form("AliPreprocessor for %s subdetector.", detector));
148
149   if (!fShuttle)
150   {
151     AliFatal("Initialized without Shuttle instance.");
152     return;
153   }
154
155   fShuttle->RegisterPreprocessor(this);
156 }
157
158 //______________________________________________________________________________________________
159 AliPreprocessor::~AliPreprocessor()
160 {
161 }
162
163 //______________________________________________________________________________________________
164 void AliPreprocessor::Initialize(Int_t run, UInt_t startTime,   UInt_t endTime)
165 {
166   // Sets the information of the run which is currently processed
167   // can be overriden for special behaviour, make sure that you call base class
168   // function
169
170   fRun = run;
171   fStartTime = startTime;
172   fEndTime = endTime;
173 }
174
175 //______________________________________________________________________________________________
176 Bool_t AliPreprocessor::Store(const char* pathLevel2, const char* pathLevel3, TObject* object,
177                 AliCDBMetaData* metaData, Int_t validityStart, Bool_t validityInfinite)
178 {
179   // Stores a CDB object in the storage for offline reconstruction. Objects that are not needed for
180   // offline reconstruction, but should be stored anyway (e.g. for debugging) should NOT be stored
181   // using this function. Use StoreReferenceData instead!
182   //
183   // This function should be called at the end of the preprocessor cycle
184   //
185   // The parameters are
186   //   1, 2) the 2nd and 3rd level of the object's path. The first level is the detector name which is provided
187   //         by the Preprocessor and converted to the Offline name. Thus the object's path is "DET/level2/level3"
188   //   3) the object to be stored
189   //   4) the metaData to be associated with the object
190   //   5) the validity start run number w.r.t. the current run,
191   //      if the data is valid only for this run leave the default 0
192   //   6) specifies if the calibration data is valid for infinity (this means until updated),
193   //      typical for calibration runs, the default is kFALSE
194   //
195   // The call is delegated to AliShuttleInterface
196
197   const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
198   if(!offlineDetName) return 0;
199
200   return fShuttle->Store(AliCDBPath(offlineDetName, pathLevel2, pathLevel3), object,
201                 metaData, validityStart, validityInfinite);
202 }
203
204 //______________________________________________________________________________________________
205 Bool_t AliPreprocessor::StoreReferenceData(const char* pathLevel2, const char* pathLevel3, TObject* object,
206                 AliCDBMetaData* metaData)
207 {
208   // Stores a CDB object in the storage for reference data. This objects will not be available during
209   // offline reconstrunction. Use this function for reference data only!
210   //
211   // This function should be called at the end of the preprocessor cycle
212   //
213   // The parameters are
214   //   1, 2) the 2nd and 3rd level of the object's path. The first level is the detector name which is provided
215   //         by the Preprocessor and converted to the Offline name. Thus the object's path is "DET/level2/level3"
216   //   3) the object to be stored
217   //   4) the metaData to be associated with the object
218   //
219   // The call is delegated to AliShuttleInterface
220
221   const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
222   if(!offlineDetName) return 0;
223
224   return fShuttle->StoreReferenceData(AliCDBPath(offlineDetName, pathLevel2, pathLevel3), object,
225                 metaData);
226 }
227     
228 //______________________________________________________________________________________________
229 Bool_t AliPreprocessor::StoreReferenceFile(const char* localFile, const char* gridFileName)
230 {
231         //
232         // Stores a file directly (without opening it) in the reference storage in the Grid
233         //
234         // The file is stored under the following location: 
235         // <base folder of reference storage>/<DET>/<RUN#>_<gridFileName>
236         // where <gridFileName> is the second parameter given to the function
237         //
238         // The call is delegated to AliShuttleInterface
239         
240         const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
241         if(!offlineDetName) return 0;
242         return fShuttle->StoreReferenceFile(GetName(), localFile, gridFileName);
243 }
244
245 //______________________________________________________________________________________________
246 const char* AliPreprocessor::GetFile(Int_t system, const char* id, const char* source)
247 {
248   // This function retrieves a file from the given system (kDAQ, kDCS, kHLT) with the given file id
249   // and from the given source in the system.
250   // The function returnes the path to the local file.
251   //
252   // The call is delegated to AliShuttleInterface
253
254   return fShuttle->GetFile(system, GetName(), id, source);
255 }
256
257 //______________________________________________________________________________________________
258 TList* AliPreprocessor::GetFileSources(Int_t system, const char* id)
259 {
260   // Returns a list of sources in a given system that saved a file with the given id
261   // if id is not given all sources are returned
262   //
263   // The call is delegated to AliShuttleInterface
264
265   return fShuttle->GetFileSources(system, GetName(), id);
266 }
267
268 //______________________________________________________________________________________________
269 TList* AliPreprocessor::GetFileIDs(Int_t system, const char* source)
270 {
271   // Returns a list of ids in a given system that saved a file with the given source
272   //
273   // The call is delegated to AliShuttleInterface
274
275   return fShuttle->GetFileIDs(system, GetName(), source);
276 }
277
278 //______________________________________________________________________________________________
279 void AliPreprocessor::Log(const char* message)
280 {
281   // Adds a log message to the Shuttle log of this preprocessor
282   //
283   // The call is delegated to AliShuttleInterface
284
285   fShuttle->Log(GetName(), message);
286 }
287
288 //______________________________________________________________________________________________
289 const char* AliPreprocessor::GetRunParameter(const char* param)
290 {
291   // Return run parameter read from run logbook
292   //
293   // The call is delegated to AliShuttleInterface
294
295   return fShuttle->GetRunParameter(param);
296 }
297
298 //______________________________________________________________________________________________
299 AliCDBEntry* AliPreprocessor::GetFromOCDB(const char* pathLevel2, const char* pathLevel3)
300 {
301   // Return object from OCDB valid for current run
302   //
303   // The call is delegated to AliShuttleInterface
304
305   const char* offlineDetName = AliShuttleInterface::GetOfflineDetName(GetName());
306   if (!offlineDetName) return 0;
307
308   return dynamic_cast<AliCDBEntry*>
309         (fShuttle->GetFromOCDB(GetName(), AliCDBPath(offlineDetName, pathLevel2, pathLevel3)));
310 }
311
312 //______________________________________________________________________________________________
313 const char* AliPreprocessor::GetRunType()
314 {
315   // Return run type string read from "run type" logbook
316   //
317   // The call is delegated to AliShuttleInterface
318
319   return fShuttle->GetRunType();
320 }
321
322 //______________________________________________________________________________________________
323 Bool_t AliPreprocessor::GetHLTStatus()
324 {
325   // Return HLT status (ON or OFF)
326   // Converts the HLT status from the status string read in the run logbook (not just a bool)
327   // The call is delegated to AliShuttleInterface
328
329   return fShuttle->GetHLTStatus();
330
331 }