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 Revision 1.4 2007/12/05 13:55:18 zampolli
19 Initialization bug fixed.
21 Revision 1.3 2007/11/27 13:12:30 zampolli
22 CDB object run range upper limit extended to AliCDBRunRange::Infinity()
24 Revision 1.2 2007/11/27 07:24:41 zampolli
25 Log used, fData member removed
27 Revision 1.1 2007/11/24 18:36:27 zampolli
28 TOF Preprocessor for FDR
32 //#include <Riostream.h>
39 #include <TObjArray.h>
40 //#include <TObjString.h>
41 #include <TTimeStamp.h>
43 #include "AliCDBMetaData.h"
46 //#include "AliTOFDataDCS.h"
47 //#include "AliTOFGeometry.h"
48 #include "AliTOFPreprocessorFDR.h"
49 #include "AliTOFFormatDCS.h"
50 #include "AliDCSValue.h"
52 // TOF preprocessor class.
53 // It takes data from DCS and passes them to the class AliTOFDataDCS, which
54 // processes them. The result is then written to the CDB.
55 // analogously, it takes data form DAQ (both at Run level and inclusive -
56 // of all the runs - level, processes them, and stores both Reference Data
57 // and Online Calibration files in the CDB.
60 ClassImp(AliTOFPreprocessorFDR)
62 //_____________________________________________________________________________
64 AliTOFPreprocessorFDR::AliTOFPreprocessorFDR(AliShuttleInterface* shuttle) :
65 AliPreprocessor("TOF", shuttle),
69 AddRunType("PHYSICS");
73 //_____________________________________________________________________________
75 AliTOFPreprocessorFDR::~AliTOFPreprocessorFDR()
80 //______________________________________________________________________________
81 void AliTOFPreprocessorFDR::Initialize(Int_t run, UInt_t startTime,
84 // Creates AliTOFDataDCS object
86 AliPreprocessor::Initialize(run, startTime, endTime);
88 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
89 TTimeStamp(startTime).AsString(),
90 TTimeStamp(endTime).AsString()));
94 //_____________________________________________________________________________
96 UInt_t AliTOFPreprocessorFDR::ProcessDCSDataPoints(TMap* aliasMap)
98 // Fills data into a AliTOFDataDCS object
101 // return=1 : no DCS input data Map
102 // return=2 : no DCS processed data was stored in Ref Data
103 // return=3 : no DCS processed data was stored in OCDB
106 Log("No DCS map found: TOF exiting from Shuttle");
107 return 1;// return error Code for DCS input data not found
113 AliDCSValue* aValue1;
114 Float_t timeMin = (Float_t)fStartTime;
115 Float_t timeMax = (Float_t)fEndTime;
120 Float_t timedelta[2];
122 TH1::AddDirectory(0);
124 Bool_t resultDCSMap=kFALSE;
125 Bool_t resultDCSStore=kFALSE;
127 TString aliasDP[4]={"tof_lv_i48_02","tof_lv_v48_02","tof_lv_i33_02","tof_lv_v33_02"};
129 TObjArray *array = new TObjArray(4);
132 AliTOFFormatDCS *lvI4802 = new AliTOFFormatDCS();
133 AliTOFFormatDCS *lvV4802 = new AliTOFFormatDCS();
134 AliTOFFormatDCS *lvI3302 = new AliTOFFormatDCS();
135 AliTOFFormatDCS *lvV3302 = new AliTOFFormatDCS();
137 array->AddAt(lvI4802,0);
138 array->AddAt(lvV4802,1);
139 array->AddAt(lvI3302,2);
140 array->AddAt(lvV3302,3);
144 for (Int_t i=0;i<4;i++){
145 for (Int_t idelta =0;idelta<2;idelta++){
149 TObjArray *aliasArr = (TObjArray*) aliasMap->GetValue(aliasDP[i].Data());
152 Log(Form("Alias %s not found!", aliasDP[i].Data()));
156 if(aliasArr->GetEntries()<3){
157 Log(Form("Alias %s has just %d entries!",
158 aliasDP[i].Data(),aliasArr->GetEntries()));
162 TIter iterarray(aliasArr);
164 Int_t nentries = aliasArr->GetEntries();
165 Int_t deltaTimeStamp = (Int_t) nentries/3;
166 Int_t deltaTimeStamp1 = (Int_t) nentries/2;
168 // filling aliases with 10 floats+1 Usign
170 for (Int_t k=0;k<3;k++){
171 index = deltaTimeStamp*k;
176 index=deltaTimeStamp1;
181 aValue = (AliDCSValue*) aliasArr->At(index);
182 val = aValue->GetFloat();
183 time = (Float_t) (aValue->GetTimeStamp());
185 AliDebug(1,Form("tof_lv_i48_02: setting value %i to %f at %f",k,val,time));
186 lvI4802->SetFloat(k,val);
187 lvI4802->SetTimeStampFloat(k,time);
190 AliDebug(1,Form("tof_lv_v48_02: setting value %i to %f at %f",k,val,time));
191 lvV4802->SetFloat(k,val);
192 lvV4802->SetTimeStampFloat(k,time);
195 AliDebug(1,Form("tof_lv_i33_02: setting value %i to %f at %f",k,val,time));
196 lvI3302->SetFloat(k,val);
197 lvI3302->SetTimeStampFloat(k,time);
200 AliDebug(1,Form("tof_lv_v33_02: setting value %i to %f at %f",k,val,time));
201 lvV3302->SetFloat(k,val);
202 lvV3302->SetTimeStampFloat(k,time);
206 // computing the most significant variations
208 Int_t deltamin = (Int_t)(60/(timeMax-timeMin)*nentries);
209 Int_t klast = nentries-deltamin;
211 for (Int_t k=0;k<klast;k++){
212 aValue = (AliDCSValue*) aliasArr->At(k);
213 aValue1 = (AliDCSValue*) aliasArr->At(k+deltamin);
214 val = aValue->GetFloat();
215 val1 = aValue1->GetFloat();
216 if (delta[0]<=TMath::Abs(val1-val)) {
217 delta[0]=TMath::Abs(val1-val);
218 timedelta[0] = (Float_t)k;
220 if (delta[1]<=delta[0]) {
221 Float_t temp = delta[1];
222 Float_t timetemp = timedelta[1];
225 timedelta[1]=timedelta[0];
226 timedelta[0]=timetemp;
230 for (Int_t kk=0;kk<2;kk++){
232 AliDebug(1,Form("tof_lv_i48: setting variation %i to %f at %f",kk,delta[kk],timedelta[kk]));
233 lvI4802->SetDelta(kk,delta[kk]);
234 lvI4802->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
237 AliDebug(1,Form("tof_lv_v48: setting variation %i to %f at %f",kk,delta[kk],timedelta[kk]));
238 lvV4802->SetDelta(kk,delta[kk]);
239 lvV4802->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
242 AliDebug(1,Form("tof_lv_i33: setting variation %i to %f at %f",kk,delta[kk],timedelta[kk]));
243 lvI3302->SetDelta(kk,delta[kk]);
244 lvI3302->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
247 AliDebug(1,Form("tof_lv_v33: setting variation %i to %f at %f",kk,delta[kk],timedelta[kk]));
248 lvV3302->SetDelta(kk,delta[kk]);
249 lvV3302->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
254 AliCDBMetaData metaDataDCS;
255 metaDataDCS.SetBeamPeriod(0);
256 metaDataDCS.SetResponsible("Chiara Zampolli");
257 metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object.");
258 Log("Storing DCS Data");
259 resultDCSStore = StoreReferenceData("Calib","DCSData",array, &metaDataDCS);
260 if (!resultDCSStore){
261 Log("Some problems occurred while storing DCS data results in Reference Data, TOF exiting from Shuttle");
262 return 2;// return error Code for processed DCS data not stored
266 Log("Storing DCS Data in OCDB");
267 resultDCSMap = Store("Calib","DCSData",array, &metaDataDCS,0,kTRUE);
269 Log("Some problems occurred while storing DCS data results in OCDB, TOF exiting from Shuttle");
270 return 3;// return error Code for processed DCS data not stored
280 //_____________________________________________________________________________
282 UInt_t AliTOFPreprocessorFDR::Process(TMap* dcsAliasMap)
284 // Fills data into a AliTOFDataDCS object
287 // return=1 : no DCS input data Map
288 // return=2 : no DCS processed data was stored in Ref Data
289 // return=3 : no DCS processed data was stored in OCDB
291 TH1::AddDirectory(0);
295 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
296 if ((iresultDCS == 1) || (iresultDCS == 2) || (iresultDCS == 3)) return iresultDCS;