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 **************************************************************************/
17 Preliminary version 2008/02 (Michal Oledzki)
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.
26 #include "AliT0PreprocessorCosmic.h"
27 #include "AliT0DataDCS.h"
28 #include "AliT0CalibWalk.h"
29 #include "AliT0CalibTimeEq.h"
31 #include "AliCDBMetaData.h"
32 #include "AliDCSValue.h"
35 #include <TTimeStamp.h>
37 #include <TObjString.h>
39 #include "AliT0Dqclass.h"
42 ClassImp(AliT0PreprocessorCosmic)
44 //____________________________________________________
45 AliT0PreprocessorCosmic::AliT0PreprocessorCosmic(AliShuttleInterface* shuttle) :
46 AliPreprocessor("T00", shuttle),
50 AddRunType("PHYSICS");
51 AddRunType("STANDALONE");
53 //____________________________________________________
55 AliT0PreprocessorCosmic::~AliT0PreprocessorCosmic()
61 //____________________________________________________
63 void AliT0PreprocessorCosmic::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
65 // Creates AliT0DataDCS object
66 AliPreprocessor::Initialize(run, startTime, endTime);
67 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, TTimeStamp(startTime).AsString(), TTimeStamp(endTime).AsString()));
68 fData = new AliT0DataDCS(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery());
70 //____________________________________________________
72 Bool_t AliT0PreprocessorCosmic::ProcessDCS(){
73 // Check whether DCS should be processed or not...
74 TString runType = GetRunType();
75 Log(Form("ProcessDCS - RunType: %s",runType.Data()));
77 if((runType == "STANDALONE")||(runType == "PHYSICS")){
83 //____________________________________________________
85 UInt_t AliT0PreprocessorCosmic::ProcessDCSDataPoints(TMap* dcsAliasMap){
86 // Fills data into AliT0DataDCS object
87 Log("Processing DCS DP");
88 Bool_t resultDCSMap=kFALSE;
89 Bool_t resultDCSStore=kFALSE;
93 Log("No DCS input data");
98 resultDCSMap=fData->ProcessData(*dcsAliasMap);
101 Log("Error when processing DCS data");
102 return 2;// return error Code for processed DCS data not stored
106 AliCDBMetaData metaDataDCS;
107 metaDataDCS.SetBeamPeriod(0);
108 metaDataDCS.SetResponsible("Tomasz Malkiewicz");
109 metaDataDCS.SetComment("This preprocessor fills an AliTODataDCS object.");
110 AliInfo("Storing DCS Data");
111 resultDCSStore = Store("Calib","DCSData",fData, &metaDataDCS);
114 Log("Some problems occurred while storing DCS data results in ReferenceDB");
115 return 2;// return error Code for processed DCS data not stored
121 //____________________________________________________
123 UInt_t AliT0PreprocessorCosmic::ProcessLaser(){
124 // Processing data from DAQ Standalone run
125 Log("Processing Laser calibration");
127 Bool_t resultLaser=kFALSE;
128 Bool_t resultLaser1=kFALSE;
130 TList* list = GetFileSources(kDAQ, "COSMIC");
135 while ((source = dynamic_cast<TObjString *> (iter.Next())))
137 const char *laserFile = GetFile(kDAQ, "COSMIC", source->GetName());
140 Log(Form("File with Id COSMIC found in source %s!", source->GetName()));
141 AliT0CalibWalk *laser = new AliT0CalibWalk();
142 laser->MakeWalkCorrGraph(laserFile);
143 AliCDBMetaData metaData;
144 metaData.SetBeamPeriod(0);
145 metaData.SetResponsible("Tomek&Michal");
146 metaData.SetComment("Walk correction from laser runs.");
147 resultLaser=Store("Calib","Slewing_Walk", laser, &metaData, 0, 1);
149 AliT0CalibTimeEq *online = new AliT0CalibTimeEq();
151 online->ComputeOnlineParams(laserFile);
152 metaData.SetComment("Time equalizing result.");
153 resultLaser1 = Store("Calib","TimeDelay", online, &metaData, 0, 1);
159 Log(Form("Could not find file with Id COSMIC in source %s!", source->GetName()));
165 Log("No Laser Data stored");
166 return 3;//return error code for failure in storing Laser Data
170 Log("No Laser1 Data stored");
171 return 3;//return error code for failure in storing Laser Data
174 Log("No sources found for id COSMIC!");
179 //____________________________________________________
181 UInt_t AliT0PreprocessorCosmic::ProcessPhysics(){
182 //Processing data from DAQ Physics run
183 Log("Processing Physics");
185 Bool_t resultOnline=kFALSE;
187 TList* listPhys = GetFileSources(kDAQ, "PHYSICS");
190 TIter iter(listPhys);
191 TObjString *sourcePhys;
192 while ((sourcePhys = dynamic_cast<TObjString *> (iter.Next())))
194 const char *filePhys = GetFile(kDAQ, "PHYSICS", sourcePhys->GetName());
197 Log(Form("File with Id PHYSICS found in source %s!", sourcePhys->GetName()));
198 AliT0CalibTimeEq *online = new AliT0CalibTimeEq();
200 online->ComputeOnlineParams(filePhys);
201 AliCDBMetaData metaData;
202 metaData.SetBeamPeriod(0);
203 metaData.SetResponsible("Tomek&Michal");
204 metaData.SetComment("Time equalizing result.");
205 resultOnline = Store("Calib","TimeDelay", online, &metaData, 0, 1);
210 Log(Form("Could not find file with Id PHYSICS in source %s!", sourcePhys->GetName()));
216 Log("No Physics Data stored");
217 return 4;//return error code for failure in storing OCDB Data
220 Log("No sources found for id PHYSICS!");
225 //____________________________________________________
227 UInt_t AliT0PreprocessorCosmic::Process(TMap* dcsAliasMap )
229 // T0 preprocessor return codes:
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()));
243 if(runType == "STANDALONE"){
244 Int_t iresultLaser = ProcessLaser();
245 if(iresultLaser==0 && dcsDP==1){
246 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
248 }else return iresultLaser;
250 else if(runType == "PHYSICS"){
251 Int_t iresultPhysics = ProcessPhysics();
252 Int_t iresultLaser = ProcessLaser();
253 if(iresultLaser==0 && iresultPhysics==0 && dcsDP==1){
254 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
257 else if(iresultPhysics==0){
260 else{ return iresultPhysics; }