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