StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTrackFitTraits.cxx
1 /***************************************************************************
2  *
3  * $Id: StTrackFitTraits.cxx,v 2.29 2015/05/13 17:06:14 ullrich Exp $
4  *
5  * Author: Thomas Ullrich, Sep 1999
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StTrackFitTraits.cxx,v $
13  * Revision 2.29 2015/05/13 17:06:14 ullrich
14  * Added hooks and interfaces to Sst detector (part of HFT).
15  *
16  * Revision 2.28 2013/11/13 19:19:40 ullrich
17  * Removed cause of warnings.
18  *
19  * Revision 2.27 2013/07/23 11:21:49 jeromel
20  * Undo past week changes
21  *
22  * Revision 2.25 2013/04/10 19:15:53 jeromel
23  * Step back from StEvent changes - previous change recoverable [Thomas OK-ed]
24  *
25  * Revision 2.23 2013/02/16 02:19:14 perev
26  * Bug fix, double counting of fitpoints
27  *
28  * Revision 2.22 2012/05/06 02:28:51 perev
29  * Again the new logic for total numbers of fit points. bugFixed
30  *
31  * Revision 2.21 2012/04/29 22:49:48 fisyak
32  * Back to old scheme of no. of fitted points for Sti, keep as possiblity a new scheme for Stv
33  *
34  * Revision 2.20 2012/04/27 01:45:07 perev
35  * Logic for total numbers of fit points changed
36  *
37  * Revision 2.19 2011/10/05 20:59:44 perev
38  * Comments++
39  *
40  * Revision 2.18 2009/11/23 16:34:07 fisyak
41  * Cleanup, remove dependence on dst tables, clean up software monitors
42  *
43  * Revision 2.17 2008/03/13 16:57:36 ullrich
44  * Add include to comply with ROOT.
45  *
46  * Revision 2.16 2007/10/11 21:52:32 ullrich
47  * Added member to handle number of fit points for PXL and IST.
48  *
49  * Revision 2.15 2004/12/02 23:35:13 ullrich
50  * Added misisng setXXX functions.
51  *
52  * Revision 2.14 2004/08/13 18:15:42 ullrich
53  * Added +1 to the number of fit points when bool flag is set.
54  *
55  * Revision 2.13 2004/08/12 17:22:31 fisyak
56  * Switch to automatic streamer for version >4 to account new no. of fit points definition
57  *
58  * Revision 2.12 2004/08/10 14:20:21 calderon
59  * Putting the streamers back in. They should not be needed, but
60  * apparently removing them causes more problems. Yuri tested that
61  * putting them back in allows reading files again.
62  *
63  * Revision 2.11 2004/08/05 22:24:32 ullrich
64  * Changes to the handling of numberOfPoints() to allow ITTF more flexibility.
65  *
66  * Revision 2.10 2001/05/04 19:49:51 perev
67  * Streamer to account old ROOT2
68  *
69  * Revision 2.9 2001/04/09 22:57:05 perev
70  * forget STAR I/O
71  *
72  * Revision 2.8 2001/04/05 04:00:58 ullrich
73  * Replaced all (U)Long_t by (U)Int_t and all redundant ROOT typedefs.
74  *
75  * Revision 2.7 2001/03/24 03:35:00 perev
76  * clone() -> clone() const
77  *
78  * Revision 2.6 2001/03/16 20:57:44 ullrich
79  * Covariant matrix now stored in TArrayF.
80  *
81  * Revision 2.5 2000/02/22 23:24:08 ullrich
82  * Fixed bug in covariantMatrix().
83  *
84  * Revision 2.4 2000/01/20 14:43:39 ullrich
85  * Fixed bug in numberOfFitPoints(). Sum was wrong.
86  *
87  * Revision 2.3 1999/12/21 15:09:18 ullrich
88  * Modified to cope with new compiler version on Sun (CC5.0).
89  *
90  * Revision 2.2 1999/11/01 12:45:14 ullrich
91  * Modified unpacking of point counter
92  *
93  * Revision 2.1 1999/10/28 22:27:32 ullrich
94  * Adapted new StArray version. First version to compile on Linux and Sun.
95  *
96  * Revision 2.0 1999/10/12 18:42:59 ullrich
97  * Completely Revised for New Version
98  *
99  **************************************************************************/
100 #include "TFile.h"
101 #include <algorithm>
102 #include "StTrackFitTraits.h"
103 #include "StParticleTypes.hh"
104 #include "StParticleTable.hh"
105 #include "TClass.h"
106 
107 #if !defined(ST_NO_NAMESPACES)
108 using std::fill_n;
109 using std::copy;
110 #endif
111 
112 ClassImp(StTrackFitTraits)
113 
114 static const char rcsid[] = "$Id: StTrackFitTraits.cxx,v 2.29 2015/05/13 17:06:14 ullrich Exp $";
115 
117 {
118  mPidHypothesis = 0;
119  mNumberOfFitPoints = 0x8000;
120  mNumberOfFitPointsTpc = 0;
121  mNumberOfFitPointsFtpcWest = 0;
122  mNumberOfFitPointsFtpcEast = 0;
123  mNumberOfFitPointsSvt = 0;
124  mNumberOfFitPointsSsd = 0;
125  mNumberOfFitPointsSst = 0;
126  mNumberOfFitPointsPxl = 0;
127  mNumberOfFitPointsIst = 0;
128  mPrimaryVertexUsedInFit = false;
129  fill_n(mChi2, 2, 0);
130 }
131 
132 
133 StTrackFitTraits::StTrackFitTraits(unsigned short pid, unsigned short nfp,
134  float chi[2], float cov[15])
135 {
136  mPidHypothesis = pid;
137  mNumberOfFitPoints = 0x8000;
138  copy(chi, chi+2, mChi2);
139  mCovariantMatrix.Set(15, cov);
140  mNumberOfFitPointsTpc = 0;
141  mNumberOfFitPointsFtpcWest = 0;
142  mNumberOfFitPointsFtpcEast = 0;
143  mNumberOfFitPointsSvt = 0;
144  mNumberOfFitPointsSsd = 0;
145  mNumberOfFitPointsSst = 0;
146  mNumberOfFitPointsPxl = 0;
147  mNumberOfFitPointsIst = 0;
148  mPrimaryVertexUsedInFit = false;
149 }
150 
151 StTrackFitTraits::~StTrackFitTraits() {/* no op */}
152 
153 unsigned short StTrackFitTraits::numberOfFitPoints() const
154 {
155  int result;
156 
157  // y2012 version
158  result = numberOfFitPoints(kTpcId) +
159  numberOfFitPoints(kFtpcWestId) +
160  numberOfFitPoints(kFtpcEastId) +
161  numberOfFitPoints(kSvtId) +
162  numberOfFitPoints(kSsdId) +
163  numberOfFitPoints(kSstId) +
164  numberOfFitPoints(kPxlId) +
165  numberOfFitPoints(kIstId);
166  if (mNumberOfFitPoints&0x8000) result += (mNumberOfFitPoints&0x7FFF);
167  if (mPrimaryVertexUsedInFit) result++;
168  return (unsigned short)result;
169 }
170 
171 unsigned short StTrackFitTraits::numberOfFitPoints(StDetectorId det) const
172 {
173  //
174  // Old and obsolete
175  //
176  if (mNumberOfFitPoints && (mNumberOfFitPoints<0x8000)) {
177  // 1*tpc + 1000*svt + 10000*ssd (Helen/Spiros Oct 29, 1999)
178  switch (det) {
179  case kFtpcWestId:
180  case kFtpcEastId:
181  case kTpcId:
182  return mNumberOfFitPoints%1000;
183  break;
184  case kSvtId:
185  return (mNumberOfFitPoints%10000)/1000;
186  break;
187  case kSsdId:
188  return mNumberOfFitPoints/10000;
189  break;
190  default:
191  return 0;
192  }
193  }
194 
195  //
196  // New version
197  //
198  else {
199  switch (det) {
200  case kFtpcWestId:
201  return mNumberOfFitPointsFtpcWest;
202  break;
203  case kFtpcEastId:
204  return mNumberOfFitPointsFtpcEast;
205  break;
206  case kTpcId:
207  return mNumberOfFitPointsTpc;
208  break;
209  case kSvtId:
210  return mNumberOfFitPointsSvt;
211  break;
212  case kSsdId:
213  return mNumberOfFitPointsSsd;
214  break;
215  case kSstId:
216  return mNumberOfFitPointsSst;
217  break;
218  case kPxlId:
219  return mNumberOfFitPointsPxl;
220  break;
221  case kIstId:
222  return mNumberOfFitPointsIst;
223  break;
224  default: //sum of all
225  return (mNumberOfFitPoints&0x7FFF)
226  + mNumberOfFitPointsFtpcWest
227  + mNumberOfFitPointsFtpcEast
228  + mNumberOfFitPointsTpc
229  + mNumberOfFitPointsSvt
230  + mNumberOfFitPointsSsd
231  + mNumberOfFitPointsSst
232  + mNumberOfFitPointsPxl
233  + mNumberOfFitPointsIst;
234  }
235  }
236 }
237 
238 StParticleDefinition* StTrackFitTraits::pidHypothesis() const
239 {
240  return StParticleTable::instance()->findParticleByGeantId(mPidHypothesis);
241 }
242 
243 double StTrackFitTraits::chi2(unsigned int i) const
244 {
245  if (i < 2)
246  return mChi2[i];
247  else
248  return 0;
249 }
250 
251 StMatrixF StTrackFitTraits::covariantMatrix() const
252 {
253  StMatrixF m(5,5);
254  if (mCovariantMatrix.GetSize() == 15) {
255 #define mCovariantMatrix ((TArrayF&)mCovariantMatrix) //temporary HACK VP
256  m(1,1) = mCovariantMatrix[0]; //yy
257  m(1,2) = m(2,1) = mCovariantMatrix[1]; //
258  m(1,3) = m(3,1) = mCovariantMatrix[2];
259  m(1,4) = m(4,1) = mCovariantMatrix[3];
260  m(1,5) = m(5,1) = mCovariantMatrix[4];
261  m(2,2) = mCovariantMatrix[5]; //zz
262  m(2,3) = m(3,2) = mCovariantMatrix[6];
263  m(2,4) = m(4,2) = mCovariantMatrix[7];
264  m(2,5) = m(5,2) = mCovariantMatrix[8];
265  m(3,3) = mCovariantMatrix[9]; //tanLtanL
266  m(3,4) = m(4,3) = mCovariantMatrix[10];
267  m(3,5) = m(5,3) = mCovariantMatrix[11];
268  m(4,4) = mCovariantMatrix[12]; //PsiPsi deg
269  m(4,5) = m(5,4) = mCovariantMatrix[13];
270  m(5,5) = mCovariantMatrix[14]; //PtiPti
271 #undef mCovariantMatrix //temporary HACK VP
272  }
273  return m;
274 }
275 
276 bool StTrackFitTraits::primaryVertexUsedInFit() const
277 { return mPrimaryVertexUsedInFit;}
278 
279 void StTrackFitTraits::clearCovariantMatrix() {mCovariantMatrix.Set(0);}
280 
281 void StTrackFitTraits::setNumberOfFitPoints(unsigned char val, StDetectorId det)
282 {
283  mNumberOfFitPoints|= 0x8000; // make sure old method is NOT active
284  switch (det) {
285  case kUnknownId:
286  break;
287  case kFtpcWestId:
288  mNumberOfFitPointsFtpcWest = val;
289  break;
290  case kFtpcEastId:
291  mNumberOfFitPointsFtpcEast = val;
292  break;
293  case kTpcId:
294  mNumberOfFitPointsTpc = val;
295  break;
296  case kSvtId:
297  mNumberOfFitPointsSvt = val;
298  break;
299  case kSsdId:
300  mNumberOfFitPointsSsd = val;
301  break;
302  case kSstId:
303  mNumberOfFitPointsSst = val;
304  break;
305  case kPxlId:
306  mNumberOfFitPointsPxl = val;
307  break;
308  case kIstId:
309  mNumberOfFitPointsIst = val;
310  break;
311  default:
312  mNumberOfFitPoints += val; mNumberOfFitPoints|=0x8000;
313  break;
314  }
315 }
316 
317 void StTrackFitTraits::setPrimaryVertexUsedInFit(bool val)
318 {mPrimaryVertexUsedInFit = val;}
319 
320 void StTrackFitTraits::setPidHypothesis(unsigned short val)
321 {
322  mPidHypothesis = val;
323 }
324 
325 void StTrackFitTraits::setChi2(float val, unsigned int i)
326 {
327  if (i<2) mChi2[i] = val;
328 }
329 
330 void StTrackFitTraits::setCovariantMatrix(float val[15])
331 {
332  mCovariantMatrix.Set(15, val);
333 }
334 
335 void StTrackFitTraits::Streamer(TBuffer &R__b)
336 {
337  // Stream an object of class StTrackFitTraits.
338 
339  if (R__b.IsReading()) {
340  UInt_t R__s, R__c;
341  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
342  if (R__v > 4) {
343  Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
344  return;
345  }
346  StObject::Streamer(R__b);
347 
348  R__b >> (unsigned short&)mPidHypothesis;
349  R__b >> (unsigned short&)mNumberOfFitPoints;
350 
351  if (R__v==2 && gFile && gFile->GetVersion()%100000<30000)
352  { Int_t dumy; R__b >> dumy;}
353 
354  R__b.ReadFastArray(mChi2,2);
355  mCovariantMatrix.Streamer(R__b);
356 
357  } else {
358  Class()->WriteBuffer(R__b,this);
359  }
360 }