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