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