]> git.uio.no Git - u/mrichter/AliRoot.git/blame - T0/AliT0PreprocessorCosmic.cxx
Reverting last commit which was not intentional
[u/mrichter/AliRoot.git] / T0 / AliT0PreprocessorCosmic.cxx
CommitLineData
a84a9142 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/*
0cd04094 17Preliminary version 2008/02 (Michal Oledzki)
a84a9142 18*/
19// T0 preprocessor:
20// 1) takes data from DCS and passes it to the class AliTOFDataDCS
21// for processing and writes the result to the Reference DB.
22// 2) takes data form DAQ (both from Laser Calibration and Physics runs),
23// processes it, and stores either to OCDB or to Reference DB.
24
25
26#include "AliT0PreprocessorCosmic.h"
27#include "AliT0DataDCS.h"
28#include "AliT0CalibWalk.h"
29#include "AliT0CalibTimeEq.h"
30
31#include "AliCDBMetaData.h"
32#include "AliDCSValue.h"
33#include "AliLog.h"
34
35#include <TTimeStamp.h>
36#include <TFile.h>
37#include <TObjString.h>
38#include <TNamed.h>
39#include "AliT0Dqclass.h"
40
41
42ClassImp(AliT0PreprocessorCosmic)
43
44//____________________________________________________
45AliT0PreprocessorCosmic::AliT0PreprocessorCosmic(AliShuttleInterface* shuttle) :
46 AliPreprocessor("T00", shuttle),
47 fData(0)
48{
49 //constructor
50}
51//____________________________________________________
52
53AliT0PreprocessorCosmic::~AliT0PreprocessorCosmic()
54{
55 //destructor
56 delete fData;
57 fData = 0;
58}
59//____________________________________________________
60
61void AliT0PreprocessorCosmic::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
62{
63 // Creates AliT0DataDCS object
64 AliPreprocessor::Initialize(run, startTime, endTime);
65 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, TTimeStamp(startTime).AsString(), TTimeStamp(endTime).AsString()));
66 fData = new AliT0DataDCS(fRun, fStartTime, fEndTime);
67}
68//____________________________________________________
69
70Bool_t AliT0PreprocessorCosmic::ProcessDCS(){
71 // Check whether DCS should be processed or not...
72 TString runType = GetRunType();
73 Log(Form("ProcessDCS - RunType: %s",runType.Data()));
74
75 if((runType == "STANDALONE")||(runType == "PHYSICS")){
76 return kFALSE;
77 }else{
78 return kFALSE;
79 }
80}
81//____________________________________________________
82
83UInt_t AliT0PreprocessorCosmic::ProcessDCSDataPoints(TMap* dcsAliasMap){
84 // Fills data into AliT0DataDCS object
85 Log("Processing DCS DP");
86 Bool_t resultDCSMap=kFALSE;
87 Bool_t resultDCSStore=kFALSE;
88
89 if(!dcsAliasMap)
90 {
91 Log("No DCS input data");
92 return 1;
93 }
94 else
95 {
96 resultDCSMap=fData->ProcessData(*dcsAliasMap);
97 if(!resultDCSMap)
98 {
99 Log("Error when processing DCS data");
100 return 2;// return error Code for processed DCS data not stored
101 }
102 else
103 {
104 AliCDBMetaData metaDataDCS;
105 metaDataDCS.SetBeamPeriod(0);
106 metaDataDCS.SetResponsible("Tomasz Malkiewicz");
107 metaDataDCS.SetComment("This preprocessor fills an AliTODataDCS object.");
108 AliInfo("Storing DCS Data");
109 resultDCSStore = Store("Calib","DCSData",fData, &metaDataDCS);
110 if (!resultDCSStore)
111 {
112 Log("Some problems occurred while storing DCS data results in ReferenceDB");
113 return 2;// return error Code for processed DCS data not stored
114 }
115 }
116 }
117 return 0;
118}
119//____________________________________________________
120
121UInt_t AliT0PreprocessorCosmic::ProcessLaser(){
122 // Processing data from DAQ Standalone run
123 Log("Processing Laser calibration");
124
125 Bool_t resultLaser=kFALSE;
0cd04094 126 Bool_t resultLaser1=kFALSE;
a84a9142 127 //processing DAQ
128 TList* list = GetFileSources(kDAQ, "COSMIC");
129 if (list)
130 {
131 TIter iter(list);
132 TObjString *source;
133 while ((source = dynamic_cast<TObjString *> (iter.Next())))
134 {
135 const char *laserFile = GetFile(kDAQ, "COSMIC", source->GetName());
136 if (laserFile)
137 {
138 Log(Form("File with Id COSMIC found in source %s!", source->GetName()));
139 AliT0CalibWalk *laser = new AliT0CalibWalk();
140 laser->MakeWalkCorrGraph(laserFile);
141 AliCDBMetaData metaData;
142 metaData.SetBeamPeriod(0);
143 metaData.SetResponsible("Tomek&Michal");
144 metaData.SetComment("Walk correction from laser runs.");
145 resultLaser=Store("Calib","Slewing_Walk", laser, &metaData, 0, 1);
0cd04094 146
147 AliT0CalibTimeEq *online = new AliT0CalibTimeEq();
148 online->Reset();
149 online->ComputeOnlineParams(laserFile);
150 metaData.SetComment("Time equalizing result.");
151 resultLaser1 = Store("Calib","TimeDelay", online, &metaData, 0, 1);
152 delete online;
a84a9142 153 delete laser;
154 }
155 else
156 {
157 Log(Form("Could not find file with Id COSMIC in source %s!", source->GetName()));
158 return 1;
159 }
160 }
161 if (!resultLaser)
162 {
163 Log("No Laser Data stored");
164 return 3;//return error code for failure in storing Laser Data
0cd04094 165 }else
166 if (!resultLaser1)
167 {
168 Log("No Laser1 Data stored");
169 return 3;//return error code for failure in storing Laser Data
a84a9142 170 }
171 } else {
172 Log("No sources found for id COSMIC!");
173 return 1;
174 }
175 return 0;
176}
177//____________________________________________________
178
179UInt_t AliT0PreprocessorCosmic::ProcessPhysics(){
180 //Processing data from DAQ Physics run
181 Log("Processing Physics");
182
183 Bool_t resultOnline=kFALSE;
184 //processing DAQ
0cd04094 185 TList* listPhys = GetFileSources(kDAQ, "PHYSICS");
a84a9142 186 if (listPhys)
187 {
188 TIter iter(listPhys);
189 TObjString *sourcePhys;
190 while ((sourcePhys = dynamic_cast<TObjString *> (iter.Next())))
191 {
0cd04094 192 const char *filePhys = GetFile(kDAQ, "PHYSICS", sourcePhys->GetName());
a84a9142 193 if (filePhys)
194 {
0cd04094 195 Log(Form("File with Id PHYSICS found in source %s!", sourcePhys->GetName()));
a84a9142 196 AliT0CalibTimeEq *online = new AliT0CalibTimeEq();
197 online->Reset();
198 online->ComputeOnlineParams(filePhys);
199 AliCDBMetaData metaData;
200 metaData.SetBeamPeriod(0);
201 metaData.SetResponsible("Tomek&Michal");
202 metaData.SetComment("Time equalizing result.");
203 resultOnline = Store("Calib","TimeDelay", online, &metaData, 0, 1);
204 delete online;
205 }
206 else
207 {
0cd04094 208 Log(Form("Could not find file with Id PHYSICS in source %s!", sourcePhys->GetName()));
a84a9142 209 return 1;
210 }
211 }
212 if (!resultOnline)
213 {
0cd04094 214 Log("No Physics Data stored");
a84a9142 215 return 4;//return error code for failure in storing OCDB Data
216 }
217 } else {
0cd04094 218 Log("No sources found for id PHYSICS!");
a84a9142 219 return 1;
220 }
221 return 0;
222}
223//____________________________________________________
224
225UInt_t AliT0PreprocessorCosmic::Process(TMap* dcsAliasMap )
226{
227 // T0 preprocessor return codes:
228 // return=0 : all ok
229 // return=1 : no DCS input data
230 // return=2 : failed to store DCS data
231 // return=3 : no Laser data (Walk correction)
232 // return=4 : failed to store OCDB time equalized data
233 // return=5 : no DAQ input for OCDB
234 // return=6 : failed to retrieve DAQ data from OCDB
235 // return=7 : failed to store T0 OCDB data
236 Bool_t dcsDP = ProcessDCS();
237 Log(Form("dcsDP = %d",dcsDP));
238 TString runType = GetRunType();
239 Log(Form("RunType: %s",runType.Data()));
240 //processing
0cd04094 241 if(runType == "STANDALONE"){
a84a9142 242 Int_t iresultLaser = ProcessLaser();
0cd04094 243 if(iresultLaser==0 && dcsDP==1){
244 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
245 return iresultDCS;
246 }else return iresultLaser;
247 }
248 else if(runType == "PHYSICS"){
249 Int_t iresultPhysics = ProcessPhysics();
250 Int_t iresultLaser = ProcessLaser();
251 if(iresultLaser==0 && iresultPhysics==0 && dcsDP==1){
a84a9142 252 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
253 return iresultDCS;
254 }
0cd04094 255 else if(iresultPhysics==0){
256 return iresultLaser;
a84a9142 257 }
0cd04094 258 else{ return iresultPhysics; }
a84a9142 259 }
a84a9142 260
261 return 0;
262}