StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTrackDetectorInfo.cxx
1 /***************************************************************************
2  *
3  * $Id: StTrackDetectorInfo.cxx,v 2.19 2016/02/24 22:02:11 ullrich Exp $
4  *
5  * Author: Thomas Ullrich, Sep 1999
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StTrackDetectorInfo.cxx,v $
13  * Revision 2.19 2016/02/24 22:02:11 ullrich
14  * Set of changes to account for SST (compared to SSD)
15  *
16  * Revision 2.18 2015/05/19 20:09:45 perev
17  * added Ist & Pxl
18  *
19  * Revision 2.17 2012/07/21 03:33:58 perev
20  * Add Other hits
21  *
22  * Revision 2.16 2009/11/23 16:34:07 fisyak
23  * Cleanup, remove dependence on dst tables, clean up software monitors
24  *
25  * Revision 2.15 2005/07/06 19:00:52 fisyak
26  * Add include of StThreeVectorD.hh
27  *
28  * Revision 2.14 2004/10/20 18:55:13 ullrich
29  * Name of enum changed: StStarMaxR(Z) now StStarMaxTrackRangeR(Z).
30  *
31  * Revision 2.13 2004/10/17 03:35:10 perev
32  * Error check improved
33  *
34  * Revision 2.12 2004/10/13 16:11:59 ullrich
35  * Added optional arg to addHit() to allow NOT to increase ref counter.
36  *
37  * Revision 2.11 2004/08/05 22:23:32 ullrich
38  * Fixed bug in first argument type of setNumberOfPoints().
39  *
40  * Revision 2.10 2004/08/05 19:25:03 ullrich
41  * Changes to the handling of numberOfPoints() to allow ITTF more flexibility.
42  *
43  * Revision 2.9 2004/07/15 16:36:26 ullrich
44  * Removed all clone() declerations and definitions. Use StObject::clone() only.
45  *
46  * Revision 2.8 2003/10/30 20:07:32 perev
47  * Check of quality added
48  *
49  * Revision 2.7 2001/04/05 04:00:58 ullrich`
50  * Replaced all (U)Long_t by (U)Int_t and all redundant ROOT typedefs.
51  *
52  * Revision 2.6 2001/03/24 03:35:00 perev
53  * clone() -> clone() const
54  *
55  * Revision 2.5 2000/04/20 13:29:58 ullrich
56  * Added new methods and removed inconsistencies in numberOfPoints().
57  *
58  * Revision 2.4 2000/01/20 14:43:07 ullrich
59  * Fixed bug in numberOfPoints(). Sum was wrong.
60  *
61  * Revision 2.3 1999/11/01 12:45:09 ullrich
62  * Modified unpacking of point counter
63  *
64  * Revision 2.2 1999/10/28 22:27:27 ullrich
65  * Adapted new StArray version. First version to compile on Linux and Sun.
66  *
67  * Revision 2.1 1999/10/13 19:45:39 ullrich
68  * Initial Revision
69  *
70  **************************************************************************/
71 #include <math.h>
72 #include "StDetectorId.h"
73 #include "StTrackDetectorInfo.h"
74 #include "StFunctional.h"
75 #include "StHit.h"
76 #include "StThreeVectorD.hh"
77 ClassImp(StTrackDetectorInfo)
78 
79 static const char rcsid[] = "$Id: StTrackDetectorInfo.cxx,v 2.19 2016/02/24 22:02:11 ullrich Exp $";
80 
81 StTrackDetectorInfo::StTrackDetectorInfo() : mNumberOfPoints(0),
82  mNumberOfPointsTpc(0),
83  mNumberOfPointsFtpcWest(0),
84  mNumberOfPointsFtpcEast(0),
85  mNumberOfPointsSvt(0),
86  mNumberOfPointsSsd(0),
87  mNumberOfPointsOth(0),
88  mNumberOfPointsIst(0),
89  mNumberOfPointsPxl(0)
90 { /* noop */ }
91 
92 StTrackDetectorInfo::~StTrackDetectorInfo() { /* noop */ }
93 
94 const StThreeVectorF&
95 StTrackDetectorInfo::firstPoint() const { return mFirstPoint; }
96 
97 const StThreeVectorF&
98 StTrackDetectorInfo::lastPoint() const { return mLastPoint; }
99 
100 unsigned short
101 StTrackDetectorInfo::numberOfPoints() const
102 {
103  if (mNumberOfPoints) {
104  return (numberOfPoints(kTpcId) +
105  numberOfPoints(kSvtId) +
106  numberOfPoints(kSsdId));
107  }
108  else {
109  return (numberOfPoints(kTpcId) +
110  numberOfPoints(kFtpcWestId) +
111  numberOfPoints(kFtpcEastId) +
112  numberOfPoints(kSvtId) +
113  numberOfPoints(kSsdId) + // internally treat SST=SSD
114  numberOfPoints(kIstId) +
115  numberOfPoints(kPxlId));
116  }
117 }
118 
119 unsigned short
120 StTrackDetectorInfo::numberOfPoints(StDetectorId det) const
121 {
122  if (mNumberOfPoints) {
123  // 1*tpc + 1000*svt + 10000*ssd (Helen/Spiros Oct 29, 1999)
124  switch (det) {
125  case kFtpcWestId:
126  case kFtpcEastId:
127  case kTpcId:
128  return mNumberOfPoints%1000;
129  break;
130  case kSvtId:
131  return (mNumberOfPoints%10000)/1000;
132  break;
133  case kSsdId:
134  case kSstId:
135  return mNumberOfPoints/10000;
136  break;
137  default:
138  return 0;
139  }
140  }
141  else {
142  switch (det) {
143  case kFtpcWestId:
144  return mNumberOfPointsFtpcWest;
145  break;
146  case kFtpcEastId:
147  return mNumberOfPointsFtpcEast;
148  break;
149  case kTpcId:
150  return mNumberOfPointsTpc;
151  break;
152  case kSvtId:
153  return mNumberOfPointsSvt;
154  break;
155  case kSsdId:
156  case kSstId:
157  return mNumberOfPointsSsd;
158  break;
159  case kIstId:
160  return mNumberOfPointsIst;
161  break;
162  case kPxlId:
163  return mNumberOfPointsPxl;
164  break;
165  default:
166  return mNumberOfPointsOth;
167  }
168  }
169 }
170 
171 unsigned short
172 StTrackDetectorInfo::numberOfReferencedPoints() const
173 {
174  return static_cast<unsigned short>(mHits.size());
175 }
176 
177 unsigned short
178 StTrackDetectorInfo::numberOfReferencedPoints(StDetectorId id) const
179 {
180  unsigned short count = 0;
181  for (StPtrVecHitConstIterator iter=mHits.begin(); iter != mHits.end(); iter++)
182  if ((*iter)->detector() == id) count++;
183  return count;
184 }
185 
186 StPtrVecHit
187 StTrackDetectorInfo::hits(StHitFilter& filter) const
188 {
189  StPtrVecHit vec;
190  for (StPtrVecHitConstIterator iter=mHits.begin(); iter != mHits.end(); iter++)
191  if (filter(*iter)) vec.push_back(*iter);
192  return vec;
193 }
194 
195 StPtrVecHit
196 StTrackDetectorInfo::hits(StDetectorId id) const
197 {
198  StPtrVecHit vec;
199  for (StPtrVecHitConstIterator iter=mHits.begin(); iter != mHits.end(); iter++)
200  if ((*iter)->detector() == id) vec.push_back(*iter);
201  return vec;
202 }
203 
204 StPtrVecHit&
205 StTrackDetectorInfo::hits() { return mHits; }
206 
207 const StPtrVecHit&
208 StTrackDetectorInfo::hits() const { return mHits; }
209 
210 void
211 StTrackDetectorInfo::setFirstPoint(const StThreeVectorF& val)
212 {
213  mFirstPoint = val;
214 }
215 
216 void
217 StTrackDetectorInfo::setLastPoint(const StThreeVectorF& val)
218 {
219  mLastPoint = val;
220 }
221 
222 void
223 StTrackDetectorInfo::setNumberOfPoints(unsigned short val)
224 {
225  mNumberOfPoints = val;
226 }
227 
228 void
229 StTrackDetectorInfo::setNumberOfPoints(unsigned char val, StDetectorId det)
230 {
231  mNumberOfPoints = 0; // make sure old method is NOT active
232  switch (det) {
233  case kFtpcWestId:
234  mNumberOfPointsFtpcWest = val;
235  break;
236  case kFtpcEastId:
237  mNumberOfPointsFtpcEast = val;
238  break;
239  case kTpcId:
240  mNumberOfPointsTpc = val;
241  break;
242  case kSvtId:
243  mNumberOfPointsSvt = val;
244  break;
245  case kSsdId:
246  case kSstId:
247  mNumberOfPointsSsd = val;
248  break;
249  case kIstId:
250  mNumberOfPointsIst = val;
251  case kPxlId:
252  mNumberOfPointsPxl = val;
253  default:
254  mNumberOfPointsOth+= val;
255 
256  break;
257  }
258 }
259 
260 void
261 StTrackDetectorInfo::addHit(StHit* hit, bool increaseRefCounter) // 2nd arg is optional, defaults to true
262 {
263  if (hit) {
264  mHits.push_back(hit);
265  if (increaseRefCounter) hit->setTrackReferenceCount(hit->trackReferenceCount()+1);
266  }
267 }
268 
269 void
270 StTrackDetectorInfo::removeHit(StHit*& hit)
271 {
272  // carefull here: mHits.erase(&hit) is not save at all
273  for (StPtrVecHitIterator iter=mHits.begin(); iter != mHits.end(); iter++) {
274  if (*iter == hit) mHits.erase(iter);
275  int i = hit->trackReferenceCount();
276  hit->setTrackReferenceCount(i > 0 ? i-1 : 0);
277  }
278 }
279 int StTrackDetectorInfo::bad() const
280 {
281  int ierr;
282 
283  ierr = mFirstPoint.bad();
284  if(ierr) return 1+100*ierr;
285  ierr = mLastPoint.bad();
286  if(ierr) return 2+100*ierr;
287  if (fabs(mFirstPoint.z())>kStarMaxTrackRangeZ) return 21;
288  if (fabs(mLastPoint.z ())>kStarMaxTrackRangeZ) return 22;
289  if (mFirstPoint.perp () >kStarMaxTrackRangeR) return 31;
290  if (mLastPoint.perp () >kStarMaxTrackRangeR) return 32;
291 
292  return 0;
293 }
Definition: StHit.h:125