]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONDigitizerV3.cxx
Small bug fix (which should have no influence online)
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitizerV3.cxx
index f61e3294493869bb60a0ad2e27162361be10cf95..b10a0b6e1728afe1b19a1dd7c877506b4b6c9b18 100644 (file)
@@ -35,7 +35,6 @@
 #include "AliMpConstants.h"
 #include "AliMpDEIterator.h"
 #include "AliMpDEManager.h"
-#include "AliMpIntPair.h"
 #include "AliMpPad.h"
 #include "AliMpStationType.h"
 #include "AliMpVSegmentation.h"
@@ -104,7 +103,8 @@ fGenerateNoisyDigits(generateNoisyDigits),
 fLogger(new AliMUONLogger(1000)),
 fTriggerStore(new AliMUONTriggerStoreV1),
 fDigitStore(0x0),
-fOutputDigitStore(0x0)
+fOutputDigitStore(0x0),
+fInputDigitStore(0x0)
 {
   /// Ctor.
 
@@ -125,7 +125,8 @@ AliMUONDigitizerV3::~AliMUONDigitizerV3()
   delete fTriggerStore;
   delete fDigitStore;
   delete fOutputDigitStore;
-   
+  delete fInputDigitStore;
+  
   AliInfo("Summary of messages");
   fLogger->Print();
   
@@ -162,6 +163,16 @@ AliMUONDigitizerV3::ApplyResponseToTrackerDigit(AliMUONVDigit& digit, Bool_t add
     return;    
   }
   
+  Int_t manuChannel = digit.ManuChannel();
+  
+  if ( pedestal->ValueAsFloat(manuChannel,0) == AliMUONVCalibParam::InvalidFloatValue() ||
+      pedestal->ValueAsFloat(manuChannel,1) == AliMUONVCalibParam::InvalidFloatValue() )
+  {
+    // protection against invalid pedestal value
+    digit.SetADC(0);
+    return;
+  }
+      
   AliMUONVCalibParam* gain = fCalibrationData->Gains(detElemId,manuId);
   if (!gain)
   {
@@ -172,8 +183,6 @@ AliMUONDigitizerV3::ApplyResponseToTrackerDigit(AliMUONVDigit& digit, Bool_t add
     return;        
   }    
 
-  Int_t manuChannel = digit.ManuChannel();
-  
   Int_t adc = DecalibrateTrackerDigit(*pedestal,*gain,manuChannel,charge,addNoise,
                                       digit.IsNoiseOnly());
   
@@ -327,6 +336,43 @@ AliMUONDigitizerV3::DecalibrateTrackerDigit(const AliMUONVCalibParam& pedestals,
   return adc;
 }
 
+//_____________________________________________________________________________
+void
+AliMUONDigitizerV3::CreateInputDigitStore()
+{
+  /// Create an input digit store, and check that all input files
+  /// actually contains the same type of AliMUONVDigitStore
+  
+  fInputDigitStore = 0x0;
+  
+  for ( Int_t iFile = 0; iFile < fManager->GetNinputs(); ++iFile )
+  {    
+    AliLoader* inputLoader = GetLoader(fManager->GetInputFolderName(iFile));
+    
+    inputLoader->LoadSDigits("READ");
+    
+    TTree* iTreeS = inputLoader->TreeS();
+    if (!iTreeS)
+    {
+      AliFatal(Form("Could not get access to input file #%d",iFile));
+    }
+    
+    AliMUONVDigitStore* inputStore = AliMUONVDigitStore::Create(*iTreeS);
+    
+    if (!fInputDigitStore)
+    {
+      fInputDigitStore = inputStore;
+    }
+    else
+    {
+      if ( inputStore->IsA() != fInputDigitStore->IsA() )
+      {
+        AliFatal("Got different types of AliMUONVDigitStore here. Please implement me.");
+      }
+    }
+  }
+}
+
 //_____________________________________________________________________________
 void
 AliMUONDigitizerV3::Exec(Option_t*)
@@ -380,17 +426,20 @@ AliMUONDigitizerV3::Exec(Option_t*)
     {
       AliFatal(Form("Could not get access to input file #%d",iFile));
     }
-    
-    AliMUONVDigitStore* inputStore = AliMUONVDigitStore::Create(*iTreeS);
-    inputStore->Connect(*iTreeS);
+
+    if (!fInputDigitStore)
+    {
+      CreateInputDigitStore();
+    }
+    fInputDigitStore->Connect(*iTreeS);
     
     iTreeS->GetEvent(0);
     
-    MergeWithSDigits(fDigitStore,*inputStore,fManager->GetMask(iFile));
+    MergeWithSDigits(fDigitStore,*fInputDigitStore,fManager->GetMask(iFile));
 
     inputLoader->UnloadSDigits();
     
-    delete inputStore;
+    fInputDigitStore->Clear();
   }
   
   // At this point, we do have digit arrays (one per chamber) which contains 
@@ -509,11 +558,11 @@ AliMUONDigitizerV3::GenerateNoisyDigitsForOneCathode(AliMUONVDigitStore& digitSt
     do {
       ix = gRandom->Integer(maxIx+1);
       iy = gRandom->Integer(maxIy+1);
-      pad = seg->PadByIndices(AliMpIntPair(ix,iy),kFALSE);
+      pad = seg->PadByIndices(ix,iy,kFALSE);
     } while ( !pad.IsValid() );
 
-    Int_t manuId = pad.GetLocation().GetFirst();
-    Int_t manuChannel = pad.GetLocation().GetSecond();    
+    Int_t manuId = pad.GetManuId();
+    Int_t manuChannel = pad.GetManuChannel();    
 
     AliMUONVCalibParam* pedestals = fCalibrationData->Pedestals(detElemId,manuId);
     
@@ -545,11 +594,6 @@ AliMUONDigitizerV3::GenerateNoisyDigitsForOneCathode(AliMUONVDigitStore& digitSt
         fLogger->Log("Added noiseOnly digit");
       }
     }
-    else
-    {
-      AliError("Pure noise below threshold. This should not happen. Not adding "
-               "this digit.");
-    }
     delete d;
   }
 }
@@ -603,8 +647,8 @@ AliMUONDigitizerV3::GenerateNoisyDigitsForTrigger(AliMUONVDigitStore& digitStore
                const AliMpVSegmentation* seg
                    = AliMpSegmentation::Instance()->GetMpSegmentation(currDetElemId,AliMp::GetCathodType(0));
                if (!seg) continue;
-               Float_t deltax = seg->Dimensions().X();
-               Float_t deltay = seg->Dimensions().Y();
+               Float_t deltax = seg->GetDimensionX();
+               Float_t deltay = seg->GetDimensionY();
                GetTransformer()->Local2Global(currDetElemId, -deltax, -deltay, 0, xg01, yg01, zg);
                GetTransformer()->Local2Global(currDetElemId,  deltax,  deltay, 0, xg02, yg02, zg);
                Float_t xg1 = xg01, xg2 = xg02, yg1 = yg01, yg2 = yg02;
@@ -619,7 +663,7 @@ AliMUONDigitizerV3::GenerateNoisyDigitsForTrigger(AliMUONVDigitStore& digitStore
                if(gx>=xg1 && gx<=xg2 && gy>=yg1 && gy<=yg2){
                    detElemId = currDetElemId;
                    GetTransformer()->Global2Local(detElemId, gx, gy, 0, x, y, z);
-                   pad[0] = seg->PadByPosition(TVector2(x,y),kFALSE);
+                   pad[0] = seg->PadByPosition(x,y,kFALSE);
                    if(!pad[0].IsValid()) continue;
                    isOk = kTRUE;
                    break;
@@ -629,14 +673,14 @@ AliMUONDigitizerV3::GenerateNoisyDigitsForTrigger(AliMUONVDigitStore& digitStore
 
        const AliMpVSegmentation* seg1
            = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(1));
-       pad[1] = seg1->PadByPosition(TVector2(x,y),kFALSE);
+       pad[1] = seg1->PadByPosition(x,y,kFALSE);
 
        for ( Int_t cathode = 0; cathode < 2; ++cathode ){
-         Int_t manuId = pad[cathode].GetLocation(0).GetFirst();
-         Int_t manuChannel = pad[cathode].GetLocation(0).GetSecond();    
+         Int_t manuId = pad[cathode].GetLocalBoardId(0);
+         Int_t manuChannel = pad[cathode].GetLocalBoardChannel(0);    
          d[cathode] = digitStore.CreateDigit(detElemId,manuId,manuChannel,cathode);
-         ix = pad[cathode].GetIndices().GetFirst();
-         iy = pad[cathode].GetIndices().GetSecond();
+         ix = pad[cathode].GetIx();
+         iy = pad[cathode].GetIy();
          d[cathode]->SetPadXY(ix,iy);
          //d[cathode].SetSignal(1);
          //d[cathode].SetPhysicsSignal(0);