]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MFT/AliMFTDigitizer.cxx
Add new global configuration for prod shuttle.
[u/mrichter/AliRoot.git] / MFT / AliMFTDigitizer.cxx
index bd4dc64a0bb0ac9dd6bf8f1223df72980d98d84f..3e43cd13f8e95a0e2dffd84b4f9dcf16d122dbaa 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "AliRun.h"
 #include "AliRunLoader.h"
-#include "AliRunDigitizer.h"
+#include "AliDigitizationInput.h"
 #include "AliLoader.h"
 #include "AliLog.h"
 #include "AliMFTDigitizer.h"
@@ -50,8 +50,8 @@ AliMFTDigitizer::AliMFTDigitizer():
 
 //====================================================================================================================================================
 
-AliMFTDigitizer::AliMFTDigitizer(AliRunDigitizer *pRunDig):
-  AliDigitizer(pRunDig),
+AliMFTDigitizer::AliMFTDigitizer(AliDigitizationInput *digInp):
+  AliDigitizer(digInp),
   fNPlanes(0),
   fSegmentation(0)
 {
@@ -60,12 +60,12 @@ AliMFTDigitizer::AliMFTDigitizer(AliRunDigitizer *pRunDig):
 
 //====================================================================================================================================================
 
-void AliMFTDigitizer::Exec(Option_t*) {
+void AliMFTDigitizer::Digitize(Option_t*) {
 
   // This method is responsible for merging sdigits to a list of digits
 
   AliDebug(1, "************************************************************************");
-  AliDebug(1, "************************ AliMFTDigitizer::Exec *************************");
+  AliDebug(1, "************************ AliMFTDigitizer::Digitize *********************");
   AliDebug(1, "************************************************************************");
   
   if (!fSegmentation) {
@@ -75,7 +75,7 @@ void AliMFTDigitizer::Exec(Option_t*) {
 
   AliDebug(1, Form("nPlanes = %d",fNPlanes));
 
-  AliDebug(1,Form("Start with %i input(s) for event %i", fManager->GetNinputs(), fManager->GetOutputEventNr()));
+  AliDebug(1,Form("Start with %i input(s) for event %i", fDigInput->GetNinputs(), fDigInput->GetOutputEventNr()));
     
   AliRunLoader *pInRunLoader=0;
   AliLoader    *pInMFTLoader=0;
@@ -85,9 +85,9 @@ void AliMFTDigitizer::Exec(Option_t*) {
   
   // filling the arrays of sdigits...
 
-  for (Int_t iFile=0; iFile<fManager->GetNinputs(); iFile++) {
+  for (Int_t iFile=0; iFile<fDigInput->GetNinputs(); iFile++) {
     
-    pInRunLoader = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iFile));
+    pInRunLoader = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(iFile));
     pInMFTLoader = pInRunLoader->GetLoader("MFTLoader"); 
     if (!pInMFTLoader) {
       AliDebug(1,"no MFT lodader, checking in the other input \n"); 
@@ -109,7 +109,7 @@ void AliMFTDigitizer::Exec(Option_t*) {
        AliDebug(2, Form("Reading digit %03d of plane %02d (A)", iSDig, iPlane));
        AliMFTDigit *pSDig = (AliMFTDigit*) ((TClonesArray*)pInMFT->GetSDigitsList()->At(iPlane))->At(iSDig);
        AliDebug(2, Form("Reading digit %03d of plane %02d (B)", iSDig, iPlane));
-       pSDig->AddOffset2TrackID(fManager->GetMask(iFile));   // -> To be introduced for merging (since all inputs count tracks independently from 0)
+       pSDig->AddOffset2TrackID(fDigInput->GetMask(iFile));   // -> To be introduced for merging (since all inputs count tracks independently from 0)
        AliDebug(2, Form("Reading digit %03d of plane %02d (C)", iSDig, iPlane));
        new ((sDigits[iPlane])[sDigits[iPlane].GetEntries()]) AliMFTDigit(*pSDig);  
        AliDebug(2, Form("Reading digit %03d of plane %02d (D)", iSDig, iPlane));
@@ -121,7 +121,7 @@ void AliMFTDigitizer::Exec(Option_t*) {
 
   }
   
-  AliRunLoader *pOutRunLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());  // open output stream (only 1 possible)
+  AliRunLoader *pOutRunLoader = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());  // open output stream (only 1 possible)
   AliLoader    *pOutMFTLoader = pOutRunLoader->GetLoader("MFTLoader");                        
   AliRun       *pAliRun       = pOutRunLoader->GetAliRun();
   AliMFT       *pOutMFT       = (AliMFT*) pAliRun->GetDetector("MFT");      
@@ -159,17 +159,22 @@ void AliMFTDigitizer::SDigits2Digits(TClonesArray *pSDigitList, TObjArray *pDigi
     AliMFTDigit *oldDig=NULL;
     pSDigitList[iPlane].Sort();
 
+    Int_t nDetElem = fSegmentation->GetPlane(iPlane)->GetNActiveElements();
+    TClonesArray *digitsPerDetElem[fNMaxDetElemPerPlane] = {0};
+    for (Int_t iDetElem=0; iDetElem<nDetElem; iDetElem++) digitsPerDetElem[iDetElem] = new TClonesArray("AliMFTDigit");
+
     AliDebug(1,"starting loop over sdigits to create digits");
     AliDebug(1, Form("MFT plane #%02d has %d SDigits", iPlane, Int_t(pSDigitList[iPlane].GetEntries())));
 
     for (Int_t iSDig=0; iSDig<pSDigitList[iPlane].GetEntries(); iSDig++) {
 
       newDig = (AliMFTDigit*) (pSDigitList[iPlane].At(iSDig));
+      Int_t localDetElemID = fSegmentation->GetDetElemLocalID(newDig->GetDetElemID());
       Bool_t digitExists = kFALSE;
-      Int_t nDigits = myDigitList[iPlane]->GetEntries();
+      Int_t nDigits = digitsPerDetElem[localDetElemID]->GetEntries();
       
       for (Int_t iDig=0; iDig<nDigits; iDig++) {
-       oldDig = (AliMFTDigit*) (myDigitList[iPlane]->At(iDig));
+       oldDig = (AliMFTDigit*) (digitsPerDetElem[localDetElemID]->At(iDig));
        if (newDig->GetDetElemID()==oldDig->GetDetElemID() &&
            newDig->GetPixelX()==oldDig->GetPixelX() &&
            newDig->GetPixelY()==oldDig->GetPixelY() &&
@@ -179,10 +184,21 @@ void AliMFTDigitizer::SDigits2Digits(TClonesArray *pSDigitList, TObjArray *pDigi
          break;
        }
       }
+      
+      if (!digitExists) new ((*digitsPerDetElem[localDetElemID])[digitsPerDetElem[localDetElemID]->GetEntries()]) AliMFTDigit(*newDig);
+
+    }
 
-      if (!digitExists) new ((*myDigitList[iPlane])[myDigitList[iPlane]->GetEntries()]) AliMFTDigit(*newDig);
+    // Now we merge the digit lists coming from each detection element, to have an ordered final list
 
+    for (Int_t iDetElem=0; iDetElem<nDetElem; iDetElem++) {
+      for (Int_t iSDig=0; iSDig<digitsPerDetElem[iDetElem]->GetEntries(); iSDig++) {
+       newDig = (AliMFTDigit*) (digitsPerDetElem[iDetElem]->At(iSDig));
+       new ((*myDigitList[iPlane])[myDigitList[iPlane]->GetEntries()]) AliMFTDigit(*newDig);
+      }
     }
+
+    for (Int_t iDetElem=0; iDetElem<nDetElem; iDetElem++) delete digitsPerDetElem[iDetElem];
     
     AliDebug(1, Form("MFT plane #%02d has %d Digits", iPlane, Int_t(myDigitList[iPlane]->GetEntries())));