]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONReconstructor.cxx
#101318: Patch for various problems in AliROOT
[u/mrichter/AliRoot.git] / MUON / AliMUONReconstructor.cxx
index 1c45f8eac8fd9dcdfe00ef911835eb250f41aba1..beaf1f5fa9f68ba23af4489748e9e93a276dbc69 100644 (file)
 #include "AliMUONVClusterServer.h"
 #include "AliMUONVTrackStore.h"
 #include "AliMUONTriggerElectronics.h"
+#include "AliMUONTriggerUtilities.h"
 
 #include "AliMpArea.h"
 #include "AliMpCDB.h"
@@ -133,11 +134,14 @@ fDigitStore(0x0),
 fTriggerCircuit(0x0),
 fCalibrationData(0x0),
 fDigitCalibrator(0x0),
-fClusterServer(0x0),
 fTriggerStore(0x0),
 fTrackStore(0x0),
 fClusterStore(0x0),
-fTriggerProcessor(0x0)  
+fTriggerProcessor(0x0),
+fTriggerUtilities(0x0),
+fClusterServers(),
+fTrackers(),
+fShouldCalibrate(kTRUE)
 {
   /// normal ctor
 
@@ -163,7 +167,9 @@ fTriggerProcessor(0x0)
   
   // Load geometry data
   fTransformer->LoadGeometryData();
-  
+  fClusterServers.SetOwner(kTRUE);
+  fTrackers.SetOwner(kTRUE);
 }
 
 //_____________________________________________________________________________
@@ -173,20 +179,22 @@ AliMUONReconstructor::~AliMUONReconstructor()
 
   AliDebug(1,"");
 
+  delete fDigitCalibrator;
+
   delete fDigitMaker;
   delete fDigitStore;
   delete fTransformer;
   delete fTriggerCircuit;
-  delete fDigitCalibrator;
-  delete fCalibrationData;
-  delete fClusterServer;
   delete fTriggerStore;
   delete fTrackStore;
   delete fClusterStore;
   delete fTriggerProcessor;
+  delete fTriggerUtilities;
 
   delete AliMpSegmentation::Instance(false);
-  delete AliMpDDLStore::Instance(false);
+  delete AliMpDDLStore::Instance(false);  
+
+  delete fCalibrationData;  
 }
 
 //_____________________________________________________________________________
@@ -198,8 +206,12 @@ AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
   {
     CreateCalibrator();
   }
-  AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()),0)
-  fDigitCalibrator->Calibrate(digitStore);      
+    
+  if ( fShouldCalibrate )
+  {
+    AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()),0)
+    fDigitCalibrator->Calibrate(digitStore);
+  }
 }
 
 //_____________________________________________________________________________
@@ -304,6 +316,20 @@ AliMUONReconstructor::CreateTriggerCircuit() const
 
 }
 
+//_____________________________________________________________________________
+void 
+AliMUONReconstructor::CreateTriggerUtilities() const
+{
+  /// Return (and create if necessary) the trigger utilities object
+  if ( fTriggerUtilities ) return;
+  
+  AliCodeTimerAuto("",0)
+  
+  if ( ! fCalibrationData ) CreateCalibrationData();
+  
+  fTriggerUtilities = new AliMUONTriggerUtilities(fCalibrationData);
+}
+
 //_____________________________________________________________________________
 AliTracker* 
 AliMUONReconstructor::CreateTracker() const
@@ -311,25 +337,45 @@ AliMUONReconstructor::CreateTracker() const
   /// Create the MUONTracker object
   
   CreateTriggerCircuit();
-  CreateClusterServer();
-
-  AliMUONTracker* tracker(0x0);
+  CreateTriggerUtilities();
   
-  if ( ! GetRecoParam()->CombineClusterTrackReco() )
-  {
-    tracker = new AliMUONTracker(GetRecoParam(),
-                                0x0,
-                                 *DigitStore(),
-                                 fTransformer,
-                                 fTriggerCircuit);
-  }
-  else
+  const AliMUONRecoParam* rp = GetRecoParam();
+  
+  Int_t es = rp->GetEventSpecie();
+  
+  AliTracker* tracker = static_cast<AliTracker*>(fTrackers.At(es));
+  
+  if (!tracker ) 
   {
-    tracker = new AliMUONTracker(GetRecoParam(),
-                                fClusterServer,
-                                 *DigitStore(),
-                                 fTransformer,
-                                 fTriggerCircuit);
+    if ( ! rp->CombineClusterTrackReco() )
+    {
+      tracker = new AliMUONTracker(rp,
+                                   0x0,
+                                   *DigitStore(),
+                                   fTransformer,
+                                   fTriggerCircuit,
+                                   fTriggerUtilities);
+
+      AliInfo(Form("Created tracker %p for recoparam of type %s es=%d",
+                   tracker,
+                   AliRecoParam::GetEventSpecieName(AliRecoParam::Convert(rp->GetEventSpecie())),es));
+    }
+    else
+    {
+      
+      tracker = new AliMUONTracker(rp,
+                                   CreateClusterServer(*rp),
+                                   *DigitStore(),
+                                   fTransformer,
+                                   fTriggerCircuit,
+                                   fTriggerUtilities);
+
+      AliInfo(Form("Created (combined) tracker %p for recoparam of type %s es=%d",
+                   tracker,
+                   AliRecoParam::GetEventSpecieName(AliRecoParam::Convert(rp->GetEventSpecie())),es));      
+    }
+    
+    fTrackers.AddAtAndExpand(tracker,es);
   }
   
   
@@ -407,22 +453,30 @@ AliMUONReconstructor::CreateClusterFinder(const char* clusterFinderType)
 }
 
 //_____________________________________________________________________________
-void
-AliMUONReconstructor::CreateClusterServer() const
+AliMUONVClusterServer*
+AliMUONReconstructor::CreateClusterServer(const AliMUONRecoParam& rp) const
 {
   /// Create cluster server
   
-  if ( fClusterServer ) return;
-  
   AliCodeTimerAuto("",0);
-    
-  AliMUONVClusterFinder* clusterFinder = CreateClusterFinder(GetRecoParam()->GetClusteringMode());
   
-  if ( !clusterFinder ) return;
+  AliMUONVClusterServer* clusterServer = static_cast<AliMUONVClusterServer*>(fClusterServers.At(rp.GetEventSpecie()));
   
-  AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
+  if (!clusterServer )
+  {
+    AliMUONVClusterFinder* clusterFinder = CreateClusterFinder(rp.GetClusteringMode());
+    
+    if ( !clusterFinder ) return 0x0;
+    
+    clusterServer = new AliMUONSimpleClusterServer(clusterFinder,*fTransformer);
+
+    AliInfo(Form("Created AliMUONSimpleClusterServer (%p) for specie %d with clustering = %s (following requesting clustering mode %s)",
+                 clusterServer,rp.GetEventSpecie(),clusterFinder->ClassName(),rp.GetClusteringMode()));
+    
+    fClusterServers.AddAtAndExpand(clusterServer,rp.GetEventSpecie());
+  }
   
-  fClusterServer = new AliMUONSimpleClusterServer(clusterFinder,*fTransformer);
+  return clusterServer;
 }
 
 //_____________________________________________________________________________
@@ -455,7 +509,7 @@ AliMUONReconstructor::CreateCalibrationData() const
   const AliRunInfo* runInfo = GetRunInfo();
   if (!runInfo)
   {
-    AliError("Could not get runinfo ?")
+    AliError("Could not get runinfo ?");
   }
   else
   {
@@ -513,9 +567,28 @@ AliMUONReconstructor::CreateCalibrator() const
     AliWarning("NOSTATUSMAP is obsolete");
   }
 
-  TString calibMode = GetRecoParam()->GetCalibrationMode();
-
-  fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,GetRecoParam(),calibMode.Data());
+  Bool_t kTracker(kFALSE);
+    
+  const AliRunInfo* runInfo = GetRunInfo();
+  if (!runInfo)
+  {
+    AliError("Could not get runinfo ?");
+  }
+  else
+  {
+    TString detectors(runInfo->GetActiveDetectors());
+    if (detectors.Contains("MUONTRK")) kTracker=kTRUE;
+  }
+    
+  if ( kTracker )
+  {
+    fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,GetRecoParam());
+  }
+  else
+  {
+    AliWarning("Apparently running without MCH so will not instantiante the DigitCalibrator nor read MCH OCDB objects...");
+    fShouldCalibrate=kFALSE;
+  }
 }
 
 //_____________________________________________________________________________
@@ -579,7 +652,9 @@ AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
   Bool_t ok(kFALSE);
   Bool_t alone(kTRUE); // is trigger the only info in TreeR ?
   
-  if ( ! GetRecoParam()->CombineClusterTrackReco() )
+   const AliMUONRecoParam* rp = GetRecoParam();
+  
+  if ( ! rp->CombineClusterTrackReco() )
   {
     alone = kFALSE; // we'll get both tracker and trigger information in TreeR
   }
@@ -601,23 +676,23 @@ AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
       fClusterStore = new AliMUONClusterStoreV2;
     }
     
-    CreateClusterServer();
+    AliMUONVClusterServer* clusterServer = CreateClusterServer(*rp);
     
     TIter next(DigitStore()->CreateIterator());
-    fClusterServer->UseDigits(next,DigitStore());
+    clusterServer->UseDigits(next,DigitStore());
 
     AliMpArea area;
     
-    AliDebug(1,Form("Doing full clusterization in local reconstruction using %s ",fClusterServer->ClassName()));
+    AliDebug(1,Form("Doing full clusterization in local reconstruction using %s ",clusterServer->ClassName()));
     
     for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i ) 
     {
-      if (GetRecoParam()->UseChamber(i))
+      if (rp->UseChamber(i))
       {
-        if ( ( i == 6 || i == 7 )  && GetRecoParam()->BypassSt4() ) continue;
-        if ( ( i == 8 || i == 9 )  && GetRecoParam()->BypassSt5() ) continue;
+        if ( ( i == 6 || i == 7 )  && rp->BypassSt4() ) continue;
+        if ( ( i == 8 || i == 9 )  && rp->BypassSt5() ) continue;
         
-        fClusterServer->Clusterize(i,*fClusterStore,area,GetRecoParam());
+        clusterServer->Clusterize(i,*fClusterStore,area,rp);
       }
     }
     
@@ -638,6 +713,14 @@ AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
   if (fClusterStore) fClusterStore->Clear();
 }
 
+//_____________________________________________________________________________
+const AliMUONRecoParam* AliMUONReconstructor::GetRecoParam()
+{ 
+  /// Get the recoparam from reconstruction
+  return dynamic_cast<const AliMUONRecoParam*>(AliReconstructor::GetRecoParam(AliReconstruction::GetDetIndex("MUON"))); 
+}
+
+
 //_____________________________________________________________________________
 Bool_t 
 AliMUONReconstructor::HasDigitConversion() const