1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Version 2.1 2007/11/21
19 Preprocessor storing data to OCDB (T.Malkiewicz)
22 Preliminary test version (T.Malkiewicz)
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.
29 #include "AliT0Preprocessor.h"
30 #include "AliT0DataDCS.h"
31 #include "AliT0CalibWalk.h"
32 #include "AliT0CalibTimeEq.h"
34 #include "AliCDBMetaData.h"
35 #include "AliDCSValue.h"
38 #include <TTimeStamp.h>
40 #include <TObjString.h>
42 #include "AliT0Dqclass.h"
45 ClassImp(AliT0Preprocessor)
47 //____________________________________________________
48 AliT0Preprocessor::AliT0Preprocessor(AliShuttleInterface* shuttle) : AliPreprocessor("T00", shuttle),
53 //____________________________________________________
55 AliT0Preprocessor::~AliT0Preprocessor()
60 //____________________________________________________
62 void AliT0Preprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
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);
68 //____________________________________________________
70 UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
72 // T0 preprocessor return codes:
74 // return=1 : no DCS input data
75 // return=2 : failed to store DCS data
76 // return=3 : no Laser data (Walk correction)
77 // return=4 : failed to store OCDB time equalized data
78 // return=5 : no DAQ input for OCDB
79 // return=6 : failed to retrieve DAQ data from OCDB
80 // return=7 : failed to store T0 OCDB data
82 Bool_t resultDCSMap=kFALSE;
83 Bool_t resultDCSStore=kFALSE;
84 Bool_t resultLaser=kFALSE;
85 Bool_t resultOnline=kFALSE;
91 Log("No DCS input data");
96 resultDCSMap=fData->ProcessData(*dcsAliasMap);
99 Log("Error when processing DCS data");
100 return 2;// return error Code for processed DCS data not stored
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);
112 Log("Some problems occurred while storing DCS data results in ReferenceDB");
113 return 2;// return error Code for processed DCS data not stored
121 TString runType = GetRunType();
123 if(runType == "T0_STANDALONE_LASER")
125 TList* list = GetFileSources(kDAQ, "LASER");
130 while ((source = dynamic_cast<TObjString *> (iter.Next())))
132 const char *laserFile = GetFile(kDAQ, "LASER", source->GetName());
135 Log(Form("File with Id TIME found in source %s!", source->GetName()));
136 AliT0CalibWalk *laser = new AliT0CalibWalk();
138 laser->MakeWalkCorrGraph(laserFile);
139 AliCDBMetaData metaData;
140 metaData.SetBeamPeriod(0);
141 metaData.SetResponsible("Tomek&Michal");
142 metaData.SetComment("Walk correction from laser runs.");
143 resultLaser = Store("Calib","Data", laser, &metaData);
148 Log(Form("Could not find file with Id TIME in source %s!", source->GetName()));
154 Log("No Laser Data stored");
155 return 3;//return error code for failure in storing Laser Data
159 else if(runType == "PHYSICS")
161 AliT0CalibTimeEq *online = new AliT0CalibTimeEq();
163 online->ComputeOnlineParams("CFD13-CFD","", "c1", 20, 1.);
164 AliCDBMetaData metaData;
165 metaData.SetBeamPeriod(0);
166 metaData.SetResponsible("Tomek&Michal");
167 metaData.SetComment("Time equalizing result.");
169 resultOnline = Store("Calib","Data", online, &metaData);
173 Log("No Laser Data stored");
174 return 4;//return error code for failure in storing OCDB Data
180 /* commented for testing, TM 22.11.2007
182 while ((source = dynamic_cast<TObjString *> (iter.Next())))
184 const char* TimefileName = GetFile(kDAQ, "TIME", source->GetName());
187 Log(Form("File with Id TIME found in source %s!", source->GetName()));
188 TFile *file = TFile::Open(TimefileName);
189 if(!file || !file->IsOpen())
191 Log(Form("Error opening file with Id TIME from source %s!", source->GetName()));
194 AliT0Dqclass *tempdata = dynamic_cast<AliT0Dqclass*> (file->Get("Time"));
197 Log("Could not find key \"Time\" in DAQ file!");
200 for(Int_t i=0;i<24;i++)
202 numbers[i] = tempdata->GetTime(i);
203 // printf("\nnumbers: %f\n",numbers[i]);
210 Log(Form("Could not find file with Id TIME in source %s!", source->GetName()));
213 // calibdata->SetTime(numbers, hv);
214 // calibdata->Print();
215 // calibdata->FitGauss();
220 Log("No sources for Id TIME found!");