]> git.uio.no Git - u/mrichter/AliRoot.git/blame - T0/AliT0Preprocessor.cxx
task - wagon fo rLEGO train
[u/mrichter/AliRoot.git] / T0 / AliT0Preprocessor.cxx
CommitLineData
bc943889 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/*
50e28e1c 17$Log: AliT0Preprocessor.cxx,v $
18Revision 1.8 2007/12/07 15:22:51 alla
19bug fixed by Alberto
271b5bd3 20
67b67126 21Revision 1.7 2007/12/06 16:35:24 alla
22new bugs fixed by Tomek
23
02cf5377 24Revision 1.5 2007/11/23 19:28:52 alla
25bug fixed
26
bc943889 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*/
387638f7 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
bc943889 39
dc7ca31d 40#include "AliT0Preprocessor.h"
bc943889 41#include "AliT0DataDCS.h"
42#include "AliT0CalibWalk.h"
43#include "AliT0CalibTimeEq.h"
dc7ca31d 44
45#include "AliCDBMetaData.h"
46#include "AliDCSValue.h"
8f1790c4 47#include "AliCDBEntry.h"
dc7ca31d 48#include "AliLog.h"
dc7ca31d 49
50#include <TTimeStamp.h>
51#include <TFile.h>
5221c818 52#include <TObjString.h>
dc7ca31d 53#include <TNamed.h>
54#include "AliT0Dqclass.h"
6a9d154f 55#include "TClass.h"
dc7ca31d 56
bc943889 57
dc7ca31d 58ClassImp(AliT0Preprocessor)
59
60//____________________________________________________
387638f7 61AliT0Preprocessor::AliT0Preprocessor(AliShuttleInterface* shuttle) :
62 AliPreprocessor("T00", shuttle),
63 fData(0)
dc7ca31d 64{
bc943889 65 //constructor
2a8e3409 66 AddRunType("PHYSICS");
67 AddRunType("STANDALONE");
d95247c3 68 AddRunType("AMPLITUDE_CALIBRATION");
dc7ca31d 69}
bc943889 70//____________________________________________________
dc7ca31d 71
72AliT0Preprocessor::~AliT0Preprocessor()
73{
50e28e1c 74 //destructor
bc943889 75 delete fData;
76 fData = 0;
77}
78//____________________________________________________
dc7ca31d 79
bc943889 80void AliT0Preprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
81{
50e28e1c 82 // Creates AliT0DataDCS object
bc943889 83 AliPreprocessor::Initialize(run, startTime, endTime);
84 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, TTimeStamp(startTime).AsString(), TTimeStamp(endTime).AsString()));
8eb4ac75 85 fData = new AliT0DataDCS(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery());
dc7ca31d 86}
bc943889 87//____________________________________________________
dc7ca31d 88
49ab1618 89Bool_t AliT0Preprocessor::ProcessDCS(){
90 // Check whether DCS should be processed or not...
91 TString runType = GetRunType();
92 Log(Form("ProcessDCS - RunType: %s",runType.Data()));
93
ab934de3 94 if(runType == "PHYSICS" )
95 return kTRUE;
96 else
97 return kFALSE;
98
49ab1618 99}
100//____________________________________________________
bc943889 101
49ab1618 102UInt_t AliT0Preprocessor::ProcessDCSDataPoints(TMap* dcsAliasMap){
103 // Fills data into AliT0DataDCS object
104 Log("Processing DCS DP");
bc943889 105 Bool_t resultDCSMap=kFALSE;
106 Bool_t resultDCSStore=kFALSE;
49ab1618 107
8bfd9a3e 108 if(!dcsAliasMap)
109 {
110 Log("No DCS input data");
49ab1618 111 return 1;
8bfd9a3e 112 }
113 else
114 {
115 resultDCSMap=fData->ProcessData(*dcsAliasMap);
116 if(!resultDCSMap)
117 {
118 Log("Error when processing DCS data");
bc943889 119 return 2;// return error Code for processed DCS data not stored
120 }
121 else
122 {
123 AliCDBMetaData metaDataDCS;
124 metaDataDCS.SetBeamPeriod(0);
125 metaDataDCS.SetResponsible("Tomasz Malkiewicz");
126 metaDataDCS.SetComment("This preprocessor fills an AliTODataDCS object.");
127 AliInfo("Storing DCS Data");
fe3c9b71 128 resultDCSStore = StoreReferenceData("Calib","DCSData",fData, &metaDataDCS);
bc943889 129 if (!resultDCSStore)
8bfd9a3e 130 {
bc943889 131 Log("Some problems occurred while storing DCS data results in ReferenceDB");
387638f7 132 return 2;// return error Code for processed DCS data not stored
bc943889 133 }
8bfd9a3e 134 }
135 }
49ab1618 136 return 0;
137}
138//____________________________________________________
02888358 139
d95247c3 140UInt_t AliT0Preprocessor::ProcessLaser()
141{
142 // Processing data from DAQ Standalone run
8f1790c4 143 Log("Processing Laser calibration - Walk Correction");
d95247c3 144 Bool_t resultLaser = kFALSE;
145 Bool_t writeok = kFALSE;
146 //processing DAQ
d95247c3 147 TList* list = GetFileSources(kDAQ, "AMPLITUDE_CALIBRATION");
148 AliT0CalibWalk *laser = new AliT0CalibWalk();
9b38eec5 149 TObjString *source;
d95247c3 150 if (list)
151 {
152 TIter iter(list);
153 while ((source = dynamic_cast<TObjString *> (iter.Next())))
154 {
155 const char *laserFile = GetFile(kDAQ, "AMPLITUDE_CALIBRATION", source->GetName());
156 if (laserFile)
157 {
2ba5f106 158 Log(Form("File with Id AMPLITUDE_CALIBRAION found in source %s!", source->GetName()));
d95247c3 159 writeok = laser->MakeWalkCorrGraph(laserFile);
160
161 }
162 }
163
164 AliCDBMetaData metaData;
165 metaData.SetBeamPeriod(0);
c5a24053 166 metaData.SetResponsible("Alla");
d95247c3 167 metaData.SetComment("Walk correction from laser runs.");
168 if (writeok) resultLaser=Store("Calib","Slewing_Walk", laser, &metaData, 0, 1);
169 else {
9b38eec5 170
d95247c3 171 Log(Form("writeok = %d no peaks in CFD spectra",writeok));
172 return 0;
173 }
174 Log(Form("resultLaser = %d",resultLaser));
2ba5f106 175 if (!resultLaser)
176 {
177 Log("No Laser Data stored");
178 return 3;//return error code for failure in storing Laser Data
179 }
d95247c3 180 }
181 else
182 {
9b38eec5 183 Log(Form("Could not find file with Id AMPLITUDE_CALIBRAION "));
d95247c3 184 return 1;
185 }
8f1790c4 186
2ba5f106 187 return 0;
49ab1618 188}
02888358 189
49ab1618 190//____________________________________________________
191
192UInt_t AliT0Preprocessor::ProcessPhysics(){
193 //Processing data from DAQ Physics run
194 Log("Processing Physics");
02888358 195
271b5bd3 196 Bool_t resultOnline=kFALSE;
49ab1618 197 //processing DAQ
198 TList* listPhys = GetFileSources(kDAQ, "PHYSICS");
199 if (listPhys)
8bfd9a3e 200 {
201 TIter iter(listPhys);
202 TObjString *sourcePhys;
203 while ((sourcePhys = dynamic_cast<TObjString *> (iter.Next())))
204 {
205 const char *filePhys = GetFile(kDAQ, "PHYSICS", sourcePhys->GetName());
206 if (filePhys)
207 {
208 AliT0CalibTimeEq *online = new AliT0CalibTimeEq();
209 online->Reset();
02888358 210 Bool_t writeok = online->ComputeOnlineParams(filePhys);
8bfd9a3e 211 AliCDBMetaData metaData;
212 metaData.SetBeamPeriod(0);
02888358 213 metaData.SetResponsible("Alla Maevskaya");
8bfd9a3e 214 metaData.SetComment("Time equalizing result.");
02888358 215
216 if (writeok) resultOnline = Store("Calib","TimeDelay", online, &metaData, 0, 1);
217 else {
218
219 Log(Form("writeok = %d not enough data for equalizing",resultOnline));
220 return 0;
221 }
271b5bd3 222 Log(Form("resultOnline = %d",resultOnline));
8bfd9a3e 223 delete online;
224 }
271b5bd3 225 else
8bfd9a3e 226 {
227 Log(Form("Could not find file with Id PHYSICS in source %s!", sourcePhys->GetName()));
228 return 1;
229 }
271b5bd3 230
8bfd9a3e 231 }
232 if (!resultOnline)
bc943889 233 {
271b5bd3 234 Log("No Data stored");
bc943889 235 return 4;//return error code for failure in storing OCDB Data
236 }
67b67126 237 } else {
238 Log("No sources found for id PHYSICS!");
239 return 1;
240 }
49ab1618 241 return 0;
242}
243//____________________________________________________
244
245UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
246{
247 // T0 preprocessor return codes:
248 // return=0 : all ok
249 // return=1 : no DCS input data
250 // return=2 : failed to store DCS data
251 // return=3 : no Laser data (Walk correction)
252 // return=4 : failed to store OCDB time equalized data
253 // return=5 : no DAQ input for OCDB
254 // return=6 : failed to retrieve DAQ data from OCDB
255 // return=7 : failed to store T0 OCDB data
02888358 256 // return=8 : not enough data for equalizing
257 Bool_t dcsDP = ProcessDCS();
258 Log(Form("dcsDP = %d",dcsDP));
259 TString runType = GetRunType();
260 Log(Form("RunType: %s",runType.Data()));
261 //processing
262 if(runType == "STANDALONE"){
263 if(dcsDP==1){
264 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
265 return iresultDCS;
266 }
267 }
d95247c3 268
269 if(runType == "AMPLITUDE_CALIBRATION"){
02888358 270 Int_t iresultLaser = ProcessLaser();
271 if(dcsDP==1){
272 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
273 return iresultDCS;
274 }
275
276 Log(Form("iresultLaser = %d",iresultLaser));
277 return iresultLaser;
278 }
d95247c3 279
02888358 280 else if(runType == "PHYSICS"){
281 Int_t iresultPhysics = ProcessPhysics();
282 if(dcsDP==1){
283 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
284 return iresultDCS;
285 }
286 Log(Form("iresultPhysics = %d",iresultPhysics));
79e2e9c6 287 return iresultPhysics;
02888358 288 }
289
290
79e2e9c6 291
292 return 0;
dc7ca31d 293}