]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONReconstructor.cxx
- Some algorithm fixes for complex clusters
[u/mrichter/AliRoot.git] / MUON / AliMUONReconstructor.cxx
index a5030e734b84bf32e948d70c028702968ec16b8e..1b32c1833bcb81cdbf4338c4bd3fd76f42caf38a 100644 (file)
@@ -14,6 +14,7 @@
  **************************************************************************/
 /* $Id$ */
 
+//-----------------------------------------------------------------------------
 /// \class AliMUONReconstructor
 ///
 /// Implementation of AliReconstructor for MUON subsystem.
@@ -30,9 +31,7 @@
 ///
 /// SIMPLEFIT : use the AliMUONClusterFinderSimpleFit clusterizer
 ///
-/// AZ : use the AliMUONClusterFinderAZ clusterizer (default)
-///
-/// MLEM : another implementation of AZ, where preclustering is external
+/// MLEM : another implementation of AZ, where preclustering is external (default)
 /// MLEMV3 : MLEM with preclustering=PRECLUSTERV2
 /// MLEMV3 : MLEM with preclustering=PRECLUSTERV3
 ///
@@ -48,9 +47,6 @@
 ///
 /// NOCLUSTERING : bypass completely the clustering stage
 ///
-/// NOSTATUSMAP : disable the computation and usage of the pad status map. Only
-/// for debug !
-///
 /// NOLOCALRECONSTRUCTION : for debug, to disable local reconstruction (and hence
 /// "recover" old behavior)
 ///
 /// DIGITSTOREV2R : use the V2R implementation of the digitstore 
 ///
 /// \author Laurent Aphecetche, Subatech
+//-----------------------------------------------------------------------------
 
 #include "AliMUONReconstructor.h"
 
 #include "AliCDBManager.h"
-#include "AliLoader.h"
 #include "AliLog.h"
-#include "AliRunLoader.h"
 #include "AliMUONCalibrationData.h"
 #include "AliMUONClusterFinderCOG.h"
 #include "AliMUONClusterFinderMLEM.h"
 #include "AliMUONClusterFinderSimpleFit.h"
-#include "AliMUONClusterFinderAZ.h"
 #include "AliMUONClusterReconstructor.h"
-#include "AliMUONClusterStoreV1.h"
+#include "AliMUONClusterStoreV2.h"
 #include "AliMUONConstants.h"
 #include "AliMUONDigitCalibrator.h"
 #include "AliMUONDigitMaker.h"
 #include "AliMUONTriggerCrateStore.h"
 #include "AliMUONTriggerStoreV1.h"
 #include "AliMUONVClusterFinder.h"
+#include "AliMUONRecoParam.h"
+#include "AliMpCDB.h"
 #include "AliRawReader.h"
 #include "AliCodeTimer.h"
 #include <Riostream.h>
 #include <TClonesArray.h>
 #include <TString.h>
 #include <TTree.h>
-//#include "AliCodeTimer.h"
+
 /// \cond CLASSIMP
 ClassImp(AliMUONReconstructor)
 /// \endcond 
 
+AliMUONRecoParam* AliMUONReconstructor::fgRecoParam = 0x0; // reconstruction parameters
+
 //_____________________________________________________________________________
 AliMUONReconstructor::AliMUONReconstructor() : 
 AliReconstructor(),
@@ -118,7 +116,21 @@ fTrackStore(0x0),
 fTrigChamberEff(0x0)
 {
   /// normal ctor
+
+  // Load mapping
+  if ( ! AliMpCDB::LoadDDLStore() ) {
+    AliFatal("Could not access mapping from OCDB !");
+  }
+  
+  // Load geometry data
   fTransformer->LoadGeometryData();
+  
+  // initialize reconstruction parameters in not already done
+  if (!fgRecoParam) {
+    AliWarning("Reconstruction parameters not initialized - Use default one");
+    fgRecoParam = AliMUONRecoParam::GetLowFluxParam();
+  }
+  
 }
 
 //_____________________________________________________________________________
@@ -139,6 +151,20 @@ AliMUONReconstructor::~AliMUONReconstructor()
   delete fTrigChamberEff;
 }
 
+//_____________________________________________________________________________
+void AliMUONReconstructor::SetRecoParam(AliMUONRecoParam *param)
+{
+  /// set reconstruction parameters
+  
+  // remove existing parameters
+  if (fgRecoParam) {
+    cout<<"AliMUONReconstructor::SetRecoParam: Reconstruction parameters already initialized - overwrite them"<<endl;
+    delete fgRecoParam;
+  }
+  
+  fgRecoParam = param;
+}
+
 //_____________________________________________________________________________
 void
 AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
@@ -159,14 +185,14 @@ AliMUONReconstructor::Clusterize(const AliMUONVDigitStore& digitStore,
 {
   /// Creates clusters from digits.
 
-  TString sopt(GetOption());
+  TString sopt(fgRecoParam->GetClusteringMode());
   sopt.ToUpper();
   if ( sopt.Contains("NOCLUSTERING") ) return;
   
-  if  (!fClusterReconstructor)
-  {
-    CreateClusterReconstructor();
-  }
+  if  (!fClusterReconstructor) CreateClusterReconstructor();
+  
+  // if the required clustering mode does not exist
+  if  (!fClusterReconstructor) return;
   
   AliCodeTimerAuto(Form("%s::Digits2Clusters(const AliMUONVDigitStore&,AliMUONVClusterStore&)",
                         fClusterReconstructor->ClassName()))
@@ -180,7 +206,7 @@ AliMUONReconstructor::ClusterStore() const
   /// Return (and create if necessary) the cluster container
   if (!fClusterStore) 
   {
-    fClusterStore = new AliMUONClusterStoreV1;
+    fClusterStore = new AliMUONClusterStoreV2;
   }
   return fClusterStore;
 }
@@ -207,6 +233,7 @@ void
 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
 {
    /// convert raw data into a digit tree
+  AliCodeTimerAuto("")
 
   Bool_t alone = ( TriggerStore() == 0 );
   
@@ -223,7 +250,9 @@ AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree)
   else
   {
     ConvertDigits(rawReader,DigitStore(),TriggerStore());
+    AliCodeTimerStart("Fill digits")
     digitsTree->Fill();
+    AliCodeTimerStop("Fill digits")
     DigitStore()->Clear();
   }
 }
@@ -279,23 +308,15 @@ AliMUONReconstructor::CreateTriggerChamberEff() const
 
 //_____________________________________________________________________________
 AliTracker* 
-AliMUONReconstructor::CreateTracker(AliRunLoader* runLoader) const
+AliMUONReconstructor::CreateTracker() const
 {
   /// Create the MUONTracker object
-  /// The MUONTracker is passed the GetOption(), i.e. our own options
   
   CreateTriggerCircuit();
   CreateDigitMaker();
   CreateTriggerChamberEff();
   
-  AliLoader* loader = runLoader->GetDetectorLoader("MUON");
-  if (!loader)
-  {
-    AliError("Cannot get MUONLoader, so cannot create MUONTracker");
-    return 0x0;
-  }
-  AliMUONTracker* tracker = new AliMUONTracker(loader,fDigitMaker,fTransformer,fTriggerCircuit,fTrigChamberEff);
-  tracker->SetOption(GetOption());
+  AliMUONTracker* tracker = new AliMUONTracker(fDigitMaker,fTransformer,fTriggerCircuit,fTrigChamberEff);
   
   return tracker;
 }
@@ -304,7 +325,7 @@ AliMUONReconstructor::CreateTracker(AliRunLoader* runLoader) const
 void
 AliMUONReconstructor::CreateClusterReconstructor() const
 {
-  /// Create cluster reconstructor, depending on GetOption()
+  /// Create cluster reconstructor, depending on clustering mode set in RecoParam
   
   AliCodeTimerAuto("")
 
@@ -312,7 +333,7 @@ AliMUONReconstructor::CreateClusterReconstructor() const
   
   AliMUONVClusterFinder* clusterFinder(0x0);
   
-  TString opt(GetOption());
+  TString opt(fgRecoParam->GetClusteringMode());
   opt.ToUpper();
   
   if ( strstr(opt,"PRECLUSTERV2") )
@@ -355,20 +376,13 @@ AliMUONReconstructor::CreateClusterReconstructor() const
   {
     clusterFinder = new AliMUONClusterFinderMLEM(kFALSE,new AliMUONPreClusterFinder);
   } 
-  else if ( strstr(opt,"AZ") )
-  {
-    clusterFinder = new AliMUONClusterFinderAZ;
-  }
   else
   {
-    // default is currently AZ
-    clusterFinder = new AliMUONClusterFinderAZ;
+    AliError(Form("clustering mode \"%s\" does not exist",opt.Data()));
+    return;
   }
   
-  if ( clusterFinder ) 
-  {
-    AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
-  }
+  AliInfo(Form("Will use %s for clusterizing",clusterFinder->ClassName()));
   
   fClusterReconstructor = new AliMUONClusterReconstructor(clusterFinder,fTransformer);
 }
@@ -408,10 +422,10 @@ AliMUONReconstructor::CreateCalibrator() const
   
   if ( strstr(opt,"NOSTATUSMAP") )
   {
-    AliWarning("Disconnecting status map : SHOULD BE USED FOR DEBUG ONLY. NOT FOR PRODUCTION !!!");
-    statusMap = kFALSE; 
+    AliWarning("NOSTATUSMAP is obsolete");
   }
-  fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,statusMap);
+
+  fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData);
 }
 
 //_____________________________________________________________________________
@@ -504,23 +518,6 @@ AliMUONReconstructor::HasDigitConversion() const
   }
 }
 
-//_____________________________________________________________________________
-Bool_t 
-AliMUONReconstructor::HasLocalReconstruction() const
-{
-  /// Whether or not we have local reconstruction
-  TString opt(GetOption());
-  opt.ToUpper();
-  if ( opt.Contains("NOLOCALRECONSTRUCTION" ) )
-  {
-    return kFALSE;
-  }
-  else
-  {
-    return kTRUE;
-  }
-}
-
 //_____________________________________________________________________________
 void 
 AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
@@ -540,84 +537,6 @@ AliMUONReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree)
   FillTreeR(TriggerStore(),ClusterStore(),*clustersTree);
 }
 
-//_____________________________________________________________________________
-void 
-AliMUONReconstructor::Reconstruct(AliRunLoader* runLoader) const
-{
-  /// Reconstruct simulated data
-  
-  AliCodeTimerAuto("Reconstruct(AliRunLoader*)")
-  
-  AliLoader* loader = runLoader->GetDetectorLoader("MUON");
-  if (!loader) 
-  {
-    AliError("Could not get MUON loader");
-    return;
-  }
-  
-  Int_t nEvents = runLoader->GetNumberOfEvents();
-  
-  for ( Int_t i = 0; i < nEvents; ++i ) 
-  {
-    runLoader->GetEvent(i);
-    
-    loader->LoadRecPoints("update");
-    loader->CleanRecPoints();
-    loader->MakeRecPointsContainer();
-    TTree* clustersTree = loader->TreeR();
-    
-    loader->LoadDigits("read");
-    TTree* digitsTree = loader->TreeD();
-
-    Reconstruct(digitsTree,clustersTree);
-    
-    loader->UnloadDigits();
-    loader->WriteRecPoints("OVERWRITE");
-    loader->UnloadRecPoints();    
-  }
-}
-
-//_____________________________________________________________________________
-void 
-AliMUONReconstructor::Reconstruct(AliRunLoader* runLoader, AliRawReader* rawReader) const
-{
-  /// This method is called by AliReconstruction if HasLocalReconstruction()==kFALSE
-  
-  AliCodeTimerAuto("AliMUONReconstructor::Reconstruct(AliRunLoader*, AliRawReader*)")
-  
-  AliLoader* loader = runLoader->GetDetectorLoader("MUON");
-  if (!loader) 
-  {
-    AliError("Could not get MUON loader");
-    return;
-  }
-
-  Int_t i(0);
-  
-  while (rawReader->NextEvent()) 
-  {
-    runLoader->GetEvent(i++);
-    
-    loader->LoadRecPoints("update");
-    loader->CleanRecPoints();
-    loader->MakeRecPointsContainer();
-    TTree* clustersTree = loader->TreeR();
-    
-    loader->LoadDigits("update");
-    loader->CleanDigits();
-    loader->MakeDigitsContainer();
-    TTree* digitsTree = loader->TreeD();
-    ConvertDigits(rawReader, digitsTree);
-    loader->WriteDigits("OVERWRITE");
-    
-    Reconstruct(digitsTree,clustersTree);
-    
-    loader->UnloadDigits();
-    loader->WriteRecPoints("OVERWRITE");
-    loader->UnloadRecPoints();    
-  }
-}
-
 //_____________________________________________________________________________
 void 
 AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
@@ -625,7 +544,7 @@ AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
   /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
   /// AND HasDigitConversion()==kTRUE
   
-//  AliCodeTimerAuto("(TTree*,TTree*)")
+  AliCodeTimerAuto("")
   
   AliDebug(1,"");