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 $Log: AliT0Preprocessor.cxx,v $
18 Revision 1.8 2007/12/07 15:22:51 alla
21 Revision 1.7 2007/12/06 16:35:24 alla
22 new bugs fixed by Tomek
24 Revision 1.5 2007/11/23 19:28:52 alla
27 Version 2.1 2007/11/21
28 Preprocessor storing data to OCDB (T.Malkiewicz)
31 Preliminary test version (T.Malkiewicz)
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.
40 #include "AliT0Preprocessor.h"
41 #include "AliT0DataDCS.h"
42 #include "AliT0CalibWalk.h"
43 #include "AliT0CalibTimeEq.h"
45 #include "AliCDBMetaData.h"
46 #include "AliDCSValue.h"
47 #include "AliCDBEntry.h"
50 #include <TTimeStamp.h>
52 #include <TObjString.h>
54 #include "AliT0Dqclass.h"
58 ClassImp(AliT0Preprocessor)
60 //____________________________________________________
61 AliT0Preprocessor::AliT0Preprocessor(AliShuttleInterface* shuttle) :
62 AliPreprocessor("T00", shuttle),
66 AddRunType("PHYSICS");
67 AddRunType("STANDALONE");
68 AddRunType("AMPLITUDE_CALIBRATION");
70 //____________________________________________________
72 AliT0Preprocessor::~AliT0Preprocessor()
78 //____________________________________________________
80 void AliT0Preprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
82 // Creates AliT0DataDCS object
83 AliPreprocessor::Initialize(run, startTime, endTime);
84 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, TTimeStamp(startTime).AsString(), TTimeStamp(endTime).AsString()));
85 fData = new AliT0DataDCS(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery());
87 //____________________________________________________
89 Bool_t AliT0Preprocessor::ProcessDCS(){
90 // Check whether DCS should be processed or not...
91 TString runType = GetRunType();
92 Log(Form("ProcessDCS - RunType: %s",runType.Data()));
94 if(runType == "PHYSICS" )
100 //____________________________________________________
102 UInt_t AliT0Preprocessor::ProcessDCSDataPoints(TMap* dcsAliasMap){
103 // Fills data into AliT0DataDCS object
104 Log("Processing DCS DP");
105 Bool_t resultDCSMap=kFALSE;
106 Bool_t resultDCSStore=kFALSE;
110 Log("No DCS input data");
115 resultDCSMap=fData->ProcessData(*dcsAliasMap);
118 Log("Error when processing DCS data");
119 return 2;// return error Code for processed DCS data not stored
123 AliCDBMetaData metaDataDCS;
124 metaDataDCS.SetBeamPeriod(0);
125 metaDataDCS.SetResponsible("Tomasz Malkiewicz");
126 metaDataDCS.SetComment("This preprocessor fills an AliTODataDCS object.");
127 AliInfo("Storing DCS Data");
128 resultDCSStore = StoreReferenceData("Calib","DCSData",fData, &metaDataDCS);
131 Log("Some problems occurred while storing DCS data results in ReferenceDB");
132 return 2;// return error Code for processed DCS data not stored
138 //____________________________________________________
140 UInt_t AliT0Preprocessor::ProcessLaser()
142 // Processing data from DAQ Standalone run
143 Log("Processing Laser calibration - Walk Correction");
144 Bool_t resultLaser = kFALSE;
145 Bool_t writeok = kFALSE;
147 TList* list = GetFileSources(kDAQ, "AMPLITUDE_CALIBRATION");
148 AliT0CalibWalk *laser = new AliT0CalibWalk();
153 while ((source = dynamic_cast<TObjString *> (iter.Next())))
155 const char *laserFile = GetFile(kDAQ, "AMPLITUDE_CALIBRATION", source->GetName());
158 Log(Form("File with Id AMPLITUDE_CALIBRAION found in source %s!", source->GetName()));
159 writeok = laser->MakeWalkCorrGraph(laserFile);
164 AliCDBMetaData metaData;
165 metaData.SetBeamPeriod(0);
166 metaData.SetResponsible("Tomek&Michal");
167 metaData.SetComment("Walk correction from laser runs.");
168 if (writeok) resultLaser=Store("Calib","Slewing_Walk", laser, &metaData, 0, 1);
171 Log(Form("writeok = %d no peaks in CFD spectra",writeok));
174 Log(Form("resultLaser = %d",resultLaser));
177 Log("No Laser Data stored");
178 return 3;//return error code for failure in storing Laser Data
183 Log(Form("Could not find file with Id AMPLITUDE_CALIBRAION "));
190 //____________________________________________________
192 UInt_t AliT0Preprocessor::ProcessPhysics(){
193 //Processing data from DAQ Physics run
194 Log("Processing Physics");
196 Bool_t resultOnline=kFALSE;
198 TList* listPhys = GetFileSources(kDAQ, "PHYSICS");
201 TIter iter(listPhys);
202 TObjString *sourcePhys;
203 while ((sourcePhys = dynamic_cast<TObjString *> (iter.Next())))
205 const char *filePhys = GetFile(kDAQ, "PHYSICS", sourcePhys->GetName());
208 AliT0CalibTimeEq *online = new AliT0CalibTimeEq();
210 Bool_t writeok = online->ComputeOnlineParams(filePhys);
211 AliCDBMetaData metaData;
212 metaData.SetBeamPeriod(0);
213 metaData.SetResponsible("Alla Maevskaya");
214 metaData.SetComment("Time equalizing result.");
216 if (writeok) resultOnline = Store("Calib","TimeDelay", online, &metaData, 0, 1);
219 Log(Form("writeok = %d not enough data for equalizing",resultOnline));
222 Log(Form("resultOnline = %d",resultOnline));
227 Log(Form("Could not find file with Id PHYSICS in source %s!", sourcePhys->GetName()));
234 Log("No Data stored");
235 return 4;//return error code for failure in storing OCDB Data
238 Log("No sources found for id PHYSICS!");
243 //____________________________________________________
245 UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
247 // T0 preprocessor return codes:
249 // return=1 : no DCS input data
250 // return=2 : failed to store DCS data
251 // return=3 : no Laser data (Walk correction)
252 // return=4 : failed to store OCDB time equalized data
253 // return=5 : no DAQ input for OCDB
254 // return=6 : failed to retrieve DAQ data from OCDB
255 // return=7 : failed to store T0 OCDB data
256 // return=8 : not enough data for equalizing
257 Bool_t dcsDP = ProcessDCS();
258 Log(Form("dcsDP = %d",dcsDP));
259 TString runType = GetRunType();
260 Log(Form("RunType: %s",runType.Data()));
262 if(runType == "STANDALONE"){
264 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
269 if(runType == "AMPLITUDE_CALIBRATION"){
270 Int_t iresultLaser = ProcessLaser();
272 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
276 Log(Form("iresultLaser = %d",iresultLaser));
280 else if(runType == "PHYSICS"){
281 Int_t iresultPhysics = ProcessPhysics();
283 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
286 Log(Form("iresultPhysics = %d",iresultPhysics));
287 return iresultPhysics;