]>
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$ | |
18 | */ | |
19 | ||
20 | #include <Riostream.h> | |
21 | #include <stdio.h> | |
22 | #include <stdlib.h> | |
23 | ||
24 | #include <TFile.h> | |
25 | #include <TH1.h> | |
26 | #include <TH1F.h> | |
27 | #include <TH1S.h> | |
28 | #include <TH2S.h> | |
29 | #include <TMath.h> | |
30 | #include <TObjArray.h> | |
31 | #include <TObjString.h> | |
32 | #include <TTimeStamp.h> | |
33 | ||
34 | #include "AliCDBMetaData.h" | |
35 | #include "AliLog.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" | |
42 | ||
43 | class TF1; | |
44 | class AliDCSValue; | |
45 | class AliTOFGeometry; | |
46 | ||
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. | |
53 | ||
54 | ||
55 | ClassImp(AliTOFPreprocessorFDR) | |
56 | ||
57 | //_____________________________________________________________________________ | |
58 | ||
59 | AliTOFPreprocessorFDR::AliTOFPreprocessorFDR(AliShuttleInterface* shuttle) : | |
60 | AliPreprocessor("TOF", shuttle), | |
61 | fData(0), | |
62 | fStoreRefData(kTRUE) | |
63 | { | |
64 | // constructor | |
65 | ||
66 | } | |
67 | ||
68 | //_____________________________________________________________________________ | |
69 | ||
70 | AliTOFPreprocessorFDR::~AliTOFPreprocessorFDR() | |
71 | { | |
72 | // destructor | |
73 | if (fData){ | |
74 | delete fData; | |
75 | fData = 0; | |
76 | } | |
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 | ||
87 | AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, | |
88 | TTimeStamp(startTime).AsString(), | |
89 | TTimeStamp(endTime).AsString())); | |
90 | ||
91 | fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime); | |
92 | } | |
93 | ||
94 | //_____________________________________________________________________________ | |
95 | ||
96 | UInt_t AliTOFPreprocessorFDR::ProcessDCSDataPoints(TMap* aliasMap) | |
97 | { | |
98 | // Fills data into a AliTOFDataDCS object | |
99 | // return codes: | |
100 | // return=0 : all ok | |
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 | |
104 | ||
105 | if (!aliasMap){ | |
106 | Log("No DCS map found: TOF exiting from Shuttle"); | |
107 | return 1;// return error Code for DCS input data not found | |
108 | } | |
109 | ||
110 | else { | |
111 | ||
112 | AliDCSValue* aValue; | |
113 | AliDCSValue* aValue1; | |
114 | Float_t timeMin = (Float_t)fStartTime; | |
115 | Float_t timeMax = (Float_t)fEndTime; | |
116 | Float_t val=0; | |
117 | Float_t val1=0; | |
118 | Float_t time=0; | |
119 | Float_t delta[2]; | |
120 | Float_t timedelta[2]; | |
121 | ||
122 | TH1::AddDirectory(0); | |
123 | ||
124 | Bool_t resultDCSMap=kFALSE; | |
125 | Bool_t resultDCSStore=kFALSE; | |
126 | ||
127 | TString aliasDP[4]={"tof_lv_i48_02","tof_lv_v48_02","tof_lv_i33_02","tof_lv_v33_02"}; | |
128 | ||
129 | TObjArray *array = new TObjArray(4); | |
130 | array->SetOwner(); | |
131 | ||
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(); | |
136 | ||
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); | |
141 | ||
142 | // processing DCS | |
143 | ||
144 | for (Int_t i=0;i<4;i++){ | |
145 | TObjArray *aliasArr = (TObjArray*) aliasMap->GetValue(aliasDP[i].Data()); | |
146 | ||
147 | if(!aliasArr){ | |
148 | AliError(Form("Alias %s not found!", aliasDP[i].Data())); | |
149 | return kFALSE; | |
150 | } | |
151 | ||
152 | if(aliasArr->GetEntries()<3){ | |
153 | AliError(Form("Alias %s has just %d entries!", | |
154 | aliasDP[i].Data(),aliasArr->GetEntries())); | |
155 | continue; | |
156 | } | |
157 | ||
158 | TIter iterarray(aliasArr); | |
159 | ||
160 | Int_t nentries = aliasArr->GetEntries(); | |
161 | Int_t deltaTimeStamp = (Int_t) nentries/3; | |
162 | Int_t deltaTimeStamp1 = (Int_t) nentries/2; | |
163 | ||
164 | // filling aliases with 10 floats+1 Usign | |
165 | Int_t index = 0; | |
166 | for (Int_t k=0;k<3;k++){ | |
167 | index = deltaTimeStamp*k; | |
168 | if (k==0) { | |
169 | index=0; | |
170 | } | |
171 | else if (k==1) { | |
172 | index=deltaTimeStamp1; | |
173 | } | |
174 | else if (k==2) { | |
175 | index=nentries-1; | |
176 | } | |
177 | aValue = (AliDCSValue*) aliasArr->At(index); | |
178 | val = aValue->GetFloat(); | |
179 | time = (Float_t) (aValue->GetTimeStamp()); | |
180 | if (i==0){ | |
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); | |
184 | } | |
185 | else if (i==1){ | |
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); | |
189 | } | |
190 | else if (i==2){ | |
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); | |
194 | } | |
195 | else if (i==3){ | |
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); | |
199 | } | |
200 | } | |
201 | ||
202 | // computing the most significant variations | |
203 | ||
204 | Int_t deltamin = (Int_t)(60/(timeMax-timeMin)*nentries); | |
205 | Int_t klast = nentries-deltamin; | |
206 | ||
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; | |
215 | } | |
216 | if (delta[1]<=delta[0]) { | |
217 | Float_t temp = delta[1]; | |
218 | Float_t timetemp = timedelta[1]; | |
219 | delta[1]=delta[0]; | |
220 | delta[0]=temp; | |
221 | timedelta[1]=timedelta[0]; | |
222 | timedelta[0]=timetemp; | |
223 | } | |
224 | } | |
225 | ||
226 | for (Int_t kk=0;kk<2;kk++){ | |
227 | if (i==0){ | |
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]); | |
231 | } | |
232 | else if (i==1){ | |
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]); | |
236 | } | |
237 | else if (i==2){ | |
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]); | |
241 | } | |
242 | else if (i==3){ | |
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]); | |
246 | } | |
247 | } | |
248 | } | |
249 | ||
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 | |
259 | // in reference data | |
260 | } | |
261 | ||
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 | |
267 | // in reference data | |
268 | } | |
269 | ||
270 | if (array) delete array; | |
271 | return 0; | |
272 | ||
273 | } | |
274 | ||
275 | } | |
276 | //_____________________________________________________________________________ | |
277 | ||
278 | UInt_t AliTOFPreprocessorFDR::Process(TMap* dcsAliasMap) | |
279 | { | |
280 | // Fills data into a AliTOFDataDCS object | |
281 | // return codes: | |
282 | // return=0 : all ok | |
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 | |
286 | ||
287 | TH1::AddDirectory(0); | |
288 | ||
289 | // processing | |
290 | ||
291 | Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap); | |
292 | if ((iresultDCS == 1) || (iresultDCS == 2) || (iresultDCS == 3)) return iresultDCS; | |
293 | ||
294 | return 0; | |
295 | } | |
296 | ||
297 |