Status word changed according to P. Martinengo.
[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/*
17$Log$
02cf5377 18Revision 1.5 2007/11/23 19:28:52 alla
19bug fixed
20
bc943889 21Version 2.1 2007/11/21
22Preprocessor storing data to OCDB (T.Malkiewicz)
23
24Version 1.1 2006/10
25Preliminary test version (T.Malkiewicz)
26*/
27
28// T0 preprocessor:
29// 1) takes data from DCS and passes it to the class AliTOFDataDCS for processing and writes the result to the Reference DB.
30// 2) takes data form DAQ (both from Laser Calibration and Physics runs), processes it, and stores either to OCDB or to Reference DB.
31
dc7ca31d 32#include "AliT0Preprocessor.h"
bc943889 33#include "AliT0DataDCS.h"
34#include "AliT0CalibWalk.h"
35#include "AliT0CalibTimeEq.h"
dc7ca31d 36
37#include "AliCDBMetaData.h"
38#include "AliDCSValue.h"
39#include "AliLog.h"
dc7ca31d 40
41#include <TTimeStamp.h>
42#include <TFile.h>
5221c818 43#include <TObjString.h>
dc7ca31d 44#include <TNamed.h>
45#include "AliT0Dqclass.h"
46
bc943889 47
dc7ca31d 48ClassImp(AliT0Preprocessor)
49
50//____________________________________________________
8bfd9a3e 51AliT0Preprocessor::AliT0Preprocessor(AliShuttleInterface* shuttle) : AliPreprocessor("T00", shuttle), fData(0)
dc7ca31d 52{
bc943889 53 //constructor
dc7ca31d 54}
bc943889 55//____________________________________________________
dc7ca31d 56
57AliT0Preprocessor::~AliT0Preprocessor()
58{
bc943889 59 delete fData;
60 fData = 0;
61}
62//____________________________________________________
dc7ca31d 63
bc943889 64void AliT0Preprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
65{
66 AliPreprocessor::Initialize(run, startTime, endTime);
67 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, TTimeStamp(startTime).AsString(), TTimeStamp(endTime).AsString()));
68 fData = new AliT0DataDCS(fRun, fStartTime, fEndTime);
dc7ca31d 69}
bc943889 70//____________________________________________________
dc7ca31d 71
72UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
73{
bc943889 74 // T0 preprocessor return codes:
75 // return=0 : all ok
76 // return=1 : no DCS input data
77 // return=2 : failed to store DCS data
78 // return=3 : no Laser data (Walk correction)
79 // return=4 : failed to store OCDB time equalized data
80 // return=5 : no DAQ input for OCDB
81 // return=6 : failed to retrieve DAQ data from OCDB
82 // return=7 : failed to store T0 OCDB data
83
84 Bool_t resultDCSMap=kFALSE;
85 Bool_t resultDCSStore=kFALSE;
86 Bool_t resultLaser=kFALSE;
87 Bool_t resultOnline=kFALSE;
8bfd9a3e 88
89 if(!dcsAliasMap)
90 {
91 Log("No DCS input data");
92 return 1;
93 }
94 else
95 {
02cf5377 96 /*
8bfd9a3e 97 resultDCSMap=fData->ProcessData(*dcsAliasMap);
98 if(!resultDCSMap)
99 {
100 Log("Error when processing DCS data");
bc943889 101 return 2;// return error Code for processed DCS data not stored
102 }
103 else
104 {
02cf5377 105 Float_t *meanScaler[24] = fData->GetScalerMean();
106
bc943889 107 AliCDBMetaData metaDataDCS;
108 metaDataDCS.SetBeamPeriod(0);
109 metaDataDCS.SetResponsible("Tomasz Malkiewicz");
110 metaDataDCS.SetComment("This preprocessor fills an AliTODataDCS object.");
111 AliInfo("Storing DCS Data");
02cf5377 112 resultDCSStore = Store("Calib","DCSData",meanScaler, &metaDataDCS);
bc943889 113 if (!resultDCSStore)
8bfd9a3e 114 {
bc943889 115 Log("Some problems occurred while storing DCS data results in ReferenceDB");
116 return 2;// return error Code for processed DCS data not stored
117 }
dc7ca31d 118
8bfd9a3e 119 }
02cf5377 120 */
8bfd9a3e 121 }
122
123 // processing DAQ
bc943889 124
8bfd9a3e 125 TString runType = GetRunType();
bc943889 126
8bfd9a3e 127 if(runType == "T0_STANDALONE_LASER")
128 {
129 TList* list = GetFileSources(kDAQ, "LASER");
bc943889 130 if (list)
131 {
132 TIter iter(list);
133 TObjString *source;
8bfd9a3e 134 while ((source = dynamic_cast<TObjString *> (iter.Next())))
bc943889 135 {
136 const char *laserFile = GetFile(kDAQ, "LASER", source->GetName());
137 if (laserFile)
138 {
02cf5377 139 Log(Form("File with Id LASER found in source %s!", source->GetName()));
8bfd9a3e 140 AliT0CalibWalk *laser = new AliT0CalibWalk();
8bfd9a3e 141 laser->MakeWalkCorrGraph(laserFile);
142 AliCDBMetaData metaData;
bc943889 143 metaData.SetBeamPeriod(0);
144 metaData.SetResponsible("Tomek&Michal");
145 metaData.SetComment("Walk correction from laser runs.");
a8d3b391 146 //TObjArray* arrLaser = laser->GetfWalk();
147 resultLaser=Store("Calib","Slewing_Walk", laser, &metaData, 0, 1);
bc943889 148 delete laser;
8bfd9a3e 149 }
bc943889 150 else
151 {
8bfd9a3e 152 Log(Form("Could not find file with Id LASER in source %s!", source->GetName()));
bc943889 153 return 1;
154 }
155 }
156 if (!resultLaser)
8bfd9a3e 157 {
bc943889 158 Log("No Laser Data stored");
159 return 3;//return error code for failure in storing Laser Data
160 }
8bfd9a3e 161 }
162 }
163 else if(runType == "PHYSICS")
164 {
02cf5377 165 TList* listPhys = GetFileSources(kDAQ, "PHYSICS");
8bfd9a3e 166 if (listPhys)
167 {
168 TIter iter(listPhys);
169 TObjString *sourcePhys;
170 while ((sourcePhys = dynamic_cast<TObjString *> (iter.Next())))
171 {
172 const char *filePhys = GetFile(kDAQ, "PHYSICS", sourcePhys->GetName());
173 if (filePhys)
174 {
175 AliT0CalibTimeEq *online = new AliT0CalibTimeEq();
176 online->Reset();
02cf5377 177 online->ComputeOnlineParams("CFD", 20, 4., filePhys);
8bfd9a3e 178 AliCDBMetaData metaData;
179 metaData.SetBeamPeriod(0);
180 metaData.SetResponsible("Tomek&Michal");
181 metaData.SetComment("Time equalizing result.");
02cf5377 182 resultOnline = Store("Calib","TimeDelay", online, &metaData, 0, 1);
8bfd9a3e 183 delete online;
184 }
185 else
186 {
187 Log(Form("Could not find file with Id PHYSICS in source %s!", sourcePhys->GetName()));
188 return 1;
189 }
190 }
191 if (!resultOnline)
bc943889 192 {
193 Log("No Laser Data stored");
194 return 4;//return error code for failure in storing OCDB Data
195 }
8bfd9a3e 196 }
197 }
dc7ca31d 198
bc943889 199 return 0;
dc7ca31d 200}
201