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 **************************************************************************/
20 #include <Riostream.h>
30 #include <TObjArray.h>
31 #include <TObjString.h>
32 #include <TTimeStamp.h>
34 #include "AliCDBMetaData.h"
36 #include "AliTOFChannelOnline.h"
37 #include "AliTOFDataDCS.h"
38 #include "AliTOFGeometry.h"
39 #include "AliTOFPreprocessorFDR.h"
40 #include "AliTOFFormatDCS.h"
41 #include "AliDCSValue.h"
47 // TOF preprocessor class.
48 // It takes data from DCS and passes them to the class AliTOFDataDCS, which
49 // processes them. The result is then written to the CDB.
50 // analogously, it takes data form DAQ (both at Run level and inclusive -
51 // of all the runs - level, processes them, and stores both Reference Data
52 // and Online Calibration files in the CDB.
55 ClassImp(AliTOFPreprocessorFDR)
57 //_____________________________________________________________________________
59 AliTOFPreprocessorFDR::AliTOFPreprocessorFDR(AliShuttleInterface* shuttle) :
60 AliPreprocessor("TOF", shuttle),
68 //_____________________________________________________________________________
70 AliTOFPreprocessorFDR::~AliTOFPreprocessorFDR()
79 //______________________________________________________________________________
80 void AliTOFPreprocessorFDR::Initialize(Int_t run, UInt_t startTime,
83 // Creates AliTOFDataDCS object
85 AliPreprocessor::Initialize(run, startTime, endTime);
87 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
88 TTimeStamp(startTime).AsString(),
89 TTimeStamp(endTime).AsString()));
91 fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime);
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 *lv_i48_02 = new AliTOFFormatDCS();
133 AliTOFFormatDCS *lv_v48_02 = new AliTOFFormatDCS();
134 AliTOFFormatDCS *lv_i33_02 = new AliTOFFormatDCS();
135 AliTOFFormatDCS *lv_v33_02 = new AliTOFFormatDCS();
137 array->AddAt(lv_i48_02,0);
138 array->AddAt(lv_v48_02,1);
139 array->AddAt(lv_i33_02,2);
140 array->AddAt(lv_v33_02,3);
144 for (Int_t i=0;i<4;i++){
145 TObjArray *aliasArr = (TObjArray*) aliasMap->GetValue(aliasDP[i].Data());
148 AliError(Form("Alias %s not found!", aliasDP[i].Data()));
152 if(aliasArr->GetEntries()<3){
153 AliError(Form("Alias %s has just %d entries!",
154 aliasDP[i].Data(),aliasArr->GetEntries()));
158 TIter iterarray(aliasArr);
160 Int_t nentries = aliasArr->GetEntries();
161 Int_t deltaTimeStamp = (Int_t) nentries/3;
162 Int_t deltaTimeStamp1 = (Int_t) nentries/2;
164 // filling aliases with 10 floats+1 Usign
166 for (Int_t k=0;k<3;k++){
167 index = deltaTimeStamp*k;
172 index=deltaTimeStamp1;
177 aValue = (AliDCSValue*) aliasArr->At(index);
178 val = aValue->GetFloat();
179 time = (Float_t) (aValue->GetTimeStamp());
181 AliDebug(1,Form("tof_lv_i48: setting value %i to %f at %f",k,val,time));
182 lv_i48_02->SetFloat(k,val);
183 lv_i48_02->SetTimeStampFloat(k,time);
186 AliDebug(1,Form("tof_lv_v48: setting value %i to %f at %f",k,val,time));
187 lv_v48_02->SetFloat(k,val);
188 lv_v48_02->SetTimeStampFloat(k,time);
191 AliDebug(1,Form("tof_lv_i33: setting value %i to %f at %f",k,val,time));
192 lv_i33_02->SetFloat(k,val);
193 lv_i33_02->SetTimeStampFloat(k,time);
196 AliDebug(1,Form("tof_lv_v33: setting value %i to %f at %f",k,val,time));
197 lv_v33_02->SetFloat(k,val);
198 lv_v33_02->SetTimeStampFloat(k,time);
202 // computing the most significant variations
204 Int_t deltamin = (Int_t)(60/(timeMax-timeMin)*nentries);
205 Int_t klast = nentries-deltamin;
207 for (Int_t k=0;k<klast;k++){
208 aValue = (AliDCSValue*) aliasArr->At(k);
209 aValue1 = (AliDCSValue*) aliasArr->At(k+deltamin);
210 val = aValue->GetFloat();
211 val1 = aValue1->GetFloat();
212 if (delta[0]<=TMath::Abs(val1-val)) {
213 delta[0]=TMath::Abs(val1-val);
214 timedelta[0] = (Float_t)k;
216 if (delta[1]<=delta[0]) {
217 Float_t temp = delta[1];
218 Float_t timetemp = timedelta[1];
221 timedelta[1]=timedelta[0];
222 timedelta[0]=timetemp;
226 for (Int_t kk=0;kk<2;kk++){
228 AliDebug(1,Form("tof_lv_i48: setting variation %i to %f at %f",kk,delta[kk],timedelta[kk]));
229 lv_i48_02->SetDelta(kk,delta[kk]);
230 lv_i48_02->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
233 AliDebug(1,Form("tof_lv_v48: setting variation %i to %f at %f",kk,delta[kk],timedelta[kk]));
234 lv_v48_02->SetDelta(kk,delta[kk]);
235 lv_v48_02->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
238 AliDebug(1,Form("tof_lv_i33: setting variation %i to %f at %f",kk,delta[kk],timedelta[kk]));
239 lv_i33_02->SetDelta(kk,delta[kk]);
240 lv_i33_02->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
243 AliDebug(1,Form("tof_lv_v33: setting variation %i to %f at %f",kk,delta[kk],timedelta[kk]));
244 lv_v33_02->SetDelta(kk,delta[kk]);
245 lv_v33_02->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
250 AliCDBMetaData metaDataDCS;
251 metaDataDCS.SetBeamPeriod(0);
252 metaDataDCS.SetResponsible("Chiara Zampolli");
253 metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object.");
254 AliInfo("Storing DCS Data");
255 resultDCSStore = StoreReferenceData("Calib","DCSData",array, &metaDataDCS);
256 if (!resultDCSStore){
257 Log("Some problems occurred while storing DCS data results in Reference Data, TOF exiting from Shuttle");
258 return 2;// return error Code for processed DCS data not stored
262 AliInfo("Storing DCS Data in OCDB");
263 resultDCSMap = Store("Calib","DCSData",array, &metaDataDCS);
264 if (!resultDCSStore){
265 Log("Some problems occurred while storing DCS data results in OCDB, TOF exiting from Shuttle");
266 return 3;// return error Code for processed DCS data not stored
270 if (array) delete array;
276 //_____________________________________________________________________________
278 UInt_t AliTOFPreprocessorFDR::Process(TMap* dcsAliasMap)
280 // Fills data into a AliTOFDataDCS object
283 // return=1 : no DCS input data Map
284 // return=2 : no DCS processed data was stored in Ref Data
285 // return=3 : no DCS processed data was stored in OCDB
287 TH1::AddDirectory(0);
291 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
292 if ((iresultDCS == 1) || (iresultDCS == 2) || (iresultDCS == 3)) return iresultDCS;