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