]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFPreprocessorFDR.cxx
Coding convention: RC12 rule violation -> suppression
[u/mrichter/AliRoot.git] / TOF / AliTOFPreprocessorFDR.cxx
CommitLineData
dc043f85 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17$Log$
6b9a73fd 18Revision 1.4 2007/12/05 13:55:18 zampolli
19Initialization bug fixed.
20
41024dec 21Revision 1.3 2007/11/27 13:12:30 zampolli
22CDB object run range upper limit extended to AliCDBRunRange::Infinity()
23
22363630 24Revision 1.2 2007/11/27 07:24:41 zampolli
25Log used, fData member removed
26
d1034a96 27Revision 1.1 2007/11/24 18:36:27 zampolli
28TOF Preprocessor for FDR
29
dc043f85 30*/
31
32#include <Riostream.h>
33#include <stdio.h>
34#include <stdlib.h>
35
36#include <TFile.h>
37#include <TH1.h>
dc043f85 38#include <TMath.h>
39#include <TObjArray.h>
40#include <TObjString.h>
41#include <TTimeStamp.h>
42
43#include "AliCDBMetaData.h"
44#include "AliLog.h"
dc043f85 45#include "AliTOFDataDCS.h"
46#include "AliTOFGeometry.h"
47#include "AliTOFPreprocessorFDR.h"
48#include "AliTOFFormatDCS.h"
49#include "AliDCSValue.h"
50
dc043f85 51// TOF preprocessor class.
52// It takes data from DCS and passes them to the class AliTOFDataDCS, which
53// processes them. The result is then written to the CDB.
54// analogously, it takes data form DAQ (both at Run level and inclusive -
55// of all the runs - level, processes them, and stores both Reference Data
56// and Online Calibration files in the CDB.
57
58
59ClassImp(AliTOFPreprocessorFDR)
60
61//_____________________________________________________________________________
62
63AliTOFPreprocessorFDR::AliTOFPreprocessorFDR(AliShuttleInterface* shuttle) :
64 AliPreprocessor("TOF", shuttle),
dc043f85 65 fStoreRefData(kTRUE)
66{
67 // constructor
68
69}
70
71//_____________________________________________________________________________
72
73AliTOFPreprocessorFDR::~AliTOFPreprocessorFDR()
74{
75 // destructor
dc043f85 76}
77
78//______________________________________________________________________________
79void AliTOFPreprocessorFDR::Initialize(Int_t run, UInt_t startTime,
80 UInt_t endTime)
81{
82 // Creates AliTOFDataDCS object
83
84 AliPreprocessor::Initialize(run, startTime, endTime);
85
d1034a96 86 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
dc043f85 87 TTimeStamp(startTime).AsString(),
88 TTimeStamp(endTime).AsString()));
89
dc043f85 90}
91
92//_____________________________________________________________________________
93
94UInt_t AliTOFPreprocessorFDR::ProcessDCSDataPoints(TMap* aliasMap)
95{
96 // Fills data into a AliTOFDataDCS object
97 // return codes:
98 // return=0 : all ok
99 // return=1 : no DCS input data Map
100 // return=2 : no DCS processed data was stored in Ref Data
101 // return=3 : no DCS processed data was stored in OCDB
102
103 if (!aliasMap){
104 Log("No DCS map found: TOF exiting from Shuttle");
105 return 1;// return error Code for DCS input data not found
106 }
107
108 else {
109
110 AliDCSValue* aValue;
111 AliDCSValue* aValue1;
112 Float_t timeMin = (Float_t)fStartTime;
113 Float_t timeMax = (Float_t)fEndTime;
114 Float_t val=0;
115 Float_t val1=0;
116 Float_t time=0;
117 Float_t delta[2];
118 Float_t timedelta[2];
119
120 TH1::AddDirectory(0);
121
122 Bool_t resultDCSMap=kFALSE;
123 Bool_t resultDCSStore=kFALSE;
124
125 TString aliasDP[4]={"tof_lv_i48_02","tof_lv_v48_02","tof_lv_i33_02","tof_lv_v33_02"};
126
127 TObjArray *array = new TObjArray(4);
128 array->SetOwner();
129
6b9a73fd 130 AliTOFFormatDCS *lvI4802 = new AliTOFFormatDCS();
131 AliTOFFormatDCS *lvV4802 = new AliTOFFormatDCS();
132 AliTOFFormatDCS *lvI3302 = new AliTOFFormatDCS();
133 AliTOFFormatDCS *lvV3302 = new AliTOFFormatDCS();
dc043f85 134
6b9a73fd 135 array->AddAt(lvI4802,0);
136 array->AddAt(lvV4802,1);
137 array->AddAt(lvI3302,2);
138 array->AddAt(lvV3302,3);
dc043f85 139
140 // processing DCS
141
142 for (Int_t i=0;i<4;i++){
41024dec 143 for (Int_t idelta =0;idelta<2;idelta++){
144 delta[idelta]=0;
145 timedelta[idelta]=0;
146 }
dc043f85 147 TObjArray *aliasArr = (TObjArray*) aliasMap->GetValue(aliasDP[i].Data());
148
149 if(!aliasArr){
d1034a96 150 Log(Form("Alias %s not found!", aliasDP[i].Data()));
dc043f85 151 return kFALSE;
152 }
153
154 if(aliasArr->GetEntries()<3){
d1034a96 155 Log(Form("Alias %s has just %d entries!",
dc043f85 156 aliasDP[i].Data(),aliasArr->GetEntries()));
157 continue;
158 }
159
160 TIter iterarray(aliasArr);
161
162 Int_t nentries = aliasArr->GetEntries();
163 Int_t deltaTimeStamp = (Int_t) nentries/3;
164 Int_t deltaTimeStamp1 = (Int_t) nentries/2;
165
166 // filling aliases with 10 floats+1 Usign
167 Int_t index = 0;
168 for (Int_t k=0;k<3;k++){
169 index = deltaTimeStamp*k;
170 if (k==0) {
171 index=0;
172 }
173 else if (k==1) {
174 index=deltaTimeStamp1;
175 }
176 else if (k==2) {
177 index=nentries-1;
178 }
179 aValue = (AliDCSValue*) aliasArr->At(index);
180 val = aValue->GetFloat();
181 time = (Float_t) (aValue->GetTimeStamp());
182 if (i==0){
41024dec 183 AliDebug(1,Form("tof_lv_i48_02: setting value %i to %f at %f",k,val,time));
6b9a73fd 184 lvI4802->SetFloat(k,val);
185 lvI4802->SetTimeStampFloat(k,time);
dc043f85 186 }
187 else if (i==1){
41024dec 188 AliDebug(1,Form("tof_lv_v48_02: setting value %i to %f at %f",k,val,time));
6b9a73fd 189 lvV4802->SetFloat(k,val);
190 lvV4802->SetTimeStampFloat(k,time);
dc043f85 191 }
192 else if (i==2){
41024dec 193 AliDebug(1,Form("tof_lv_i33_02: setting value %i to %f at %f",k,val,time));
6b9a73fd 194 lvI3302->SetFloat(k,val);
195 lvI3302->SetTimeStampFloat(k,time);
dc043f85 196 }
197 else if (i==3){
41024dec 198 AliDebug(1,Form("tof_lv_v33_02: setting value %i to %f at %f",k,val,time));
6b9a73fd 199 lvV3302->SetFloat(k,val);
200 lvV3302->SetTimeStampFloat(k,time);
dc043f85 201 }
202 }
203
204 // computing the most significant variations
205
206 Int_t deltamin = (Int_t)(60/(timeMax-timeMin)*nentries);
207 Int_t klast = nentries-deltamin;
208
209 for (Int_t k=0;k<klast;k++){
210 aValue = (AliDCSValue*) aliasArr->At(k);
211 aValue1 = (AliDCSValue*) aliasArr->At(k+deltamin);
212 val = aValue->GetFloat();
213 val1 = aValue1->GetFloat();
214 if (delta[0]<=TMath::Abs(val1-val)) {
215 delta[0]=TMath::Abs(val1-val);
216 timedelta[0] = (Float_t)k;
217 }
218 if (delta[1]<=delta[0]) {
219 Float_t temp = delta[1];
220 Float_t timetemp = timedelta[1];
221 delta[1]=delta[0];
222 delta[0]=temp;
223 timedelta[1]=timedelta[0];
224 timedelta[0]=timetemp;
225 }
226 }
227
228 for (Int_t kk=0;kk<2;kk++){
229 if (i==0){
230 AliDebug(1,Form("tof_lv_i48: setting variation %i to %f at %f",kk,delta[kk],timedelta[kk]));
6b9a73fd 231 lvI4802->SetDelta(kk,delta[kk]);
232 lvI4802->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
dc043f85 233 }
234 else if (i==1){
235 AliDebug(1,Form("tof_lv_v48: setting variation %i to %f at %f",kk,delta[kk],timedelta[kk]));
6b9a73fd 236 lvV4802->SetDelta(kk,delta[kk]);
237 lvV4802->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
dc043f85 238 }
239 else if (i==2){
240 AliDebug(1,Form("tof_lv_i33: setting variation %i to %f at %f",kk,delta[kk],timedelta[kk]));
6b9a73fd 241 lvI3302->SetDelta(kk,delta[kk]);
242 lvI3302->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
dc043f85 243 }
244 else if (i==3){
245 AliDebug(1,Form("tof_lv_v33: setting variation %i to %f at %f",kk,delta[kk],timedelta[kk]));
6b9a73fd 246 lvV3302->SetDelta(kk,delta[kk]);
247 lvV3302->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
dc043f85 248 }
249 }
250 }
251
252 AliCDBMetaData metaDataDCS;
253 metaDataDCS.SetBeamPeriod(0);
254 metaDataDCS.SetResponsible("Chiara Zampolli");
255 metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object.");
d1034a96 256 Log("Storing DCS Data");
dc043f85 257 resultDCSStore = StoreReferenceData("Calib","DCSData",array, &metaDataDCS);
258 if (!resultDCSStore){
259 Log("Some problems occurred while storing DCS data results in Reference Data, TOF exiting from Shuttle");
260 return 2;// return error Code for processed DCS data not stored
261 // in reference data
262 }
263
d1034a96 264 Log("Storing DCS Data in OCDB");
22363630 265 resultDCSMap = Store("Calib","DCSData",array, &metaDataDCS,0,kTRUE);
dc043f85 266 if (!resultDCSStore){
267 Log("Some problems occurred while storing DCS data results in OCDB, TOF exiting from Shuttle");
268 return 3;// return error Code for processed DCS data not stored
269 // in reference data
270 }
271
272 if (array) delete array;
273 return 0;
274
275 }
276
277}
278//_____________________________________________________________________________
279
280UInt_t AliTOFPreprocessorFDR::Process(TMap* dcsAliasMap)
281{
282 // Fills data into a AliTOFDataDCS object
283 // return codes:
284 // return=0 : all ok
285 // return=1 : no DCS input data Map
286 // return=2 : no DCS processed data was stored in Ref Data
287 // return=3 : no DCS processed data was stored in OCDB
288
289 TH1::AddDirectory(0);
290
291 // processing
292
293 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
294 if ((iresultDCS == 1) || (iresultDCS == 2) || (iresultDCS == 3)) return iresultDCS;
295
296 return 0;
297}
298
299