]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - T0/AliT0Preprocessor.cxx
Bugfix: lowercase b should be upper case B for component id: TPCClusterFinder32Bit
[u/mrichter/AliRoot.git] / T0 / AliT0Preprocessor.cxx
... / ...
CommitLineData
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: AliT0Preprocessor.cxx,v $
18Revision 1.8 2007/12/07 15:22:51 alla
19bug fixed by Alberto
20
21Revision 1.7 2007/12/06 16:35:24 alla
22new bugs fixed by Tomek
23
24Revision 1.5 2007/11/23 19:28:52 alla
25bug fixed
26
27Version 2.1 2007/11/21
28Preprocessor storing data to OCDB (T.Malkiewicz)
29
30Version 1.1 2006/10
31Preliminary test version (T.Malkiewicz)
32*/
33// T0 preprocessor:
34// 1) takes data from DCS and passes it to the class AliTOFDataDCS
35// for processing and writes the result to the Reference DB.
36// 2) takes data form DAQ (both from Laser Calibration and Physics runs),
37// processes it, and stores either to OCDB or to Reference DB.
38
39
40#include "AliT0Preprocessor.h"
41#include "AliT0DataDCS.h"
42#include "AliT0CalibWalk.h"
43#include "AliT0CalibTimeEq.h"
44
45#include "AliCDBMetaData.h"
46#include "AliDCSValue.h"
47#include "AliLog.h"
48
49#include <TTimeStamp.h>
50#include <TFile.h>
51#include <TObjString.h>
52#include <TNamed.h>
53#include "AliT0Dqclass.h"
54
55
56ClassImp(AliT0Preprocessor)
57
58//____________________________________________________
59AliT0Preprocessor::AliT0Preprocessor(AliShuttleInterface* shuttle) :
60 AliPreprocessor("T00", shuttle),
61 fData(0)
62{
63 //constructor
64 AddRunType("PHYSICS");
65 AddRunType("STANDALONE");
66 AddRunType("LASER");
67}
68//____________________________________________________
69
70AliT0Preprocessor::~AliT0Preprocessor()
71{
72 //destructor
73 delete fData;
74 fData = 0;
75}
76//____________________________________________________
77
78void AliT0Preprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
79{
80 // Creates AliT0DataDCS object
81 AliPreprocessor::Initialize(run, startTime, endTime);
82 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, TTimeStamp(startTime).AsString(), TTimeStamp(endTime).AsString()));
83 fData = new AliT0DataDCS(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery());
84}
85//____________________________________________________
86
87Bool_t AliT0Preprocessor::ProcessDCS(){
88 // Check whether DCS should be processed or not...
89 TString runType = GetRunType();
90 Log(Form("ProcessDCS - RunType: %s",runType.Data()));
91
92 if((runType == "STANDALONE")||
93 (runType == "PHYSICS")||
94 (runType == "LASER")){
95 // return kFALSE;
96 return kTRUE;
97 }else{
98 return kFALSE;
99 }
100}
101//____________________________________________________
102
103UInt_t AliT0Preprocessor::ProcessDCSDataPoints(TMap* dcsAliasMap){
104 // Fills data into AliT0DataDCS object
105 Log("Processing DCS DP");
106 Bool_t resultDCSMap=kFALSE;
107 Bool_t resultDCSStore=kFALSE;
108
109 if(!dcsAliasMap)
110 {
111 Log("No DCS input data");
112 return 1;
113 }
114 else
115 {
116 resultDCSMap=fData->ProcessData(*dcsAliasMap);
117 if(!resultDCSMap)
118 {
119 Log("Error when processing DCS data");
120 return 2;// return error Code for processed DCS data not stored
121 }
122 else
123 {
124 AliCDBMetaData metaDataDCS;
125 metaDataDCS.SetBeamPeriod(0);
126 metaDataDCS.SetResponsible("Tomasz Malkiewicz");
127 metaDataDCS.SetComment("This preprocessor fills an AliTODataDCS object.");
128 AliInfo("Storing DCS Data");
129 resultDCSStore = StoreReferenceData("Calib","DCSData",fData, &metaDataDCS);
130 if (!resultDCSStore)
131 {
132 Log("Some problems occurred while storing DCS data results in ReferenceDB");
133 return 2;// return error Code for processed DCS data not stored
134 }
135 }
136 }
137 return 0;
138}
139//____________________________________________________
140
141UInt_t AliT0Preprocessor::ProcessLaser(){
142 // Processing data from DAQ Standalone run
143 Log("Processing Laser calibration - Walk Correction");
144
145 Bool_t resultLaser=kFALSE;
146 //processing DAQ
147 TList* list = GetFileSources(kDAQ, "LASER");
148 if (list)
149 {
150 TIter iter(list);
151 TObjString *source;
152 while ((source = dynamic_cast<TObjString *> (iter.Next())))
153 {
154 const char *laserFile = GetFile(kDAQ, "LASER", source->GetName());
155 if (laserFile)
156 {
157 Log(Form("File with Id LASER found in source %s!", source->GetName()));
158 AliT0CalibWalk *laser = new AliT0CalibWalk();
159 laser->MakeWalkCorrGraph(laserFile);
160 AliCDBMetaData metaData;
161 metaData.SetBeamPeriod(0);
162 metaData.SetResponsible("Tomek&Michal");
163 metaData.SetComment("Walk correction from laser runs.");
164 resultLaser=Store("Calib","Slewing_Walk", laser, &metaData, 0, 1);
165 delete laser;
166 Log(Form("resultLaser = %d",resultLaser));
167 }
168 else
169 {
170 Log(Form("Could not find file with Id LASER in source %s!", source->GetName()));
171 return 1;
172 }
173 }
174 if (!resultLaser)
175 {
176 Log("No Laser Data stored");
177 return 3;//return error code for failure in storing Laser Data
178 }
179 } else {
180 Log("No sources found for id LASER!");
181 return 1;
182 }
183 return 0;
184}
185//____________________________________________________
186
187UInt_t AliT0Preprocessor::ProcessPhysics(){
188 //Processing data from DAQ Physics run
189 Log("Processing Physics");
190
191 Bool_t resultOnline=kFALSE;
192 //processing DAQ
193 TList* listPhys = GetFileSources(kDAQ, "PHYSICS");
194 if (listPhys)
195 {
196 TIter iter(listPhys);
197 TObjString *sourcePhys;
198 while ((sourcePhys = dynamic_cast<TObjString *> (iter.Next())))
199 {
200 const char *filePhys = GetFile(kDAQ, "PHYSICS", sourcePhys->GetName());
201 if (filePhys)
202 {
203 AliT0CalibTimeEq *online = new AliT0CalibTimeEq();
204 online->Reset();
205 online->ComputeOnlineParams(filePhys);
206 AliCDBMetaData metaData;
207 metaData.SetBeamPeriod(0);
208 metaData.SetResponsible("Tomek&Michal");
209 metaData.SetComment("Time equalizing result.");
210 resultOnline = Store("Calib","TimeDelay", online, &metaData, 0, 1);
211 Log(Form("resultOnline = %d",resultOnline));
212 delete online;
213 }
214 else
215 {
216 Log(Form("Could not find file with Id PHYSICS in source %s!", sourcePhys->GetName()));
217 return 1;
218 }
219
220 }
221 if (!resultOnline)
222 {
223 Log("No Data stored");
224 return 4;//return error code for failure in storing OCDB Data
225 }
226 } else {
227 Log("No sources found for id PHYSICS!");
228 return 1;
229 }
230 return 0;
231}
232//____________________________________________________
233
234UInt_t AliT0Preprocessor::ProcessCosmic(){
235 //Processing data from DAQ Physics run
236 Log("Processing Laser Physics");
237
238 Bool_t resultLaserOnline=kFALSE;
239 //processing DAQ
240 TList* listLaser = GetFileSources(kDAQ, "COSMIC");
241 if (listLaser)
242 {
243 TIter iter(listLaser);
244 TObjString *sourceLaser;
245 while ((sourceLaser = dynamic_cast<TObjString *> (iter.Next())))
246 {
247 const char *fileLaser = GetFile(kDAQ, "COSMIC", sourceLaser->GetName());
248 if (fileLaser)
249 {
250 AliT0CalibTimeEq *onlineLaser = new AliT0CalibTimeEq();
251 onlineLaser->Reset();
252 onlineLaser->ComputeOnlineParams(fileLaser);
253 AliCDBMetaData metaData;
254 metaData.SetBeamPeriod(0);
255 metaData.SetResponsible("Tomek&Michal");
256 metaData.SetComment("Time equalizing result.");
257 resultLaserOnline = Store("Calib","LaserTimeDelay", onlineLaser, &metaData, 0, 1);
258 Log(Form("resultLaserOnline = %d",resultLaserOnline));
259 delete onlineLaser;
260 }
261 else
262 {
263 Log(Form("Could not find file with Id COSMIC in source %s!", sourceLaser->GetName()));
264 return 0;
265 }
266
267 }
268 if (!resultLaserOnline)
269 {
270 Log("No Laser Data stored");
271 return 0;//return error code for failure in storing OCDB Data
272 }
273 } else {
274 Log("No sources found for id COSMIC!");
275 return 0;
276 }
277 return 0;
278}
279//____________________________________________________
280
281UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
282{
283 // T0 preprocessor return codes:
284 // return=0 : all ok
285 // return=1 : no DCS input data
286 // return=2 : failed to store DCS data
287 // return=3 : no Laser data (Walk correction)
288 // return=4 : failed to store OCDB time equalized data
289 // return=5 : no DAQ input for OCDB
290 // return=6 : failed to retrieve DAQ data from OCDB
291 // return=7 : failed to store T0 OCDB data
292 Bool_t dcsDP = ProcessDCS();
293 Log(Form("dcsDP = %d",dcsDP));
294 TString runType = GetRunType();
295 Log(Form("RunType: %s",runType.Data()));
296 //processing
297 if(runType == "STANDALONE"){
298 if(dcsDP==1){
299 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
300 return iresultDCS;
301 }
302 }
303 if(runType == "LASER"){
304 Int_t iresultLaser = ProcessLaser();
305 if(dcsDP==1){
306 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
307 return iresultDCS;
308 }
309 Log(Form("iresultLaser = %d",iresultLaser));
310 return iresultLaser;
311 }
312 else if(runType == "PHYSICS"){
313 Int_t iresultPhysics = ProcessPhysics();
314 // Int_t iresultCosmic = ProcessCosmic();
315 if(dcsDP==1){
316 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
317 return iresultDCS;
318 }
319 Log(Form("iresultPhysics = %d",iresultPhysics));
320 return iresultPhysics;
321 // Log(Form("iresultPhysics =iresultCosmic %d",iresultCosmic));
322 // return iresultCosmic;
323 }
324
325 return 0;
326}