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