]> git.uio.no Git - u/mrichter/AliRoot.git/blame - T0/AliT0Preprocessor.cxx
correct to make it work on amore agent (Yaxian)
[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"
55
43c247cf 56#include "iostream"
8f1790c4 57
bc943889 58
dc7ca31d 59ClassImp(AliT0Preprocessor)
60
61//____________________________________________________
387638f7 62AliT0Preprocessor::AliT0Preprocessor(AliShuttleInterface* shuttle) :
63 AliPreprocessor("T00", shuttle),
64 fData(0)
dc7ca31d 65{
bc943889 66 //constructor
2a8e3409 67 AddRunType("PHYSICS");
68 AddRunType("STANDALONE");
79e2e9c6 69 AddRunType("LASER");
dc7ca31d 70}
bc943889 71//____________________________________________________
dc7ca31d 72
73AliT0Preprocessor::~AliT0Preprocessor()
74{
50e28e1c 75 //destructor
bc943889 76 delete fData;
77 fData = 0;
78}
79//____________________________________________________
dc7ca31d 80
bc943889 81void AliT0Preprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
82{
50e28e1c 83 // Creates AliT0DataDCS object
bc943889 84 AliPreprocessor::Initialize(run, startTime, endTime);
85 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, TTimeStamp(startTime).AsString(), TTimeStamp(endTime).AsString()));
8eb4ac75 86 fData = new AliT0DataDCS(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery());
dc7ca31d 87}
bc943889 88//____________________________________________________
dc7ca31d 89
49ab1618 90Bool_t AliT0Preprocessor::ProcessDCS(){
91 // Check whether DCS should be processed or not...
92 TString runType = GetRunType();
93 Log(Form("ProcessDCS - RunType: %s",runType.Data()));
94
4b5d6a0a 95 if((runType == "STANDALONE")||
96 (runType == "PHYSICS")||
97 (runType == "LASER")){
8f1790c4 98 return kFALSE;
99 // return kTRUE;
49ab1618 100 }else{
101 return kFALSE;
102 }
103}
104//____________________________________________________
bc943889 105
49ab1618 106UInt_t AliT0Preprocessor::ProcessDCSDataPoints(TMap* dcsAliasMap){
107 // Fills data into AliT0DataDCS object
108 Log("Processing DCS DP");
bc943889 109 Bool_t resultDCSMap=kFALSE;
110 Bool_t resultDCSStore=kFALSE;
49ab1618 111
8bfd9a3e 112 if(!dcsAliasMap)
113 {
114 Log("No DCS input data");
49ab1618 115 return 1;
8bfd9a3e 116 }
117 else
118 {
119 resultDCSMap=fData->ProcessData(*dcsAliasMap);
120 if(!resultDCSMap)
121 {
122 Log("Error when processing DCS data");
bc943889 123 return 2;// return error Code for processed DCS data not stored
124 }
125 else
126 {
127 AliCDBMetaData metaDataDCS;
128 metaDataDCS.SetBeamPeriod(0);
129 metaDataDCS.SetResponsible("Tomasz Malkiewicz");
130 metaDataDCS.SetComment("This preprocessor fills an AliTODataDCS object.");
131 AliInfo("Storing DCS Data");
fe3c9b71 132 resultDCSStore = StoreReferenceData("Calib","DCSData",fData, &metaDataDCS);
bc943889 133 if (!resultDCSStore)
8bfd9a3e 134 {
bc943889 135 Log("Some problems occurred while storing DCS data results in ReferenceDB");
387638f7 136 return 2;// return error Code for processed DCS data not stored
bc943889 137 }
8bfd9a3e 138 }
139 }
49ab1618 140 return 0;
141}
142//____________________________________________________
8bfd9a3e 143
49ab1618 144UInt_t AliT0Preprocessor::ProcessLaser(){
145 // Processing data from DAQ Standalone run
8f1790c4 146 Log("Processing Laser calibration - Walk Correction");
147
148 //Retrieve the last T0 calibration object
149
150 Float_t parqtcold[24][2], parledold[24][2],parqtcnew[24][2], parlednew[24][2] , goodled[24][2], goodqtc[24][2];
151
152
153 AliT0CalibWalk* clb=0;
154 AliCDBEntry* entryCalib = GetFromOCDB("Calib", "Slewing_Walk");
155 if(!entryCalib)
156 Log(Form("Cannot find any AliCDBEntry for [Calib, SlewingWalk]!"));
157 else {
158 clb = (AliT0CalibWalk*)entryCalib->GetObject();
159
160 for(Int_t i=0; i<24; i++)
161 {
162 for(Int_t ipar=0; ipar<2; ipar++)
163 {
164 parqtcold[i][ipar] = clb->GetQTCpar(i,ipar);
165 parledold[i][ipar] = clb->GetLEDpar(i, ipar);
166 goodqtc[i][ipar] = 999;
167 goodled[i][ipar] = 999;
168 // cout<<" old "<<i<<" "<<ipar<<" qtc "<< parqtcold[i][ipar]<<" led "<<parledold[i][ipar]<<endl;
169 }
170 }
171 }
172 Bool_t resultLaser=kFALSE;
173 //processing DAQ
174 TList* list = GetFileSources(kDAQ, "LASER");
175 if (list)
176 {
bc943889 177 TIter iter(list);
178 TObjString *source;
8bfd9a3e 179 while ((source = dynamic_cast<TObjString *> (iter.Next())))
bc943889 180 {
181 const char *laserFile = GetFile(kDAQ, "LASER", source->GetName());
182 if (laserFile)
183 {
02cf5377 184 Log(Form("File with Id LASER found in source %s!", source->GetName()));
8bfd9a3e 185 AliT0CalibWalk *laser = new AliT0CalibWalk();
8bfd9a3e 186 laser->MakeWalkCorrGraph(laserFile);
8f1790c4 187 Int_t iStore=0;
188 //check difference with what was before
189 if(laser && clb){
190 iStore = 1;
191 for(Int_t i=0; i<24; i++)
192 {
193 for(Int_t ifit=0; ifit<2; ifit++)
194 {
195 parqtcnew[i][ifit] = laser->GetQTCpar(i,ifit);
196 if( parqtcold[i][ifit] != 0 && parqtcnew[i][ifit] !=0)
197 {
198 goodqtc[i][ifit] =
199 (parqtcnew[i][ifit] - parqtcold[i][ifit])/parqtcold[i][ifit];
200 // cout<<"qtc "<<i<<" "<<ifit<<" "<< goodqtc[i][ifit]<<endl;
201 }
202 parlednew[i][ifit] = laser->GetLEDpar(i,ifit);
203 if(parledold[i][ifit] != 0 )
204 {
205 goodled[i][ifit]=
206 (parlednew[i][ifit] - parledold[i][ifit])/parledold[i][ifit];
207 // cout<<"led "<<i<<" "<<ifit<<" "<< goodled[i][ifit]<<endl;
208 }
209 if(TMath::Abs(goodqtc[i][ifit])>0.1 ||
210 TMath::Abs(goodled[i][ifit])>0.1)
211 iStore = 0;
212 }
213 }
214 }
215 AliCDBMetaData metaData;
216 metaData.SetBeamPeriod(0);
bc943889 217 metaData.SetResponsible("Tomek&Michal");
218 metaData.SetComment("Walk correction from laser runs.");
8f1790c4 219 if( iStore>0)
220 resultLaser=Store("Calib","Slewing_Walk", laser, &metaData, 0, 1);
bc943889 221 delete laser;
271b5bd3 222 Log(Form("resultLaser = %d",resultLaser));
8bfd9a3e 223 }
bc943889 224 else
225 {
8bfd9a3e 226 Log(Form("Could not find file with Id LASER in source %s!", source->GetName()));
bc943889 227 return 1;
228 }
229 }
230 if (!resultLaser)
8bfd9a3e 231 {
bc943889 232 Log("No Laser Data stored");
233 return 3;//return error code for failure in storing Laser Data
234 }
67b67126 235 } else {
236 Log("No sources found for id LASER!");
237 return 1;
238 }
49ab1618 239 return 0;
240}
241//____________________________________________________
242
243UInt_t AliT0Preprocessor::ProcessPhysics(){
244 //Processing data from DAQ Physics run
245 Log("Processing Physics");
246
271b5bd3 247 Bool_t resultOnline=kFALSE;
49ab1618 248 //processing DAQ
249 TList* listPhys = GetFileSources(kDAQ, "PHYSICS");
250 if (listPhys)
8bfd9a3e 251 {
252 TIter iter(listPhys);
253 TObjString *sourcePhys;
254 while ((sourcePhys = dynamic_cast<TObjString *> (iter.Next())))
255 {
256 const char *filePhys = GetFile(kDAQ, "PHYSICS", sourcePhys->GetName());
257 if (filePhys)
258 {
259 AliT0CalibTimeEq *online = new AliT0CalibTimeEq();
260 online->Reset();
387638f7 261 online->ComputeOnlineParams(filePhys);
8bfd9a3e 262 AliCDBMetaData metaData;
263 metaData.SetBeamPeriod(0);
264 metaData.SetResponsible("Tomek&Michal");
265 metaData.SetComment("Time equalizing result.");
02cf5377 266 resultOnline = Store("Calib","TimeDelay", online, &metaData, 0, 1);
271b5bd3 267 Log(Form("resultOnline = %d",resultOnline));
8bfd9a3e 268 delete online;
269 }
271b5bd3 270 else
8bfd9a3e 271 {
272 Log(Form("Could not find file with Id PHYSICS in source %s!", sourcePhys->GetName()));
273 return 1;
274 }
271b5bd3 275
8bfd9a3e 276 }
277 if (!resultOnline)
bc943889 278 {
271b5bd3 279 Log("No Data stored");
bc943889 280 return 4;//return error code for failure in storing OCDB Data
281 }
67b67126 282 } else {
283 Log("No sources found for id PHYSICS!");
284 return 1;
285 }
49ab1618 286 return 0;
287}
288//____________________________________________________
289
271b5bd3 290UInt_t AliT0Preprocessor::ProcessCosmic(){
291 //Processing data from DAQ Physics run
292 Log("Processing Laser Physics");
293
294 Bool_t resultLaserOnline=kFALSE;
295 //processing DAQ
296 TList* listLaser = GetFileSources(kDAQ, "COSMIC");
297 if (listLaser)
298 {
299 TIter iter(listLaser);
300 TObjString *sourceLaser;
301 while ((sourceLaser = dynamic_cast<TObjString *> (iter.Next())))
302 {
303 const char *fileLaser = GetFile(kDAQ, "COSMIC", sourceLaser->GetName());
304 if (fileLaser)
305 {
306 AliT0CalibTimeEq *onlineLaser = new AliT0CalibTimeEq();
307 onlineLaser->Reset();
308 onlineLaser->ComputeOnlineParams(fileLaser);
309 AliCDBMetaData metaData;
310 metaData.SetBeamPeriod(0);
311 metaData.SetResponsible("Tomek&Michal");
312 metaData.SetComment("Time equalizing result.");
313 resultLaserOnline = Store("Calib","LaserTimeDelay", onlineLaser, &metaData, 0, 1);
314 Log(Form("resultLaserOnline = %d",resultLaserOnline));
315 delete onlineLaser;
316 }
317 else
318 {
319 Log(Form("Could not find file with Id COSMIC in source %s!", sourceLaser->GetName()));
320 return 0;
321 }
322
323 }
324 if (!resultLaserOnline)
325 {
326 Log("No Laser Data stored");
327 return 0;//return error code for failure in storing OCDB Data
328 }
329 } else {
330 Log("No sources found for id COSMIC!");
331 return 0;
332 }
333 return 0;
334}
335//____________________________________________________
336
49ab1618 337UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
338{
339 // T0 preprocessor return codes:
340 // return=0 : all ok
341 // return=1 : no DCS input data
342 // return=2 : failed to store DCS data
343 // return=3 : no Laser data (Walk correction)
344 // return=4 : failed to store OCDB time equalized data
345 // return=5 : no DAQ input for OCDB
346 // return=6 : failed to retrieve DAQ data from OCDB
347 // return=7 : failed to store T0 OCDB data
348 Bool_t dcsDP = ProcessDCS();
349 Log(Form("dcsDP = %d",dcsDP));
350 TString runType = GetRunType();
351 Log(Form("RunType: %s",runType.Data()));
352 //processing
353 if(runType == "STANDALONE"){
79e2e9c6 354 if(dcsDP==1){
355 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
356 return iresultDCS;
357 }
358 }
359 if(runType == "LASER"){
360 Int_t iresultLaser = ProcessLaser();
4b5d6a0a 361 if(dcsDP==1){
362 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
363 return iresultDCS;
364 }
79e2e9c6 365 Log(Form("iresultLaser = %d",iresultLaser));
366 return iresultLaser;
49ab1618 367 }
79e2e9c6 368 else if(runType == "PHYSICS"){
369 Int_t iresultPhysics = ProcessPhysics();
6318dd46 370 // Int_t iresultCosmic = ProcessCosmic();
79e2e9c6 371 if(dcsDP==1){
372 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
373 return iresultDCS;
374 }
375 Log(Form("iresultPhysics = %d",iresultPhysics));
376 return iresultPhysics;
377 // Log(Form("iresultPhysics =iresultCosmic %d",iresultCosmic));
378 // return iresultCosmic;
379 }
380
381 return 0;
dc7ca31d 382}