+ Double_t clusterCharge = clusterSignal[0]
+ + clusterSignal[1]
+ + clusterSignal[2];
+
+ // The position of the cluster
+ clusterPads[0] = row + 0.5;
+ // Take the shift of the additional time bins into account
+ clusterPads[2] = time + 0.5;
+
+ if (recParam->LUTOn()) {
+ // Calculate the position of the cluster by using the
+ // lookup table method
+ clusterPads[1] = recParam->LUTposition(iplan,clusterSignal[0]
+ ,clusterSignal[1]
+ ,clusterSignal[2]);
+ }
+ else {
+ // Calculate the position of the cluster by using the
+ // center of gravity method
+ for (Int_t i = 0; i < kNsig; i++) {
+ padSignal[i] = 0.0;
+ }
+ padSignal[2] = TMath::Abs(digitsOut->GetDataUnchecked(row,col ,time)); // Central pad
+ padSignal[1] = TMath::Abs(digitsOut->GetDataUnchecked(row,col-1,time)); // Left pad
+ padSignal[3] = TMath::Abs(digitsOut->GetDataUnchecked(row,col+1,time)); // Right pad
+ if ((col > 2) &&
+ (TMath::Abs(digitsOut->GetDataUnchecked(row,col-2,time)) < padSignal[1])) {
+ padSignal[0] = TMath::Abs(digitsOut->GetDataUnchecked(row,col-2,time));
+ }
+ if ((col < nColMax - 3) &&
+ (TMath::Abs(digitsOut->GetDataUnchecked(row,col+2,time)) < padSignal[3])) {
+ padSignal[4] = TMath::Abs(digitsOut->GetDataUnchecked(row,col+2,time));
+ }
+ clusterPads[1] = GetCOG(padSignal);
+ }
+
+ Double_t q0 = clusterSignal[0];
+ Double_t q1 = clusterSignal[1];
+ Double_t q2 = clusterSignal[2];
+ Double_t clusterSigmaY2 = (q1 * (q0 + q2) + 4.0 * q0 * q2)
+ / (clusterCharge*clusterCharge);
+
+ //
+ // Calculate the position and the error
+ //
+
+ // Correct for t0 (sum of chamber and pad wise values !!!)
+ Float_t calT0ROCValue = calT0ROC->GetValue(col,row);
+ Char_t clusterTimeBin = ((Char_t) TMath::Nint(time - (calT0DetValue + calT0ROCValue)));
+ Double_t colSize = padPlane->GetColSize(col);
+ Double_t rowSize = padPlane->GetRowSize(row);
+
+ Float_t clusterPos[3];
+ clusterPos[0] = padPlane->GetColPos(col) - (clusterPads[1] + 0.5) * colSize;
+ clusterPos[1] = padPlane->GetRowPos(row) - 0.5 * rowSize;
+ clusterPos[2] = CalcXposFromTimebin(clusterPads[2],idet,col,row);
+ Float_t clusterSig[2];
+ clusterSig[0] = (clusterSigmaY2 + 1.0/12.0) * colSize*colSize;
+ clusterSig[1] = rowSize * rowSize / 12.0;
+
+ // Store the amplitudes of the pads in the cluster for later analysis
+ Short_t signals[7] = { 0, 0, 0, 0, 0, 0, 0 };
+ for (Int_t jPad = col-3; jPad <= col+3; jPad++) {
+ if ((jPad < 0) ||
+ (jPad >= nColMax-1)) {
+ continue;
+ }
+ signals[jPad-col+3] = TMath::Nint(TMath::Abs(digitsOut->GetDataUnchecked(row,jPad,time)));
+ }
+
+ // Add the cluster to the output array
+ // The track indices will be stored later
+ AliTRDcluster *cluster = new AliTRDcluster(idet
+ ,clusterCharge
+ ,clusterPos
+ ,clusterSig
+ ,0x0
+ ,((Char_t) nPadCount)
+ ,signals
+ ,((UChar_t) col)
+ ,clusterTimeBin
+ ,clusterPads[1]
+ ,volid);
+ // Temporarily store the row, column and time bin of the center pad
+ // Used to later on assign the track indices
+ cluster->SetLabel( row,0);
+ cluster->SetLabel( col,1);
+ cluster->SetLabel(time,2);
+ RecPoints()->Add(cluster);
+
+ // Store the index of the first cluster in the current ROC
+ if (firstClusterROC < 0) {
+ firstClusterROC = RecPoints()->GetEntriesFast() - 1;
+ }
+ // Count the number of cluster in the current ROC
+ nClusterROC++;
+
+ } // if: Maximum found ?
+
+ } // loop: pad columns
+ } // loop: time bins
+ } // loop: pad rows
+
+ delete digitsOut;
+
+ //
+ // Add the track indices to the found clusters
+ //
+
+ // Temporary array to collect the track indices
+ Int_t *idxTracks = new Int_t[kNtrack*nClusterROC];
+
+ // Loop through the dictionary arrays one-by-one
+ // to keep memory consumption low
+ for (Int_t iDict = 0; iDict < kNdict; iDict++) {
+
+ tracksIn = fDigitsManager->GetDictionary(idet,iDict);
+ tracksIn->Expand();
+
+ // Loop though the clusters found in this ROC
+ for (iClusterROC = 0; iClusterROC < nClusterROC; iClusterROC++) {
+
+ AliTRDcluster *cluster = (AliTRDcluster *)
+ RecPoints()->UncheckedAt(firstClusterROC+iClusterROC);
+ row = cluster->GetLabel(0);
+ col = cluster->GetLabel(1);
+ time = cluster->GetLabel(2);
+
+ for (iPad = 0; iPad < kNclus; iPad++) {
+ Int_t iPadCol = col - 1 + iPad;
+ Int_t index = tracksIn->GetDataUnchecked(row,iPadCol,time) - 1;
+ idxTracks[3*iPad+iDict + iClusterROC*kNtrack] = index;
+ }