+//_____________________________________________________________________________
+void AliTRDtrack::CookdEdxTimBin(const Int_t/* tid*/)
+{
+ //
+ // Set fdEdxPlane and fTimBinPlane and also get the
+ // Time bin for Max. Cluster
+ //
+ // Authors:
+ // Prashant Shukla (shukla@physi.uni-heidelberg.de)
+ // Alexandru Bercuci (A.Bercuci@gsi.de)
+ //
+
+ // Max charge in chamber
+ Double_t maxcharge[kNplane];
+ // Number of clusters attached to track per chamber and slice
+ Int_t nCluster[kNplane][AliTRDCalPID::kNSlicesLQ];
+ // Number of time bins in chamber
+ Int_t ntb = AliTRDcalibDB::Instance()->GetNumberOfTimeBinsDCS();
+ Int_t plane; // Plane of current cluster
+ Int_t tb; // Time bin of current cluster
+ Int_t slice; // Current slice
+ AliTRDcluster *cluster = 0x0; // Pointer to current cluster
+
+ // Reset class and local counters/variables
+ for (Int_t iPlane = 0; iPlane < kNplane; iPlane++) {
+ fTimBinPlane[iPlane] = -1;
+ maxcharge[iPlane] = 0.0;
+ for (Int_t iSlice = 0; iSlice < AliTRDCalPID::kNSlicesLQ; iSlice++) {
+ fdEdxPlane[iPlane][iSlice] = 0.0;
+ nCluster[iPlane][iSlice] = 0;
+ }
+ }
+
+ // Start looping over clusters attached to this track
+ for (Int_t iClus = 0; iClus < GetNumberOfClusters(); iClus++) {
+
+ cluster = fClusters[iClus]; //(AliTRDcluster*)tracker->GetCluster(fIndex[iClus]);
+ if (!cluster) continue;
+
+ // Read info from current cluster
+ plane = AliTRDgeometry::GetLayer(cluster->GetDetector());
+ if (plane < 0 || plane >= kNplane) {
+ AliError(Form("Wrong plane %d", plane));
+ continue;
+ }
+
+ tb = cluster->GetLocalTimeBin();
+ if ((tb < 0) || (tb >= ntb)) {
+ AliWarning(Form("time bin < 0 or > %d in cluster %d", ntb, iClus));
+ AliInfo(Form("dQ/dl %f", fdQdl[iClus]));
+ continue;
+ }
+
+ slice = tb * AliTRDCalPID::kNSlicesLQ / ntb;
+
+ fdEdxPlane[plane][slice] += fdQdl[iClus];
+ if (fdQdl[iClus] > maxcharge[plane]) {
+ maxcharge[plane] = fdQdl[iClus];
+ fTimBinPlane[plane] = tb;
+ }