]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONDigitizer.cxx
Use of appropriate sensor depending response objects in SPD simulation
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitizer.cxx
index c48ecb34e3270710ee5b716b4e3834feffeaeab8..9ff58252882f11449419f7eba6f5ac580f95c471 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "AliMUONDigitizer.h"
 #include "AliMUONConstants.h"
-#include "AliMUONChamber.h"
+#include "AliMUONSegmentation.h"
 #include "AliMUONHitMapA1.h"
 #include "AliMUON.h"
 #include "AliMUONLoader.h"
@@ -31,7 +31,9 @@
 #include "AliMUONTransientDigit.h"
 #include "AliMUONTriggerDecision.h"
 #include "AliLog.h"
-
+#include "AliMUONGeometryTransformer.h"
+#include "AliMUONGeometryModule.h"
+#include "AliMUONGeometryStore.h"
 
 /////////////////////////////////////////////////////////////////////////////////////
 //
@@ -53,8 +55,7 @@ AliMUONDigitizer::AliMUONDigitizer() :
        fTDList(0),
        fTDCounter(0),
        fMask(0),
-       fSignal(0),
-       fDebug(0)
+       fSignal(0)
 {
 // Default constructor.
 // Initializes all pointers to NULL.
@@ -73,8 +74,7 @@ AliMUONDigitizer::AliMUONDigitizer(AliRunDigitizer* manager) :
        fTDList(0),
        fTDCounter(0),
        fMask(0),
-       fSignal(0),
-       fDebug(0)
+       fSignal(0)
 {
 // Constructor which should be used rather than the default constructor.
 // Initializes all pointers to NULL.
@@ -118,17 +118,6 @@ AliMUONDigitizer::operator=(const AliMUONDigitizer& rhs)
     
   return *this;  
 }    
-
-//------------------------------------------------------------------------
-Int_t AliMUONDigitizer::GetSegmentation()
-{
-  if (!fMUON->WhichSegmentation()) {
-      AliFatal("No Segmentation Type defined.");
-      return kFALSE;
-  } else 
-    return fMUON->WhichSegmentation();
-
-}
          
 //------------------------------------------------------------------------
 Bool_t AliMUONDigitizer::Init()
@@ -138,7 +127,7 @@ Bool_t AliMUONDigitizer::Init()
 }
 
 //------------------------------------------------------------------------
-void AliMUONDigitizer::Exec(Option_t* option)
+void AliMUONDigitizer::Exec(Option_t* /*option*/)
 {
 // The main work loop starts here. 
 // The digitization process is broken up into two steps: 
@@ -148,7 +137,6 @@ void AliMUONDigitizer::Exec(Option_t* option)
 //    stream. Done in CreateDigits()
 
        AliDebug(1, "Running digitiser.");
-       ParseOptions(option);
 
        if (fManager->GetNinputs() == 0)
        {
@@ -218,7 +206,10 @@ void AliMUONDigitizer::UpdateTransientDigit(AliMUONTransientDigit* mTD)
 
        AliDebug(4,Form( "Updating transient digit 0x%X", (void*)mTD));
        // Choosing the maping of the cathode plane of the chamber:
-       Int_t iNchCpl= mTD->Chamber() + (mTD->Cathode()-1) * AliMUONConstants::NCh();
+       Int_t detElemId =  mTD->DetElemId();
+
+       Int_t iNchCpl= fNDetElemId[detElemId] + (mTD->Cathode()-1) * AliMUONConstants::NDetElem();
+
        AliMUONTransientDigit *pdigit = 
                static_cast<AliMUONTransientDigit*>( fHitMap[iNchCpl]->GetHit(mTD->PadX(),mTD->PadY()) );
 
@@ -251,10 +242,15 @@ void AliMUONDigitizer::AddTransientDigit(AliMUONTransientDigit* mTD)
 
        AliDebug(4,Form( "Adding transient digit 0x%X", (void*)mTD));
        // Choosing the maping of the cathode plane of the chamber:
-       Int_t iNchCpl= mTD->Chamber() + (mTD->Cathode()-1) * AliMUONConstants::NCh();
+
+       Int_t detElemId =  mTD->DetElemId();
+       Int_t iNchCpl= fNDetElemId[detElemId] + (mTD->Cathode()-1) * AliMUONConstants::NDetElem();
+
        fTDList->AddAtAndExpand(mTD, fTDCounter);
-       fHitMap[iNchCpl]->SetHit( mTD->PadX(), mTD->PadY(), fTDCounter);
-       fTDCounter++;
+       if (iNchCpl>-1 && iNchCpl<2*AliMUONConstants::NDetElem()) {
+         fHitMap[iNchCpl]->SetHit( mTD->PadX(), mTD->PadY(), fTDCounter);
+         fTDCounter++;
+       }
 }
 
 //------------------------------------------------------------------------
@@ -265,8 +261,14 @@ Bool_t AliMUONDigitizer::ExistTransientDigit(AliMUONTransientDigit* mTD)
 // as mTD. If yes then kTRUE is returned else kFASLE is returned.
 
        // Choosing the maping of the cathode plane of the chamber:
-       Int_t iNchCpl= mTD->Chamber() + (mTD->Cathode()-1) * AliMUONConstants::NCh();
-       return( fHitMap[iNchCpl]->TestHit(mTD->PadX(), mTD->PadY()) );
+       Int_t detElemId =  mTD->DetElemId();
+
+       Int_t iNchCpl= fNDetElemId[detElemId] + (mTD->Cathode()-1) *AliMUONConstants::NDetElem() ;
+
+       //      Int_t iNchCpl= mTD->Chamber() + (mTD->Cathode()-1) * AliMUONConstants::NCh();
+       if (iNchCpl>-1 && iNchCpl<2*AliMUONConstants::NDetElem())
+         return( fHitMap[iNchCpl]->TestHit(mTD->PadX(), mTD->PadY()) );
+       else return kFALSE;
 }
 
 //-----------------------------------------------------------------------
@@ -277,7 +279,7 @@ void AliMUONDigitizer::CreateDigits()
 
        fTDList->Sort(); // sort by idDE
         AliDebug(2, "Creating digits...");
-       for (Int_t icat = 0; icat < 2; icat++) {
+       //      for (Int_t icat = 0; icat < 2; icat++) {
 
           Int_t digitindex[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
@@ -291,7 +293,7 @@ void AliMUONDigitizer::CreateDigits()
                        
            // Must be the same cathode, otherwise we will fill a mixture
            // of digits from both cathodes.
-           if (icat != td->Cathode() - 1) continue;
+           //if (icat != td->Cathode() - 1) continue;
                        
            AliDebug(3,Form( "Creating digit from transient digit 0x%X", (void*)td));
 
@@ -300,13 +302,14 @@ void AliMUONDigitizer::CreateDigits()
            if (q > 0) AddDigit(td, q, digitindex[td->Chamber()]++);
          }
          FillOutputData();
-       }
+         //    }
+         fTDCounter = 0;
 }
 
 //------------------------------------------------------------------------
 void AliMUONDigitizer::AddDigit(
                AliMUONTransientDigit* td, Int_t responseCharge,
-               const Int_t digitindex
+               Int_t digitindex
        )
 {
 // Prepares the digits, track and charge arrays in preparation for a call to
@@ -328,10 +331,7 @@ void AliMUONDigitizer::AddDigit(
        digits[3] = responseCharge;
        digits[4] = td->Physics();
        digits[5] = td->Hit();
-       if (GetSegmentation() == 1)
-         digits[6] = 0;
-       else
-         digits[6] =  td->DetElemId();
+       digits[6] =  td->DetElemId();
 
        Int_t nptracks = td->GetNTracks();
        if (nptracks > kMAXTRACKS) {
@@ -467,26 +467,6 @@ Bool_t  AliMUONDigitizer::FetchTriggerPointer(AliMUONLoader* loader)
   
   return kTRUE;
 }
-//------------------------------------------------------------------------
-void AliMUONDigitizer::ParseOptions(Option_t* options)
-{
-// Called by the Exec method. ParseOptions should parse the option string given to the Exec method.
-// 
-// The following options are defined:
-//     "debug" - Sets the debug level to 99, which will show all debug messages.
-//     "deb"   - Same as "debug", implemented for backward comparability.
-//
-// If an invalid option is specified it is simply ignored.
-
-       TString optionString = options;
-       if (optionString.Data() == "debug" || 
-               optionString.Data() == "deb"   // maintained for compatability.
-          )
-       {
-               AliInfo("Called with option \"debug\".");
-               SetDebug(99);
-       }
-}
 
 //------------------------------------------------------------------------
 void AliMUONDigitizer::InitArrays()
@@ -504,38 +484,40 @@ void AliMUONDigitizer::InitArrays()
        
     // Array of pointer of the AliMUONHitMapA1:
     //  two HitMaps per chamber, or one HitMap per cahtode plane
-    fHitMap = new AliMUONHitMapA1* [2*AliMUONConstants::NCh()];
-
-    if (fMUON->WhichSegmentation() == 1) {
-      // Loop over chambers for the definition AliMUONHitMap
-      for (Int_t i = 0; i < AliMUONConstants::NCh(); i++)  {
-
-       AliDebug(4,Form( "Creating hit map for chamber %d, cathode 1.", i+1));
-       AliMUONChamber* chamber = &(fMUON->Chamber(i));
-       AliSegmentation* c1Segmentation = chamber->SegmentationModel(1); // Cathode plane 1
-       fHitMap[i] = new AliMUONHitMapA1(c1Segmentation, fTDList);
-       AliDebug(4,Form( "Creating hit map for chamber %d, cathode 2.", i+1));
-       AliSegmentation* c2Segmentation = chamber->SegmentationModel(2); // Cathode plane 2
-       fHitMap[i+AliMUONConstants::NCh()] = new AliMUONHitMapA1(c2Segmentation, fTDList);
-      }
+    fHitMap = new AliMUONHitMapA1* [2*AliMUONConstants::NDetElem()];
+    for (Int_t i=0; i<2*AliMUONConstants::NDetElem(); i++) fHitMap[i] = 0x0;
+
+    Int_t k = 0;
+    Int_t idDE;
+
+    for (Int_t i = 0; i < AliMUONConstants::NCh(); i++) {
 
-    } else {
-      for (Int_t i = 0; i < AliMUONConstants::NCh(); i++) {
 
-       Int_t idDE = 100*(i+1);// central DE = max # of pads ?
-       if (i == 4 || i == 5) //St3
-         idDE += 4;
+      AliDebug(4,Form( "Creating hit map for chamber %d, cathode 1.", i+1));
+      AliMUONSegmentation* segmentation = fMUON->GetSegmentation();
+      AliMUONGeometrySegmentation* c1Segmentation 
+        = segmentation->GetModuleSegmentation(i, 0); // Cathode plane 1
+      AliDebug(4,Form( "Creating hit map for chamber %d, cathode 2.", i+1));
+      AliMUONGeometrySegmentation* c2Segmentation 
+        = segmentation->GetModuleSegmentation(i, 1); // Cathode plane 2
 
-       if (i > 5)
-         idDE += 5;// DE for max # of pads in St45 and Trigger Station
+      const AliMUONGeometryTransformer* kGeometryTransformer 
+        = fMUON->GetGeometryTransformer();
+      AliMUONGeometryStore* detElements 
+        = kGeometryTransformer->GetModuleTransformer(i)->GetDetElementStore();
+    
+
+    // Loop over detection elements
+      for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
+       
+       idDE = detElements->GetEntry(j)->GetUniqueID();
+       fNDetElemId[idDE] = k;
 
-       AliDebug(4,Form( "Creating hit map for chamber %d, cathode 1.", i+1));
-       AliMUONChamber* chamber = &(fMUON->Chamber(i));
-       AliMUONGeometrySegmentation* c1Segmentation = chamber->SegmentationModel2(1); // Cathode plane 1
-       fHitMap[i] = new AliMUONHitMapA1(idDE,c1Segmentation, fTDList); 
-       AliDebug(4,Form( "Creating hit map for chamber %d, cathode 2.", i+1));
-       AliMUONGeometrySegmentation* c2Segmentation = chamber->SegmentationModel2(2); // Cathode plane 2
-       fHitMap[i+AliMUONConstants::NCh()] = new AliMUONHitMapA1(idDE,c2Segmentation, fTDList);
+       fHitMap[k] = new AliMUONHitMapA1(idDE,c1Segmentation, fTDList); 
+     
+       fHitMap[k+AliMUONConstants::NDetElem()] = new AliMUONHitMapA1(idDE,c2Segmentation, fTDList);
+       k++;
       }
     }
 }
@@ -545,10 +527,7 @@ void AliMUONDigitizer::CleanupArrays()
 // The arrays fTDList and fHitMap are deleted and the pointers set to NULL.
 
        AliDebug(2, "Deleting internal arrays.");
-       for(Int_t i = 0; i < 2*AliMUONConstants::NCh(); i++)
-       {
-               AliDebug(4,Form( "Deleting hit map for chamber %d, cathode %d.", 
-                       i%AliMUONConstants::NCh()+1, i/AliMUONConstants::NCh()+1));
+       for(Int_t i = 0; i < 2*AliMUONConstants::NDetElem(); i++) {
                delete fHitMap[i];
        }
        delete [] fHitMap;