]>
Commit | Line | Data |
---|---|---|
0145e89a | 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 | // $Id$ | |
17 | ||
18 | #include "AliMUONTrackerRawDataMaker.h" | |
19 | ||
49419555 | 20 | #include "AliCDBManager.h" |
21 | #include "AliCDBStorage.h" | |
8741815f | 22 | #include "AliCodeTimer.h" |
23 | #include "AliLog.h" | |
49419555 | 24 | #include "AliLog.h" |
0145e89a | 25 | #include "AliMUON2DMap.h" |
26 | #include "AliMUONCalibParamND.h" | |
27 | #include "AliMUONCalibrationData.h" | |
49419555 | 28 | #include "AliMUONRawStreamTracker.h" |
29 | #include "AliMUONRawStreamTrackerHP.h" | |
0145e89a | 30 | #include "AliMUONTrackerData.h" |
0145e89a | 31 | #include "AliMpDDLStore.h" |
0145e89a | 32 | #include "AliRawEventHeaderBase.h" |
33 | #include "AliRawReader.h" | |
34 | #include <Riostream.h> | |
35 | ||
36 | ///\class AliMUONTrackerRawDataMaker | |
37 | /// | |
8741815f | 38 | /// Creator of raw AliMUONVTrackerData from AliRawReader |
0145e89a | 39 | /// |
40 | ///\author Laurent Aphecetche, Subatech | |
41 | ||
42 | ///\cond CLASSIMP | |
43 | ClassImp(AliMUONTrackerRawDataMaker) | |
44 | ///\endcond | |
45 | ||
46 | Int_t AliMUONTrackerRawDataMaker::fgkCounter(0); | |
47 | ||
515cc5b5 | 48 | //_____________________________________________________________________________ |
49 | AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(TRootIOCtor*) | |
50 | : AliMUONVTrackerDataMaker(), | |
51 | fRawReader(0x0), | |
52 | fIsOwnerOfRawReader(kFALSE), | |
53 | fAccumulatedData(0x0), | |
54 | fOneEventData(0x0), | |
55 | fSource(""), | |
56 | fIsRunning(kFALSE), | |
57 | fNumberOfEvents(0), | |
58 | fRunNumber(0), | |
59 | fIsEventByEvent(kFALSE), | |
60 | fUseHPDecoder(kTRUE) | |
61 | { | |
62 | /// Ctor | |
63 | ++fgkCounter; | |
64 | } | |
65 | ||
0145e89a | 66 | //_____________________________________________________________________________ |
49419555 | 67 | AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(AliRawReader* reader, |
68 | Bool_t histogram, | |
69 | Bool_t useHPdecoder) | |
0145e89a | 70 | : AliMUONVTrackerDataMaker(), |
515cc5b5 | 71 | fRawReader(reader), |
72 | fIsOwnerOfRawReader(kTRUE), | |
73 | fAccumulatedData(0x0), | |
74 | fOneEventData(new AliMUON2DMap(true)), | |
75 | fSource("unspecified"), | |
76 | fIsRunning(kFALSE), | |
77 | fNumberOfEvents(0), | |
78 | fRunNumber(0), | |
79 | fIsEventByEvent(kFALSE), | |
80 | fUseHPDecoder(useHPdecoder) | |
0145e89a | 81 | { |
82 | /// Ctor | |
515cc5b5 | 83 | |
49419555 | 84 | if (fRawReader) |
85 | { | |
86 | fRawReader->NextEvent(); // to be sure to get run number available | |
87 | fRunNumber = fRawReader->GetRunNumber(); | |
88 | fRawReader->RewindEvents(); | |
89 | } | |
90 | ||
515cc5b5 | 91 | Ctor(histogram); |
92 | } | |
93 | ||
94 | //_____________________________________________________________________________ | |
95 | AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(Int_t runNumber, | |
96 | AliRawReader* reader, | |
97 | Bool_t histogram, | |
98 | Bool_t useHPdecoder) | |
99 | : AliMUONVTrackerDataMaker(), | |
100 | fRawReader(reader), | |
101 | fIsOwnerOfRawReader(kTRUE), | |
102 | fAccumulatedData(0x0), | |
103 | fOneEventData(new AliMUON2DMap(true)), | |
104 | fSource("unspecified"), | |
105 | fIsRunning(kFALSE), | |
106 | fNumberOfEvents(0), | |
107 | fRunNumber(runNumber), | |
108 | fIsEventByEvent(kFALSE), | |
109 | fUseHPDecoder(useHPdecoder) | |
110 | { | |
111 | /// Ctor | |
112 | ||
113 | Ctor(histogram); | |
114 | } | |
115 | ||
116 | //_____________________________________________________________________________ | |
117 | void | |
118 | AliMUONTrackerRawDataMaker::Ctor(Bool_t histogram) | |
119 | { | |
120 | /// Designated ctor | |
121 | ||
0145e89a | 122 | TString name; |
123 | ||
49419555 | 124 | if (!fRunNumber) |
0145e89a | 125 | { |
8741815f | 126 | ++fgkCounter; |
515cc5b5 | 127 | name = Form("%sRAW_%d",(histogram?"H":""),fgkCounter); |
0145e89a | 128 | } |
129 | else | |
130 | { | |
49419555 | 131 | name = Form("%sRAW%d",(histogram?"H":""),fRunNumber); |
0145e89a | 132 | } |
133 | ||
134 | fAccumulatedData = new AliMUONTrackerData(name.Data(),"charge values",1); | |
8741815f | 135 | fAccumulatedData->SetDimensionName(0,"Raw charge"); |
136 | if ( histogram ) | |
0145e89a | 137 | { |
10eb3d17 | 138 | fAccumulatedData->MakeHistogramForDimension(0,kTRUE); |
0145e89a | 139 | } |
140 | } | |
141 | ||
142 | //_____________________________________________________________________________ | |
143 | AliMUONTrackerRawDataMaker::~AliMUONTrackerRawDataMaker() | |
144 | { | |
145 | /// dtor | |
146 | delete fOneEventData; | |
49419555 | 147 | delete fAccumulatedData; |
515cc5b5 | 148 | if (fIsOwnerOfRawReader) delete fRawReader; |
49419555 | 149 | } |
150 | ||
151 | //_____________________________________________________________________________ | |
e83120bd | 152 | Bool_t |
153 | AliMUONTrackerRawDataMaker::Add(const AliMUONTrackerRawDataMaker& other) | |
49419555 | 154 | { |
e83120bd | 155 | /// Adds other to this |
49419555 | 156 | |
e83120bd | 157 | // AliRawReader* fRawReader; //!< reader of the data (owner or not) |
158 | // Bool_t fIsOwnerOfRawReader; //!< whether we must delete rawReader or not | |
49419555 | 159 | // AliMUONVTrackerData* fAccumulatedData; ///< data (owner) |
160 | // AliMUONVStore* fOneEventData; ///< data for one event (owner) | |
161 | // TString fSource; ///< where the data comes from | |
162 | // Bool_t fIsRunning; ///< whether we are running or are paused | |
163 | // Int_t fNumberOfEvents; ///< number of events seen | |
164 | // Int_t fRunNumber; ///< run number of the data | |
165 | // Bool_t fIsEventByEvent; ///< we only keep one event's data (no accumulation) | |
e83120bd | 166 | // Bool_t fUseHPDecoder; ///< whether to use high performance decoder or not |
167 | // static Int_t fgkCounter; ///< to count the number of instances | |
168 | ||
169 | if (!fAccumulatedData) return kFALSE; | |
170 | ||
171 | if ( fIsEventByEvent ) | |
172 | { | |
173 | AliError("Cannot add event by event objects !"); | |
174 | return kFALSE; | |
175 | } | |
176 | ||
177 | if ( fRunNumber != other.fRunNumber ) fRunNumber = -1; | |
178 | ||
179 | fSource += "\n"; | |
180 | fSource += other.fSource; | |
181 | ||
182 | fNumberOfEvents += other.fNumberOfEvents; | |
183 | ||
184 | TList list; | |
185 | list.Add(other.fAccumulatedData); | |
186 | ||
187 | fAccumulatedData->Merge(&list); | |
188 | ||
189 | return kTRUE; | |
190 | } | |
49419555 | 191 | |
e83120bd | 192 | //_____________________________________________________________________________ |
193 | Long64_t | |
194 | AliMUONTrackerRawDataMaker::Merge(TCollection* list) | |
195 | { | |
196 | /// Merge objects in collection | |
197 | ||
198 | if (!list) return 0; | |
199 | ||
200 | if ( list->IsEmpty() ) return NumberOfEvents(); | |
201 | ||
202 | TIter next(list); | |
203 | const TObject* o(0x0); | |
204 | ||
205 | while ( ( o = next() ) ) | |
206 | { | |
207 | const AliMUONTrackerRawDataMaker* data = dynamic_cast<const AliMUONTrackerRawDataMaker*>(o); | |
208 | if (!o) | |
209 | { | |
210 | AliError(Form("Object named %s is not an AliMUONTrackerRawDataMaker ! Skipping it", | |
211 | o->GetName())); | |
212 | } | |
213 | else | |
214 | { | |
215 | Bool_t ok = Add(*data); | |
216 | if (!ok) | |
217 | { | |
218 | AliError("Got incompatible objects"); | |
219 | } | |
220 | } | |
221 | } | |
222 | ||
223 | return NumberOfEvents(); | |
0145e89a | 224 | } |
225 | ||
226 | //_____________________________________________________________________________ | |
227 | Bool_t | |
228 | AliMUONTrackerRawDataMaker::NextEvent() | |
229 | { | |
515cc5b5 | 230 | /// Read and process next event |
0145e89a | 231 | |
8741815f | 232 | AliCodeTimerAuto(""); |
233 | ||
d59411b9 | 234 | static Int_t nphysics(0); |
235 | static Int_t ngood(0); | |
236 | ||
8741815f | 237 | fOneEventData->Clear(); |
238 | ||
0145e89a | 239 | if ( !IsRunning() ) return kTRUE; |
240 | ||
241 | Bool_t ok = fRawReader->NextEvent(); | |
242 | ||
243 | if (!ok) | |
244 | { | |
245 | return kFALSE; | |
246 | } | |
247 | ||
248 | Int_t eventType = fRawReader->GetType(); | |
d59411b9 | 249 | |
250 | ++fNumberOfEvents; | |
0145e89a | 251 | |
252 | if (eventType != AliRawEventHeaderBase::kPhysicsEvent ) | |
253 | { | |
254 | return kTRUE; // for the moment | |
255 | } | |
256 | ||
d59411b9 | 257 | ++nphysics; |
258 | ||
515cc5b5 | 259 | if ( ProcessEvent() ) |
260 | { | |
261 | ++ngood; | |
262 | } | |
263 | ||
264 | AliDebug(1,Form("n %10d nphysics %10d ngood %10d",fNumberOfEvents,nphysics,ngood)); | |
265 | ||
266 | return kTRUE; | |
267 | } | |
268 | ||
269 | //_____________________________________________________________________________ | |
270 | Bool_t | |
271 | AliMUONTrackerRawDataMaker::ProcessEvent() | |
272 | { | |
273 | /// Process current event | |
274 | ||
49419555 | 275 | AliMUONVRawStreamTracker* stream = 0x0; |
276 | ||
277 | if ( fUseHPDecoder ) | |
278 | { | |
279 | stream = new AliMUONRawStreamTrackerHP(fRawReader); | |
280 | } | |
281 | else | |
282 | { | |
283 | stream = new AliMUONRawStreamTracker(fRawReader); | |
284 | } | |
8741815f | 285 | |
286 | stream->First(); | |
287 | ||
288 | Int_t buspatchId; | |
289 | UShort_t manuId; | |
290 | UChar_t manuChannel; | |
291 | UShort_t adc; | |
292 | ||
293 | while ( stream->Next(buspatchId,manuId,manuChannel,adc) ) | |
294 | { | |
295 | Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(buspatchId); | |
296 | ||
297 | AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fOneEventData->FindObject(detElemId,manuId)); | |
298 | if (!param) | |
299 | { | |
300 | param = new AliMUONCalibParamND(1,64,detElemId,manuId, | |
301 | AliMUONVCalibParam::InvalidFloatValue()); | |
302 | fOneEventData->Add(param); | |
303 | } | |
304 | ||
305 | param->SetValueAsDouble(manuChannel,0,adc); | |
306 | } | |
0145e89a | 307 | |
515cc5b5 | 308 | Bool_t good(kFALSE); |
309 | ||
8741815f | 310 | if ( !stream->IsErrorMessage() ) |
0145e89a | 311 | { |
515cc5b5 | 312 | good = kTRUE; |
8741815f | 313 | fAccumulatedData->Add(*fOneEventData); |
0145e89a | 314 | } |
d59411b9 | 315 | |
8741815f | 316 | delete stream; |
0145e89a | 317 | |
515cc5b5 | 318 | return good; |
0145e89a | 319 | } |
320 | ||
321 | //_____________________________________________________________________________ | |
322 | void | |
323 | AliMUONTrackerRawDataMaker::Print(Option_t*) const | |
324 | { | |
325 | /// Printout | |
326 | ||
327 | cout << "Source=" << Source() << " Running=" << ( IsRunning() ? "YES" : "NO") | |
328 | << endl; | |
329 | ||
330 | } | |
331 | ||
332 | //_____________________________________________________________________________ | |
333 | void | |
334 | AliMUONTrackerRawDataMaker::Rewind() | |
335 | { | |
336 | /// Rewind events | |
337 | fRawReader->RewindEvents(); | |
d59411b9 | 338 | fNumberOfEvents=0; |
0145e89a | 339 | } |
515cc5b5 | 340 | |
341 | //_____________________________________________________________________________ | |
342 | void | |
343 | AliMUONTrackerRawDataMaker::SetRawReader(AliRawReader* rawReader) | |
344 | { | |
345 | /// Points to another raw reader | |
346 | ||
347 | if ( fIsOwnerOfRawReader ) | |
348 | { | |
349 | AliFatal("Improper use of this class ! Cannot change raw reader in this case"); | |
350 | } | |
351 | fRawReader = rawReader; | |
352 | } |