+//_____________________________________________________________________________
+void AliTRDtrack::CookdEdx(Double_t low, Double_t up) {
+ //-----------------------------------------------------------------
+ // Calculates dE/dX within the "low" and "up" cuts.
+ //-----------------------------------------------------------------
+ Int_t i;
+ Int_t nc=GetNclusters();
+
+ Float_t sorted[200];
+ for (i=0; i<200; i++) sorted[i]=fdQdl[i];
+
+ Int_t swap;
+ do {
+ swap=0;
+ for (i=0; i<nc-1; i++) {
+ if (sorted[i]<=sorted[i+1]) continue;
+ Float_t tmp=sorted[i];
+ sorted[i]=sorted[i+1]; sorted[i+1]=tmp;
+ swap++;
+ }
+ } while (swap);
+
+ Int_t nl=Int_t(low*nc), nu=Int_t(up*nc);
+ Float_t dedx=0;
+ for (i=nl; i<=nu; i++) dedx += sorted[i];
+ dedx /= (nu-nl+1);
+ SetdEdx(dedx);
+}
+
+
+