]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONReconstructor.cxx
- Disentangle masks effect from trigger chamber efficiency estimation.
[u/mrichter/AliRoot.git] / MUON / AliMUONReconstructor.cxx
index 935c2f9e6fe0051a690672c9bae3623fbea38045..50688e16eaee57dd737c00e244dafe47fb345d28 100644 (file)
 ///
 /// Implementation of AliReconstructor for MUON subsystem.
 ///
-/// The clustering mode and the associated parameters can be changed by using
-/// AliMUONRecoParam *muonRecoParam = AliMUONRecoParam::GetLow(High)FluxParam();
-/// muonRecoParam->Set...(); // see methods in AliMUONRecoParam.h for details
-/// AliRecoParam::Instance()->RegisterRecoParam(muonRecoParam);
+/// The clustering mode and the associated parameters can be changed through the
+/// AliMUONRecoParam object set in the reconstruction macro or read from the CDB
+/// (see methods in AliMUONRecoParam.h file for details)
 ///
 /// Valid modes are :
 ///
 ///
 /// TRIGGERDISABLE : disable the treatment of MUON trigger
 ///
-/// NOFASTTRKDECODER : makes the digit maker class use the non-high performance decoder
-///                  AliMUONPayloadTracker instead of  AliMUONTrackerDDLDecoder.
-///
-/// NOFASTTRGDECODER : makes the digit maker class use the non-high performance decoder
-///                  AliMUONPayloadTrigger instead of AliMUONTriggerDDLDecoder.
-///
-/// NOFASTDECODERS : makes the digit maker class use the non-high performance decoders
-///                  AliMUONPayloadTracker and AliMUONPayloadTrigger.
+/// ENABLEERRORLOGGING : enable error logging (this activates also warnings in RawStreamTracker)
 ///
 /// \author Laurent Aphecetche, Subatech
 //-----------------------------------------------------------------------------
@@ -97,6 +89,7 @@
 #include "AliMUONDigitStoreV1.h"
 #include "AliMUONDigitStoreV2R.h"
 #include "AliMUONGeometryTransformer.h"
+#include "AliMUONPadStatusMaker.h"
 #include "AliMUONPreClusterFinder.h"
 #include "AliMUONPreClusterFinderV2.h"
 #include "AliMUONPreClusterFinderV3.h"
 #include "AliMUONVClusterFinder.h"
 #include "AliMUONVClusterServer.h"
 #include "AliMUONVTrackStore.h"
+#include "AliMUONTriggerElectronics.h"
+#include "AliMUONTriggerUtilities.h"
 
 #include "AliMpArea.h"
 #include "AliMpCDB.h"
 #include "AliMpConstants.h"
+#include "AliMpDDLStore.h"
+#include "AliMpSegmentation.h"
 
 #include "AliRawReader.h"
 #include "AliCDBManager.h"
 #include "AliCodeTimer.h"
 #include "AliLog.h"
+#include "AliRunInfo.h"
 
 #include <Riostream.h>
 #include <TObjArray.h>
@@ -139,10 +137,27 @@ fDigitCalibrator(0x0),
 fClusterServer(0x0),
 fTriggerStore(0x0),
 fTrackStore(0x0),
-fClusterStore(0x0)
+fClusterStore(0x0),
+fTriggerProcessor(0x0),
+fTriggerUtilities(0x0)
 {
   /// normal ctor
 
+  AliDebug(1,"");
+  
+  // Unload mapping objects
+  // if they have been loaded from the obsolete OCDB mapping objects
+
+  if ( AliMpDDLStore::Instance(false) ) {
+    AliCDBManager::Instance()->UnloadFromCache("MUON/Calib/DDLStore");
+    delete AliMpDDLStore::Instance();
+  }  
+
+  if ( AliMpSegmentation::Instance(false) ) { 
+    AliCDBManager::Instance()->UnloadFromCache("MUON/Calib/Mapping");
+    delete AliMpSegmentation::Instance();
+  }  
+
   // Load mapping
   if ( ! AliMpCDB::LoadDDLStore() ) {
     AliFatal("Could not access mapping from OCDB !");
@@ -157,16 +172,24 @@ fClusterStore(0x0)
 AliMUONReconstructor::~AliMUONReconstructor()
 {
   /// dtor
+
+  AliDebug(1,"");
+
   delete fDigitMaker;
   delete fDigitStore;
   delete fTransformer;
   delete fTriggerCircuit;
-  delete fCalibrationData;
   delete fDigitCalibrator;
+  delete fCalibrationData;
   delete fClusterServer;
   delete fTriggerStore;
   delete fTrackStore;
   delete fClusterStore;
+  delete fTriggerProcessor;
+  delete fTriggerUtilities;
+
+  delete AliMpSegmentation::Instance(false);
+  delete AliMpDDLStore::Instance(false);
 }
 
 //_____________________________________________________________________________
@@ -178,8 +201,8 @@ AliMUONReconstructor::Calibrate(AliMUONVDigitStore& digitStore) const
   {
     CreateCalibrator();
   }
-  AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()))
-  fDigitCalibrator->Calibrate(digitStore);  
+  AliCodeTimerAuto(Form("%s::Calibrate(AliMUONVDigitStore*)",fDigitCalibrator->ClassName()),0)
+  fDigitCalibrator->Calibrate(digitStore);      
 }
 
 //_____________________________________________________________________________
@@ -190,6 +213,14 @@ AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader,
 {
   /// Convert raw data into digit and trigger stores
   CreateDigitMaker();
+
+  // Skip reconstruction if event is Calibration
+  if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) {
+    digitStore->Clear(); // Remove possible digits from previous event
+    triggerStore->Clear(); // Remove possible triggers from previous event
+    AliInfo("Calibration event: do not convert digits");
+    return;
+  }
   
   AliCodeTimerStart(Form("%s::Raw2Digits(AliRawReader*,AliMUONVDigitStore*,AliMUONVTriggerStore*)",
                     fDigitMaker->ClassName()))
@@ -204,7 +235,7 @@ void
 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
 {
    /// convert raw data into a digit tree
-  AliCodeTimerAuto("")
+  AliCodeTimerAuto("",0)
 
   Bool_t alone = ( TriggerStore() == 0 );
   
@@ -235,33 +266,32 @@ AliMUONReconstructor::CreateDigitMaker() const
   /// Create (and create if necessary) the digit maker
   if (fDigitMaker) return;
 
-  AliCodeTimerAuto("")
+  AliCodeTimerAuto("",0)
 
   TString option = GetOption();
-  Bool_t enableErrorLogging = kTRUE;
-  Bool_t useFastTrackerDecoder = kTRUE;
-  Bool_t useFastTriggerDecoder = kTRUE;
-  if (option.Contains("NOFASTTRKDECODER"))
+  
+  Bool_t enableErrorLogging = kFALSE;
+
+  if (option.Contains("ENABLEERRORLOGGING"))
   {
-    useFastTrackerDecoder = kFALSE;
+    enableErrorLogging = kTRUE;
   }
-  if (option.Contains("NOFASTTRGDECODER"))
+
+  fDigitMaker = new AliMUONDigitMaker(enableErrorLogging);
+  option.ToUpper();
+
+  // Always make trigger digits
+  // (needed when calculating trigger chamber efficiency)
+  fDigitMaker->SetMakeTriggerDigits(kTRUE);
+
+  if ( GetRecoParam()->TryRecover() )
   {
-    useFastTriggerDecoder = kFALSE;
+    fDigitMaker->SetTryRecover(kTRUE);
   }
-  if (option.Contains("NOFASTDECODERS"))
+  else
   {
-    useFastTrackerDecoder = kFALSE;
-    useFastTriggerDecoder = kFALSE;
+    fDigitMaker->SetTryRecover(kFALSE);    
   }
-  fDigitMaker = new AliMUONDigitMaker(
-      enableErrorLogging, useFastTrackerDecoder, useFastTriggerDecoder
-    );
-  option.ToUpper();
-  if ( option.Contains("SAVEDIGITS" ))
-    {
-      fDigitMaker->SetMakeTriggerDigits(kTRUE);
-    }
 }
 
 //_____________________________________________________________________________
@@ -271,12 +301,26 @@ AliMUONReconstructor::CreateTriggerCircuit() const
   /// Return (and create if necessary) the trigger circuit object
   if (fTriggerCircuit) return;
 
-  AliCodeTimerAuto("")
+  AliCodeTimerAuto("",0)
 
   fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
 
 }
 
+//_____________________________________________________________________________
+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
@@ -284,7 +328,7 @@ AliMUONReconstructor::CreateTracker() const
   /// Create the MUONTracker object
   
   CreateTriggerCircuit();
-  CreateDigitMaker();
+  CreateTriggerUtilities();
   CreateClusterServer();
 
   AliMUONTracker* tracker(0x0);
@@ -294,18 +338,18 @@ AliMUONReconstructor::CreateTracker() const
     tracker = new AliMUONTracker(GetRecoParam(),
                                 0x0,
                                  *DigitStore(),
-                                 fDigitMaker,
                                  fTransformer,
-                                 fTriggerCircuit);
+                                 fTriggerCircuit,
+                                 fTriggerUtilities);
   }
   else
   {
     tracker = new AliMUONTracker(GetRecoParam(),
                                 fClusterServer,
                                  *DigitStore(),
-                                 fDigitMaker,
                                  fTransformer,
-                                 fTriggerCircuit);
+                                 fTriggerCircuit,
+                                 fTriggerUtilities);
   }
   
   
@@ -318,7 +362,7 @@ AliMUONReconstructor::CreateClusterFinder(const char* clusterFinderType)
 {
   /// Create a given cluster finder instance
   
-  AliCodeTimerAutoGeneral("")
+  AliCodeTimerAutoGeneral("",0)
 
   AliMUONVClusterFinder* clusterFinder(0x0);
   
@@ -390,7 +434,7 @@ AliMUONReconstructor::CreateClusterServer() const
   
   if ( fClusterServer ) return;
   
-  AliCodeTimerAuto("");
+  AliCodeTimerAuto("",0);
     
   AliMUONVClusterFinder* clusterFinder = CreateClusterFinder(GetRecoParam()->GetClusteringMode());
   
@@ -403,16 +447,14 @@ AliMUONReconstructor::CreateClusterServer() const
 
 //_____________________________________________________________________________
 void
-AliMUONReconstructor::CreateCalibrator() const
+AliMUONReconstructor::CreateCalibrationData() const
 {
   /// Create the calibrator
   
-  AliCodeTimerAuto("")
+  AliCodeTimerAuto("",0);
   
   Int_t runNumber = AliCDBManager::Instance()->GetRun();
 
-  AliInfo("Calibration will occur.");
-  
   fCalibrationData = new AliMUONCalibrationData(runNumber);
   if ( !fCalibrationData->IsValid() )
   {
@@ -422,14 +464,67 @@ AliMUONReconstructor::CreateCalibrator() const
     return;
   }    
   
-  // Check that we get all the calibrations we'll need
-  if ( !fCalibrationData->Pedestals() ||
-       !fCalibrationData->Gains() ||
-       !fCalibrationData->HV() )
+  // It is now time to check whether we have everything to proceed.
+  // What we need depends on whether both tracker and trigger
+  // are in the readout chain, and what specific "bad channel policy"
+  // we use
+  
+  Bool_t kTracker(kFALSE);
+  Bool_t kTrigger(kFALSE);
+  
+  const AliRunInfo* runInfo = GetRunInfo();
+  if (!runInfo)
+  {
+    AliError("Could not get runinfo ?");
+  }
+  else
   {
-    AliFatal("Could not access all required calibration data");
+    TString detectors(runInfo->GetActiveDetectors());
+    if (detectors.Contains("MUONTRK")) kTracker=kTRUE;
+    if (detectors.Contains("MUONTRG")) kTrigger=kTRUE;
   }
+   
+  AliInfo(Form("Run with MUON TRIGGER : %s and MUON TRACKER : %s",
+               kTrigger ? "YES":"NO" , 
+               kTracker ? "YES":"NO"));
   
+  if ( kTracker ) 
+  {
+    // Check that we get all the calibrations we'll need
+    if ( !fCalibrationData->Pedestals() ||
+        !fCalibrationData->Gains() )
+    {
+      AliFatal(Form("Could not access all required calibration data (PED %p GAIN %p)",
+                    fCalibrationData->Pedestals(),fCalibrationData->Gains()));      
+    }
+    
+    if ( !fCalibrationData->HV() ) 
+    {
+      // Special treatment of HV. We only break if the values
+      // are not there *AND* we cut on them.
+      UInt_t mask = GetRecoParam()->PadGoodnessMask();
+      TString smask(AliMUONPadStatusMaker::AsCondition(mask));
+      if ( smask.Contains("HV") )
+      {
+        AliFatal("Could not access all required calibration data (HV)");      
+      }
+    } 
+  }
+}
+
+//_____________________________________________________________________________
+void
+AliMUONReconstructor::CreateCalibrator() const
+{
+  /// Create the calibrator
+
+  AliCodeTimerAuto("",0);
+
+  if ( ! fCalibrationData )
+    CreateCalibrationData();
+
+  AliInfo("Calibration will occur.");
+
   TString opt(GetOption());
   opt.ToUpper();
   
@@ -443,6 +538,23 @@ AliMUONReconstructor::CreateCalibrator() const
   fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,GetRecoParam(),calibMode.Data());
 }
 
+//_____________________________________________________________________________
+void
+AliMUONReconstructor::ResponseRemovingChambers(AliMUONVTriggerStore* triggerStore) const
+{
+  /// Update trigger information with informatins obtained after
+  /// re-calculation of trigger response
+  AliCodeTimerAuto("",0);
+
+  if ( ! fCalibrationData )
+    CreateCalibrationData();
+
+  if ( ! fTriggerProcessor )
+    fTriggerProcessor = new AliMUONTriggerElectronics(fCalibrationData);
+
+  fTriggerProcessor->ResponseRemovingChambers(*triggerStore);
+}
+
 //_____________________________________________________________________________
 AliMUONVDigitStore*
 AliMUONReconstructor::DigitStore() const
@@ -481,11 +593,9 @@ AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
                                 TTree& clustersTree) const
 {
   /// Write the trigger and cluster information into TreeR
-  
-  AliCodeTimerAuto("")
 
-  AliDebug(1,"");
-  
+  AliCodeTimerAuto("",0)
+
   Bool_t ok(kFALSE);
   Bool_t alone(kTRUE); // is trigger the only info in TreeR ?
   
@@ -496,6 +606,7 @@ AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
   
   if ( triggerStore ) 
   {
+    ResponseRemovingChambers(triggerStore);
     ok = triggerStore->Connect(clustersTree,alone);
     if (!ok)
     {
@@ -513,7 +624,7 @@ AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
     CreateClusterServer();
     
     TIter next(DigitStore()->CreateIterator());
-    fClusterServer->UseDigits(next);
+    fClusterServer->UseDigits(next,DigitStore());
 
     AliMpArea area;
     
@@ -526,7 +637,7 @@ AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
         if ( ( i == 6 || i == 7 )  && GetRecoParam()->BypassSt4() ) continue;
         if ( ( i == 8 || i == 9 )  && GetRecoParam()->BypassSt5() ) continue;
         
-        fClusterServer->Clusterize(i,*fClusterStore,area);
+        fClusterServer->Clusterize(i,*fClusterStore,area,GetRecoParam());
       }
     }
     
@@ -591,7 +702,7 @@ AliMUONReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
   /// This method is called by AliReconstruction if HasLocalReconstruction()==kTRUE
   /// AND HasDigitConversion()==kTRUE
   
-  AliCodeTimerAuto("")
+  AliCodeTimerAuto("",0)
   
   AliDebug(1,"");