#include "AliRun.h"
#include "AliRunLoader.h"
-#include "AliRunDigitizer.h"
+#include "AliDigitizationInput.h"
#include "AliLoader.h"
#include "AliLog.h"
#include "AliMFTDigitizer.h"
//====================================================================================================================================================
-AliMFTDigitizer::AliMFTDigitizer(AliRunDigitizer *pRunDig):
- AliDigitizer(pRunDig),
+AliMFTDigitizer::AliMFTDigitizer(AliDigitizationInput *digInp):
+ AliDigitizer(digInp),
fNPlanes(0),
fSegmentation(0)
{
//====================================================================================================================================================
-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) {
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;
// 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");
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));
}
- 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");
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() &&
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())));