]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Adding a switch to turn on/off the gain calibration
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 25 Jan 2008 13:52:17 +0000 (13:52 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 25 Jan 2008 13:52:17 +0000 (13:52 +0000)
(Laurent)

MUON/AliMUONDigitCalibrator.cxx
MUON/AliMUONDigitCalibrator.h
MUON/AliMUONRecoParam.cxx
MUON/AliMUONRecoParam.h
MUON/AliMUONReconstructor.cxx

index ac6aad1dbae54f437dff35c0adf0af37044d9033..c7fd8888df791aabc2b92e2d273ff70827a2ad92 100644 (file)
@@ -17,8 +17,6 @@
 
 #include "AliMUONDigitCalibrator.h"
 
-#include "AliLog.h"
-#include "AliMpConstants.h"
 #include "AliMUONCalibrationData.h"
 #include "AliMUONVDigit.h"
 #include "AliMUONVDigitStore.h"
 #include "AliMUONPadStatusMapMaker.h"
 #include "AliMUONVStore.h"
 #include "AliMUONVCalibParam.h"
+#include "AliMpConstants.h"
+#include "AliMpDetElement.h"
+#include "AliMpDDLStore.h"
+#include "AliLog.h"
 
 //-----------------------------------------------------------------------------
 /// \class AliMUONDigitCalibrator
 ClassImp(AliMUONDigitCalibrator)
 /// \endcond
 
+const Int_t AliMUONDigitCalibrator::fgkNoGain(0);
+const Int_t AliMUONDigitCalibrator::fgkGainConstantCapa(1);
+const Int_t AliMUONDigitCalibrator::fgkGain(2);
+
 //_____________________________________________________________________________
-AliMUONDigitCalibrator::AliMUONDigitCalibrator(const AliMUONCalibrationData& calib)
+AliMUONDigitCalibrator::AliMUONDigitCalibrator(const AliMUONCalibrationData& calib,
+                                               const char* calibMode)
 : TObject(),
 fLogger(new AliMUONLogger(1000)),
 fStatusMaker(0x0),
 fStatusMapMaker(0x0),
 fPedestals(0x0),
-fGains(0x0)
+fGains(0x0),
+fApplyGains(0),
+fCapacitances(0x0)
 {
   /// ctor
+  
+  TString cMode(calibMode);
+  cMode.ToUpper();
+  
+  if ( cMode == "NOGAIN" ) 
+  {
+    fApplyGains = fgkNoGain;
+    AliInfo("Will NOT apply gain correction");
+  }
+  else if ( cMode = "GAINCONSTANTCAPA" ) 
+  {
+    fApplyGains = fgkGainConstantCapa;
+    AliInfo("Will apply gain correction, but with constant capacitance");
+  }
+  else if ( cMode == "GAIN" ) 
+  {
+    fApplyGains = fgkGain;
+    AliInfo("Will apply gain correction, with measured capacitances");
+  }
+  else
+  {
+    AliError(Form("Invalid calib mode = %s. Will use NOGAIN instead",calibMode));
+    fApplyGains = fgkNoGain;
+  }
+       
   fStatusMaker = new AliMUONPadStatusMaker(calib);
   
   // this is here that we decide on our "goodness" policy, i.e.
@@ -85,7 +119,14 @@ fGains(0x0)
   fStatusMapMaker = new AliMUONPadStatusMapMaker(*fStatusMaker,mask,deferredInitialization);
   
   fPedestals = calib.Pedestals();
-  fGains = calib.Gains();
+
+  fGains = calib.Gains(); // we get gains whatever the calibMode is, in order
+  // to get the saturation value...
+
+  if ( fApplyGains == fgkGain ) 
+  {
+    fCapacitances = calib.Capacitances();
+  }
 }
 
 //_____________________________________________________________________________
@@ -150,15 +191,16 @@ AliMUONDigitCalibrator::CalibrateDigit(AliMUONVDigit& digit)
     AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*>
     (fPedestals->FindObject(digit.DetElemId(),digit.ManuId()));
     
-    AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*>
-      (fGains->FindObject(digit.DetElemId(),digit.ManuId()));
-    
     if (!pedestal)
     {
       AliFatal(Form("Got a null ped object for DE,manu=%d,%d",
                     digit.DetElemId(),digit.ManuId()));
       
     }
+
+    AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*>
+        (fGains->FindObject(digit.DetElemId(),digit.ManuId()));
+
     if (!gain)
     {
       AliFatal(Form("Got a null gain object for DE,manu=%d,%d",
@@ -169,23 +211,48 @@ AliMUONDigitCalibrator::CalibrateDigit(AliMUONVDigit& digit)
     Float_t adc = digit.ADC();
     Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0);
     Float_t charge(0);
+    Float_t capa(1.0);
+    
+    if ( fApplyGains == fgkGainConstantCapa ) 
+    {
+      capa = 0.2; // pF
+    }
+    else if ( fApplyGains == fgkGain ) 
+    {
+      AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(digit.DetElemId());
+      
+      Int_t serialNumber = de->GetManuSerialFromId(digit.ManuId());
+
+      AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fCapacitances->FindObject(serialNumber));
+      
+      capa = param->ValueAsFloat(digit.ManuChannel());
+    }
+    
     if ( padc > 3.0*pedestal->ValueAsFloat(manuChannel,1) ) 
     {
-      Float_t a0 = gain->ValueAsFloat(manuChannel,0);
-      Float_t a1 = gain->ValueAsFloat(manuChannel,1);
-      Int_t thres = gain->ValueAsInt(manuChannel,2);
-      if ( padc < thres ) 
+      if ( fApplyGains != fgkNoGain ) 
       {
-        charge = a0*padc;
+        Float_t a0 = gain->ValueAsFloat(manuChannel,0);
+        Float_t a1 = gain->ValueAsFloat(manuChannel,1);
+        Int_t thres = gain->ValueAsInt(manuChannel,2);
+        if ( padc < thres ) 
+        {
+          charge = a0*padc;
+        }
+        else
+        {
+          charge = a0*thres + a0*(padc-thres) + a1*(padc-thres)*(padc-thres);
+        }
       }
       else
       {
-        charge = a0*thres + a0*(padc-thres) + a1*(padc-thres)*(padc-thres);
+        charge = padc;
       }
     }
+    charge *= capa;
     digit.SetCharge(charge);
     Int_t saturation = gain->ValueAsInt(manuChannel,4);
-    if ( charge >= saturation )
+    if ( padc >= saturation )
     {
       digit.Saturated(kTRUE);
     }
index 008238ad84c1cb39d04f559fcb9b72d8cb318b4e..e64c5b341e8a23c1b7469558ec22db12d43558a8 100644 (file)
@@ -27,7 +27,7 @@ class AliMUONPadStatusMapMaker;
 class AliMUONDigitCalibrator : public TObject
 {
 public:
-  AliMUONDigitCalibrator(const AliMUONCalibrationData& calib);
+  AliMUONDigitCalibrator(const AliMUONCalibrationData& calib, const char* calibMode="NOGAIN");
   
   virtual ~AliMUONDigitCalibrator();
   
@@ -47,8 +47,14 @@ private:
     AliMUONPadStatusMapMaker* fStatusMapMaker; //!< to build status map
     AliMUONVStore* fPedestals; //!< pedestal values
     AliMUONVStore* fGains; //!< gain values
+    Int_t fApplyGains; //!< whether we should apply gains or not, capa or not...
+    AliMUONVStore* fCapacitances; //!< capa values
     
-  ClassDef(AliMUONDigitCalibrator,4) // Calibrate raw digit
+    static const Int_t fgkNoGain; //!< do not apply gain calib at all
+    static const Int_t fgkGainConstantCapa; //!< apply gain (from OCDB) with constant capa
+    static const Int_t fgkGain; //!< apply gain and capa (from OCDB)
+    
+  ClassDef(AliMUONDigitCalibrator,5) // Calibrate raw digit
 };
 
 #endif
index a567ad90c59511085b48f9e85c355921395b8ad0..37bc02d07f6bea36c9e3b3f7733f1dfeecf6712f 100644 (file)
@@ -56,7 +56,8 @@ AliMUONRecoParam::AliMUONRecoParam()
   fComplementTracks(kFALSE),
   fImproveTracks(kFALSE),
   fUseSmoother(kFALSE),
-  fSaveFullClusterInESD(kTRUE)
+  fSaveFullClusterInESD(kTRUE),
+  fCalibrationMode("NOGAIN")
 {
   /// Constructor
   SetNameTitle("MUON","MUON");
@@ -149,6 +150,7 @@ void AliMUONRecoParam::Print(Option_t *option) const
   
   cout<<endl<<"\t------Reconstruction parameters------"<<endl;
   
+  cout<<Form("Calibration mode = %s",fCalibrationMode.Data())<<endl;
   cout<<Form("Clustering mode = %s",fClusteringMode.Data())<<endl;
   
   cout<<Form("Tracking mode = %s",fTrackingMode.Data())<<endl;
index f38496171d1ed979da17fc2682ced2d17f2b60b4..ceefea71f56a8cd59a88cfd34e368edb6a13d6ac 100644 (file)
@@ -21,6 +21,11 @@ class AliMUONRecoParam : public AliDetectorRecoParam
   static AliMUONRecoParam *GetLowFluxParam();
   static AliMUONRecoParam *GetHighFluxParam();
   
+  /// set the calibration mode
+  void SetCalibrationMode(Option_t* mode) { fCalibrationMode = mode; }
+  /// get the calibration mode
+  Option_t* GetCalibrationMode() const { return fCalibrationMode.Data(); }
+    
   /// set the clustering (pre-clustering) mode
   void      SetClusteringMode(Option_t* mode) {fClusteringMode = mode;}
   /// get the clustering (pre-clustering) mode
@@ -167,12 +172,15 @@ class AliMUONRecoParam : public AliDetectorRecoParam
   
   Bool_t     fSaveFullClusterInESD; ///< kTRUE to save all cluster info (including pads) in ESD
   
+  /// calibration mode:  GAIN, NOGAIN
+  TString fCalibrationMode; ///<\brief calibration mode
+  
   // functions
   void SetLowFluxParam();
   void SetHighFluxParam();
   
   
-  ClassDef(AliMUONRecoParam,1) // MUON reco parameters
+  ClassDef(AliMUONRecoParam,2) // MUON reco parameters
 };
 
 #endif
index 13084e40b76c2cb18cccdee95fb3e008d0b094ea..92294816a53dbfd15cc75d3a46327f4a79834fc0 100644 (file)
@@ -449,7 +449,9 @@ AliMUONReconstructor::CreateCalibrator() const
     AliWarning("NOSTATUSMAP is obsolete");
   }
 
-  fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData);
+  TString calibMode = GetRecoParam()->GetCalibrationMode();
+
+  fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,calibMode.Data());
 }
 
 //_____________________________________________________________________________