#include "AliMUONTrackerRawDataMaker.h"
+#include "AliCDBManager.h"
+#include "AliCDBStorage.h"
#include "AliCodeTimer.h"
#include "AliLog.h"
+#include "AliLog.h"
#include "AliMUON2DMap.h"
#include "AliMUONCalibParamND.h"
#include "AliMUONCalibrationData.h"
-#include "AliMUONDigitCalibrator.h"
-#include "AliMUONDigitMaker.h"
-#include "AliMUONDigitStoreV2R.h"
+#include "AliMUONRawStreamTracker.h"
+#include "AliMUONRawStreamTrackerHP.h"
#include "AliMUONTrackerData.h"
-#include "AliMUONVDigit.h"
-#include "AliMUONVDigitStore.h"
#include "AliMpDDLStore.h"
-#include "AliCDBManager.h"
-#include "AliCDBStorage.h"
#include "AliRawEventHeaderBase.h"
#include "AliRawReader.h"
-#include "AliLog.h"
#include <Riostream.h>
-#include "AliMUONRawStreamTracker.h"
///\class AliMUONTrackerRawDataMaker
///
Int_t AliMUONTrackerRawDataMaker::fgkCounter(0);
//_____________________________________________________________________________
-AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(AliRawReader* reader, Bool_t histogram)
+AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(TRootIOCtor*)
+: AliMUONVTrackerDataMaker(),
+fRawReader(0x0),
+fIsOwnerOfRawReader(kFALSE),
+fAccumulatedData(0x0),
+fOneEventData(0x0),
+fSource(""),
+fIsRunning(kFALSE),
+fNumberOfEvents(0),
+fRunNumber(0),
+fIsEventByEvent(kFALSE),
+fUseHPDecoder(kTRUE)
+{
+ /// Ctor
+ ++fgkCounter;
+}
+
+//_____________________________________________________________________________
+AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(AliRawReader* reader,
+ Bool_t histogram,
+ Bool_t useHPdecoder)
: AliMUONVTrackerDataMaker(),
- fRawReader(reader),
- fAccumulatedData(0x0),
- fOneEventData(new AliMUON2DMap(true)),
- fIsOwner(kTRUE),
- fSource("unspecified"),
- fIsRunning(kFALSE),
- fNumberOfEvents(0)
+fRawReader(reader),
+fIsOwnerOfRawReader(kTRUE),
+fAccumulatedData(0x0),
+fOneEventData(new AliMUON2DMap(true)),
+fSource("unspecified"),
+fIsRunning(kFALSE),
+fNumberOfEvents(0),
+fRunNumber(0),
+fIsEventByEvent(kFALSE),
+fUseHPDecoder(useHPdecoder)
{
/// Ctor
- reader->NextEvent(); // to be sure to get run number available
- Int_t runNumber = reader->GetRunNumber();
+ if (fRawReader)
+ {
+ fRawReader->NextEvent(); // to be sure to get run number available
+ fRunNumber = fRawReader->GetRunNumber();
+ fRawReader->RewindEvents();
+ }
+
+ Ctor(histogram);
+}
+
+//_____________________________________________________________________________
+AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(Int_t runNumber,
+ AliRawReader* reader,
+ Bool_t histogram,
+ Bool_t useHPdecoder)
+: AliMUONVTrackerDataMaker(),
+fRawReader(reader),
+fIsOwnerOfRawReader(kTRUE),
+fAccumulatedData(0x0),
+fOneEventData(new AliMUON2DMap(true)),
+fSource("unspecified"),
+fIsRunning(kFALSE),
+fNumberOfEvents(0),
+fRunNumber(runNumber),
+fIsEventByEvent(kFALSE),
+fUseHPDecoder(useHPdecoder)
+{
+ /// Ctor
+
+ Ctor(histogram);
+}
+
+//_____________________________________________________________________________
+void
+AliMUONTrackerRawDataMaker::Ctor(Bool_t histogram)
+{
+ /// Designated ctor
TString name;
- if (!runNumber)
+ if (!fRunNumber)
{
++fgkCounter;
- name = Form("%sRAW(%d)",(histogram?"H":""),fgkCounter);
+ name = Form("%sRAW_%d",(histogram?"H":""),fgkCounter);
}
else
{
- name = Form("%sRAW%d",(histogram?"H":""),runNumber);
+ name = Form("%sRAW%d",(histogram?"H":""),fRunNumber);
}
fAccumulatedData = new AliMUONTrackerData(name.Data(),"charge values",1);
{
fAccumulatedData->MakeHistogramForDimension(0,kTRUE);
}
-
- reader->RewindEvents();
}
//_____________________________________________________________________________
{
/// dtor
delete fOneEventData;
- if ( fIsOwner ) delete fAccumulatedData;
+ delete fAccumulatedData;
+ if (fIsOwnerOfRawReader) delete fRawReader;
+}
+
+//_____________________________________________________________________________
+Bool_t
+AliMUONTrackerRawDataMaker::Add(const AliMUONTrackerRawDataMaker& other)
+{
+ /// Adds other to this
+
+// AliRawReader* fRawReader; //!< reader of the data (owner or not)
+// Bool_t fIsOwnerOfRawReader; //!< whether we must delete rawReader or not
+// AliMUONVTrackerData* fAccumulatedData; ///< data (owner)
+// AliMUONVStore* fOneEventData; ///< data for one event (owner)
+// TString fSource; ///< where the data comes from
+// Bool_t fIsRunning; ///< whether we are running or are paused
+// Int_t fNumberOfEvents; ///< number of events seen
+// Int_t fRunNumber; ///< run number of the data
+// Bool_t fIsEventByEvent; ///< we only keep one event's data (no accumulation)
+// Bool_t fUseHPDecoder; ///< whether to use high performance decoder or not
+// static Int_t fgkCounter; ///< to count the number of instances
+
+ if (!fAccumulatedData) return kFALSE;
+
+ if ( fIsEventByEvent )
+ {
+ AliError("Cannot add event by event objects !");
+ return kFALSE;
+ }
+
+ if ( fRunNumber != other.fRunNumber ) fRunNumber = -1;
+
+ fSource += "\n";
+ fSource += other.fSource;
+
+ fNumberOfEvents += other.fNumberOfEvents;
+
+ TList list;
+ list.Add(other.fAccumulatedData);
+
+ fAccumulatedData->Merge(&list);
+
+ return kTRUE;
+}
+
+//_____________________________________________________________________________
+Long64_t
+AliMUONTrackerRawDataMaker::Merge(TCollection* list)
+{
+ /// Merge objects in collection
+
+ if (!list) return 0;
+
+ if ( list->IsEmpty() ) return NumberOfEvents();
+
+ TIter next(list);
+ const TObject* o(0x0);
+
+ while ( ( o = next() ) )
+ {
+ const AliMUONTrackerRawDataMaker* data = dynamic_cast<const AliMUONTrackerRawDataMaker*>(o);
+ if (!o)
+ {
+ AliError(Form("Object named %s is not an AliMUONTrackerRawDataMaker ! Skipping it",
+ o->GetName()));
+ }
+ else
+ {
+ Bool_t ok = Add(*data);
+ if (!ok)
+ {
+ AliError("Got incompatible objects");
+ }
+ }
+ }
+
+ return NumberOfEvents();
}
//_____________________________________________________________________________
Bool_t
AliMUONTrackerRawDataMaker::NextEvent()
{
- /// Read next event
+ /// Read and process next event
AliCodeTimerAuto("");
++nphysics;
- AliMUONVRawStreamTracker* stream = new AliMUONRawStreamTracker(fRawReader);
+ if ( ProcessEvent() )
+ {
+ ++ngood;
+ }
+
+ AliDebug(1,Form("n %10d nphysics %10d ngood %10d",fNumberOfEvents,nphysics,ngood));
+
+ return kTRUE;
+}
+
+//_____________________________________________________________________________
+Bool_t
+AliMUONTrackerRawDataMaker::ProcessEvent()
+{
+ /// Process current event
+
+ AliMUONVRawStreamTracker* stream = 0x0;
+
+ if ( fUseHPDecoder )
+ {
+ stream = new AliMUONRawStreamTrackerHP(fRawReader);
+ }
+ else
+ {
+ stream = new AliMUONRawStreamTracker(fRawReader);
+ }
stream->First();
param->SetValueAsDouble(manuChannel,0,adc);
}
+ Bool_t good(kFALSE);
+
if ( !stream->IsErrorMessage() )
{
- ++ngood;
+ good = kTRUE;
fAccumulatedData->Add(*fOneEventData);
}
- AliDebug(1,Form("n %10d nphysics %10d ngood %10d",fNumberOfEvents,nphysics,ngood));
-
delete stream;
- return kTRUE;
+ return good;
}
//_____________________________________________________________________________
fRawReader->RewindEvents();
fNumberOfEvents=0;
}
+
+//_____________________________________________________________________________
+void
+AliMUONTrackerRawDataMaker::SetRawReader(AliRawReader* rawReader)
+{
+ /// Points to another raw reader
+
+ if ( fIsOwnerOfRawReader )
+ {
+ AliFatal("Improper use of this class ! Cannot change raw reader in this case");
+ }
+ fRawReader = rawReader;
+}