]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTrackerRawDataMaker.cxx
Analysis now deriving from AliAnalysisTaskSE. The subtasks are still there but now...
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackerRawDataMaker.cxx
index bdb894cb78918c696ce63129f232b7855cafb748..c320f0e252453df12649aae8074bea9511a4a32c 100644 (file)
 #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 "AliRawEventHeaderBase.h"
 #include "AliRawReader.h"
@@ -50,23 +45,42 @@ ClassImp(AliMUONTrackerRawDataMaker)
 
 Int_t AliMUONTrackerRawDataMaker::fgkCounter(0);
 
+//_____________________________________________________________________________
+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)),
-  fSource("unspecified"),
-  fIsRunning(kFALSE),
-  fNumberOfEvents(0),
-  fRunNumber(0),
-  fIsEventByEvent(kFALSE),
-  fUseHPDecoder(useHPdecoder)
+fRawReader(reader),
+fIsOwnerOfRawReader(kTRUE),
+fAccumulatedData(0x0),
+fOneEventData(new AliMUON2DMap(true)),
+fSource("unspecified"),
+fIsRunning(kFALSE),
+fNumberOfEvents(0),
+fRunNumber(0),
+fIsEventByEvent(kFALSE),
+fUseHPDecoder(useHPdecoder)
 {
   /// Ctor
-    
+  
   if (fRawReader)
   {
     fRawReader->NextEvent(); // to be sure to get run number available
@@ -74,12 +88,43 @@ AliMUONTrackerRawDataMaker::AliMUONTrackerRawDataMaker(AliRawReader* reader,
     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 (!fRunNumber)
   {
     ++fgkCounter;    
-    name = Form("%sRAW(%d)",(histogram?"H":""),fgkCounter);
+    name = Form("%sRAW_%d",(histogram?"H":""),fgkCounter);
   }
   else
   {
@@ -100,16 +145,17 @@ AliMUONTrackerRawDataMaker::~AliMUONTrackerRawDataMaker()
   /// dtor
   delete fOneEventData;
   delete fAccumulatedData;
-  delete fRawReader;
+       if (fIsOwnerOfRawReader) delete fRawReader;
 }
 
 //_____________________________________________________________________________
-Long64_t
-AliMUONTrackerRawDataMaker::Merge(TCollection*)
+Bool_t
+AliMUONTrackerRawDataMaker::Add(const AliMUONTrackerRawDataMaker& other) 
 {
-  /// Merge objects in collection
+  /// Adds other to this
   
-//  AliRawReader* fRawReader; //!< reader of the data (owner)
+//  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
@@ -117,17 +163,71 @@ AliMUONTrackerRawDataMaker::Merge(TCollection*)
 //  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 (false by default)
+//  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;
+}
 
-  AliError("Not implemented yet");
-  return 0;
+//_____________________________________________________________________________
+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("");
   
@@ -156,6 +256,22 @@ AliMUONTrackerRawDataMaker::NextEvent()
 
   ++nphysics;
 
+       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 ) 
@@ -189,17 +305,17 @@ AliMUONTrackerRawDataMaker::NextEvent()
     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;
 }
 
 //_____________________________________________________________________________
@@ -221,3 +337,16 @@ AliMUONTrackerRawDataMaker::Rewind()
   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;
+}