]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONReconstructor.cxx
The logics of handling the geometry file for simulation has changed. The variables...
[u/mrichter/AliRoot.git] / MUON / AliMUONReconstructor.cxx
index 42caec75ad8bbe24bc03e5e2a7a8851440829b5a..3d028937f00a0c9121ab0ea520c7177b2fb4521b 100644 (file)
@@ -89,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 "AliMpArea.h"
 #include "AliMpCDB.h"
 #include "AliCDBManager.h"
 #include "AliCodeTimer.h"
 #include "AliLog.h"
+#include "AliRunInfo.h"
 
 #include <Riostream.h>
 #include <TObjArray.h>
@@ -133,7 +136,8 @@ fDigitCalibrator(0x0),
 fClusterServer(0x0),
 fTriggerStore(0x0),
 fTrackStore(0x0),
-fClusterStore(0x0)
+fClusterStore(0x0),
+fTriggerProcessor(0x0)  
 {
   /// normal ctor
 
@@ -172,6 +176,7 @@ AliMUONReconstructor::~AliMUONReconstructor()
   delete fTriggerStore;
   delete fTrackStore;
   delete fClusterStore;
+  delete fTriggerProcessor;
 
   delete AliMpSegmentation::Instance(false);
   delete AliMpDDLStore::Instance(false);
@@ -186,8 +191,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);      
 }
 
 //_____________________________________________________________________________
@@ -198,6 +203,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()))
@@ -212,7 +225,7 @@ void
 AliMUONReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
 {
    /// convert raw data into a digit tree
-  AliCodeTimerAuto("")
+  AliCodeTimerAuto("",0)
 
   Bool_t alone = ( TriggerStore() == 0 );
   
@@ -243,7 +256,7 @@ AliMUONReconstructor::CreateDigitMaker() const
   /// Create (and create if necessary) the digit maker
   if (fDigitMaker) return;
 
-  AliCodeTimerAuto("")
+  AliCodeTimerAuto("",0)
 
   TString option = GetOption();
   
@@ -269,7 +282,7 @@ AliMUONReconstructor::CreateTriggerCircuit() const
   /// Return (and create if necessary) the trigger circuit object
   if (fTriggerCircuit) return;
 
-  AliCodeTimerAuto("")
+  AliCodeTimerAuto("",0)
 
   fTriggerCircuit = new AliMUONTriggerCircuit(fTransformer);
 
@@ -316,7 +329,7 @@ AliMUONReconstructor::CreateClusterFinder(const char* clusterFinderType)
 {
   /// Create a given cluster finder instance
   
-  AliCodeTimerAutoGeneral("")
+  AliCodeTimerAutoGeneral("",0)
 
   AliMUONVClusterFinder* clusterFinder(0x0);
   
@@ -388,7 +401,7 @@ AliMUONReconstructor::CreateClusterServer() const
   
   if ( fClusterServer ) return;
   
-  AliCodeTimerAuto("");
+  AliCodeTimerAuto("",0);
     
   AliMUONVClusterFinder* clusterFinder = CreateClusterFinder(GetRecoParam()->GetClusteringMode());
   
@@ -401,16 +414,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() )
   {
@@ -420,14 +431,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();
   
@@ -441,6 +505,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
@@ -480,7 +561,7 @@ AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
 {
   /// Write the trigger and cluster information into TreeR
   
-  AliCodeTimerAuto("")
+  AliCodeTimerAuto("",0)
 
   AliDebug(1,"");
   
@@ -494,6 +575,7 @@ AliMUONReconstructor::FillTreeR(AliMUONVTriggerStore* triggerStore,
   
   if ( triggerStore ) 
   {
+    ResponseRemovingChambers(triggerStore);
     ok = triggerStore->Connect(clustersTree,alone);
     if (!ok)
     {
@@ -589,7 +671,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,"");