re-activate contrib code
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackGTU.cxx
index 2776e3b..da37be0 100644 (file)
@@ -107,6 +107,36 @@ AliTRDtrackGTU& AliTRDtrackGTU::operator=(const AliTRDtrackGTU &rhs)
   return *this;
 }
 
+AliTRDtrackGTU& AliTRDtrackGTU::operator=(const AliESDTrdTrack &rhs)
+{
+  if ((void*) &rhs != (void*) this) {
+    TObject::operator=(rhs);
+    fStack         = rhs.GetStack();
+    fSector        = rhs.GetSector();
+    fPID           = rhs.GetPID();
+    fTrackletMask  = rhs.GetLayerMask();
+    fNTracklets    = 0;
+    fRefLayerIdx   = -1;
+    fZChannel      = -1;
+    fZSubChannel   = -1;
+    fA             = rhs.GetA();
+    fB             = rhs.GetB();
+    fC             = rhs.GetC();
+    fLabel         = rhs.GetLabel();
+    for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++) {
+      AliTRDtrackletGTU *trkl = new ((*fTracklets)[iTracklet]) AliTRDtrackletGTU();
+      if (fTrackletMask & (1 << iTracklet)) {
+       ++fNTracklets;
+       trkl->SetIndex(rhs.GetTrackletIndex(iTracklet));
+      }
+      else
+       trkl->SetIndex(-1);
+    }
+  }
+
+  return *this;
+}
+
 AliTRDtrackGTU::~AliTRDtrackGTU()
 {
 // dtor
@@ -170,10 +200,20 @@ Int_t AliTRDtrackGTU::GetZSubChannel()
 // returns the z-subchannel
 
   if (fZSubChannel < 0) {
-    for (Int_t layer = 0; layer < AliTRDgtuParam::GetNLayers(); layer++)
-    {
-      if (IsTrackletInLayer(layer))
-       fZSubChannel = ((AliTRDtrackletGTU*) (*fTracklets)[layer])->GetSubChannel(GetZChannel());
+    for (Int_t layer = 0; layer < AliTRDgtuParam::GetNLayers(); layer++) {
+      if (IsTrackletInLayer(layer)) {
+       AliTRDtrackletGTU *trkl = (AliTRDtrackletGTU*) (*fTracklets)[layer];
+       if (trkl) {
+         if ((fZSubChannel > -1) &&
+             (fZSubChannel != trkl->GetSubChannel(GetZChannel())))
+           AliError(Form("found inconsistent z-subchannels: track = %i/%i, trkl = %i",
+                         GetZChannel(), fZSubChannel, trkl->GetSubChannel(GetZChannel())));
+         fZSubChannel = trkl->GetSubChannel(GetZChannel());
+       }
+       else {
+         AliError("no tracklet where one should be according to layer mask");
+       }
+      }
     }
   }
   return fZSubChannel;
@@ -197,9 +237,10 @@ AliESDTrdTrack* AliTRDtrackGTU::CreateTrdTrack() const
 
   AliESDTrdTrack *trk = new AliESDTrdTrack();
   trk->SetA((Int_t) fA);
+  trk->SetB(TMath::Nint(128. * fB));
+  trk->SetC(TMath::Nint(256. * fC));
   trk->SetLayerMask(fTrackletMask);
   trk->SetPID(fPID);
-  trk->SetB((Int_t) fB);
   trk->SetStack(fStack);
   trk->SetSector(fSector);
   trk->SetLabel(fLabel);
@@ -247,7 +288,7 @@ Bool_t AliTRDtrackGTU::CookLabel()
     }
   }
 
-  Int_t index[16];
+  Int_t index[32];
   TMath::Sort(6, count, index);
   fLabel = label[index[0]];