+void AliSignal::AddTrack(AliTrack& t,Int_t mode)
+{
+// Relate an AliTrack object to this signal.
+// Only the pointer values are stored for (backward) reference, meaning
+// that the tracks of which the pointers are stored are NOT owned
+// by the AliSignal object.
+//
+// mode = 0 : Only the reference to the specified track is stored in
+// the current signal, without storing the (backward) reference
+// to this signal into the AliTrack structure.
+// 1 : The (backward) reference to the current signal is also automatically
+// stored into the AliTrack (or derived) object specified in the
+// input argument.
+//
+// The default is mode=1.
+
+ if (!fTracks) fTracks=new TObjArray(1);
+
+ // Check if this track is already stored for this signal
+ Int_t ntk=GetNtracks();
+ for (Int_t i=0; i<ntk; i++)
+ {
+ if (&t==fTracks->At(i)) return;
+ }
+
+ fTracks->Add(&t);
+ if (mode==1) t.AddSignal(*this,0);
+}
+///////////////////////////////////////////////////////////////////////////
+void AliSignal::RemoveTrack(AliTrack& t,Int_t mode)
+{
+// Remove related AliTrack object from this signal.
+// Also all references (if any) to this track in the slot links area
+// are removed.
+//
+// mode = 0 : All references to the specified track are removed from
+// the current signal, without removing the (backward) reference
+// to this signal from the AliTrack structure.
+// 1 : The (backward) reference to the current signal is also automatically
+// removed from the AliTrack (or derived) object specified in the
+// input argument.
+//
+// The default is mode=1.
+
+ if (fTracks)
+ {
+ AliTrack* test=(AliTrack*)fTracks->Remove(&t);
+ if (test) fTracks->Compress();
+ }
+
+ ResetLinks(&t);
+
+ if (mode==1) t.RemoveSignal(*this,0);
+}
+///////////////////////////////////////////////////////////////////////////
+void AliSignal::RemoveTracks(Int_t mode)
+{
+// Remove all related AliTrack objects from this signal.
+// Also all references (if any) to the related tracks in the slot links area
+// are removed.
+//
+// mode = 0 : All track references are removed from the current signal,
+// without removing the (backward) references to this signal from
+// the corresponding AliTrack objects.
+// 1 : The (backward) references to the current signal are also automatically
+// removed from the corresponding AliTrack (or derived) objects.
+//
+// The default is mode=1.
+
+ if (!fTracks) return;
+
+ Int_t ntk=GetNtracks();
+ for (Int_t i=0; i<ntk; i++)
+ {
+ AliTrack* tx=(AliTrack*)fTracks->At(i);
+ if (tx)
+ {
+ ResetLinks(tx);
+ if (mode==1) tx->RemoveSignal(*this,0);
+ }
+ }
+
+ delete fTracks;
+ fTracks=0;
+}
+///////////////////////////////////////////////////////////////////////////
+Int_t AliSignal::GetNtracks(AliTrack* t) const
+{
+// Provide the number of related AliTracks.
+// In case an AliTrack pointer is specified as input argument,
+// the number returned will be the number of occurrences (i.e. 0 or 1)
+// for that specified track.
+// By default t=0, which implies that just the number of all associated
+// tracks will be returned.
+
+ if (!fTracks) return 0;
+
+ Int_t ntk=fTracks->GetEntries();
+
+ if (!t) return ntk;
+
+ for (Int_t i=0; i<ntk; i++)
+ {
+ AliTrack* tx=(AliTrack*)fTracks->At(i);
+ if (tx==t) return 1;
+ }
+
+ return 0;
+}
+///////////////////////////////////////////////////////////////////////////
+AliTrack* AliSignal::GetTrack(Int_t j) const
+{
+// Provide the related AliTrack number j.
+// Note : j=1 denotes the first track.
+
+ if (!fTracks) return 0;
+
+ if ((j >= 1) && (j <= GetNtracks()))
+ {
+ return (AliTrack*)fTracks->At(j-1);
+ }
+ else
+ {
+ cout << " *AliSignal* track number : " << j << " out of range."
+ << " Ntk = " << GetNtracks() << endl;
+ return 0;
+ }
+}
+///////////////////////////////////////////////////////////////////////////
+AliTrack* AliSignal::GetIdTrack(Int_t id) const
+{
+// Return the track with user identifier "id" of this signal
+ if (!fTracks) return 0;
+
+ AliTrack* tx=0;
+ for (Int_t i=0; i<GetNtracks(); i++)
+ {
+ tx=(AliTrack*)fTracks->At(i);
+ if (id == tx->GetId()) return tx;
+ }
+ return 0; // No matching id found
+}
+///////////////////////////////////////////////////////////////////////////