1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONTrackerRawDataMaker.h"
20 #include "AliCDBManager.h"
21 #include "AliCDBStorage.h"
22 #include "AliCodeTimer.h"
25 #include "AliMUON2DMap.h"
26 #include "AliMUONCalibParamND.h"
27 #include "AliMUONCalibrationData.h"
28 #include "AliMUONRawStreamTracker.h"
29 #include "AliMUONRawStreamTrackerHP.h"
30 #include "AliMUONTrackerData.h"
31 #include "AliMpDDLStore.h"
32 #include "AliRawEventHeaderBase.h"
33 #include "AliRawReader.h"
34 #include <Riostream.h>
36 ///\class AliMUONTrackerRawDataMaker
38 /// Creator of raw AliMUONVTrackerData from AliRawReader
40 ///\author Laurent Aphecetche, Subatech
43 ClassImp(AliMUONTrackerRawDataMaker)
46 Int_t AliMUONTrackerRawDataMaker::fgkCounter(0);
48 //_____________________________________________________________________________
49 AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(TRootIOCtor*)
50 : AliMUONVTrackerDataMaker(),
52 fIsOwnerOfRawReader(kFALSE),
53 fAccumulatedData(0x0),
59 fIsEventByEvent(kFALSE),
66 //_____________________________________________________________________________
67 AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(AliRawReader* reader,
70 : AliMUONVTrackerDataMaker(),
72 fIsOwnerOfRawReader(kTRUE),
73 fAccumulatedData(0x0),
74 fOneEventData(new AliMUON2DMap(true)),
75 fSource("unspecified"),
79 fIsEventByEvent(kFALSE),
80 fUseHPDecoder(useHPdecoder)
86 fRawReader->NextEvent(); // to be sure to get run number available
87 fRunNumber = fRawReader->GetRunNumber();
88 fRawReader->RewindEvents();
94 //_____________________________________________________________________________
95 AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(Int_t runNumber,
99 : AliMUONVTrackerDataMaker(),
101 fIsOwnerOfRawReader(kTRUE),
102 fAccumulatedData(0x0),
103 fOneEventData(new AliMUON2DMap(true)),
104 fSource("unspecified"),
107 fRunNumber(runNumber),
108 fIsEventByEvent(kFALSE),
109 fUseHPDecoder(useHPdecoder)
116 //_____________________________________________________________________________
118 AliMUONTrackerRawDataMaker::Ctor(Bool_t histogram)
127 name = Form("%sRAW_%d",(histogram?"H":""),fgkCounter);
131 name = Form("%sRAW%d",(histogram?"H":""),fRunNumber);
134 fAccumulatedData = new AliMUONTrackerData(name.Data(),"charge values",1);
135 fAccumulatedData->SetDimensionName(0,"Raw charge");
138 fAccumulatedData->MakeHistogramForDimension(0,kTRUE);
142 //_____________________________________________________________________________
143 AliMUONTrackerRawDataMaker::~AliMUONTrackerRawDataMaker()
146 delete fOneEventData;
147 delete fAccumulatedData;
148 if (fIsOwnerOfRawReader) delete fRawReader;
151 //_____________________________________________________________________________
153 AliMUONTrackerRawDataMaker::Add(const AliMUONTrackerRawDataMaker& other)
155 /// Adds other to this
157 // AliRawReader* fRawReader; //!< reader of the data (owner or not)
158 // Bool_t fIsOwnerOfRawReader; //!< whether we must delete rawReader or not
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)
166 // Bool_t fUseHPDecoder; ///< whether to use high performance decoder or not
167 // static Int_t fgkCounter; ///< to count the number of instances
169 if (!fAccumulatedData) return kFALSE;
171 if ( fIsEventByEvent )
173 AliError("Cannot add event by event objects !");
177 if ( fRunNumber != other.fRunNumber ) fRunNumber = -1;
180 fSource += other.fSource;
182 fNumberOfEvents += other.fNumberOfEvents;
185 list.Add(other.fAccumulatedData);
187 fAccumulatedData->Merge(&list);
192 //_____________________________________________________________________________
194 AliMUONTrackerRawDataMaker::Merge(TCollection* list)
196 /// Merge objects in collection
200 if ( list->IsEmpty() ) return NumberOfEvents();
203 const TObject* o(0x0);
205 while ( ( o = next() ) )
207 const AliMUONTrackerRawDataMaker* data = dynamic_cast<const AliMUONTrackerRawDataMaker*>(o);
210 AliError(Form("Object named %s is not an AliMUONTrackerRawDataMaker ! Skipping it",
215 Bool_t ok = Add(*data);
218 AliError("Got incompatible objects");
223 return NumberOfEvents();
226 //_____________________________________________________________________________
228 AliMUONTrackerRawDataMaker::NextEvent()
230 /// Read and process next event
232 AliCodeTimerAuto("");
234 static Int_t nphysics(0);
235 static Int_t ngood(0);
237 fOneEventData->Clear();
239 if ( !IsRunning() ) return kTRUE;
241 Bool_t ok = fRawReader->NextEvent();
248 Int_t eventType = fRawReader->GetType();
252 if (eventType != AliRawEventHeaderBase::kPhysicsEvent )
254 return kTRUE; // for the moment
259 if ( ProcessEvent() )
264 AliDebug(1,Form("n %10d nphysics %10d ngood %10d",fNumberOfEvents,nphysics,ngood));
269 //_____________________________________________________________________________
271 AliMUONTrackerRawDataMaker::ProcessEvent()
273 /// Process current event
275 AliMUONVRawStreamTracker* stream = 0x0;
279 stream = new AliMUONRawStreamTrackerHP(fRawReader);
283 stream = new AliMUONRawStreamTracker(fRawReader);
293 while ( stream->Next(buspatchId,manuId,manuChannel,adc) )
295 Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(buspatchId);
297 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fOneEventData->FindObject(detElemId,manuId));
300 param = new AliMUONCalibParamND(1,64,detElemId,manuId,
301 AliMUONVCalibParam::InvalidFloatValue());
302 fOneEventData->Add(param);
305 param->SetValueAsDouble(manuChannel,0,adc);
310 if ( !stream->IsErrorMessage() )
313 fAccumulatedData->Add(*fOneEventData);
321 //_____________________________________________________________________________
323 AliMUONTrackerRawDataMaker::Print(Option_t*) const
327 cout << "Source=" << Source() << " Running=" << ( IsRunning() ? "YES" : "NO")
332 //_____________________________________________________________________________
334 AliMUONTrackerRawDataMaker::Rewind()
337 fRawReader->RewindEvents();
341 //_____________________________________________________________________________
343 AliMUONTrackerRawDataMaker::SetRawReader(AliRawReader* rawReader)
345 /// Points to another raw reader
347 if ( fIsOwnerOfRawReader )
349 AliFatal("Improper use of this class ! Cannot change raw reader in this case");
351 fRawReader = rawReader;