StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StHit.cxx
1 /***************************************************************************
2  *
3  * $Id: StHit.cxx,v 2.28 2016/02/25 17:07:14 ullrich Exp $
4  *
5  * Author: Thomas Ullrich, Sept 1999
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StHit.cxx,v $
13  * Revision 2.28 2016/02/25 17:07:14 ullrich
14  * Removed implentation of detector() making class pure abstract.
15  *
16  * Revision 2.27 2015/10/09 17:46:14 ullrich
17  * Changed type of mIdTruth from ushort to int.
18  *
19  * Revision 2.26 2012/10/23 20:18:33 fisyak
20  * Add/modify print outs
21  *
22  * Revision 2.25 2012/01/24 03:05:08 perev
23  * Cleanup
24  *
25  * Revision 2.24 2011/10/17 00:13:49 fisyak
26  * Add handles for IdTruth info
27  *
28  * Revision 2.23 2011/01/21 18:30:45 fisyak
29  * fix setFlag with UShort_t
30  *
31  * Revision 2.22 2009/11/23 16:34:06 fisyak
32  * Cleanup, remove dependence on dst tables, clean up software monitors
33  *
34  * Revision 2.21 2009/11/10 00:40:17 ullrich
35  * Changed print-out format.
36  *
37  * Revision 2.20 2006/02/14 21:04:31 perev
38  * WarnOff
39  *
40  * Revision 2.19 2006/01/19 21:49:41 ullrich
41  * Changed order of initializer in constructor.
42  *
43  * Revision 2.18 2005/07/19 21:34:10 perev
44  * quality ==> qaTruth to avoid misleading
45  *
46  * Revision 2.17 2005/07/06 18:57:48 fisyak
47  * Add StHit print out
48  *
49  * Revision 2.16 2004/10/13 16:10:52 ullrich
50  * Fixed bug in operator==
51  *
52  * Revision 2.15 2004/08/06 15:37:09 fisyak
53  * Add clster id
54  *
55  * Revision 2.14 2004/07/30 22:28:31 fisyak
56  * Add transient pointer to next Hit
57  *
58  * Revision 2.13 2004/07/15 16:36:24 ullrich
59  * Removed all clone() declerations and definitions. Use StObject::clone() only.
60  *
61  * Revision 2.12 2004/03/30 15:59:08 calderon
62  * Added method to set mFitFlag (new chain no longer uses tables, so must set
63  * this by hand).
64  *
65  * Revision 2.11 2004/01/13 21:01:32 fisyak
66  * Add Truth and Quality information from simulation
67  *
68  * Revision 2.10 2001/04/05 04:00:51 ullrich
69  * Replaced all (U)Long_t by (U)Int_t and all redundant ROOT typedefs.
70  *
71  * Revision 2.9 2001/03/24 03:34:50 perev
72  * clone() -> clone() const
73  *
74  * Revision 2.8 2001/03/06 21:04:30 ullrich
75  * Modified detector() method. Replaced switch
76  * statement by simple static_cast.
77  *
78  * Revision 2.7 2000/12/08 20:21:07 genevb
79  * Changed kTofPatchId -> kTofId
80  *
81  * Revision 2.6 2000/07/28 23:29:42 calderon
82  * Added handling of Fit Flag: use this flag to tell if the point
83  * is used in the fit.
84  *
85  * Revision 2.5 2000/07/28 19:49:28 akio
86  * Change in Detector Id for Endcap SMD
87  *
88  * Revision 2.4 2000/06/07 09:43:17 ullrich
89  * Changed return type of flag() to unsigned int
90  *
91  * Revision 2.3 2000/06/01 21:38:53 ullrich
92  * Added member mFlag and access member flag() and setFlag().
93  *
94  * Revision 2.2 2000/05/19 18:33:14 ullrich
95  * Minor changes (add const) to cope with modified StArray.
96  *
97  * Revision 2.1 1999/10/28 22:25:47 ullrich
98  * Adapted new StArray version. First version to compile on Linux and Sun.
99  *
100  * Revision 2.0 1999/10/12 18:42:17 ullrich
101  * Completely Revised for New Version
102  *
103  **************************************************************************/
104 #include "StHit.h"
105 #include "StTrack.h"
106 #include "StTrackNode.h"
107 #include "StTrackDetectorInfo.h"
108 
109 static const char rcsid[] = "$Id: StHit.cxx,v 2.28 2016/02/25 17:07:14 ullrich Exp $";
110 
111 ClassImp(StHit)
112 
113 //______________________________________________________________________________
114 StHit::StHit()
115 {
116  mHardwarePosition = 0;
117  mCharge = 0;
118  mTrackRefCount = 0;
119  mFlag = mFitFlag = 0;
120  mIdTruth = mQuality = 0;
121  mId = 0;
122  mNextHit = 0;
123 }
124 
125 //______________________________________________________________________________
126 StHit::StHit(const StThreeVectorF& p,
127  const StThreeVectorF& e,
128  unsigned int hp, float q, unsigned char c, int idTruth, unsigned short quality, unsigned short id)
129  :StMeasuredPoint(p),mHardwarePosition(hp),mPositionError(e),mCharge(q),
130  mId(id),mIdTruth(idTruth),mQuality(quality),mFitFlag(0),mTrackRefCount(c),mFlag(0),mNextHit(0)
131 {
132 }
133 
134 //______________________________________________________________________________
135 StHit::~StHit() { /* noop */ }
136 
137 //______________________________________________________________________________
138 int StHit::operator==(const StHit& h) const
139 {
140  return h.mPosition == mPosition &&
141  h.mPositionError == h.mPositionError &&
142  h.mCharge == mCharge &&
143  h.mHardwarePosition == mHardwarePosition &&
144  h.mFlag == mFlag &&
145  h.mIdTruth == mIdTruth &&
146  h.mQuality == mQuality &&
147  h.mId == mId &&
148  h.mNextHit == mNextHit;
149 }
150 
151 //______________________________________________________________________________
152 int StHit::operator!=(const StHit& h) const
153 {
154  return !(*this == h); // use operator==()
155 }
156 
157 //______________________________________________________________________________
158 void StHit::setCharge(float val) { mCharge = val; }
159 
160 //______________________________________________________________________________
161 void StHit::setTrackReferenceCount(unsigned char val) { mTrackRefCount = val; }
162 
163 //______________________________________________________________________________
164 void StHit::setFitFlag(unsigned char val) { mFitFlag = val; }
165 
166 //______________________________________________________________________________
167 void StHit::setHardwarePosition(unsigned int val) { mHardwarePosition = val; }
168 
169 //______________________________________________________________________________
170 void StHit::setPositionError(const StThreeVectorF& e) { mPositionError = e; }
171 
172 //______________________________________________________________________________
173 float StHit::charge() const { return mCharge; }
174 
175 //______________________________________________________________________________
176 unsigned int StHit::flag() const { return static_cast<unsigned int>(mFlag); }
177 
178 //______________________________________________________________________________
179 int StHit::usedInFit() const { return static_cast<int>(mFitFlag); }
180 
181 //______________________________________________________________________________
182 unsigned int StHit::trackReferenceCount() const { return static_cast<unsigned int>(mTrackRefCount); }
183 
184 //______________________________________________________________________________
185 StThreeVectorF StHit::positionError() const { return mPositionError; }
186 
187 //______________________________________________________________________________
188 StMatrixF StHit::covariantMatrix() const
189 {
190  // for now the diagonal elements is all we have
191  StMatrixF m(3,3);
192  m(1,1) = mPositionError.x()*mPositionError.x();
193  m(2,2) = mPositionError.y()*mPositionError.y();
194  m(3,3) = mPositionError.z()*mPositionError.z();
195  return m;
196 }
197 
198 
199 //______________________________________________________________________________
200 void StHit::setIdTruth(int idtru,int qatru)
201 {
202  if (qatru==0) qatru = (idtru>>16);
203  idtru = idtru&((1<<16)-1);
204  mIdTruth = idtru;
205  mQuality = (UShort_t) qatru;
206 }
207 
208 //______________________________________________________________________________
209 int StHit::idTruth() const
210 {
211  return mIdTruth;
212 }
213 
214 //______________________________________________________________________________
215 ostream& operator<<(ostream& os, const StHit& v)
216 {
217  os << Form("id %5i ",v.id()) << *((const StMeasuredPoint *)&v );
218  if (v.charge() > 1) os << Form(" q(ADC) %6.1f", v.charge());
219  else os << Form(" q(keV) %6.2f", 1e6*v.charge());
220  os << Form(" idT %5i qa %3i fl%3i us %1i",v.idTruth(), v.qaTruth(), v.flag(), v.usedInFit());
221  return os;
222 }
223 
224 //______________________________________________________________________________
225 void StHit::Print(Option_t *option) const {cout << *this << endl;}
Definition: StHit.h:125