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