]>
Commit | Line | Data |
---|---|---|
5c6b40ae | 1 | #include "AliTestPreprocessor.h" |
2 | ||
3 | #include "AliCDBMetaData.h" | |
d461a8a7 | 4 | #include "AliCDBEntry.h" |
5c6b40ae | 5 | #include "AliDCSValue.h" |
6 | #include "AliLog.h" | |
7 | #include "AliTestDataDCS.h" | |
8 | ||
9 | #include <TTimeStamp.h> | |
d461a8a7 | 10 | #include <TObjString.h> |
9827400b | 11 | #include <TList.h> |
5c6b40ae | 12 | |
13 | // | |
14 | // This class is an example for a simple preprocessor. | |
15 | // It takes data from DCS and passes it to the class AliTestDataDCS, which | |
16 | // reformats its. This class is then written to the CDB. | |
17 | // | |
18 | ||
19 | ClassImp(AliTestPreprocessor) | |
20 | ||
36137ac1 | 21 | //______________________________________________________________________________________________ |
fc5a4708 | 22 | AliTestPreprocessor::AliTestPreprocessor(AliShuttleInterface* shuttle) : |
23 | AliPreprocessor("TPC", shuttle), | |
5c6b40ae | 24 | fData(0) |
25 | { | |
26 | // constructor | |
0ffe41b3 | 27 | |
28 | AddRunType("PHYSICS"); | |
29 | AddRunType("CALIBRATION"); | |
5c6b40ae | 30 | } |
31 | ||
36137ac1 | 32 | //______________________________________________________________________________________________ |
5c6b40ae | 33 | AliTestPreprocessor::~AliTestPreprocessor() |
34 | { | |
35 | // destructor | |
36 | } | |
37 | ||
36137ac1 | 38 | //______________________________________________________________________________________________ |
5c6b40ae | 39 | void AliTestPreprocessor::Initialize(Int_t run, UInt_t startTime, |
40 | UInt_t endTime) | |
41 | { | |
42 | // Creates AliTestDataDCS object | |
43 | ||
44 | AliPreprocessor::Initialize(run, startTime, endTime); | |
45 | ||
9827400b | 46 | Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, |
5c6b40ae | 47 | TTimeStamp(startTime).AsString(), |
48 | TTimeStamp(endTime).AsString())); | |
49 | ||
50 | fData = new AliTestDataDCS(fRun, fStartTime, fEndTime); | |
51 | } | |
52 | ||
9827400b | 53 | //______________________________________________________________________________________________ |
54 | Bool_t AliTestPreprocessor::ProcessDCS() | |
55 | { | |
56 | // | |
57 | // decide here if DCS data is to be processed | |
58 | // | |
59 | ||
60 | // TODO implement a decision, e.g. based on the run type | |
61 | // In this example: Skip DCS if run type is CALIB | |
62 | if (strcmp(GetRunType(), "CALIB") == 0) | |
63 | return kFALSE; | |
64 | ||
65 | return kTRUE; | |
66 | } | |
67 | ||
36137ac1 | 68 | //______________________________________________________________________________________________ |
69 | UInt_t AliTestPreprocessor::Process(TMap* dcsAliasMap) | |
5c6b40ae | 70 | { |
71 | // Fills data into a AliTestDataDCS object | |
72 | ||
73 | if (!dcsAliasMap) | |
886d60e6 | 74 | { |
75 | Log("ERROR: No DCS map provided by SHUTTLE!"); | |
76 | return 1; | |
77 | } | |
87968cd5 | 78 | |
36137ac1 | 79 | // The processing of the DCS input data is forwarded to AliTestDataDCS |
441b0e9c | 80 | fData->ProcessData(*dcsAliasMap); |
5c6b40ae | 81 | |
441b0e9c | 82 | // Example of how to retrieve the run type from the Shuttle, using GetRunType() function |
83 | // TODO Here the run type for the "DET" detector must be set manually with SetInputRunType function, | |
84 | // in reality it will be read from the "run type" logbook! | |
85 | TString runType = GetRunType(); | |
9827400b | 86 | Log(Form("Run type for run %d: %s", fRun, runType.Data())); |
441b0e9c | 87 | |
886d60e6 | 88 | // Example of how to retrieve the list of sources that produced the file with id DRIFTVELOCITY |
89 | TList* sourceList = GetFileSources(kDAQ, "DRIFTVELOCITY"); | |
87968cd5 | 90 | sourceList = GetFileSources(kHLT, "HLTData"); |
886d60e6 | 91 | if (!sourceList) |
92 | { | |
87968cd5 | 93 | Log("Error retrieving list of sources from FXS!"); |
94 | return 1; | |
886d60e6 | 95 | } |
87968cd5 | 96 | |
97 | if (sourceList->GetEntries() == 0) | |
98 | { | |
99 | Log("No sources found for id HLTData!"); | |
100 | // TODO What to do now depends on the expected behaviour of the | |
101 | // online DA: if it expected to produce data for the FXS every run, then | |
102 | // if no sources are found it means a problem happened and you should return error; | |
103 | // if DA may or may not send files to FXS, then you shouldn't return error | |
104 | // and go on with the analysis! | |
105 | return 1; | |
106 | } | |
107 | ||
108 | // TODO We have the list of sources that produced the files with Id DRIFTVELOCITY. | |
886d60e6 | 109 | // Now we will loop on the list and we'll query the files one by one. |
110 | Log("The following sources produced files with the id DRIFTVELOCITY"); | |
111 | sourceList->Print(); | |
4a33bdd9 | 112 | |
886d60e6 | 113 | TIter iter(sourceList); |
114 | TObjString *source = 0; | |
115 | while((source=dynamic_cast<TObjString*> (iter.Next()))){ | |
116 | TString fileName = GetFile(kDAQ, "DRIFTVELOCITY", source->GetName()); | |
117 | if (fileName.Length() > 0) | |
118 | Log(Form("Got the file %s, now we can extract some values.", fileName.Data())); | |
119 | } | |
36137ac1 | 120 | |
886d60e6 | 121 | delete sourceList; |
122 | ||
87968cd5 | 123 | // Example of retrieving files from HLT, including how to query HLT status |
124 | ||
125 | Bool_t hltStatus = GetHLTStatus(); // 1 = HLT ON (=> Query HLT), 0 = HLT OFF (=> skip HLT query) | |
126 | ||
127 | if (hltStatus) | |
128 | { | |
129 | Log("HLT is ON, let's query our files"); | |
130 | sourceList = GetFileSources(kHLT, "HLTData"); | |
131 | if (!sourceList) | |
132 | { | |
133 | Log("Error retrieving list of sources from FXS!"); | |
134 | return 1; | |
135 | } | |
136 | ||
137 | if (sourceList->GetEntries() == 0) | |
138 | { | |
139 | Log("No sources found for id HLTData!"); | |
140 | // TODO What to do now depends on the expected behaviour of the | |
141 | // online DA: if it expected to produce data for the FXS every run, then | |
142 | // if no sources are found it means a problem happened and you should return error; | |
143 | // if DA may or may not send files to FXS, then you shouldn't return error | |
144 | // and go on with the analysis! | |
145 | return 1; | |
146 | } | |
147 | Log("The following sources produced files with the id HLTData"); | |
148 | ||
149 | sourceList->Print(); | |
150 | ||
151 | TIter iter(sourceList); | |
152 | TObjString *source = 0; | |
153 | while((source=dynamic_cast<TObjString*> (iter.Next()))){ | |
154 | TString fileName = GetFile(kHLT, "HLTData", source->GetName()); | |
155 | if (fileName.Length() > 0) | |
156 | Log(Form("Got the file %s from HLT, now we can extract some values.", fileName.Data())); | |
157 | } | |
158 | ||
159 | delete sourceList; | |
160 | ||
161 | } else { | |
162 | Log("HLT is OFF, skipping query..."); | |
163 | } | |
164 | ||
4a33bdd9 | 165 | // Example of how to retrieve the list of sources that produced files |
166 | sourceList = GetFileSources(kDAQ); | |
167 | if (!sourceList) | |
168 | { | |
169 | Log("Error: No sources found!"); | |
170 | return 1; | |
171 | } | |
172 | ||
173 | Log("The following sources produced files"); | |
174 | sourceList->Print(); | |
175 | delete sourceList; | |
176 | ||
177 | // Example of how to retrieve the list of ids from a given source | |
178 | TList* idList = GetFileIDs(kDAQ, "LDC0"); | |
179 | if (!idList) | |
180 | { | |
181 | Log("Error: No IDs found!"); | |
182 | return 1; | |
183 | } | |
184 | ||
185 | Log("The following ids are available"); | |
186 | idList->Print(); | |
187 | delete idList; | |
188 | ||
886d60e6 | 189 | // Example to store a file directly to the reference storage |
190 | // Suppose we have queried the file from the FXS. Now the file is available locally and is called "file1.root". | |
191 | const char* refFileName="file1.root"; | |
192 | if (!StoreReferenceFile(refFileName, "InputData.root")) | |
9827400b | 193 | return 1; |
194 | ||
36137ac1 | 195 | |
eba76848 | 196 | // Example of how to retrieve a run parameter using GetRunParameter function |
197 | // TODO Here the parameter must be set manually with SetInputRunParameter function, | |
198 | // in reality it will be read from the run logbook! | |
199 | ||
200 | // note that the parameters are returned as character strings! | |
201 | const char* nEvents = GetRunParameter("totalEvents"); | |
202 | if (nEvents) { | |
203 | Log(Form("Number of events for run %d: %s",fRun, nEvents)); | |
204 | } else { | |
205 | Log(Form("Number of events not put in logbook!")); | |
206 | } | |
207 | ||
d461a8a7 | 208 | // Example of how to retrieve a condition object from OCDB |
209 | ||
210 | AliCDBEntry *entry = GetFromOCDB("Calib", "Data"); | |
211 | if (!entry) | |
212 | { | |
213 | Log("No object found in OCDB!"); | |
214 | } else { | |
87968cd5 | 215 | Log("Got TPC/Calib/Data object from OCDB. The object's metadata is: "); |
216 | entry->PrintMetaData(); | |
d461a8a7 | 217 | } |
218 | ||
eba76848 | 219 | |
36137ac1 | 220 | //Now we have to store the final CDB file |
5c6b40ae | 221 | AliCDBMetaData metaData; |
222 | metaData.SetBeamPeriod(0); | |
441b0e9c | 223 | metaData.SetResponsible("TPC expert"); |
5c6b40ae | 224 | metaData.SetComment("This preprocessor fills an AliTestDataDCS object."); |
225 | ||
9827400b | 226 | Bool_t result = Store("Calib", "Data", fData, &metaData, 0, 0); |
5c6b40ae | 227 | delete fData; |
228 | fData = 0; | |
229 | ||
9827400b | 230 | if (!result) |
231 | return 1; | |
232 | ||
233 | return 0; | |
5c6b40ae | 234 | } |
235 |