+ // Number of track dictionary arrays
+ const Int_t kNDict = AliTRDdigitsManager::kNDict;
+
+ Int_t iDict = 0;
+
+ AliTRDdataArrayI *digitsA;
+ AliTRDdataArrayI *digitsB;
+ AliTRDdataArrayI *dictionaryA[kNDict];
+ AliTRDdataArrayI *dictionaryB[kNDict];
+
+ // Get the first s-digits
+ fSDigitsManager = (AliTRDdigitsManager *) fSDigitsManagerList->First();
+ if (!fSDigitsManager) return kFALSE;
+
+ // Loop through the other sets of s-digits
+ AliTRDdigitsManager *mergeSDigitsManager;
+ mergeSDigitsManager = (AliTRDdigitsManager *)
+ fSDigitsManagerList->After(fSDigitsManager);
+
+ if (fVerbose > 0) {
+ if (mergeSDigitsManager) {
+ printf("AliTRDdigitizer::MergeSDigits -- ");
+ printf("Merge serveral input files.\n");
+ }
+ else {
+ printf("AliTRDdigitizer::MergeSDigits -- ");
+ printf("Only one input file.\n");
+ }
+ }
+
+ Int_t iMerge = 0;
+ while (mergeSDigitsManager) {
+
+ iMerge++;
+
+ // Loop through the detectors
+ for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) {
+
+ Int_t plane = fGeo->GetPlane(iDet);
+ Int_t sector = fGeo->GetSector(iDet);
+ Int_t chamber = fGeo->GetChamber(iDet);
+ Int_t nRowMax = fGeo->GetRowMax(plane,chamber,sector);
+ Int_t nColMax = fGeo->GetColMax(plane);
+ Int_t nTimeTotal = fGeo->GetTimeTotal();
+
+ // Loop through the pixels of one detector and add the signals
+ digitsA = fSDigitsManager->GetDigits(iDet);
+ digitsB = mergeSDigitsManager->GetDigits(iDet);
+ digitsA->Expand();
+ digitsB->Expand();
+ for (iDict = 0; iDict < kNDict; iDict++) {
+ dictionaryA[iDict] = fSDigitsManager->GetDictionary(iDet,iDict);
+ dictionaryB[iDict] = mergeSDigitsManager->GetDictionary(iDet,iDict);
+ dictionaryA[iDict]->Expand();
+ dictionaryB[iDict]->Expand();
+ }
+
+ if (fVerbose > 0) {
+ printf("AliTRDdigitizer::MergeSDigits -- ");
+ printf("Merge detector %d of input no.%d.\n",iDet,iMerge);
+ }
+
+ for (Int_t iRow = 0; iRow < nRowMax; iRow++ ) {
+ for (Int_t iCol = 0; iCol < nColMax; iCol++ ) {
+ for (Int_t iTime = 0; iTime < nTimeTotal; iTime++) {
+
+ // Add the amplitudes of the summable digits
+ Int_t ampA = digitsA->GetDataUnchecked(iRow,iCol,iTime);
+ Int_t ampB = digitsB->GetDataUnchecked(iRow,iCol,iTime);
+ ampA += ampB;
+ digitsA->SetDataUnchecked(iRow,iCol,iTime,ampA);
+
+ // Take only one track from each input
+ Int_t track = dictionaryB[0]->GetDataUnchecked(iRow,iCol,iTime);
+ if (iMerge < kNDict) {
+ dictionaryA[iMerge]->SetDataUnchecked(iRow,iCol,iTime,track);
+ }
+
+ }
+ }
+ }
+
+ if (fCompress) {
+ digitsA->Compress(1,0);
+ digitsB->Compress(1,0);
+ for (iDict = 0; iDict < kNDict; iDict++) {
+ dictionaryA[iDict]->Compress(1,0);
+ dictionaryB[iDict]->Compress(1,0);
+ }
+ }
+
+ }
+
+ // The next set of s-digits
+ mergeSDigitsManager = (AliTRDdigitsManager *)
+ fSDigitsManagerList->After(mergeSDigitsManager);
+
+ }
+