]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTrackerRawDataMaker.cxx
In mapping:
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackerRawDataMaker.cxx
CommitLineData
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
43ClassImp(AliMUONTrackerRawDataMaker)
44///\endcond
45
46Int_t AliMUONTrackerRawDataMaker::fgkCounter(0);
47
515cc5b5 48//_____________________________________________________________________________
49AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(TRootIOCtor*)
50: AliMUONVTrackerDataMaker(),
51fRawReader(0x0),
52fIsOwnerOfRawReader(kFALSE),
53fAccumulatedData(0x0),
54fOneEventData(0x0),
55fSource(""),
56fIsRunning(kFALSE),
57fNumberOfEvents(0),
58fRunNumber(0),
59fIsEventByEvent(kFALSE),
60fUseHPDecoder(kTRUE)
61{
62 /// Ctor
63 ++fgkCounter;
64}
65
0145e89a 66//_____________________________________________________________________________
49419555 67AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(AliRawReader* reader,
68 Bool_t histogram,
69 Bool_t useHPdecoder)
0145e89a 70: AliMUONVTrackerDataMaker(),
515cc5b5 71fRawReader(reader),
72fIsOwnerOfRawReader(kTRUE),
73fAccumulatedData(0x0),
74fOneEventData(new AliMUON2DMap(true)),
75fSource("unspecified"),
76fIsRunning(kFALSE),
77fNumberOfEvents(0),
78fRunNumber(0),
79fIsEventByEvent(kFALSE),
80fUseHPDecoder(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//_____________________________________________________________________________
95AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(Int_t runNumber,
96 AliRawReader* reader,
97 Bool_t histogram,
98 Bool_t useHPdecoder)
99: AliMUONVTrackerDataMaker(),
100fRawReader(reader),
101fIsOwnerOfRawReader(kTRUE),
102fAccumulatedData(0x0),
103fOneEventData(new AliMUON2DMap(true)),
104fSource("unspecified"),
105fIsRunning(kFALSE),
106fNumberOfEvents(0),
107fRunNumber(runNumber),
108fIsEventByEvent(kFALSE),
109fUseHPDecoder(useHPdecoder)
110{
111 /// Ctor
112
113 Ctor(histogram);
114}
115
116//_____________________________________________________________________________
117void
118AliMUONTrackerRawDataMaker::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//_____________________________________________________________________________
143AliMUONTrackerRawDataMaker::~AliMUONTrackerRawDataMaker()
144{
145 /// dtor
146 delete fOneEventData;
49419555 147 delete fAccumulatedData;
515cc5b5 148 if (fIsOwnerOfRawReader) delete fRawReader;
49419555 149}
150
151//_____________________________________________________________________________
152Long64_t
153AliMUONTrackerRawDataMaker::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//_____________________________________________________________________________
172Bool_t
173AliMUONTrackerRawDataMaker::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//_____________________________________________________________________________
215Bool_t
216AliMUONTrackerRawDataMaker::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//_____________________________________________________________________________
267void
268AliMUONTrackerRawDataMaker::Print(Option_t*) const
269{
270 /// Printout
271
272 cout << "Source=" << Source() << " Running=" << ( IsRunning() ? "YES" : "NO")
273 << endl;
274
275}
276
277//_____________________________________________________________________________
278void
279AliMUONTrackerRawDataMaker::Rewind()
280{
281 /// Rewind events
282 fRawReader->RewindEvents();
d59411b9 283 fNumberOfEvents=0;
0145e89a 284}
515cc5b5 285
286//_____________________________________________________________________________
287void
288AliMUONTrackerRawDataMaker::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}