]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTrackHit.cxx
e94748d18663b7ba07e11147673ddbed0aebce5e
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackHit.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////
19 //
20 // Reconstructed track hit
21 // in
22 // ALICE
23 // dimuon
24 // spectrometer
25 //
26 ///////////////////////////////////////////////////////
27
28 #include "AliMUONTrackHit.h" 
29 #include "AliMUONHitForRec.h" 
30
31 ClassImp(AliMUONTrackHit) // Class implementation in ROOT context
32
33   //__________________________________________________________________________
34 AliMUONTrackHit::AliMUONTrackHit()
35   : TObject()
36 {
37   // Default constructor
38   fHitForRecPtr = 0;
39   fNextTrackHitWithSameHitForRec = 0;
40   fPrevTrackHitWithSameHitForRec = 0;
41 }
42   //__________________________________________________________________________
43 AliMUONTrackHit::AliMUONTrackHit (const AliMUONTrackHit& theMUONTrackHit)
44   :  TObject(theMUONTrackHit)
45 {
46   fTrackParam                    =  theMUONTrackHit.fTrackParam;
47   fHitForRecPtr                  =  theMUONTrackHit.fHitForRecPtr;
48   fNextTrackHitWithSameHitForRec =  theMUONTrackHit.fNextTrackHitWithSameHitForRec;
49   fPrevTrackHitWithSameHitForRec =  theMUONTrackHit.fPrevTrackHitWithSameHitForRec;
50 }
51   //__________________________________________________________________________
52 AliMUONTrackHit & AliMUONTrackHit::operator=(const AliMUONTrackHit& theMUONTrackHit)
53 {
54   // check assignement to self
55   if (this == &theMUONTrackHit)
56     return *this;
57
58   // base class assignement
59   TObject::operator=(theMUONTrackHit);
60
61   fTrackParam                    =  theMUONTrackHit.fTrackParam;
62   fHitForRecPtr                  =  theMUONTrackHit.fHitForRecPtr;
63   fNextTrackHitWithSameHitForRec = theMUONTrackHit.fNextTrackHitWithSameHitForRec;
64   fPrevTrackHitWithSameHitForRec = theMUONTrackHit.fPrevTrackHitWithSameHitForRec;
65
66   return *this;
67
68 }
69   //__________________________________________________________________________
70 AliMUONTrackHit::AliMUONTrackHit(AliMUONHitForRec* Hit)
71 {
72   // Constructor from the HitForRec pointed to by "Hit"
73   fHitForRecPtr = Hit; // pointer to HitForRec
74   // links from/to HitForRec
75   if (Hit->GetNTrackHits() == 0) {
76     fPrevTrackHitWithSameHitForRec = NULL;
77     Hit->SetFirstTrackHitPtr(this);
78   }
79   else {
80     fPrevTrackHitWithSameHitForRec = Hit->GetLastTrackHitPtr();
81     fNextTrackHitWithSameHitForRec = NULL;
82   }
83   Hit->SetLastTrackHitPtr(this);
84   fNextTrackHitWithSameHitForRec = NULL;
85   Hit->SetNTrackHits(Hit->GetNTrackHits() + 1);
86 }
87
88   //__________________________________________________________________________
89 AliMUONTrackHit::~AliMUONTrackHit()
90 {
91   // Destructor
92   // Update links between HitForRec's and TrackHit's
93   // connected to the current TrackHit being removed.
94   AliMUONHitForRec *hit = fHitForRecPtr; // pointer to HitForRec
95   // remove current TrackHit in HitForRec links
96   if (this == hit->GetFirstTrackHitPtr())
97     hit->SetFirstTrackHitPtr(fNextTrackHitWithSameHitForRec); // if first
98   if (this == hit->GetLastTrackHitPtr())
99     hit->SetLastTrackHitPtr(fPrevTrackHitWithSameHitForRec); // if last
100   hit->SetNTrackHits(hit->GetNTrackHits() - 1); // decrement NTrackHits of hit
101   // update link to next TrackHit of previous TrackHit
102   if (fPrevTrackHitWithSameHitForRec != NULL)
103     fPrevTrackHitWithSameHitForRec->
104       SetNextTrackHitWithSameHitForRec(fNextTrackHitWithSameHitForRec);
105   // update link to previous TrackHit of next TrackHit
106   if (fNextTrackHitWithSameHitForRec)
107     fNextTrackHitWithSameHitForRec->
108       SetPrevTrackHitWithSameHitForRec(fPrevTrackHitWithSameHitForRec);
109   // to be checked thoroughly !!!!
110   // with Root counter of AliMUONTrackHit objects,
111   // with loop over all these links after the update
112 }
113
114   //__________________________________________________________________________
115 Int_t AliMUONTrackHit::Compare(const TObject* TrackHit) const
116 {
117   // "Compare" function to sort with decreasing Z (spectro. muon Z <0).
118   // Returns 1 (0, -1) if Z of current TrackHit
119   // is smaller than (equal to, larger than) Z of TrackHit
120   if (fHitForRecPtr->GetZ() <
121       ((AliMUONTrackHit*)TrackHit)->fHitForRecPtr->GetZ()) return(1);
122   else if (fHitForRecPtr->GetZ() ==
123            ((AliMUONTrackHit*)TrackHit)->fHitForRecPtr->GetZ()) return( 0);
124   else return(-1);
125 }