]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONDigitCalibrator.cxx
Add Config/HighVoltage directory and entry
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitCalibrator.cxx
index b0c2ae4330e8a662abf89f7ad1fc7f0e76dc170f..ac6aad1dbae54f437dff35c0adf0af37044d9033 100644 (file)
@@ -28,6 +28,7 @@
 #include "AliMUONVStore.h"
 #include "AliMUONVCalibParam.h"
 
+//-----------------------------------------------------------------------------
 /// \class AliMUONDigitCalibrator
 /// Class used to calibrate digits (either real or simulated ones).
 ///
@@ -44,6 +45,7 @@
 /// bad digits).
 ///
 /// \author Laurent Aphecetche
+//-----------------------------------------------------------------------------
 
 
 /// \cond CLASSIMP
@@ -51,57 +53,47 @@ ClassImp(AliMUONDigitCalibrator)
 /// \endcond
 
 //_____________________________________________________________________________
-AliMUONDigitCalibrator::AliMUONDigitCalibrator(const AliMUONCalibrationData& calib,
-                                               Bool_t createAndUseStatusMap)
+AliMUONDigitCalibrator::AliMUONDigitCalibrator(const AliMUONCalibrationData& calib)
 : TObject(),
-fCalibrationData(calib),
-fStatusMap(0x0),
-fLogger(new AliMUONLogger(1000))
+fLogger(new AliMUONLogger(1000)),
+fStatusMaker(0x0),
+fStatusMapMaker(0x0),
+fPedestals(0x0),
+fGains(0x0)
 {
   /// ctor
-  if (createAndUseStatusMap) 
-  {
-    AliMUONPadStatusMaker maker(fCalibrationData);
-    
-    // this is here that we decide on our "goodness" policy, i.e.
-    // what do we call an invalid pad (a pad maybe bad because its HV
-    // was too low, or its pedestals too high, etc..)
-    // FIXME: find a way not to hard-code the goodness policy (i.e. the limits)
-    // here...
-    maker.SetHVSt12Limits(1300,1600);
-    maker.SetHVSt345Limits(1500,2000);
-    maker.SetPedMeanLimits(50,200);
-    maker.SetPedSigmaLimits(0.1,3);
-    
-    // From this set of limits, compute the status of all tracker pads.
-    AliMUONVStore* status = maker.MakeStatus();      
-    // we do not check that status is != 0x0, as this is supposed to be
-    // the responsability of the padStatusMaker.
-    
-    AliMUONPadStatusMapMaker mapMaker(fCalibrationData);
-    
-    Int_t mask(0x8080); 
-    //FIXME: kind of fake one for the moment, we consider dead only 
-    // if ped and/or hv value missing.
-    //WARNING : getting this mask wrong is a very effective way of getting
-    //no digits at all out of this class ;-)
-    
-    fStatusMap = mapMaker.MakePadStatusMap(*status,mask);
-    
-    delete status;
-    }
-  else
-  {
-    // make a fake (empty) status map
-    fStatusMap = AliMUONPadStatusMapMaker::MakeEmptyPadStatusMap();
-  }
+  fStatusMaker = new AliMUONPadStatusMaker(calib);
+  
+  // this is here that we decide on our "goodness" policy, i.e.
+  // what do we call an invalid pad (a pad maybe bad because its HV
+  // was too low, or its pedestals too high, etc..)
+  // FIXME: find a way not to hard-code the goodness policy (i.e. the limits)
+  // here...
+  fStatusMaker->SetHVSt12Limits(1300,1600);
+  fStatusMaker->SetHVSt345Limits(1500,2000);
+  fStatusMaker->SetPedMeanLimits(50,200);
+  fStatusMaker->SetPedSigmaLimits(0.1,3);
+  
+  Int_t mask(0x8080); 
+  //FIXME: kind of fake one for the moment, we consider dead only 
+  // if ped and/or hv value missing.
+  //WARNING : getting this mask wrong is a very effective way of getting
+  //no digits at all out of this class ;-)
+  
+  Bool_t deferredInitialization = kTRUE;
+  
+  fStatusMapMaker = new AliMUONPadStatusMapMaker(*fStatusMaker,mask,deferredInitialization);
+  
+  fPedestals = calib.Pedestals();
+  fGains = calib.Gains();
 }
 
 //_____________________________________________________________________________
 AliMUONDigitCalibrator::~AliMUONDigitCalibrator()
 {
   /// dtor.
-  delete fStatusMap;
+  delete fStatusMaker;
+  delete fStatusMapMaker;
   
   AliInfo("Summary of messages:");
   fLogger->Print();
@@ -129,11 +121,19 @@ AliMUONDigitCalibrator::CalibrateDigit(AliMUONVDigit& digit)
 {
   /// Calibrate one digit
   
-  AliMUONVCalibParam* deadmap = static_cast<AliMUONVCalibParam*>
-  (fStatusMap->FindObject(digit.DetElemId(),digit.ManuId()));
-  Int_t statusMap = deadmap->ValueAsInt(digit.ManuChannel());
+  if ( digit.IsCalibrated() ) 
+  {
+    fLogger->Log("ERROR : trying to calibrate a digit twice");
+    return;
+  }
+  
+  Int_t statusMap = fStatusMapMaker->StatusMap(digit.DetElemId(),
+                                               digit.ManuId(),
+                                               digit.ManuChannel());
+
   digit.SetStatusMap(statusMap);
   digit.Calibrated(kTRUE);
+  
   if ( ( statusMap & AliMUONPadStatusMapMaker::SelfDeadMask() ) != 0 ) 
   {
     // pad itself is bad (not testing its neighbours at this stage)
@@ -148,10 +148,10 @@ AliMUONDigitCalibrator::CalibrateDigit(AliMUONVDigit& digit)
     // If the channel is good, go on with the calibration itself.
 
     AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*>
-    (fCalibrationData.Pedestals(digit.DetElemId(),digit.ManuId()));
+    (fPedestals->FindObject(digit.DetElemId(),digit.ManuId()));
     
     AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*>
-      (fCalibrationData.Gains(digit.DetElemId(),digit.ManuId()));
+      (fGains->FindObject(digit.DetElemId(),digit.ManuId()));
     
     if (!pedestal)
     {
@@ -168,13 +168,23 @@ AliMUONDigitCalibrator::CalibrateDigit(AliMUONVDigit& digit)
     Int_t manuChannel = digit.ManuChannel();
     Float_t adc = digit.ADC();
     Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0);
-    if ( padc < 3.0*pedestal->ValueAsFloat(manuChannel,1) ) 
+    Float_t charge(0);
+    if ( padc > 3.0*pedestal->ValueAsFloat(manuChannel,1) ) 
     {
-      padc = 0.0;
+      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);
+      }
     }
-    Float_t charge = padc*gain->ValueAsFloat(manuChannel,0);
     digit.SetCharge(charge);
-    Int_t saturation = gain->ValueAsInt(manuChannel,1);
+    Int_t saturation = gain->ValueAsInt(manuChannel,4);
     if ( charge >= saturation )
     {
       digit.Saturated(kTRUE);