]>
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 | //_____________________________________________________________________________ | |
152 | Long64_t | |
153 | AliMUONTrackerRawDataMaker::Merge(TCollection*) | |
154 | { | |
155 | /// Merge objects in collection | |
156 | ||
157 | // AliRawReader* fRawReader; //!< reader of the data (owner) | |
158 | // AliMUONVTrackerData* fAccumulatedData; ///< data (owner) | |
159 | // AliMUONVStore* fOneEventData; ///< data for one event (owner) | |
160 | // TString fSource; ///< where the data comes from | |
161 | // Bool_t fIsRunning; ///< whether we are running or are paused | |
162 | // Int_t fNumberOfEvents; ///< number of events seen | |
163 | // Int_t fRunNumber; ///< run number of the data | |
164 | // Bool_t fIsEventByEvent; ///< we only keep one event's data (no accumulation) | |
165 | // Bool_t fUseHPDecoder; ///< whether to use high performance decoder or not (false by default) | |
166 | ||
167 | AliError("Not implemented yet"); | |
168 | return 0; | |
0145e89a | 169 | } |
170 | ||
171 | //_____________________________________________________________________________ | |
172 | Bool_t | |
173 | AliMUONTrackerRawDataMaker::NextEvent() | |
174 | { | |
515cc5b5 | 175 | /// Read and process next event |
0145e89a | 176 | |
8741815f | 177 | AliCodeTimerAuto(""); |
178 | ||
d59411b9 | 179 | static Int_t nphysics(0); |
180 | static Int_t ngood(0); | |
181 | ||
8741815f | 182 | fOneEventData->Clear(); |
183 | ||
0145e89a | 184 | if ( !IsRunning() ) return kTRUE; |
185 | ||
186 | Bool_t ok = fRawReader->NextEvent(); | |
187 | ||
188 | if (!ok) | |
189 | { | |
190 | return kFALSE; | |
191 | } | |
192 | ||
193 | Int_t eventType = fRawReader->GetType(); | |
d59411b9 | 194 | |
195 | ++fNumberOfEvents; | |
0145e89a | 196 | |
197 | if (eventType != AliRawEventHeaderBase::kPhysicsEvent ) | |
198 | { | |
199 | return kTRUE; // for the moment | |
200 | } | |
201 | ||
d59411b9 | 202 | ++nphysics; |
203 | ||
515cc5b5 | 204 | if ( ProcessEvent() ) |
205 | { | |
206 | ++ngood; | |
207 | } | |
208 | ||
209 | AliDebug(1,Form("n %10d nphysics %10d ngood %10d",fNumberOfEvents,nphysics,ngood)); | |
210 | ||
211 | return kTRUE; | |
212 | } | |
213 | ||
214 | //_____________________________________________________________________________ | |
215 | Bool_t | |
216 | AliMUONTrackerRawDataMaker::ProcessEvent() | |
217 | { | |
218 | /// Process current event | |
219 | ||
49419555 | 220 | AliMUONVRawStreamTracker* stream = 0x0; |
221 | ||
222 | if ( fUseHPDecoder ) | |
223 | { | |
224 | stream = new AliMUONRawStreamTrackerHP(fRawReader); | |
225 | } | |
226 | else | |
227 | { | |
228 | stream = new AliMUONRawStreamTracker(fRawReader); | |
229 | } | |
8741815f | 230 | |
231 | stream->First(); | |
232 | ||
233 | Int_t buspatchId; | |
234 | UShort_t manuId; | |
235 | UChar_t manuChannel; | |
236 | UShort_t adc; | |
237 | ||
238 | while ( stream->Next(buspatchId,manuId,manuChannel,adc) ) | |
239 | { | |
240 | Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(buspatchId); | |
241 | ||
242 | AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fOneEventData->FindObject(detElemId,manuId)); | |
243 | if (!param) | |
244 | { | |
245 | param = new AliMUONCalibParamND(1,64,detElemId,manuId, | |
246 | AliMUONVCalibParam::InvalidFloatValue()); | |
247 | fOneEventData->Add(param); | |
248 | } | |
249 | ||
250 | param->SetValueAsDouble(manuChannel,0,adc); | |
251 | } | |
0145e89a | 252 | |
515cc5b5 | 253 | Bool_t good(kFALSE); |
254 | ||
8741815f | 255 | if ( !stream->IsErrorMessage() ) |
0145e89a | 256 | { |
515cc5b5 | 257 | good = kTRUE; |
8741815f | 258 | fAccumulatedData->Add(*fOneEventData); |
0145e89a | 259 | } |
d59411b9 | 260 | |
8741815f | 261 | delete stream; |
0145e89a | 262 | |
515cc5b5 | 263 | return good; |
0145e89a | 264 | } |
265 | ||
266 | //_____________________________________________________________________________ | |
267 | void | |
268 | AliMUONTrackerRawDataMaker::Print(Option_t*) const | |
269 | { | |
270 | /// Printout | |
271 | ||
272 | cout << "Source=" << Source() << " Running=" << ( IsRunning() ? "YES" : "NO") | |
273 | << endl; | |
274 | ||
275 | } | |
276 | ||
277 | //_____________________________________________________________________________ | |
278 | void | |
279 | AliMUONTrackerRawDataMaker::Rewind() | |
280 | { | |
281 | /// Rewind events | |
282 | fRawReader->RewindEvents(); | |
d59411b9 | 283 | fNumberOfEvents=0; |
0145e89a | 284 | } |
515cc5b5 | 285 | |
286 | //_____________________________________________________________________________ | |
287 | void | |
288 | AliMUONTrackerRawDataMaker::SetRawReader(AliRawReader* rawReader) | |
289 | { | |
290 | /// Points to another raw reader | |
291 | ||
292 | if ( fIsOwnerOfRawReader ) | |
293 | { | |
294 | AliFatal("Improper use of this class ! Cannot change raw reader in this case"); | |
295 | } | |
296 | fRawReader = rawReader; | |
297 | } |