]> git.uio.no Git - u/mrichter/AliRoot.git/blame - T0/AliT0Preprocessor.cxx
added more options to run D0 finder from offline or online data (Gaute)
[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"
6a9d154f 55#include "TClass.h"
dc7ca31d 56
96c0c856 57// #include "iostream.h"
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
6a9d154f 152 // std::cout<<"sizeof "<<sizeof(parqtcold)<<std::endl;
153 memset(parqtcold, 0, sizeof(parqtcold));
154 memset(parqtcnew, 0, sizeof(parqtcnew));
155 memset(parledold, 0, sizeof(parledold));
156 memset(parlednew, 0, sizeof(parlednew));
157 Int_t iStore=0;
158 Bool_t clbold = true;
8f1790c4 159
160 AliT0CalibWalk* clb=0;
161 AliCDBEntry* entryCalib = GetFromOCDB("Calib", "Slewing_Walk");
162 if(!entryCalib)
163 Log(Form("Cannot find any AliCDBEntry for [Calib, SlewingWalk]!"));
164 else {
6a9d154f 165 clb =dynamic_cast<AliT0CalibWalk*>(entryCalib->GetObject());
0c2f5b5a 166 for(Int_t i=0; i<24; i++)
8f1790c4 167 {
0c2f5b5a 168 for(Int_t ipar=0; ipar<2; ipar++)
8f1790c4 169 {
0c2f5b5a 170 // std::cout<<"parqtcold "<<parqtcold[i][ipar]<<std::endl;
171 parqtcold[i][ipar] = clb->GetQTCpar(i,ipar);
172 parledold[i][ipar] = clb->GetLEDpar(i, ipar);
173 goodqtc[i][ipar] = 999;
174 goodled[i][ipar] = 999;
175 // cout<<" old "<<i<<" "<<ipar<<" qtc "<< parqtcold[i][ipar]<<" led "<<parledold[i][ipar]<<endl;
8f1790c4 176 }
177 }
0c2f5b5a 178 }
179
6a9d154f 180
181 Bool_t resultLaser=kFALSE;
182 //processing DAQ
183 TList* list = GetFileSources(kDAQ, "LASER");
184 if (list)
185 {
186 TIter iter(list);
187 TObjString *source;
188 while ((source = dynamic_cast<TObjString *> (iter.Next())))
189 {
190 const char *laserFile = GetFile(kDAQ, "LASER", source->GetName());
191 if (laserFile)
bc943889 192 {
02cf5377 193 Log(Form("File with Id LASER found in source %s!", source->GetName()));
8bfd9a3e 194 AliT0CalibWalk *laser = new AliT0CalibWalk();
8bfd9a3e 195 laser->MakeWalkCorrGraph(laserFile);
8f1790c4 196 //check difference with what was before
0c2f5b5a 197 if(laser && clb ){
6a9d154f 198 iStore = 1;
8f1790c4 199 for(Int_t i=0; i<24; i++)
200 {
201 for(Int_t ifit=0; ifit<2; ifit++)
202 {
203 parqtcnew[i][ifit] = laser->GetQTCpar(i,ifit);
204 if( parqtcold[i][ifit] != 0 && parqtcnew[i][ifit] !=0)
205 {
206 goodqtc[i][ifit] =
207 (parqtcnew[i][ifit] - parqtcold[i][ifit])/parqtcold[i][ifit];
208 // cout<<"qtc "<<i<<" "<<ifit<<" "<< goodqtc[i][ifit]<<endl;
209 }
210 parlednew[i][ifit] = laser->GetLEDpar(i,ifit);
6a9d154f 211 if(parledold[i][ifit] != 0 && parlednew[i][ifit]!= 0 )
8f1790c4 212 {
213 goodled[i][ifit]=
214 (parlednew[i][ifit] - parledold[i][ifit])/parledold[i][ifit];
215 // cout<<"led "<<i<<" "<<ifit<<" "<< goodled[i][ifit]<<endl;
216 }
217 if(TMath::Abs(goodqtc[i][ifit])>0.1 ||
218 TMath::Abs(goodled[i][ifit])>0.1)
219 iStore = 0;
220 }
221 }
222 }
6a9d154f 223
8f1790c4 224 AliCDBMetaData metaData;
225 metaData.SetBeamPeriod(0);
bc943889 226 metaData.SetResponsible("Tomek&Michal");
227 metaData.SetComment("Walk correction from laser runs.");
8f1790c4 228 if( iStore>0)
229 resultLaser=Store("Calib","Slewing_Walk", laser, &metaData, 0, 1);
bc943889 230 delete laser;
271b5bd3 231 Log(Form("resultLaser = %d",resultLaser));
8bfd9a3e 232 }
bc943889 233 else
234 {
8bfd9a3e 235 Log(Form("Could not find file with Id LASER in source %s!", source->GetName()));
bc943889 236 return 1;
237 }
238 }
239 if (!resultLaser)
8bfd9a3e 240 {
bc943889 241 Log("No Laser Data stored");
242 return 3;//return error code for failure in storing Laser Data
243 }
67b67126 244 } else {
245 Log("No sources found for id LASER!");
246 return 1;
247 }
49ab1618 248 return 0;
249}
250//____________________________________________________
251
252UInt_t AliT0Preprocessor::ProcessPhysics(){
253 //Processing data from DAQ Physics run
254 Log("Processing Physics");
255
271b5bd3 256 Bool_t resultOnline=kFALSE;
49ab1618 257 //processing DAQ
258 TList* listPhys = GetFileSources(kDAQ, "PHYSICS");
259 if (listPhys)
8bfd9a3e 260 {
261 TIter iter(listPhys);
262 TObjString *sourcePhys;
263 while ((sourcePhys = dynamic_cast<TObjString *> (iter.Next())))
264 {
265 const char *filePhys = GetFile(kDAQ, "PHYSICS", sourcePhys->GetName());
266 if (filePhys)
267 {
268 AliT0CalibTimeEq *online = new AliT0CalibTimeEq();
269 online->Reset();
387638f7 270 online->ComputeOnlineParams(filePhys);
8bfd9a3e 271 AliCDBMetaData metaData;
272 metaData.SetBeamPeriod(0);
273 metaData.SetResponsible("Tomek&Michal");
274 metaData.SetComment("Time equalizing result.");
02cf5377 275 resultOnline = Store("Calib","TimeDelay", online, &metaData, 0, 1);
271b5bd3 276 Log(Form("resultOnline = %d",resultOnline));
8bfd9a3e 277 delete online;
278 }
271b5bd3 279 else
8bfd9a3e 280 {
281 Log(Form("Could not find file with Id PHYSICS in source %s!", sourcePhys->GetName()));
282 return 1;
283 }
271b5bd3 284
8bfd9a3e 285 }
286 if (!resultOnline)
bc943889 287 {
271b5bd3 288 Log("No Data stored");
bc943889 289 return 4;//return error code for failure in storing OCDB Data
290 }
67b67126 291 } else {
292 Log("No sources found for id PHYSICS!");
293 return 1;
294 }
49ab1618 295 return 0;
296}
297//____________________________________________________
298
271b5bd3 299UInt_t AliT0Preprocessor::ProcessCosmic(){
300 //Processing data from DAQ Physics run
301 Log("Processing Laser Physics");
302
303 Bool_t resultLaserOnline=kFALSE;
304 //processing DAQ
305 TList* listLaser = GetFileSources(kDAQ, "COSMIC");
306 if (listLaser)
307 {
308 TIter iter(listLaser);
309 TObjString *sourceLaser;
310 while ((sourceLaser = dynamic_cast<TObjString *> (iter.Next())))
311 {
312 const char *fileLaser = GetFile(kDAQ, "COSMIC", sourceLaser->GetName());
313 if (fileLaser)
314 {
315 AliT0CalibTimeEq *onlineLaser = new AliT0CalibTimeEq();
316 onlineLaser->Reset();
317 onlineLaser->ComputeOnlineParams(fileLaser);
318 AliCDBMetaData metaData;
319 metaData.SetBeamPeriod(0);
320 metaData.SetResponsible("Tomek&Michal");
321 metaData.SetComment("Time equalizing result.");
322 resultLaserOnline = Store("Calib","LaserTimeDelay", onlineLaser, &metaData, 0, 1);
323 Log(Form("resultLaserOnline = %d",resultLaserOnline));
324 delete onlineLaser;
325 }
326 else
327 {
328 Log(Form("Could not find file with Id COSMIC in source %s!", sourceLaser->GetName()));
329 return 0;
330 }
331
332 }
333 if (!resultLaserOnline)
334 {
335 Log("No Laser Data stored");
336 return 0;//return error code for failure in storing OCDB Data
337 }
338 } else {
339 Log("No sources found for id COSMIC!");
340 return 0;
341 }
342 return 0;
343}
344//____________________________________________________
345
49ab1618 346UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
347{
348 // T0 preprocessor return codes:
349 // return=0 : all ok
350 // return=1 : no DCS input data
351 // return=2 : failed to store DCS data
352 // return=3 : no Laser data (Walk correction)
353 // return=4 : failed to store OCDB time equalized data
354 // return=5 : no DAQ input for OCDB
355 // return=6 : failed to retrieve DAQ data from OCDB
356 // return=7 : failed to store T0 OCDB data
357 Bool_t dcsDP = ProcessDCS();
358 Log(Form("dcsDP = %d",dcsDP));
359 TString runType = GetRunType();
360 Log(Form("RunType: %s",runType.Data()));
361 //processing
362 if(runType == "STANDALONE"){
79e2e9c6 363 if(dcsDP==1){
364 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
365 return iresultDCS;
366 }
367 }
368 if(runType == "LASER"){
369 Int_t iresultLaser = ProcessLaser();
4b5d6a0a 370 if(dcsDP==1){
371 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
372 return iresultDCS;
373 }
79e2e9c6 374 Log(Form("iresultLaser = %d",iresultLaser));
375 return iresultLaser;
49ab1618 376 }
79e2e9c6 377 else if(runType == "PHYSICS"){
378 Int_t iresultPhysics = ProcessPhysics();
6318dd46 379 // Int_t iresultCosmic = ProcessCosmic();
79e2e9c6 380 if(dcsDP==1){
381 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
382 return iresultDCS;
383 }
384 Log(Form("iresultPhysics = %d",iresultPhysics));
385 return iresultPhysics;
386 // Log(Form("iresultPhysics =iresultCosmic %d",iresultCosmic));
387 // return iresultCosmic;
388 }
389
390 return 0;
dc7ca31d 391}