]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliPreprocessor.cxx
moved AliSelector, AliSelectorRL to STEER
[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.5  2006/09/04 17:42:34  hristov
19 Changes required by Effective C++
20
21 Revision 1.4  2006/08/08 14:20:49  jgrosseo
22 Update to shuttle classes (Alberto)
23
24 - Possibility to set the full object's path in the Preprocessor's and
25 Shuttle's  Store functions
26 - Possibility to extend the object's run validity in the same classes
27 ("startValidity" and "validityInfinite" parameters)
28 - Implementation of the StoreReferenceData function to store reference
29 data in a dedicated CDB storage.
30
31 Revision 1.3  2006/07/11 12:42:43  jgrosseo
32 adding parameters for extended validity range of data produced by preprocessor
33
34 Revision 1.2  2006/06/06 16:36:49  jgrosseo
35 minor changes in AliShuttleInterface and AliPreprocessor
36
37 Revision 1.1  2006/06/02 14:14:36  hristov
38 Separate library for CDB (Jan)
39
40 Revision 1.2  2006/03/07 07:52:34  hristov
41 New version (B.Yordanov)
42
43 Revision 1.3  2005/11/17 17:47:34  byordano
44 TList changed to TObjArray
45
46 Revision 1.2  2005/11/17 14:43:22  byordano
47 import to local CVS
48
49 Revision 1.1.1.1  2005/10/28 07:33:58  hristov
50 Initial import as subdirectory in AliRoot
51
52 Revision 1.1.1.1  2005/09/12 22:11:40  byordano
53 SHUTTLE package
54
55 Revision 1.2  2005/08/29 21:15:47  byordano
56 some docs added
57
58 */
59
60 // Description:
61 // This class is the CDBPreProcessor interface,
62 // supposed to be implemented by any detector
63 // interested in immediate processing of data 
64 // which is retrieved from DCS.
65 // For every particular run set of aliases and
66 // their corespoding value sets are returned.
67 // Usage schema:
68 //      1) virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime) 
69 //      This method is called at the begining of data retrieval.
70 //      run: run number
71 //      startTime: when the run started
72 //      endTime: when the run finished  
73 //
74 //      2) virtual void Process()
75 //
76 //      This method is called and passed a list of retrieved values from DCS
77 //
78 //
79
80
81 #include "AliPreprocessor.h"
82
83 #include <TString.h>
84 #include <TList.h>
85 #include <TMap.h>
86
87 #include "AliLog.h"
88 #include "AliCDBMetaData.h"
89 #include "AliCDBStorage.h"
90 #include "AliCDBId.h"
91 #include "AliCDBPath.h"
92 #include "AliShuttleInterface.h"
93
94 ClassImp(AliPreprocessor)
95
96 //______________________________________________________________________________________________
97 AliPreprocessor::AliPreprocessor(const char* detector, AliShuttleInterface* shuttle) :
98   TNamed(detector, ""),
99   fRun(-1),
100   fStartTime(0),
101   fEndTime(0),
102   fShuttle(shuttle)
103 {
104         SetTitle(Form("AliPreprocessor for %s subdetector.", detector));
105
106   if (!fShuttle)
107   {
108     AliFatal("Initialized without Shuttle instance.");
109     return;
110   }
111
112   fShuttle->RegisterPreprocessor(this);
113 }
114
115 //______________________________________________________________________________________________
116 AliPreprocessor::~AliPreprocessor()
117 {
118 }
119
120 //______________________________________________________________________________________________
121 void AliPreprocessor::Initialize(Int_t run, UInt_t startTime,   UInt_t endTime)
122 {
123   // Sets the information of the run which is currently processed
124   // can be overriden for special behaviour, make sure that you call base class
125   // function
126
127   fRun = run;
128   fStartTime = startTime;
129   fEndTime = endTime;
130 }
131
132 //______________________________________________________________________________________________
133 UInt_t AliPreprocessor::Store(const char* pathLevel2, const char* pathLevel3, TObject* object,
134                 AliCDBMetaData* metaData, Int_t validityStart, Bool_t validityInfinite)
135 {
136   // Stores a CDB object in the storage for offline reconstruction. Objects that are not needed for
137   // offline reconstruction, but should be stored anyway (e.g. for debugging) should NOT be stored
138   // using this function. Use StoreReferenceData instead!
139   //
140   // This function should be called at the end of the preprocessor cycle
141   //
142   // The parameters are
143   //   1, 2) the 2nd and 3rd level of the object's path. The first level is the detector name which is provided
144   //         by the Preprocessor. Thus the object's path is "DET/level2/level3"
145   //   3) the object to be stored
146   //   4) the metaData to be associated with the object
147   //   5) the validity start run number w.r.t. the current run,
148   //      if the data is valid only for this run leave the default 0
149   //   6) specifies if the calibration data is valid for infinity (this means until updated),
150   //      typical for calibration runs, the default is kFALSE
151   //
152   // The call is delegated to AliShuttleInterface
153
154   return fShuttle->Store(AliCDBPath(GetName(), pathLevel2, pathLevel3), object,
155                 metaData, validityStart, validityInfinite);
156 }
157
158 //______________________________________________________________________________________________
159 UInt_t AliPreprocessor::StoreReferenceData(const char* pathLevel2, const char* pathLevel3, TObject* object,
160                 AliCDBMetaData* metaData)
161 {
162   // Stores a CDB object in the storage for reference data. This objects will not be available during
163   // offline reconstrunction. Use this function for reference data only!
164   //
165   // This function should be called at the end of the preprocessor cycle
166   //
167   // The parameters are
168   //   1, 2) the 2nd and 3rd level of the object's path. The first level is the detector name which is provided
169   //         by the Preprocessor. Thus the object's path is "DET/level2/level3"
170   //   3) the object to be stored
171   //   4) the metaData to be associated with the object
172   //
173   // The call is delegated to AliShuttleInterface
174
175   return fShuttle->StoreReferenceData(AliCDBPath(GetName(), pathLevel2, pathLevel3), object,
176                 metaData);
177 }
178
179 //______________________________________________________________________________________________
180 const char* AliPreprocessor::GetFile(Int_t system, const char* id, const char* source)
181 {
182   // This function retrieves a file from the given system (kDAQ, kDCS, kHLT) with the given file id
183   // and from the given source in the system.
184   // The function returnes the path to the local file.
185   //
186   // The call is delegated to AliShuttleInterface
187
188   return fShuttle->GetFile(system, GetName(), id, source);
189 }
190
191 //______________________________________________________________________________________________
192 TList* AliPreprocessor::GetFileSources(Int_t system, const char* id)
193 {
194   // Returns a list of sources in a given system that saved a file with the given id
195   //
196   // The call is delegated to AliShuttleInterface
197
198   return fShuttle->GetFileSources(system, GetName(), id);
199 }
200
201 //______________________________________________________________________________________________
202 void AliPreprocessor::Log(const char* message)
203 {
204   // Adds a log message to the Shuttle log of this preprocessor
205   //
206   // The call is delegated to AliShuttleInterface
207
208   fShuttle->Log(GetName(), message);
209 }