]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTrackerDataMaker.cxx
removed warnings
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackerDataMaker.cxx
index 239d7c0d6c7e196e69d2d06cfc930c5aaf8e9627..01f151bf6e660e0a84c6852208b7097c72dd06bd 100644 (file)
@@ -41,6 +41,8 @@
 #include "AliRawReader.h"
 #include "Riostream.h"
 
+using std::endl;
+using std::cout;
 /// \cond CLASSIMP
 ClassImp(AliMUONTrackerDataMaker)
 /// \endcond
@@ -53,6 +55,7 @@ AliMUONTrackerDataMaker::AliMUONTrackerDataMaker(TRootIOCtor*)
 AliMUONVTrackerDataMaker(),
 fRawReader(0x0),
 fAccumulatedData(0x0),
+fIsOwnerOfAccumulatedData(kTRUE),
 fOneEventData(0x0),
 fDigitCalibrator(0x0),
 fCalibrationData(0x0), 
@@ -63,7 +66,13 @@ fRunNumber(0),
 fIsRunning(kFALSE),
 fIsOwnerOfRawReader(kFALSE),
 fIsEventByEvent(kFALSE),
-fLogger(0x0)
+fLogger(0x0),
+fLastEventWasEmpty(kFALSE),
+fNumberOfPhysicsEvents(0),
+fNumberOfGoodPhysicsEvents(0),
+fTryRecover(kFALSE),
+fFirstEvent(-1),
+fLastEvent(-1)
 {
 /// Root IO ctor
 }
@@ -81,6 +90,7 @@ AliMUONTrackerDataMaker::AliMUONTrackerDataMaker(const AliMUONRecoParam* recoPar
 AliMUONVTrackerDataMaker(),
 fRawReader(rawReader),
 fAccumulatedData(0x0),
+fIsOwnerOfAccumulatedData(kTRUE),
 fOneEventData(new AliMUON2DMap(true)),
 fDigitCalibrator(0x0),
 fCalibrationData(0x0), 
@@ -91,7 +101,13 @@ fRunNumber(runNumber),
 fIsRunning(kFALSE),
 fIsOwnerOfRawReader(kFALSE),
 fIsEventByEvent(kFALSE),
-fLogger(0x0)
+fLogger(0x0),
+fLastEventWasEmpty(kFALSE),
+fNumberOfPhysicsEvents(0),
+fNumberOfGoodPhysicsEvents(0),
+fTryRecover(kFALSE),
+fFirstEvent(-1),
+fLastEvent(-1)
 {
   /// Ctor in which this object will NOT be the owner of the reader
   /// and can NOT apply rewind to it, nor use Next on it. 
@@ -111,6 +127,7 @@ AliMUONTrackerDataMaker::AliMUONTrackerDataMaker(const AliMUONRecoParam* recoPar
 AliMUONVTrackerDataMaker(),
 fRawReader(rawReader),
 fAccumulatedData(0x0),
+fIsOwnerOfAccumulatedData(kTRUE),
 fOneEventData(new AliMUON2DMap(true)),
 fDigitCalibrator(0x0),
 fCalibrationData(0x0), 
@@ -121,14 +138,19 @@ fRunNumber(0),
 fIsRunning(kFALSE),
 fIsOwnerOfRawReader(kTRUE),
 fIsEventByEvent(kFALSE),
-fLogger(0x0)
+fLogger(0x0),
+fLastEventWasEmpty(kFALSE),
+fNumberOfPhysicsEvents(0),
+fNumberOfGoodPhysicsEvents(0),
+fTryRecover(kFALSE),
+fFirstEvent(-1),
+fLastEvent(-1)
 {
   /// Ctor in which we take the ownership of the rawReader, so we can rewind
   /// and advance it as we wish
   
-  if (fRawReader
+  if ( fRawReader && fRawReader->NextEvent() 
   {
-    fRawReader->NextEvent(); // to be sure to get run number available
     fRunNumber = fRawReader->GetRunNumber();
     fRawReader->RewindEvents();
   }
@@ -142,6 +164,7 @@ AliMUONTrackerDataMaker::AliMUONTrackerDataMaker(AliRawReader* rawReader, Bool_t
 AliMUONVTrackerDataMaker(),
 fRawReader(rawReader),
 fAccumulatedData(0x0),
+fIsOwnerOfAccumulatedData(kTRUE),
 fOneEventData(new AliMUON2DMap(true)),
 fDigitCalibrator(0x0),
 fCalibrationData(0x0), 
@@ -152,12 +175,17 @@ fRunNumber(0),
 fIsRunning(kFALSE),
 fIsOwnerOfRawReader(kTRUE),
 fIsEventByEvent(kFALSE),
-fLogger(0x0)
+fLogger(0x0),
+fLastEventWasEmpty(kFALSE),
+fNumberOfPhysicsEvents(0),
+fNumberOfGoodPhysicsEvents(0),
+fTryRecover(kFALSE),
+fFirstEvent(-1),
+fLastEvent(-1)
 {
   /// Ctor from raw data reader
-  if (fRawReader
+  if ( fRawReader && fRawReader->NextEvent() 
   {
-    fRawReader->NextEvent(); // to be sure to get run number available
     fRunNumber = fRawReader->GetRunNumber();
     fRawReader->RewindEvents();
   }
@@ -242,7 +270,7 @@ AliMUONTrackerDataMaker::Ctor(const AliMUONRecoParam* recoParam,
       AliCDBManager::Instance()->SetDefaultStorage(storage);
     }
     
-    fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,recoParam,calibMode);
+    fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,recoParam);
     //FIXME: get the reco param from GUI and/or from OCDB if not used from the QA code ?
   }
 }
@@ -253,7 +281,7 @@ AliMUONTrackerDataMaker::~AliMUONTrackerDataMaker()
 /// dtor
 
   delete fOneEventData;
-  delete fAccumulatedData;
+  if ( fIsOwnerOfAccumulatedData ) delete fAccumulatedData;
   if ( fIsOwnerOfRawReader ) delete fRawReader;
   delete fCalibrationData;
   delete fDigitCalibrator;
@@ -279,7 +307,9 @@ AliMUONTrackerDataMaker::Add(const AliMUONTrackerDataMaker& other)
   fSource += other.fSource;
   
   fNumberOfEvents += other.fNumberOfEvents;
-  
+  fNumberOfPhysicsEvents += other.fNumberOfPhysicsEvents;
+  fNumberOfGoodPhysicsEvents += other.fNumberOfGoodPhysicsEvents;
+
   TList list;
   list.Add(other.fAccumulatedData);
   
@@ -302,34 +332,41 @@ AliMUONTrackerDataMaker::NextEvent()
   
   AliCodeTimerAuto("",0);
   
-  static Int_t nphysics(0);
-  static Int_t ngood(0);
-  
   if ( !IsRunning() ) return kTRUE;
   
-  Bool_t ok = fRawReader->NextEvent();
+  Bool_t ok(kTRUE);
   
-  if (!ok) 
+  if ( fLastEvent >= fFirstEvent && fLastEvent > 0 ) // do we have an event range to consider ?
   {
-    return kFALSE;
+    // skip up to first event
+    
+    while ( (fNumberOfEvents-1) < fFirstEvent && ( ok = fRawReader->NextEvent() ) ) 
+    {
+      ++fNumberOfEvents; 
+    }
+    
+    if ( ok && (fNumberOfEvents-1) <= fLastEvent ) 
+    {
+      ok = fRawReader->NextEvent();
+    }
+    else
+    {
+      fNumberOfEvents=fLastEvent+1;
+      return kFALSE;
+    }
   }
-  
-  Int_t eventType = fRawReader->GetType();
-  
-  ++fNumberOfEvents;
-  
-  if (eventType != AliRawEventHeaderBase::kPhysicsEvent ) 
+  else
   {
-    return kTRUE; // for the moment
+    // no event range, just proceed...
+    ok = fRawReader->NextEvent();
   }
   
-  ++nphysics;
+  if (!ok) 
+  {
+    return kFALSE;
+  }
   
-       Bool_t pok = ProcessEvent();
-       
-       if ( pok ) ++ngood;
-       
-       AliDebug(1,Form("n %10d nphysics %10d ngood %10d",fNumberOfEvents,nphysics,ngood));
+       ProcessEvent();
        
        return kTRUE;  
 }
@@ -347,6 +384,19 @@ Bool_t AliMUONTrackerDataMaker::ProcessEvent()
   /// duplicate this critical piece of calibration code !
   ///
   
+  ++fNumberOfEvents;
+  
+  Int_t eventType = fRawReader->GetType();
+  
+  if (eventType != AliRawEventHeaderBase::kPhysicsEvent ) 
+  {
+    return kTRUE; // for the moment
+  }
+  
+  ++fNumberOfPhysicsEvents;
+  
+  fLastEventWasEmpty = kFALSE;
+  
   AliCodeTimerAuto("",0);
   
   AliMUONRawStreamTrackerHP stream(fRawReader);
@@ -354,6 +404,15 @@ Bool_t AliMUONTrackerDataMaker::ProcessEvent()
   stream.DisableWarnings();
   stream.DisableRawReaderErrorLogger();
   stream.DisableMUONErrorLogger();
+
+  if ( fTryRecover ) 
+  {
+    stream.TryRecover(kTRUE);
+  }
+  else
+  {
+    stream.TryRecover(kFALSE);
+  }
   
   if (fLogger)
   {
@@ -419,9 +478,13 @@ Bool_t AliMUONTrackerDataMaker::ProcessEvent()
 
        if (!badEvent)
   {
-    fAccumulatedData->Add(*fOneEventData,&nevents);    
+    fAccumulatedData->Add(*fOneEventData,&nevents);  
+    if ( fOneEventData->GetSize() == 0 ) fLastEventWasEmpty = kTRUE;
+    ++fNumberOfGoodPhysicsEvents;
   }
     
+  AliDebug(1,Form("n %10d nphysics %10d ngood %10d",fNumberOfEvents,fNumberOfPhysicsEvents,fNumberOfGoodPhysicsEvents));
+       
   return !badEvent;
 }
 
@@ -444,6 +507,8 @@ void AliMUONTrackerDataMaker::Rewind()
   {
     fRawReader->RewindEvents();
     fNumberOfEvents=0;  
+    fNumberOfPhysicsEvents=0;
+    fNumberOfGoodPhysicsEvents=0;
   }
   else
   {
@@ -466,7 +531,7 @@ Long64_t AliMUONTrackerDataMaker::Merge(TCollection* list)
   while ( ( o = next() ) )
   {
     const AliMUONTrackerDataMaker* data = dynamic_cast<const AliMUONTrackerDataMaker*>(o);
-    if (!o)
+    if (!data)
     {
       AliError(Form("Object named %s is not an AliMUONTrackerDataMaker ! Skipping it",
                     o->GetName()));