]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONDigitizerV3.cxx
Updated list of MUON libraries
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitizerV3.cxx
index c3ba71044b27168aa7a9a6d5105a1ed3b3bc624d..6df5a2df058a4152403c80f51c980e53bf14f6f3 100644 (file)
 
 // $Id$
 
+
 #include "AliMUONDigitizerV3.h"
 
-#include "AliLog.h"
 #include "AliMUON.h"
 #include "AliMUONCalibrationData.h"
+#include "AliCDBManager.h"
 #include "AliMUONConstants.h"
-#include "AliMUONData.h"
+#include "AliMUONSimData.h"
 #include "AliMUONDataIterator.h"
 #include "AliMUONDigit.h"
+#include "AliMUONLogger.h"
 #include "AliMUONSegmentation.h"
-#include "AliMUONTriggerDecisionV1.h"
 #include "AliMUONTriggerEfficiencyCells.h"
 #include "AliMUONTriggerElectronics.h"
 #include "AliMUONVCalibParam.h"
+
 #include "AliMpDEIterator.h"
 #include "AliMpDEManager.h"
 #include "AliMpIntPair.h"
 #include "AliMpPad.h"
 #include "AliMpStationType.h"
+#include "AliMpSegmentation.h"
 #include "AliMpVSegmentation.h"
+#include "AliMpDEManager.h"
+#include "AliMpCathodType.h"
+
 #include "AliRun.h"
 #include "AliRunDigitizer.h"
 #include "AliRunLoader.h"
-#include "Riostream.h"
-#include "TF1.h"
-#include "TRandom.h"
-#include "TString.h"
+#include "AliLog.h"
 
+#include <Riostream.h>
+#include <TF1.h>
+#include <TMath.h>
+#include <TRandom.h>
+#include <TString.h>
 ///
+/// \class AliMUONDigitizerV3
 /// The digitizer is performing the transformation to go from SDigits (digits
 /// w/o any electronic noise) to Digits (w/ electronic noise, and decalibration)
 /// 
@@ -56,6 +65,7 @@
 /// (for performance reason mainly, and because anyway we know we have to do it
 /// here, at the digitization level).
 ///
+/// \author Laurent Aphecetche
 
 namespace
 {
@@ -63,58 +73,43 @@ namespace
   {
     return static_cast<AliMUON*>(gAlice->GetModule("MUON"));
   }
-
-  AliMUONSegmentation* Segmentation()
-  {
-    static AliMUONSegmentation* segmentation = muon()->GetSegmentation();
-    return segmentation;
-  }
 }
 
 const Double_t AliMUONDigitizerV3::fgkNSigmas=3;
 
+/// \cond CLASSIMP
 ClassImp(AliMUONDigitizerV3)
+/// \endcond
 
 //_____________________________________________________________________________
 AliMUONDigitizerV3::AliMUONDigitizerV3(AliRunDigitizer* manager, 
-                                       ETriggerCodeVersion triggerCodeVersion,
-                                       Bool_t useTriggerEfficiency,
                                        Bool_t generateNoisyDigits)
 : AliDigitizer(manager),
 fIsInitialized(kFALSE),
 fOutputData(0x0),
 fCalibrationData(0x0),
 fTriggerProcessor(0x0),
-fTriggerCodeVersion(triggerCodeVersion),
-fUseTriggerEfficiency(useTriggerEfficiency),
 fTriggerEfficiency(0x0),
+fFindDigitIndexTimer(),
+fGenerateNoisyDigitsTimer(),
+fExecTimer(),
 fNoiseFunction(0x0),
-fGenerateNoisyDigits(generateNoisyDigits)
+  fGenerateNoisyDigits(generateNoisyDigits),
+  fLogger(new AliMUONLogger(1000))
 {
-  //
-  // Ctor.
-  //
+  /// Ctor.
+
   AliDebug(1,Form("AliRunDigitizer=%p",fManager));
   fGenerateNoisyDigitsTimer.Start(kTRUE); fGenerateNoisyDigitsTimer.Stop();
   fExecTimer.Start(kTRUE); fExecTimer.Stop();
   fFindDigitIndexTimer.Start(kTRUE); fFindDigitIndexTimer.Stop();
 }
 
-//______________________________________________________________________________
-AliMUONDigitizerV3::AliMUONDigitizerV3(const AliMUONDigitizerV3& right) 
-  : AliDigitizer(right) 
-{  
-/// Protected copy constructor (not implemented)
-
-  AliFatal("Copy constructor not provided.");
-}
-
 //_____________________________________________________________________________
 AliMUONDigitizerV3::~AliMUONDigitizerV3()
 {
-  //
-  // Dtor. Note we're the owner of some pointers.
-  // 
+  /// Dtor. Note we're the owner of some pointers.
+
   AliDebug(1,"dtor");
 
   delete fOutputData;
@@ -122,54 +117,43 @@ AliMUONDigitizerV3::~AliMUONDigitizerV3()
   delete fTriggerProcessor;
   delete fNoiseFunction;
   
-  AliInfo(Form("Execution time for FindDigitIndex() : R:%.2fs C:%.2fs",
+  AliDebug(1, Form("Execution time for FindDigitIndex() : R:%.2fs C:%.2fs",
                fFindDigitIndexTimer.RealTime(),fFindDigitIndexTimer.CpuTime()));
   if ( fGenerateNoisyDigits )
   {
-    AliInfo(Form("Execution time for GenerateNoisyDigits() : R:%.2fs C:%.2fs",
+    AliDebug(1, Form("Execution time for GenerateNoisyDigits() : R:%.2fs C:%.2fs",
                  fGenerateNoisyDigitsTimer.RealTime(),
                  fGenerateNoisyDigitsTimer.CpuTime()));
   }
-  AliInfo(Form("Execution time for Exec() : R:%.2fs C:%.2fs",
+  AliDebug(1, Form("Execution time for Exec() : R:%.2fs C:%.2fs",
                fExecTimer.RealTime(),fExecTimer.CpuTime()));
+  AliInfo("Summary of messages");
+  fLogger->Print();
   
+  delete fLogger;
 }
 
-//______________________________________________________________________________
-AliMUONDigitizerV3& 
-AliMUONDigitizerV3::operator=(const AliMUONDigitizerV3& right)
-{
-/// Protected assignement operator (not implemented)
-
-  // check assignement to self
-  if (this == &right) return *this;
-
-  AliFatal("Assignement operator not provided.");
-    
-  return *this;  
-}    
-
 //_____________________________________________________________________________
 void 
 AliMUONDigitizerV3::ApplyResponseToTrackerDigit(AliMUONDigit& digit, Bool_t addNoise)
 {
-  // For tracking digits, starting from an ideal digit's charge, we :
-  //
-  // - add some noise (thus leading to a realistic charge), if requested to do so
-  // - divide by a gain (thus decalibrating the digit)
-  // - add a pedestal (thus decalibrating the digit)
-  // - sets the signal to zero if below 3*sigma of the noise
-  //
+  /// For tracking digits, starting from an ideal digit's charge, we :
+  ///
+  /// - add some noise (thus leading to a realistic charge), if requested to do so
+  /// - divide by a gain (thus decalibrating the digit)
+  /// - add a pedestal (thus decalibrating the digit)
+  /// - sets the signal to zero if below 3*sigma of the noise
 
   static const Int_t kMaxADC = (1<<12)-1; // We code the charge on a 12 bits ADC.
-
+  
   Float_t signal = digit.Signal();
-
+  
   if ( !addNoise )
-    {
-      digit.SetADC(TMath::Nint(signal));
-      return;
-    }
+  {
+    digit.SetADC(TMath::Nint(signal));
+    return;
+  }
   
   Int_t detElemId = digit.DetElemId();
   
@@ -178,47 +162,57 @@ AliMUONDigitizerV3::ApplyResponseToTrackerDigit(AliMUONDigit& digit, Bool_t addN
   
   AliMUONVCalibParam* pedestal = fCalibrationData->Pedestals(detElemId,manuId);
   if (!pedestal)
-    {
-      AliFatal(Form("Could not get pedestal for DE=%d manuId=%d",
-                   detElemId,manuId));    
-    }
+  {
+    fLogger->Log(Form("%s:%d:Could not get pedestal for DE=%4d manuId=%4d. Disabling.",
+                      __FILE__,__LINE__,
+                      detElemId,manuId));
+    digit.SetPhysicsSignal(0);
+    digit.SetSignal(0);
+    digit.SetADC(0);
+    return;    
+  }
   Float_t pedestalMean = pedestal->ValueAsFloat(manuChannel,0);
   Float_t pedestalSigma = pedestal->ValueAsFloat(manuChannel,1);
   
   AliMUONVCalibParam* gain = fCalibrationData->Gains(detElemId,manuId);
   if (!gain)
-    {
-      AliFatal(Form("Could not get gain for DE=%d manuId=%d",
-                   detElemId,manuId));    
-    }    
+  {
+    fLogger->Log(Form("%s:%d:Could not get gain for DE=%4d manuId=%4d. Disabling.",
+                      __FILE__,__LINE__,
+                      detElemId,manuId));
+    digit.SetPhysicsSignal(0);
+    digit.SetSignal(0);
+    digit.SetADC(0);
+    return;        
+  }    
   Float_t gainMean = gain->ValueAsFloat(manuChannel,0);
-
+  
   Float_t adcNoise = gRandom->Gaus(0.0,pedestalSigma);
-     
+  
   Int_t adc;
-
+  
   if ( gainMean < 1E-6 )
-    {
-      AliError(Form("Got a too small gain %e for DE=%d manuId=%d manuChannel=%d. "
-                   "Setting signal to 0.",
-                   gainMean,detElemId,manuId,manuChannel));
-      adc = 0;
-    }
+  {
+    AliError(Form("Got a too small gain %e for DE=%d manuId=%d manuChannel=%d. "
+                  "Setting signal to 0.",
+                  gainMean,detElemId,manuId,manuChannel));
+    adc = 0;
+  }
   else
+  {
+    adc = TMath::Nint( signal / gainMean + pedestalMean + adcNoise);///
+    
+    if ( adc <= pedestalMean + fgkNSigmas*pedestalSigma ) 
     {
-      adc = TMath::Nint( signal / gainMean + pedestalMean + adcNoise);///
-      
-      if ( adc <= pedestalMean + fgkNSigmas*pedestalSigma ) 
-       {
-         adc = 0;
-       }
+      adc = 0;
     }
+  }
   
   // be sure we stick to 12 bits.
   if ( adc > kMaxADC )
-    {
-      adc = kMaxADC;
-    }
+  {
+    adc = kMaxADC;
+  }
   
   digit.SetPhysicsSignal(TMath::Nint(signal));
   digit.SetSignal(adc);
@@ -227,19 +221,25 @@ AliMUONDigitizerV3::ApplyResponseToTrackerDigit(AliMUONDigit& digit, Bool_t addN
 
 //_____________________________________________________________________________
 void 
-AliMUONDigitizerV3::ApplyResponseToTriggerDigit(AliMUONDigit& digit,
-                                                AliMUONData* data)
+AliMUONDigitizerV3::ApplyResponseToTriggerDigit(AliMUONDigit& digit)
 {
+  /// \todo add comment
+
   if ( !fTriggerEfficiency ) return;
 
-  AliMUONDigit* correspondingDigit = FindCorrespondingDigit(digit,data);
+  if (digit.IsEfficiencyApplied()) return;
+
+  AliMUONDigit* correspondingDigit = FindCorrespondingDigit(digit);
+
+  if (!correspondingDigit) return; //reject bad correspondences
 
   Int_t detElemId = digit.DetElemId();
-  
+
+  AliMpSegmentation* segmentation = AliMpSegmentation::Instance();
   const AliMpVSegmentation* segment[2] = 
   {
-    Segmentation()->GetMpSegmentation(detElemId,digit.Cathode()), 
-    Segmentation()->GetMpSegmentation(detElemId,correspondingDigit->Cathode())
+    segmentation->GetMpSegmentation(detElemId,AliMp::GetCathodType(digit.Cathode())), 
+    segmentation->GetMpSegmentation(detElemId,AliMp::GetCathodType(correspondingDigit->Cathode()))
   };
 
   AliMpPad pad[2] = 
@@ -248,32 +248,19 @@ AliMUONDigitizerV3::ApplyResponseToTriggerDigit(AliMUONDigit& digit,
     segment[1]->PadByIndices(AliMpIntPair(correspondingDigit->PadX(),correspondingDigit->PadY()),kTRUE)
   };
 
-  Int_t ix(0);
-  Int_t iy(1);
+  Int_t p0(1);
+  if (digit.Cathode()==0) p0=0;
+
+  AliMpIntPair location = pad[p0].GetLocation(0);
+  Int_t nboard = location.GetFirst();
 
-  if (digit.Cathode()==0)
-  {
-         ix=1;
-         iy=0;
-  }
-  
-  Float_t x = pad[ix].Position().X();
-  Float_t y = pad[iy].Position().Y();
-  if ( x==-1 && y==-1 )
-  {
-         x=-9999.;
-         y=-9999.;
-    AliError(Form("Got an unknown position for a digit in DE %d at (ix,iy)=(%d,%d)",
-             detElemId,pad[ix].GetIndices().GetFirst(),pad[iy].GetIndices().GetSecond()));
-  }
-  Float_t x0 = segment[0]->Dimensions().X();
-  Float_t y0 = segment[1]->Dimensions().Y();
-  TVector2 newCoord = fTriggerEfficiency->ChangeReferenceFrame(x, y, x0, y0);
-  
   Bool_t isTrig[2];
-  fTriggerEfficiency->IsTriggered(detElemId, newCoord.Px(), newCoord.Py(), 
+
+  fTriggerEfficiency->IsTriggered(detElemId, nboard-1, 
                                   isTrig[0], isTrig[1]);
-  
+  digit.EfficiencyApplied(kTRUE);
+  correspondingDigit->EfficiencyApplied(kTRUE);
+
   if (!isTrig[digit.Cathode()])
   {
          digit.SetSignal(0);
@@ -292,10 +279,9 @@ AliMUONDigitizerV3::ApplyResponseToTriggerDigit(AliMUONDigit& digit,
 void
 AliMUONDigitizerV3::ApplyResponse()
 {
-  //
-  // Loop over all chamber digits, and apply the response to them
-  // Note that this method may remove digits.
-  //
+  /// Loop over all chamber digits, and apply the response to them
+  /// Note that this method may remove digits.
+
   const Bool_t kAddNoise = kTRUE;
   
   for ( Int_t ich = 0; ich < AliMUONConstants::NCh(); ++ich )
@@ -306,20 +292,22 @@ AliMUONDigitizerV3::ApplyResponse()
     for ( Int_t i = 0; i < n; ++i )
     {
       AliMUONDigit* d = static_cast<AliMUONDigit*>(digits->UncheckedAt(i));
+      if ( !d ) continue; // that digit might have been removed
       if ( trackingChamber )
       {
         ApplyResponseToTrackerDigit(*d,kAddNoise);
       }
       else
       {
-        ApplyResponseToTriggerDigit(*d,fOutputData);
+        ApplyResponseToTriggerDigit(*d);
       }
       if ( d->Signal() <= 0 )
       {
         digits->RemoveAt(i);
       }
     }
-    digits->Compress();
+    digits->Compress(); // only do the compress at the end in order not to
+    // change the n = digits->GetEntriesFast()
   }    
   
 // The version below, using iterator, does not yet work (as the iterator
@@ -359,10 +347,9 @@ void
 AliMUONDigitizerV3::AddOrUpdateDigit(TClonesArray& array, 
                                      const AliMUONDigit& digit)
 {
-  //
-  // Add or update a digit, depending on whether there's already a digit
-  // for the corresponding channel.
-  //
+  /// Add or update a digit, depending on whether there's already a digit
+  /// for the corresponding channel.
+
   Int_t ix = FindDigitIndex(array,digit);
   
   if (ix>=0)
@@ -386,13 +373,11 @@ AliMUONDigitizerV3::AddOrUpdateDigit(TClonesArray& array,
 void
 AliMUONDigitizerV3::Exec(Option_t*)
 {
-  //
-  // Main method.
-  // We first loop over input files, and merge the sdigits we found there.
-  // Second, we digitize all the resulting sdigits
-  // Then we generate noise-only digits (for tracker only)
-  // And we finally generate the trigger outputs.
-  //
+  /// Main method.
+  /// We first loop over input files, and merge the sdigits we found there.
+  /// Second, we digitize all the resulting sdigits
+  /// Then we generate noise-only digits (for tracker only)
+  /// And we finally generate the trigger outputs.
     
   AliDebug(1, "Running digitizer.");
   
@@ -414,7 +399,7 @@ AliMUONDigitizerV3::Exec(Option_t*)
   
   if ( fOutputData->TreeD() == 0x0 )
   {
-    AliDebug(1,"Calling MakeDigitsContainer");
+    AliDebug(2,"Calling MakeDigitsContainer");
     fOutputData->GetLoader()->MakeDigitsContainer();
   }
   fOutputData->MakeBranch("D,GLT");
@@ -424,7 +409,7 @@ AliMUONDigitizerV3::Exec(Option_t*)
   // files.
   for ( Int_t iFile = 0; iFile < nInputFiles; ++iFile )
   {    
-    AliMUONData* inputData = GetDataAccess(fManager->GetInputFolderName(iFile));
+    AliMUONSimData* inputData = GetDataAccess(fManager->GetInputFolderName(iFile));
     if (!inputData)
     {
       AliFatal(Form("Could not get access to input file #%d",iFile));
@@ -476,21 +461,42 @@ AliMUONDigitizerV3::Exec(Option_t*)
 
 //_____________________________________________________________________________
 AliMUONDigit* 
-AliMUONDigitizerV3::FindCorrespondingDigit(AliMUONDigit& digit,
-                                           AliMUONData* data)
+AliMUONDigitizerV3::FindCorrespondingDigit(AliMUONDigit& digit) const
 {                                                
-  AliMUONDataIterator it(data,"D",AliMUONDataIterator::kAllChambers);
-  AliMUONDigit* cd;
+  /// Find, if it exists, the digit corresponding to digit.Hit(), in the 
+  /// other cathode
+
+// Iterator does not yet work when writing digits (only works when reading,
+// which is not the case here)
+//
+//  AliMUONDataIterator it(data,"D",AliMUONDataIterator::kTriggerChambers);
+//  AliMUONDigit* cd;
+//
+//  while ( ( cd = static_cast<AliMUONDigit*>(it.Next()) ) )
+//  {
+//    if ( cd->DetElemId() == digit.DetElemId() &&
+//         cd->Hit() == digit.Hit() &&
+//         cd->Cathode() != digit.Cathode() )
+//    {
+//      break;
+//    }
+//  }
   
-  while ( ( cd = static_cast<AliMUONDigit*>(it.Next()) ) )
+  Int_t ich = AliMpDEManager::GetChamberId(digit.DetElemId());  
+  TClonesArray* digits = fOutputData->Digits(ich);
+  Int_t n = digits->GetEntriesFast();
+  for ( Int_t i = 0; i < n; ++i )
   {
-    if ( cd->DetElemId() == digit.DetElemId() &&
-         cd->Hit() == digit.Hit() &&
-         cd->Cathode() != digit.Cathode() )
+    AliMUONDigit* d = static_cast<AliMUONDigit*>(digits->UncheckedAt(i));
+    if ( d &&
+         d->DetElemId() == digit.DetElemId() &&
+         d->Hit() == digit.Hit() &&
+         d->Cathode() != digit.Cathode() )
     {
-      return cd;
-    }
-  }
+      return d;
+    }      
+  }    
+
   return 0x0;
 }
 
@@ -500,13 +506,11 @@ Int_t
 AliMUONDigitizerV3::FindDigitIndex(TClonesArray& array, 
                                    const AliMUONDigit& digit) const
 {
-  // 
-  // Return the index of digit within array, if that digit is there, 
-  // otherwise returns -1
-  //
-  // FIXME: this is of course not the best implementation you can think of.
-  // Reconsider the use of hit/digit map... ? (but be sure it's needed!)
-  //
+  /// Return the index of digit within array, if that digit is there, 
+  /// otherwise returns -1
+  ///
+  /// \todo FIXME: this is of course not the best implementation you can think of.
+  /// Reconsider the use of hit/digit map... ? (but be sure it's needed!)
   
   fFindDigitIndexTimer.Start(kFALSE);
   
@@ -531,11 +535,9 @@ AliMUONDigitizerV3::FindDigitIndex(TClonesArray& array,
 void
 AliMUONDigitizerV3::GenerateNoisyDigits()
 {
-  //
-  // According to a given probability, generate digits that
-  // have a signal above the noise cut (ped+n*sigma_ped), i.e. digits
-  // that are "only noise".
-  //
+  /// According to a given probability, generate digits that
+  /// have a signal above the noise cut (ped+n*sigma_ped), i.e. digits
+  /// that are "only noise".
   
   if ( !fNoiseFunction )
   {
@@ -557,7 +559,7 @@ AliMUONDigitizerV3::GenerateNoisyDigits()
     {
       for ( Int_t cathode = 0; cathode < 2; ++cathode )
       {
-        GenerateNoisyDigitsForOneCathode(it.CurrentDE(),cathode);
+        GenerateNoisyDigitsForOneCathode(it.CurrentDEId(),cathode);
       }
       it.Next();
     }
@@ -570,22 +572,22 @@ AliMUONDigitizerV3::GenerateNoisyDigits()
 void
 AliMUONDigitizerV3::GenerateNoisyDigitsForOneCathode(Int_t detElemId, Int_t cathode)
 {
-  //
-  // Generate noise-only digits for one cathode of one detection element.
-  // Called by GenerateNoisyDigits()
-  //
+  /// Generate noise-only digits for one cathode of one detection element.
+  /// Called by GenerateNoisyDigits()
   
-  TClonesArray* digits = fOutputData->Digits(detElemId/100-1);
+  Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
+  TClonesArray* digits = fOutputData->Digits(chamberId);
   
-  const AliMpVSegmentation* seg = Segmentation()->GetMpSegmentation(detElemId,cathode);
+  const AliMpVSegmentation* seg 
+    = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode));
   Int_t nofPads = seg->NofPads();
   
   Int_t maxIx = seg->MaxPadIndexX();
   Int_t maxIy = seg->MaxPadIndexY();
   
-  static const Double_t probToBeOutsideNsigmas = 1 - TMath::Erf(fgkNSigmas/TMath::Sqrt(2.0));
+  static const Double_t kProbToBeOutsideNsigmas = TMath::Erfc(fgkNSigmas/TMath::Sqrt(2.0)) / 2. ;
   
-  Int_t nofNoisyPads = TMath::Nint(probToBeOutsideNsigmas*nofPads);
+  Int_t nofNoisyPads = TMath::Nint(kProbToBeOutsideNsigmas*nofPads);
   if ( !nofNoisyPads ) return;
   
   nofNoisyPads = 
@@ -620,6 +622,12 @@ AliMUONDigitizerV3::GenerateNoisyDigitsForOneCathode(Int_t detElemId, Int_t cath
     
     AliMUONVCalibParam* pedestals = fCalibrationData->Pedestals(detElemId,manuId);
     
+    if (!pedestals) 
+    {
+      // no pedestal available for this channel, simply give up
+      return;
+    }
+    
     Float_t pedestalMean = pedestals->ValueAsFloat(manuChannel,0);
     Float_t pedestalSigma = pedestals->ValueAsFloat(manuChannel,1);
     
@@ -629,8 +637,8 @@ AliMUONDigitizerV3::GenerateNoisyDigitsForOneCathode(Int_t detElemId, Int_t cath
     d.SetPhysicsSignal(0);
     d.NoiseOnly(kTRUE);
     AliDebug(3,Form("Adding a pure noise digit :"));
-    StdoutToAliDebug(3,cout << "Before Response: " << endl; 
-                     d.Print(););
+//    StdoutToAliDebug(3,cout << "Before Response: " << endl; 
+//                     d.Print(););
     ApplyResponseToTrackerDigit(d,kFALSE);
     if ( d.Signal() > 0 )
     {
@@ -641,19 +649,18 @@ AliMUONDigitizerV3::GenerateNoisyDigitsForOneCathode(Int_t detElemId, Int_t cath
       AliError("Pure noise below threshold. This should not happen. Not adding "
                "this digit.");
     }
-    StdoutToAliDebug(3,cout << "After Response: " << endl; 
-                     d.Print(););
+//    StdoutToAliDebug(3,cout << "After Response: " << endl; 
+//                     d.Print(););
   }
 }
 
 //_____________________________________________________________________________
-AliMUONData* 
+AliMUONSimData* 
 AliMUONDigitizerV3::GetDataAccess(const TString& folderName)
 {
-  //
-  // Create an AliMUONData to deal with data found in folderName.
-  //
-  AliDebug(1,Form("Getting access to folder %s",folderName.Data()));
+  /// Create an AliMUONSimData to deal with data found in folderName.
+
+  AliDebug(2,Form("Getting access to folder %s",folderName.Data()));
   AliRunLoader* runLoader = AliRunLoader::GetRunLoader(folderName);
   if (!runLoader)
   {
@@ -666,8 +673,8 @@ AliMUONDigitizerV3::GetDataAccess(const TString& folderName)
     AliError(Form("Could not get MuonLoader from folder %s",folderName.Data()));
     return 0x0;
   }
-  AliMUONData* data = new AliMUONData(loader,"MUON","MUONDataForDigitOutput");
-  AliDebug(1,Form("AliMUONData=%p loader=%p",data,loader));
+  AliMUONSimData* data = new AliMUONSimData(loader,"MUON","MUONDataForDigitOutput");
+  AliDebug(2,Form("AliMUONSimData=%p loader=%p",data,loader));
   return data;
 }
 
@@ -675,13 +682,12 @@ AliMUONDigitizerV3::GetDataAccess(const TString& folderName)
 Bool_t
 AliMUONDigitizerV3::Init()
 {
-  //
-  // Initialization of the TTask :
-  // a) set the outputData pointer
-  // b) create the calibrationData, according to run number
-  // c) create the trigger processing task
-  //
-  AliDebug(1,"");
+  /// Initialization of the TTask :
+  /// a) set the outputData pointer
+  /// b) create the calibrationData, according to run number
+  /// c) create the trigger processing task
+
+  AliDebug(2,"");
   
   if ( fIsInitialized )
   {
@@ -701,48 +707,38 @@ AliMUONDigitizerV3::Init()
     AliError("Can not perform digitization. I'm sorry");
     return kFALSE;
   }
-  AliDebug(1,Form("fOutputData=%p",fOutputData));
+  AliDebug(2,Form("fOutputData=%p",fOutputData));
   
-  AliRunLoader* runLoader = fOutputData->GetLoader()->GetRunLoader();
-  AliRun* galice = runLoader->GetAliRun();  
-  Int_t runnumber = galice->GetRunNumber();
+  Int_t runnumber = AliCDBManager::Instance()->GetRun();
   
   fCalibrationData = new AliMUONCalibrationData(runnumber);
-  
-  switch (fTriggerCodeVersion)
-  {
-    case kTriggerDecision:
-      fTriggerProcessor = new AliMUONTriggerDecisionV1(fOutputData);
-      break;
-    case kTriggerElectronics:
-      fTriggerProcessor = new AliMUONTriggerElectronics(fOutputData,fCalibrationData);
-      break;
-    default:
-      AliFatal("Unknown trigger processor type");
-      break;
+  if ( !fCalibrationData->Pedestals() )
+  {
+    AliFatal("Could not access pedestals from OCDB !");
   }
-  AliDebug(1,Form("Using the following trigger code %s - %s",
-                  fTriggerProcessor->GetName(),fTriggerProcessor->GetTitle()));
+  if ( !fCalibrationData->Gains() )
+  {
+    AliFatal("Could not access gains from OCDB !");
+  }
+  fTriggerProcessor = new AliMUONTriggerElectronics(fOutputData,fCalibrationData);
   
-  if ( fUseTriggerEfficiency )
+  if ( muon()->GetTriggerEffCells() )
   {
     fTriggerEfficiency = fCalibrationData->TriggerEfficiency();
     if ( fTriggerEfficiency )
     {
-      AliInfo("Will apply trigger efficiency");
+      AliDebug(1, "Will apply trigger efficiency");
     }
     else
     {
-      AliError("I was requested to apply trigger efficiency, but I could "
+      AliFatal("I was requested to apply trigger efficiency, but I could "
                "not get it !");
     }
   }
   
-  if ( fGenerateNoisyDigits )
-  {
-    AliInfo("Will generate noise-only digits for tracker");
-  }
-  
+  AliDebug(1, Form("Will %s generate noise-only digits for tracker",
+                     (fGenerateNoisyDigits ? "":"NOT")));
+
   fIsInitialized = kTRUE;
   return kTRUE;
 }
@@ -752,12 +748,11 @@ Bool_t
 AliMUONDigitizerV3::MergeDigits(const AliMUONDigit& src, 
                                 AliMUONDigit& srcAndDest)
 {
-  //
-  // Merge 2 digits (src and srcAndDest) into srcAndDest.
-  //
-  AliDebug(1,"Merging the following digits:");
-  StdoutToAliDebug(1,src.Print("tracks"););
-  StdoutToAliDebug(1,srcAndDest.Print("tracks"););
+  /// Merge 2 digits (src and srcAndDest) into srcAndDest.
+
+  AliDebug(2,"Merging the following digits:");
+//  StdoutToAliDebug(2,src.Print("tracks"););
+//  StdoutToAliDebug(2,srcAndDest.Print("tracks"););
   
   Bool_t check = ( src.DetElemId() == srcAndDest.DetElemId() &&
                    src.PadX() == srcAndDest.PadX() &&
@@ -774,19 +769,18 @@ AliMUONDigitizerV3::MergeDigits(const AliMUONDigit& src,
   {
     srcAndDest.AddTrack(src.Track(i),src.TrackCharge(i));
   }
-  StdoutToAliDebug(1,cout << "result:"; srcAndDest.Print("tracks"););
+//  StdoutToAliDebug(2,cout << "result:"; srcAndDest.Print("tracks"););
   return kTRUE;
 }
 
 //_____________________________________________________________________________
 void 
-AliMUONDigitizerV3::MergeWithSDigits(AliMUONData& outputData, 
-                                     const AliMUONData& inputData, Int_t mask)
+AliMUONDigitizerV3::MergeWithSDigits(AliMUONSimData& outputData, 
+                                     const AliMUONSimData& inputData, Int_t mask)
 {
-  //
-  // Merge the sdigits in inputData with the digits already present in outputData
-  //
-  AliDebug(1,"");
+  /// Merge the sdigits in inputData with the digits already present in outputData
+
+  AliDebug(2,"");
   
        for ( Int_t ich = 0; ich < AliMUONConstants::NCh(); ++ich )
        {
@@ -814,6 +808,6 @@ AliMUONDigitizerV3::MergeWithSDigits(AliMUONData& outputData,
         // Then add or update the digit to the output.
         AddOrUpdateDigit(*oDigits,*sdigit);
       }
-               }   
+    }   
   }
 }