StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StiStEventFiller.cxx
1 /***************************************************************************
2  *
3  * $Id: StiStEventFiller.cxx,v 2.124 2020/01/27 21:27:45 genevb Exp $
4  *
5  * Author: Manuel Calderon de la Barca Sanchez, Mar 2002
6  ***************************************************************************
7  *
8  * $Log: StiStEventFiller.cxx,v $
9  * Revision 2.124 2020/01/27 21:27:45 genevb
10  * Add short tracks toward ETOF when there, remove toward EEMC when not there
11  *
12  * Revision 2.123 2018/06/29 21:46:33 smirnovd
13  * Revert iTPC-related changes committed on 2018-06-20 through 2018-06-28
14  *
15  * Revert "NoDead option added"
16  * Revert "Fill mag field more carefully"
17  * Revert "Assert commented out"
18  * Revert "Merging with TPC group code"
19  * Revert "Remove too strong assert"
20  * Revert "Restore removed by mistake line"
21  * Revert "Remove not used anymore file"
22  * Revert "iTPCheckIn"
23  *
24  * Revision 2.121 2018/04/30 23:18:11 smirnovd
25  * [Cosmetic] Minor changes in various files
26  *
27  * - Renamed data member s/m/mMass/ in StikalmanTrack
28  * - Changes in white space
29  * - Return STAR code
30  *
31  * Revision 2.120 2018/04/10 11:32:10 smirnovd
32  * Minor corrections across multiple files
33  *
34  * - Remove ClassImp macro
35  * - Change white space
36  * - Correct windows newlines to unix
37  * - Remove unused debugging
38  * - Correct StTpcRTSHitMaker header guard
39  * - Remove unused preprocessor directives in StiCA
40  * - Minor changes in status and debug print out
41  * - Remove using std namespace from StiKalmanTrackFinder
42  * - Remove includes for unused headers
43  *
44  * Revision 2.119 2016/06/30 18:33:48 perev
45  * simplifacation
46  *
47  * Revision 2.117.2.4 2016/06/29 20:09:06 perev
48  * Small simplificatoins
49  *
50  * Revision 2.117.2.3 2016/06/03 16:07:15 smirnovd
51  * Sync with MAIN branch as of 2016-05-31
52  *
53  * Revision 2.118 2016/04/13 23:09:13 perev
54  * -opt2 proble solved. Array A[1] removed
55  *
56  * Revision 2.117 2015/12/28 23:50:27 perev
57  * Remove assert temporary
58  *
59  * Revision 2.116 2015/12/21 19:41:31 perev
60  * bug #3166 assert vertex closer to 0,0 <9 removed
61  *
62  * Revision 2.115 2015/12/20 01:46:56 fisyak
63  * Move back commits done by mistake
64  *
65  * Revision 2.113 2015/12/19 03:40:50 perev
66  * assert rxy<4 ==> <9 temporary
67  *
68  * Revision 2.112 2015/12/18 03:50:06 perev
69  * *** empty log message ***
70  *
71  * Revision 2.111 2015/12/03 19:12:24 perev
72  * Remove redundant GTrack error: mFlag: is Negative
73  *
74  * Revision 2.110 2015/03/27 20:13:43 perev
75  * Add printout of good track hits
76  *
77  * Revision 2.109 2015/03/24 16:37:28 perev
78  * fix printout hit: to hits:
79  *
80  * Revision 2.108 2015/03/21 02:16:53 perev
81  * By Lidia request, addet printing number of used hits detector by detector
82  * No any modification of any algorithmes
83  *
84  * Revision 2.107 2015/01/23 20:07:08 perev
85  * Debug++
86  *
87  * Revision 2.106 2014/07/03 00:37:51 perev
88  * c++11 fix
89  *
90  * Revision 2.105 2013/04/10 22:14:20 fisyak
91  * Roll back to version 04/04/2013
92  *
93  * Revision 2.103 2013/01/28 21:51:17 fisyak
94  * Correct ranking
95  *
96  * Revision 2.102 2013/01/18 15:03:37 fisyak
97  * Fix TrackData data name clash with StiPPVertexFinder
98  *
99  * Revision 2.101 2013/01/17 15:57:26 fisyak
100  * Add handles for debugging
101  *
102  * Revision 2.100 2012/11/09 18:28:10 perev
103  * fillpull development
104  *
105  * Revision 2.99 2012/09/16 21:38:42 fisyak
106  * use of Tpc West Only and East Only tracks, clean up
107  *
108  * Revision 2.98 2012/05/07 14:56:14 fisyak
109  * Add StKFVertexMaker
110  *
111  * Revision 2.97 2011/10/17 00:14:34 fisyak
112  * Move handles for IdTruth to StEvent
113  *
114  * Revision 2.96 2011/07/19 19:07:20 perev
115  * Remove previous tracks & vertices in StEvrent added
116  *
117  * Revision 2.95 2011/05/27 18:25:33 genevb
118  * Propagate StTrack::key => Int_t to other codes
119  *
120  * Revision 2.94 2011/04/01 15:52:21 fisyak
121  * Enlarge array for possible candidates, add requirement that dominant track should have > 2 good hits
122  *
123  * Revision 2.93 2011/03/31 22:11:24 fisyak
124  * Propagate IdTruth to StEvent
125  *
126  * Revision 2.92 2011/01/26 20:11:54 perev
127  * track id into StiPull
128  *
129  * Revision 2.91 2010/09/01 21:26:15 fisyak
130  * switch from direct access to public members to methods
131  *
132  * Revision 2.90 2010/01/27 21:43:49 perev
133  * Add _nPrimTracks for case of fiterr
134  *
135  * Revision 2.89 2009/10/18 22:47:29 perev
136  * assert instead of skip
137  *
138  * Revision 2.88 2009/10/16 14:56:02 fisyak
139  * Add check that pHit exists
140  *
141  * Revision 2.87 2009/10/15 03:29:30 perev
142  * Add primary vertex number and charge(GVB)
143  *
144  * Revision 2.86 2009/08/19 21:27:57 perev
145  * Account time of flight for StiPulls
146  *
147  * Revision 2.85 2009/03/16 13:50:14 fisyak
148  * Move out all Sti Chairs into StDetectorDb
149  *
150  * Revision 2.84 2008/08/22 13:32:52 fisyak
151  * add one more digit in trakc flag, mFlag=zxyy, where z = 1 for pile up track in TPC (otherwise 0)
152  *
153  * Revision 2.83 2008/04/03 20:04:05 fisyak
154  * Straighten out DB access via chairs
155  *
156  * Revision 2.82 2007/10/17 15:32:35 fisyak
157  * rename Hft => Pxl
158  *
159  * Revision 2.81 2007/04/16 22:47:18 perev
160  * aux.mPt is +ve
161  *
162  * Revision 2.80 2007/03/21 17:51:36 fisyak
163  * adjust for ROOT 5.14
164  *
165  * Revision 2.79 2006/12/19 19:46:09 perev
166  * Filling pull tracks added
167  *
168  * Revision 2.78 2006/12/18 01:30:39 perev
169  * fillPulls reorganized
170  *
171  * Revision 2.77 2006/08/31 03:25:58 fisyak
172  * Make cut for EEMC pointing track based on StTrackDetectorInfo instead of StTrackFitTraits
173  *
174  * Revision 2.76 2006/08/29 22:18:37 fisyak
175  * move filling of StTrackDetectorInfo into fillTrack
176  *
177  * Revision 2.75 2006/08/28 17:02:23 fisyak
178  * Add +x11 short tracks pointing to EEMC, clean up StiDedxCalculator
179  *
180  * Revision 2.74 2006/06/16 21:28:57 perev
181  * FillStHitErr method added and called
182  *
183  * Revision 2.73 2006/05/31 03:59:04 fisyak
184  * Add Victor's dca track parameters, clean up
185  *
186  * Revision 2.72 2006/04/07 18:00:30 perev
187  * Back to the latest Sti
188  *
189  * Revision 2.69 2006/02/14 18:56:18 perev
190  * setGlobalDca==>setDca
191  *
192  * Revision 2.68 2006/01/19 22:29:57 jeromel
193  * kMaxId -> kMaxDetectorId
194  *
195  * Revision 2.67 2005/12/08 00:06:27 perev
196  * BugFix, Instead of vertex, first hit was used
197  *
198  * Revision 2.66 2005/08/18 22:31:47 perev
199  * More tests
200  *
201  * Revision 2.65 2005/08/17 22:04:36 perev
202  * PoinCount cleanup
203  *
204  * Revision 2.64 2005/08/16 21:09:06 perev
205  * remeve 5fit cut
206  *
207  * Revision 2.63 2005/08/16 20:37:23 perev
208  * remove small pt cut
209  *
210  * Revision 2.62 2005/08/14 01:24:40 perev
211  * test for nhits<5 removed
212  *
213  * Revision 2.61 2005/08/04 04:04:19 perev
214  * Cleanup
215  *
216  * Revision 2.60 2005/07/21 21:50:24 perev
217  * First/last point of track filled from node now
218  *
219  * Revision 2.59 2005/07/20 17:34:08 perev
220  * MultiVertex
221  *
222  * Revision 2.58 2005/05/12 18:32:20 perev
223  * Temprary hack, save residuals
224  *
225  * Revision 2.57 2005/04/11 17:42:39 perev
226  * Temporary residuals saving added
227  *
228  * Revision 2.56 2005/03/24 17:51:16 perev
229  * print error code added
230  *
231  * Revision 2.55 2005/03/17 06:33:20 perev
232  * TPT like errors implemented
233  *
234  * Revision 2.54 2005/02/25 17:43:15 perev
235  * StTrack::setKey(...StiTrack::getId()) now
236  *
237  * Revision 2.53 2005/02/17 23:19:03 perev
238  * NormalRefangle + Error reseting
239  *
240  * Revision 2.52 2005/02/07 18:34:16 fisyak
241  * Add VMC dead material
242  *
243  * Revision 2.51 2005/01/17 03:56:56 pruneau
244  * change track container to vector
245  *
246  * Revision 2.50 2005/01/17 01:32:13 perev
247  * parameters protected
248  *
249  * Revision 2.49 2004/12/21 20:46:00 perev
250  * Cleanup. All known bugs fixed
251  *
252  * Revision 2.48 2004/12/02 22:14:53 calderon
253  * Only fill the fitTraits.chi2[1] data member for primaries.
254  * It holds node->getChi2() from the innerMostHitNode, which will be the
255  * vertex for primaries.
256  *
257  * Revision 2.47 2004/12/02 04:18:06 pruneau
258  * chi2[1] now set to incremental chi2 at inner most hit or vertex
259  *
260  * Revision 2.46 2004/12/01 15:35:46 pruneau
261  * removed throw and replaced with continue
262  *
263  * Revision 2.45 2004/11/08 15:34:16 pruneau
264  * fix of the chi2 calculation
265  *
266  * Revision 2.44 2004/10/27 03:25:54 perev
267  * Version V3V
268  *
269  * Revision 2.43 2004/10/26 06:45:41 perev
270  * version V2V
271  *
272  * Revision 2.42 2004/10/14 02:21:34 calderon
273  * Updated code in StTrackDetectorInfo, now only increment the reference count
274  * for globals, not for primaries. So fillTrackDetectorInfo changed to reflect
275  * this.
276  *
277  * Revision 2.41 2004/10/01 01:13:51 calderon
278  * Added bug fix from Marco:
279  * flag%100 -> flag/100.
280  *
281  * Revision 2.40 2004/08/17 20:04:28 perev
282  * small leak fixed, delete physicalHelix,originD
283  *
284  * Revision 2.39 2004/08/17 04:53:05 calderon
285  * When filling fit traits for primary tracks, set the new flag
286  * mPrimaryVertexUsedInFit.
287  *
288  * Revision 2.38 2004/08/10 14:21:13 calderon
289  * Use the firstHit from the dynamic_cast, to avoid a compiler warning
290  * for an unused variable.
291  *
292  * Revision 2.37 2004/08/06 22:23:29 calderon
293  * Modified the code to use the setNumberOfxxxPoints(unsigned char,StDetectorId)
294  * methods of StTrack, StTrackDetectorInfo, StTrackFitTraits, and to use
295  * the maxPointCount(unsigned int detId) method of StiKalmanTrack.
296  *
297  * Revision 2.36 2004/08/06 02:29:20 andrewar
298  * Modifed call to getMaxPointCount
299  *
300  * Revision 2.35 2004/08/05 05:25:25 calderon
301  * Fix the assignment of the first point for primaries. Now,
302  * the logic for both globals and primaries is that the first
303  * point is the first element of the stHits() vector that
304  * can actually be casted to an StHit (the vertex will fail this test,
305  * all other hits coming from detectors will satisfy it).
306  *
307  * Revision 2.34 2004/07/30 18:49:18 calderon
308  * For running in production, Yuri's dEdx Maker will fill the Pid Traits,
309  * so the filling of Pid Traits in the filler is no longer needed:
310  * it actually causes confusion because the V0 finders will loop over
311  * the PID traits vector and find the first one, so they won't find
312  * the trait created by the dEdx Maker. It is best to just comment
313  * out the filling of the Pid Traits here.
314  *
315  * Revision 2.33 2004/07/07 19:33:48 calderon
316  * Added method fillFlags. Flags tpc, tpc+svt (globals and primaries) and flags -x02 tracks with less than 5 total fit points
317  *
318  * Revision 2.32 2004/04/21 21:36:24 calderon
319  * Correction in the comments about the encoded method.
320  *
321  * Revision 2.31 2004/03/31 00:27:29 calderon
322  * Modifications for setting the fit points based on the chi2<chi2Max algorithm.
323  * -Distinguish between points and fit points, so I added a function for each.
324  * -Points is done as it was before, just counting the stHits for a given
325  * detector id.
326  * -Fit points is done the same with the additional condition that each
327  * StiKalmanTrackNode has to satisfy the chi2 criterion.
328  *
329  * Revision 2.30 2004/03/29 00:52:20 andrewar
330  * Added key value to StTrack fill. Key is simply the size of the
331  * StTrackNode container at the time the track is filled.
332  *
333  * Revision 2.29 2004/03/23 23:12:36 calderon
334  * Added an "accept" function to filter unwanted tracks from Sti into StEvent.
335  * The current method just looks for tracks with a negative length, since
336  * these were causing problems for the vertex finder (length was nan). The
337  * nan's have been trapped (one hopes!) in StiKalmanTrack, and for these
338  * cases the return value is negative, so we can filter them out with a
339  * simple length>0 condition.
340  *
341  * Revision 2.28 2004/03/19 19:33:23 andrewar
342  * Restored primary filling logic. Now taking parameters at the
343  * vertex for Primary tracks.
344  *
345  * Revision 2.27 2004/01/27 23:40:46 calderon
346  * The filling of the impactParameter() for global tracks is done now
347  * only after finding the vertex. The
348  * StPhysicalHelix::distance(StThreeVectorD) method is used for both globals
349  * and primaries, the only difference is where the helix is obtained:
350  * - globals - helix from StTrack::geometry(), which was filled from the
351  * innermost hit node, which should be a hit at the time.
352  * - primaries - helix from innermost hit node, which should be the vertex
353  * at the time it is called.
354  *
355  * Revision 2.26 2003/12/11 03:44:29 calderon
356  * set the length right again, it had dissappeared from the code...
357  *
358  * Revision 2.25 2003/11/26 04:02:53 calderon
359  * track->getChi2() returns the sum of chi2 for all sti nodes. In StEvent,
360  * chi2(0) should be chi2/dof, so we need to divide by
361  * dof=track->getPointCount()-5;
362  *
363  * Revision 2.24 2003/09/07 03:49:10 perev
364  * gcc 3.2 + WarnOff
365  *
366  * Revision 2.23 2003/09/02 17:59:59 perev
367  * gcc 3.2 updates + WarnOff
368  *
369  * Revision 2.22 2003/08/21 21:21:56 andrewar
370  * Added trap for non-finite dEdx. Added logic to fillGeometry so
371  * info is for innerMostHitNode on a detector, not vertex (note:
372  * Primaries only)
373  *
374  * Revision 2.21 2003/08/05 18:26:15 andrewar
375  * DCA track update logic modified.
376  *
377  * Revision 2.20 2003/07/01 20:25:28 calderon
378  * fillGeometry() - use node->getX(), as it should have been since the
379  * beginning
380  * impactParameter() - always use the innermos hit node, not just for globals
381  * removed extra variables which are no longer used.
382  *
383  * Revision 2.19 2003/05/15 03:50:26 andrewar
384  * Disabled call to filldEdxInfo for the SVT. Checks need to be
385  * applied to make sure the detector is active before calculator
386  * is called, but for the review filling this info is unnecessary.
387  *
388  * Revision 2.18 2003/05/14 00:04:35 calderon
389  * The array of 15 floats containing the covariance matrix has a different
390  * order in Sti than in StEvent. In Sti the array is counted starting from
391  * the first row, column go to next column until you hit the diagonal,
392  * jump to next row starting from first column. In StEvent the array is
393  * counted starting from the first row, column go to the next row until you
394  * hit the end, jump to next column starting from diagonal.
395  * The filling of the fitTraits was fixed to reflect this.
396  *
397  * Revision 2.17 2003/05/12 21:21:39 calderon
398  * switch back to getting the chi2 from track->getChi2()
399  * Covariance matrix is still obtained from node->get(), and the values
400  * are not as expected in StEvent, so this will still need to change.
401  *
402  * Revision 2.16 2003/05/08 22:23:33 calderon
403  * Adding a check for finiteness of node origin and node curvature. If any
404  * of the numbers is not finite, the code will abort().
405  *
406  * Revision 2.15 2003/04/29 18:48:52 pruneau
407  * *** empty log message ***
408  *
409  * Revision 2.14 2003/04/29 15:28:10 andrewar
410  * Removed hacks to get helicity right; switch now done at source
411  * (StiKalmanTrackNode).
412  *
413  * Revision 2.13 2003/04/25 21:42:47 andrewar
414  * corrected DCA bug and added temp fix for helicity problem. This will
415  * have to be modified when the helicity convention in StiStKalmanTrack
416  * is updated.
417  *
418  * Revision 2.12 2003/04/04 14:48:34 pruneau
419  * *** empty log message ***
420  *
421  * Revision 2.11 2003/03/14 19:02:55 pruneau
422  * various updates - DCA is a bitch
423  *
424  * Revision 2.10 2003/03/13 21:20:10 pruneau
425  * bug fix in filler fixed.
426  *
427  * Revision 2.9 2003/03/13 18:59:44 pruneau
428  * various updates
429  *
430  * Revision 2.8 2003/03/13 16:01:48 pruneau
431  * remove various cout
432  *
433  * Revision 2.7 2003/03/13 15:15:52 pruneau
434  * various
435  *
436  * Revision 2.6 2003/03/12 17:58:05 pruneau
437  * fixing stuff
438  *
439  * Revision 2.5 2003/02/25 16:56:20 pruneau
440  * *** empty log message ***
441  *
442  * Revision 2.4 2003/02/25 14:21:10 pruneau
443  * *** empty log message ***
444  *
445  * Revision 2.3 2003/01/24 06:12:28 pruneau
446  * removing centralized io
447  *
448  * Revision 2.2 2003/01/23 05:26:02 pruneau
449  * primaries rec reasonable now
450  *
451  * Revision 2.1 2003/01/22 21:12:15 calderon
452  * Restored encoded method, uses enums but stores the value in constructor
453  * as a data member so bit operations are only done once.
454  * Fixed warnings.
455  *
456  * Revision 2.0 2002/12/04 16:50:59 pruneau
457  * introducing version 2.0
458  *
459  * Revision 1.21 2002/09/20 02:19:32 calderon
460  * Quick hack for getting code for review:
461  * The filler now checks the global Dca for the tracks and only fills
462  * primaries when dca<3 cm.
463  * Also removed some comments so that the production log files are not swamped
464  * with debug info.
465  *
466  * Revision 1.20 2002/09/12 22:27:15 andrewar
467  * Fixed signed curvature -> StHelixModel conversion bug.
468  *
469  * Revision 1.19 2002/09/05 05:47:36 pruneau
470  * Adding Editable Parameters and dynamic StiOptionFrame
471  *
472  * Revision 1.18 2002/08/29 21:09:22 andrewar
473  * Fixed seg violation bug.
474  *
475  * Revision 1.17 2002/08/22 21:46:00 pruneau
476  * Made a fix to StiStEventFiller to remove calls to StHelix and StPhysicalHelix.
477  * Currently there is one instance of StHelix used a calculation broker to
478  * get helix parameters such as the distance of closest approach to the main
479  * vertex.
480  *
481  * Revision 1.16 2002/08/19 19:33:00 pruneau
482  * eliminated cout when unnecessary, made helix member of the EventFiller
483  *
484  * Revision 1.15 2002/08/12 21:39:56 calderon
485  * Introduced fillPidTraits, which uses the values obtained from
486  * Andrews brand new dEdxCalculator to create two instances of an
487  * StTrackPidTraits object and pass it to the track being filled.
488  *
489  * Revision 1.14 2002/08/12 15:29:21 andrewar
490  * Added dedx calculators
491  *
492  * Revision 1.13 2002/06/28 23:30:56 calderon
493  * Updated with changes debugging for number of primary tracks added.
494  * Merged with Claude's latest changes, but restored the tabs, othewise
495  * cvs diff will not give useful information: everything will be different.
496  *
497  * Revision 1.12 2002/06/26 23:05:31 pruneau
498  * changed macro
499  *
500  * Revision 1.11 2002/06/25 15:09:16 pruneau
501  * *** empty log message ***
502  *
503  * Revision 1.10 2002/06/18 18:08:34 pruneau
504  * some cout statements removed/added
505  *
506  * Revision 1.9 2002/06/05 20:31:15 calderon
507  * remove some redundant statements, the call to
508  * StTrackNode::addTrack()
509  * already calls
510  * track->SetNode(this), so I don't need to do it again
511  *
512  * Revision 1.8 2002/05/29 19:14:45 calderon
513  * Filling of primaries, in
514  * StiStEventFiller::fillEventPrimaries()
515  *
516  * Revision 1.7 2002/04/16 19:46:44 pruneau
517  * must catch exception
518  *
519  * Revision 1.6 2002/04/16 13:11:30 pruneau
520  * *** empty log message ***
521  *
522  * Revision 1.5 2002/04/09 16:03:13 pruneau
523  * Included explicit extension of tracks to the main vertex.
524  *
525  * Revision 1.4 2002/04/03 16:35:03 calderon
526  * Check if primary vertex is available in StiStEventFiller::impactParameter(),
527  * if not, return DBL_MAX;
528  *
529  * Revision 1.3 2002/03/28 04:29:49 calderon
530  * First test version of Filler
531  * Currently fills only global tracks with the following characteristics
532  * -Flag is set to 101, as most current global tracks are. This is not
533  * strictly correct, as this flag is supposed to mean a tpc only track, so
534  * really need to check if the track has svt hits and then set it to the
535  * appropriate flag (501 or 601).
536  * -Encoded method is set with bits 15 and 1 (starting from bit 0). Bit 1
537  * means Kalman fit.
538  * Bit 15 is an as-yet unused track-finding bit, which Thomas said ITTF
539  * could grab.
540  * -Impact Parameter calculation is done using StHelix and the primary vertex
541  * from StEvent
542  * -length is set using getTrackLength, which might still need tweaking
543  * -possible points is currently set from getMaxPointCount which returns the
544  * total, and it is not
545  * what we need for StEvent, so this needs to be modified
546  * -inner geometry (using the innermostHitNode -> Ben's transformer ->
547  * StPhysicalHelix -> StHelixModel)
548  * -outer geometry, needs inside-out pass to obtain good parameters at
549  * outermostHitNode
550  * -fit traits, still missing the probability of chi2
551  * -topology map, filled from StuFixTopoMap once StDetectorInfo is properly set
552  *
553  * This version prints out lots of messages for debugging, should be more quiet
554  * when we make progress.
555  *
556  **************************************************************************/
557 //ROOT
558 #include "RVersion.h"
559 #if ROOT_VERSION_CODE < 331013
560 #include "TCL.h"
561 #else
562 #include "TCernLib.h"
563 #endif
564 //std
565 #include "Stiostream.h"
566 #include <algorithm>
567 #include <stdexcept>
568 using namespace std;
569 
570 // SCL
571 #include "StPhysicalHelix.hh"
572 #include "StThreeVector.hh"
573 #include "StThreeVectorF.hh"
574 #include "PhysicalConstants.h"
575 #include "SystemOfUnits.h"
576 #include "StTrackDefinitions.h"
577 #include "StTrackMethod.h"
578 #include "StDedxMethod.h"
579 
580 //StEvent
581 #include "StPrimaryVertex.h"
582 #include "StEventTypes.h"
583 #include "StDetectorId.h"
584 #include "StHelix.hh"
585 #include "StDcaGeometry.h"
586 #include "StHit.h"
587 
588 
589 #include "StEventUtilities/StEventHelper.h"
590 #include "StEventUtilities/StuFixTopoMap.cxx"
591 //Sti
592 #include "Sti/StiTrackContainer.h"
593 #include "Sti/StiKalmanTrack.h"
594 #include "StDetectorDbMaker/StiKalmanTrackFitterParameters.h"
596 #include "StiUtilities/StiDebug.h"
597 #include "StiUtilities/StiPullEvent.h"
598 
599 //StiMaker
600 #include "StiMaker/StiStEventFiller.h"
601 #include "TMath.h"
602 #include "StTrack2FastDetectorMatcher.h"
603 #include "Sti/StiHitTest.h"
604 #define NICE(angle) StiKalmanTrackNode::nice((angle))
605 map<StiKalmanTrack*, StTrackNode*> StiStEventFiller::mTrkNodeMap;
606 map<StTrackNode*, StiKalmanTrack*> StiStEventFiller::mNodeTrkMap;
607 StiStEventFiller *StiStEventFiller::fgStiStEventFiller = 0;
608 
609 //_____________________________________________________________________________
610 StiStEventFiller::StiStEventFiller() : mEvent(0), mTrackStore(0), mFastDetectorMatcher(0)
611 {
612  fgStiStEventFiller = this;
613  mUseAux = 0;
614  mAux = 0;
615  mGloPri = 0;
616  mPullEvent=0;
617 
618  originD = new StThreeVectorD(0,0,0);
619  physicalHelix = new StPhysicalHelixD(0.,0.,0.,*originD,-1);
620 
621 
622  //mResMaker.setLimits(-1.5,1.5,-1.5,1.5,-10,10,-10,10);
623  //mResMaker.setDetector(kSvtId);
624 
625  // encoded method = 16 bits = 12 finding and 4 fitting, Refer
626  // to StTrackMethod.h and StTrackDefinitions.h in pams/global/inc/
627  // and StEvent/StEnumerations.h
628  // For the IT tracks use:
629  // Fitting: kITKalmanFitId (should be something like 7, but don't hardwire it)
630  // Finding: tpcOther (should be 9th LSB, or shift the "1" 8 places to the left, but also don't hardwire it)
631  // so need this bit pattern:
632  // finding 000000010000
633  // fitting 0111
634  // 256 + 7 = 263;
635  unsigned short bit = 1 << tpcOther; // shifting the "1" exactly tpcOther places to the left
636  mStiEncoded = kITKalmanFitId + bit; // adding that to the proper fitting Id
637  mFastDetectorMatcher = new StTrack2FastDetectorMatcher();
638 }
639 //_____________________________________________________________________________
640 StiStEventFiller::~StiStEventFiller()
641 {
642  delete physicalHelix; physicalHelix=0;
643  delete originD; originD =0;
644  SafeDelete(mFastDetectorMatcher);
645  cout <<"StiStEventFiller::~StiStEventFiller()"<<endl;
646 }
647 //_____________________________________________________________________________
699 //_____________________________________________________________________________
701 {
702  mFastDetectorMatcher->Clear();
703  mFastDetectorMatcher->fillArrays(e);
704  //cout << "StiStEventFiller::fillEvent() -I- Started"<<endl;
705  mGloPri=0;
706  if (e==0 || t==0)
707  {
708  cout <<"StiStEventFiller::fillEvent(). ERROR:\t"
709  <<"Null StEvent ("<<e<<") || StiTrackContainer ("<<t<<"). Exit"<<endl;
710  return;
711  }
712  mEvent = e;
713  StEventHelper::Remove(mEvent,"StSPtrVecTrackNode");
714  StEventHelper::Remove(mEvent,"StSPtrVecPrimaryVertex");
715 
716  if (mUseAux) { mAux = new StiAux; e->Add(mAux);}
717  mTrackStore = t;
718  memset(mUsedHits,0,sizeof(mUsedHits));
719  memset(mUsedGits,0,sizeof(mUsedGits));
720  mTrkNodeMap.clear(); // need to reset for this event
721  mNodeTrkMap.clear();
722  StSPtrVecTrackNode& trNodeVec = mEvent->trackNodes();
723  StSPtrVecTrackDetectorInfo& detInfoVec = mEvent->trackDetectorInfo();
724  int errorCount=0;
725 
726  int fillTrackCount1=0;
727  int fillTrackCount2=0;
728  int fillTrackCountG=0;
729  StErrorHelper errh;
730  mTrackNumber=0;
731  for (int trackIt = 0;trackIt <(int)mTrackStore->size(); trackIt++)
732  {
733  StiKalmanTrack* kTrack = static_cast<StiKalmanTrack*>((*mTrackStore)[trackIt]);
734  if (!accept(kTrack)) continue; // get rid of riff-raff
735  mTrackNumber++;
737  fillDetectorInfo(detInfo,kTrack,true); //3d argument used to increase/not increase the refCount. MCBS oct 04.
738  // track node where the new StTrack will reside
739  StTrackNode* trackNode = new StTrackNode;
740  // actual filling of StTrack from StiKalmanTrack
741  StGlobalTrack* gTrack = new StGlobalTrack;
742  try
743  {
744  fillTrackCount1++;
745  fillTrack(gTrack,kTrack,detInfo);
746  // filling successful, set up relationships between objects
747  detInfoVec.push_back(detInfo);
748  //cout <<"Setting key: "<<(unsigned short)(trNodeVec.size())<<endl;
749  gTrack->setKey(kTrack->getId());
750  gTrack->setIdTruth();
751  trackNode->addTrack(gTrack);
752  trNodeVec.push_back(trackNode);
753  // reuse the utility to fill the topology map
754  // this has to be done at the end as it relies on
755  // having the proper track->detectorInfo() relationship
756  // and a valid StDetectorInfo object.
757  //cout<<"Tester: Event Track Node Entries: "<<trackNode->entries()<<endl;
758  StTrackNode* node = trNodeVec.back();
759  mTrkNodeMap.insert(pair<StiKalmanTrack*,StTrackNode*> (kTrack,node) );
760  mNodeTrkMap.insert(pair<StTrackNode*,StiKalmanTrack*> (node,kTrack) );
761  if (trackNode->entries(global)<1)
762  cout << "StiStEventFiller::fillEvent() -E- Track Node has no entries!! -------------------------" << endl;
763  int ibad = gTrack->bad();
764  if (ibad) {
765  errh.Add(ibad);
766  if (errh.Say(ibad).Contains("Negative")) continue;
767  printf("GTrack error: %s\n",errh.Say(ibad).Data());
768  continue;
769  }
770  fillTrackCount2++;
771 if (kTrack->getPointCount(kTpcId)>10)
772 StiHftHits::hftHist("HFTAfterAll",kTrack);//???????????????????????
773  fillPulls(kTrack,gTrack,0);
774  if (kTrack->getPointCount()<15) continue;
775  fillTrackCountG++;
776 
777  }
778  catch (runtime_error & rte )
779  {
780  cout << "StiStEventFiller::fillEvent() -W- runtime-e filling track"<<rte.what() << endl;
781  delete trackNode;
782  delete detInfo;
783  delete gTrack;
784  }
785  catch (...)
786  {
787  cout << "StiStEventFiller::fillEvent() -W- Unknown exception filling track."<<endl;
788  delete trackNode;
789  delete detInfo;
790  delete gTrack;
791  }
792  }
793  if (errorCount>4)
794  cout << "There were "<<errorCount<<"runtime_error while filling StEvent"<<endl;
795 
796  cout <<"StiStEventFiller::fillEvent() -I- Number of filled as global(1):"<< fillTrackCount1<<endl;
797  cout <<"StiStEventFiller::fillEvent() -I- Number of filled as global(2):"<< fillTrackCount2<<endl;
798  cout <<"StiStEventFiller::fillEvent() -I- Number of filled GOOD globals:"<< fillTrackCountG<<endl;
799  errh.Print();
800  for (int ij=1; ij<=mUsedHits[0]; ij++) {
801  if (!mUsedHits[ij]) continue;
802  const char *det = detectorNameById((StDetectorId)ij);
803  cout <<"StiStEventFiller::fillEvent() -I- Number of used hits:"<< det << "(" << ij << ") :"<<mUsedHits[ij]
804  << " per track:"<<double(mUsedHits[ij])/fillTrackCount2 <<endl;
805  }
806  for (int ij=1; ij<=mUsedGits[0]; ij++) {
807  if (!mUsedGits[ij]) continue;
808  const char *det = detectorNameById((StDetectorId)ij);
809  cout <<"StiStEventFiller::fillEvent() -I- Number of GOOD hits:"<< det << "(" << ij << ") :"<<mUsedGits[ij]
810  << " per track:"<<double(mUsedHits[ij])/fillTrackCountG <<endl;
811  }
812 
813 
814  return;
815 }
816 //_____________________________________________________________________________
817 void StiStEventFiller::fillEventPrimaries()
818 {
819  //cout <<"StiStEventFiller::fillEventPrimaries() -I- Started"<<endl;
820  mGloPri=1;
821  if (!mTrkNodeMap.size())
822  {
823  cout <<"StiStEventFiller::fillEventPrimaries(). ERROR:\t"
824  << "Mapping between the StTrackNodes and the StiKalmanTracks is empty. Exit." << endl;
825  return;
826  }
827  //Added residual maker...aar
828  StPrimaryVertex* vertex = 0;
829  StSPtrVecTrackDetectorInfo& detInfoVec = mEvent->trackDetectorInfo();
830  cout << "StiStEventFiller::fillEventPrimaries() -I- Tracks in container:" << mTrackStore->size() << endl;
831  int mTrackN=0,mVertN=0;
832  int fillTrackCount1=0;
833  int fillTrackCount2=0;
834  int fillTrackCountG=0;
835  StErrorHelper errh;
836  int nTracks = mTrackStore->size();
837  StiKalmanTrack *kTrack = 0;
838  StPrimaryTrack *pTrack = 0;
839  StGlobalTrack *gTrack = 0;
840  StTrackNode *nTRack = 0;
841  mTrackNumber=0;
842  for (mTrackN=0; mTrackN<nTracks;++mTrackN) {
843  kTrack = (StiKalmanTrack*)(*mTrackStore)[mTrackN];
844  if (!accept(kTrack)) continue;
845  map<StiKalmanTrack*, StTrackNode*>::iterator itKtrack = mTrkNodeMap.find(kTrack);
846  if (itKtrack == mTrkNodeMap.end()) continue;//Sti global was rejected
847  mTrackNumber++;
848 
849  nTRack = (*itKtrack).second;
850  assert(nTRack->entries()<=10);
851  assert(nTRack->entries(global));
852 
853  //double globalDca = nTRack->track(global)->impactParameter();
854  //Even though this is filling of primary tracks, there are certain
855  // quantities that need to be filled for global tracks that are only known
856  // after the vertex is found, such as dca. Here we can fill them.
857  //
858  gTrack = static_cast<StGlobalTrack*>(nTRack->track(global));
859  assert(gTrack->key()==kTrack->getId());
860  float minDca = 1e10; //We do not know which primary. Use the smallest one
861 
862  pTrack = 0;
863  for (mVertN=0; (vertex = mEvent->primaryVertex(mVertN));mVertN++) {
864  StThreeVectorD vertexPosition = vertex->position();
865  double zPrim = vertexPosition.z();
866  // loop over StiKalmanTracks
867  float globalDca = impactParameter(gTrack,vertexPosition);
868  if (fabs(minDca) > fabs(globalDca)) minDca = globalDca;
869 
870  if (!kTrack->isPrimary()) continue;
871  StiKalmanTrackNode *lastNode = kTrack->getLastNode();
872  StiHit *pHit = lastNode->getHit();
873  assert (pHit);
874  if (fabs(pHit->z_g()-zPrim)>0.1) continue;//not this primary
875 
876  fillTrackCount1++;
877  // detector info
879  fillDetectorInfo(detInfo,kTrack,false); //3d argument used to increase/not increase the refCount. MCBS oct 04.
880 // double rxy = detInfo->firstPoint().perp();
881 // assert(rxy < 9);
882  auto myDif = (detInfo->firstPoint()-vertexPosition);
883 //?? assert(myDif.mag()<0.01);
884 
885  StPrimaryTrack* pTrack = new StPrimaryTrack;
886  pTrack->setKey( gTrack->key());
887  nTRack->addTrack(pTrack); // StTrackNode::addTrack() calls track->setNode(this);
888  fillTrack(pTrack,kTrack, detInfo);
889  // set up relationships between objects
890  detInfoVec.push_back(detInfo);
891 
892  vertex->addDaughter(pTrack);
893  fillPulls(kTrack,gTrack,1);
894  int ibad = pTrack->bad();
895  errh.Add(ibad);
896  if (ibad) {
897 //VP printf("PTrack error: %s\n",errh.Say(ibad).Data());
898 //VP throw runtime_error("StiStEventFiller::fillEventPrimaries() StTrack::bad() non zero");
899  continue;
900  }
901 // rxy = pTrack->geometry()->origin().perp();
902 // assert(rxy<9);
903  fillTrackCount2++;
904  if (kTrack->getPointCount()<15) break;
905  if (pTrack->geometry()->momentum().mag()<0.1) break;
906  fillTrackCountG++;
907  break;
908  } //end of verteces
909  kTrack->setDca(minDca);
910  gTrack->setImpactParameter(minDca);
911  if (pTrack) pTrack->setImpactParameter(minDca);
912 
913  } // kalman track loop
914  for (mVertN=0; (vertex = mEvent->primaryVertex(mVertN));mVertN++) {vertex->setTrackNumbers();}
915 
916  mTrkNodeMap.clear(); // need to reset for the next event
917  cout <<"StiStEventFiller::fillEventPrimaries() -I- Primaries (1):"<< fillTrackCount1 <<endl;
918  cout <<"StiStEventFiller::fillEventPrimaries() -I- Primaries (2):"<< fillTrackCount2 <<endl;
919  cout <<"StiStEventFiller::fillEventPrimaries() -I- GOOD:"<< fillTrackCountG <<endl;
920  errh.Print();
921  return;
922 }
923 //_____________________________________________________________________________
928 //_____________________________________________________________________________
930 {
931  //cout << "StiStEventFiller::fillDetectorInfo() -I- Started"<<endl;
932  int dets[kMaxDetectorId][3];
933  track->getAllPointCount(dets,kMaxDetectorId-1);
934  int nTotHits = dets[0][2];
935  int nTpcHits = dets[kTpcId][2];
936  for (int i=1;i<kMaxDetectorId;i++) {
937  if (!dets[i][1]) continue;
938  detInfo->setNumberOfPoints(dets[i][1],static_cast<StDetectorId>(i));
939  }
940  StiKTNIterator tNode = track->rbegin();
941  StiKTNIterator eNode = track->rend();
942  StiKalmanTrackNode *lastNode=0,*fistNode=0;
943  for (;tNode!=eNode;++tNode)
944  {
945  StiKalmanTrackNode *node = &(*tNode);
946  if(!node->isValid()) continue;
947 
948  StiHit *stiHit = node->getHit();
949  if (!stiHit) continue;
950 
951  if (node->getChi2()>1000) continue;
952  if (!node->isFitted()) continue;
953 
954  const StiDetector *detector = node->getDetector();
955  assert(detector == stiHit->detector());
956  assert(!detector || stiHit->timesUsed());
957  if (!fistNode) fistNode = node;
958  lastNode = node;
959  if (!detector) continue;
960 
961 // Count used hits for tracks tpc hits >10
962  if (nTpcHits > 10) {
963  int gid = detector->getGroupId();
964  if (mUsedHits[0]<gid) mUsedHits[0]=gid;
965  mUsedHits[gid]++;
966  if (nTotHits>=15) {
967  if (mUsedGits[0]<gid) mUsedGits[0]=gid;
968  mUsedGits[gid]++;
969  }
970  }
971  StHit *hh = (StHit*)stiHit->stHit();
972  if (!hh) continue;
973  assert(detector->getGroupId()==hh->detector());
974 #if 0
975 // Fill StHit errors for Gene
976  FillStHitErr(hh,node);
977 #endif
978  detInfo->addHit(hh,refCountIncr);
979  if (!refCountIncr) continue;
980  hh->setFitFlag(1);
981  FillTpcdX(track,node,hh);
982 //Kind of HACK, save residials into StiHack
983  fillResHack(hh,stiHit,node);
984  }
985  assert(lastNode && fistNode && (lastNode != fistNode));
986 
987  StThreeVectorF posL(lastNode->x_g(),lastNode->y_g(),lastNode->z_g());
988  detInfo->setLastPoint (posL);
989  StThreeVectorF posF(fistNode->x_g(),fistNode->y_g(),fistNode->z_g());
990  detInfo->setFirstPoint(posF);
991 
992 
993  //cout << "StiStEventFiller::fillDetectorInfo() -I- Done"<<endl;
994 }
995 
996 //_____________________________________________________________________________
997 void StiStEventFiller::fillGeometry(StTrack* gTrack, StiKalmanTrack* track, bool outer)
998 {
999  //cout << "StiStEventFiller::fillGeometry() -I- Started"<<endl;
1000  assert(gTrack);
1001  assert(track) ;
1002 
1003  StiKalmanTrackNode* node = track->getInnOutMostNode(outer,3);
1004  StiHit *ihit = node->getHit();
1005  StThreeVectorF origin(node->x_g(),node->y_g(),node->z_g());
1006  StThreeVectorF hitpos(ihit->x_g(),ihit->y_g(),ihit->z_g());
1007  if (node->getDetector()) {
1008  double dif = (hitpos-origin).mag();
1009 
1010  if (dif>3.) {
1011  dif = node->z_g()-ihit->z_g();
1012  double nowChi2 = node->evaluateChi2(ihit);
1013  printf("***Track(%d) DIFF TOO BIG %g chi2 = %g %g\n",track->getId(),dif,node->getChi2(),nowChi2);
1014  printf("H=%g %g %g N =%g %g %g\n",ihit->x() ,ihit->y() ,ihit->z()
1015  ,node->getX(),node->getY(),node->getZ());
1016  const StMeasuredPoint *mp = ihit->stHit();
1017  printf("H=%g %g %g N =%g %g %g\n",mp->position().x(),mp->position().y(),mp->position().z()
1018  ,origin.x(),origin.y(),origin.z());
1019 
1020  assert(fabs(dif)<50.);
1021  }
1022  }
1023  // making some checks. Seems the curvature is infinity sometimes and
1024  // the origin is sometimes filled with nan's...
1025 
1026  int ibad = origin.bad();
1027  if (ibad) {
1028  cout << "StiStEventFiller::fillGeometry() Encountered non-finite numbers!!!! Bail out completely!!! " << endl;
1029  cout << "StThreeVectorF::bad() = " << ibad << endl;
1030  cout << "Last node had:" << endl;
1031  cout << "Ref Position " << node->getRefPosition() << endl;
1032  cout << "node->getY() " << node->getY() << endl;
1033  cout << "node->getZ() " << node->getZ() << endl;
1034  cout << "Ref Angle " << node->getAlpha() << endl;
1035  cout << "origin " << origin << endl;
1036  cout << "curvature " << node->getCurvature() << endl;
1037  abort();
1038  }
1039  StTrackGeometry* geometry =new StHelixModel(short(track->getCharge()),
1040  node->getPsi(),
1041  fabs(node->getCurvature()),
1042  node->getDipAngle(),
1043  origin,
1044  node->getGlobalMomentumF(),
1045  node->getHelicity());
1046 
1047  if (outer)
1048  gTrack->setOuterGeometry(geometry);
1049  else
1050  gTrack->setGeometry(geometry);
1051 
1052 
1053  return;
1054 }
1055 
1056 //_____________________________________________________________________________
1057 // void StiStEventFiller::fillTopologyMap(StTrack* gTrack, StiKalmanTrack* track){
1058 // cout << "StiStEventFiller::fillTopologyMap()" << endl;
1059 // int map1,map2;
1060 // map1 = map2 = 0;
1061 // // change: add code to set the bits appropriately here
1062 
1063 // StTrackTopologyMap topomap(map1,map2);
1064 // gTrack->setTopologyMap(topomap);
1065 // return;
1066 // }
1067 
1068 //_____________________________________________________________________________
1069 void StiStEventFiller::fillFitTraits(StTrack* gTrack, StiKalmanTrack* track){
1070  // mass
1071  // this makes no sense right now... double massHyp = track->getMass(); // change: perhaps this mass is not set right?
1072  unsigned short geantIdPidHyp = 9999;
1073  //if (.13< massHyp<.14)
1074  geantIdPidHyp = 9;
1075  // chi square and covariance matrix, plus other stuff from the
1076  // innermost track node
1077  StiKalmanTrackNode* node = track->getInnerMostHitNode(3);
1078  float x[6],covMFloat[15];
1079  node->getGlobalTpt(x,covMFloat);
1080  float chi2[2];
1081  //get chi2/dof
1082  chi2[0] = track->getChi2();
1083  assert(chi2[0]<100);
1084  chi2[1] = -999; // change: here goes an actual probability, need to calculate?
1085  // December 04: The second element of the array will now hold the incremental chi2 of adding
1086  // the vertex for primary tracks
1087  if (gTrack->type()==primary) {
1088  assert(node->getDetector()==0);
1089  chi2[1]=node->getChi2();
1090  }
1091 
1092  // setFitTraits uses assignment operator of StTrackFitTraits, which is the default one,
1093  // which does a memberwise copy. Therefore, constructing a local instance of
1094  // StTrackFitTraits is fine, as it will get properly copied.
1095  StTrackFitTraits fitTraits(geantIdPidHyp,0,chi2,covMFloat);
1096  // Now we have to use the new setters that take a detector ID to fix
1097  // a bug. There is no encoding anymore.
1098 
1099  int dets[kMaxDetectorId][3];
1100  track->getAllPointCount(dets,kMaxDetectorId-1);
1101 
1102  for (int i=1;i<kMaxDetectorId;i++) {
1103  if (!dets[i][2]) continue;
1104  fitTraits.setNumberOfFitPoints((unsigned char)dets[i][2],(StDetectorId)i);
1105  }
1106  if (gTrack->type()==primary) {
1107  fitTraits.setPrimaryVertexUsedInFit(true);
1108  }
1109  gTrack->setFitTraits(fitTraits);
1110  return;
1111 }
1112 
1145 
1147 {
1148  Int_t flag = 0;
1149  if (gTrack->type()==global) {
1150  flag = 101; //change: make sure flag is ok
1151  }
1152  else if (gTrack->type()==primary) {
1153  flag = 301;
1154  }
1155  StTrackFitTraits& fitTrait = gTrack->fitTraits();
1156  //int tpcFitPoints = fitTrait.numberOfFitPoints(kTpcId);
1157  int svtFitPoints = fitTrait.numberOfFitPoints(kSvtId);
1158  int ssdFitPoints = fitTrait.numberOfFitPoints(kSsdId);
1159  int pxlFitPoints = fitTrait.numberOfFitPoints(kPxlId);
1160  int istFitPoints = fitTrait.numberOfFitPoints(kIstId);
1161  // int totFitPoints = fitTrait.numberOfFitPoints();
1165 
1166  // first case is default above, tpc only = 101 and tpc+vertex = 301
1167  // next case is:
1168  // if the track has svt points, it will be an svt+tpc track
1169  // (we assume that the ittf tracks start from tpc, so we don't
1170  // use the "svt only" case.)
1171  if (svtFitPoints+ssdFitPoints+pxlFitPoints+istFitPoints>0) {
1172  if (gTrack->type()==global) {
1173  flag = 501; //svt+tpc
1174  }
1175  else if (gTrack->type()==primary) {
1176  flag = 601; //svt+tpc+primary
1177  }
1178  }
1179  const StTrackDetectorInfo *dinfo = gTrack->detectorInfo();
1180  if (dinfo) {
1181  Int_t NoTpcFitPoints = dinfo->numberOfPoints(kTpcId);
1182  Int_t NoFtpcWestId = dinfo->numberOfPoints(kFtpcWestId);
1183  Int_t NoFtpcEastId = dinfo->numberOfPoints(kFtpcEastId);
1184  // Check that it could be TPC pile-up track, i.e. in the same half TPC (West East)
1185  // there are more than 2 hits with wrong Z -position
1186  if (NoTpcFitPoints >= 11) {
1187  const StPtrVecHit& hits = dinfo->hits(kTpcId);
1188  Int_t Nhits = hits.size();
1189  Int_t NoWrongSignZ = 0;
1190  Int_t NoPositiveSignZ = 0;
1191  Int_t NoNegativeSignZ = 0;
1192  Int_t NoPromptHits = 0;
1193  Double_t zE = -200, zW = 200;
1194  Int_t rE = 0, rW = 0;
1195  Int_t nW = 0, nE = 0;
1196  for (Int_t i = 0; i < Nhits; i++) {
1197  const StTpcHit *hit = (StTpcHit *) hits[i];
1198  Double_t z = hit->position().z();
1199  Int_t sector = hit->sector();
1200  if (sector <= 12) nW++;
1201  else nE++;
1202  Int_t row = hit->padrow();
1203  if ((z < -1.0 && sector <= 12) ||
1204  (z > 1.0 && sector > 12)) NoWrongSignZ++;
1205  else {
1206  if (z < -1.0) {NoNegativeSignZ++; if (z > zE) {zE = z; rE = row;}}
1207  if (z > 1.0) {NoPositiveSignZ++; if (z < zW) {zW = z; rW = row;}}
1208  }
1209  if (TMath::Abs(209.4 - TMath::Abs(z)) < 3.0) NoPromptHits++;
1210  }
1211  if (NoWrongSignZ >= 2) gTrack->setPostCrossingTrack();
1212  else {
1213  if (NoPromptHits == 1) gTrack->setPromptTrack();
1214  if (NoPositiveSignZ >= 2 && NoNegativeSignZ >=2) {
1215  if (zW - zE < 10 ||
1216  TMath::Abs(rW - rE) < 3)
1217  gTrack->setMembraneCrossingTrack();
1218  }
1219  }
1220  if (nW > 0 && nE == 0) gTrack->setWestTpcOnly();
1221  if (nW == 0 && nE > 0) gTrack->setEastTpcOnly();
1222  }
1223  if (NoTpcFitPoints < 11 && NoFtpcWestId < 5 && NoFtpcEastId < 5) {
1224  // hardcoded number correspondant to __MIN_HITS_TPC__ 11 in StMuFilter.cxx
1225  //keep most sig. digit, set last digit to 2, and set negative sign
1226  gTrack->setRejected();
1227  flag = - ((flag/100)*100 + 2); // -x02
1228 
1229  // Deciding which short tracks to keep based on event time.
1230  // Hardcoded times are not optimal, and will need revisiting
1231  // when EEMC is turned back on after BES-II, eTOF stays or goes?
1232  int evtTime = mEvent->time();
1233  bool doShort2EMC = (evtTime < 1538352000 || evtTime > 1633046400); // t < 2018-10-01 or t > 2021-10-01
1234  bool doShort2ETOF = (evtTime > 1525910400); // 2018-05-10 < t < (no end)
1235 
1236  if ((doShort2EMC || doShort2ETOF) && gTrack->geometry()) {
1237  const StThreeVectorF &momentum = gTrack->geometry()->momentum();
1238  const float eta = momentum.pseudoRapidity();
1239  if (TMath::Abs(eta) > 0.5) {
1240  const StTrackDetectorInfo *dinfo = gTrack->detectorInfo();
1241  const StPtrVecHit& hits = dinfo->hits();
1242  Int_t Nhits = hits.size();
1243  Bool_t ShortTrack2EMC = kFALSE;
1244  Bool_t ShortTrack2ETOF = kFALSE;
1245  for (Int_t i = 0; i < Nhits; i++) {
1246  const StHit *hit = hits[i];
1247  if (doShort2EMC && eta > 0.5 && hit->position().z() > 150.0) {
1248  ShortTrack2EMC = kTRUE;
1249  break;
1250  }
1251  if (doShort2ETOF && eta < -0.5 && hit->position().z() < -150.0) {
1252  ShortTrack2ETOF = kTRUE;
1253  break;
1254  }
1255  }
1256  if (ShortTrack2EMC) {
1257  gTrack->setShortTrack2EMC();
1258  flag = (TMath::Abs(flag)/100)*100+11; // +x11
1259  } else if (ShortTrack2ETOF) {
1260  gTrack->setShortTrack2ETOF();
1261  flag = (TMath::Abs(flag)/100)*100+12; // +x12
1262  }
1263  }
1264  }
1265  }
1266  }
1267 
1268  gTrack->setFlag( flag);
1269  if (gTrack->type()==global) {
1270  // Match with fast detectors
1271  StPhysicalHelixD hlx = gTrack->outerGeometry()->helix();
1273  mFastDetectorMatcher->matchTrack2FastDetectors(&hlx,&t);
1274  if (t.btofBin > 0) {
1275  if (t.mBtof > 0) gTrack->setToFMatched();
1276  else gTrack->setToFNotMatched();
1277  }
1278  if (t.ctbBin > 0) {
1279  if (t.mCtb > 0) gTrack->setCtbMatched();
1280  else gTrack->setCtbNotMatched();
1281  }
1282  if (t.bemcBin > 0 || t.eemcBin > 0) {
1283  Int_t W = 0;
1284  if (t.bemcBin > 0) {
1285  W = StBemcHitList::instance()->getFired(t.bemcBin);
1286  if (W > 0) gTrack->setBemcMatched();
1287  else gTrack->setBemcNotMatched();
1288  } else if (t.eemcBin > 0) {
1289  W = StEemcHitList::instance()->getFired(t.eemcBin);
1290  if (W > 0) gTrack->setEemcMatched();
1291  else gTrack->setEemcNotMatched();
1292  }
1293  if (W > 0) {
1294  UInt_t fext = gTrack->flagExtension();
1295  if (W > 7) W = 7;
1296  fext &= ~7;
1297  fext += W;
1298  gTrack->setFlagExtension(fext);
1299  }
1300  }
1301  } else if (gTrack->type()==primary) {
1302  StTrackNode *n = gTrack->node();
1303  assert(n);
1304  StTrack *t = n->track(global);
1305  assert(t);
1306  gTrack->setFlagExtension(t->flagExtension());
1307  }
1308 }
1309 //_____________________________________________________________________________
1310 void StiStEventFiller::fillTrack(StTrack* gTrack, StiKalmanTrack* track,StTrackDetectorInfo* detInfo )
1311 {
1312 
1313  //cout << "StiStEventFiller::fillTrack()" << endl;
1314  // encoded method = 16 bits = 12 fitting and 4 finding, for the moment use:
1315  // kKalmanFitId
1316  // bit 15 for finding, (needs to be changed in StEvent).
1317  // change: make sure bits are ok, are the bits set up one in each position and nothing else?
1318  // this would mean that the encoded method is wasting space!
1319  // the problem is that in principle there might be combinations of finders for each tracking detector
1320  // but the integrated tracker will use only one for all detectors maybe
1321  // so need this bit pattern:
1322  // finding 100000000000
1323  // fitting 0010
1324  // 32768 + 2 = 32770;
1325  //
1326  // above is no longer used, instead use kITKalmanfitId as fitter and tpcOther as finding method
1327 
1328  gTrack->setEncodedMethod(mStiEncoded);
1329  double tlen = track->getTrackLength();
1330  assert(tlen >0.0 && tlen<1000.);
1331  gTrack->setLength(tlen);// someone removed this, grrrr!!!!
1332  gTrack->setSeedQuality(track->getSeedHitCount());
1333  // Follow the StDetectorId.h enumerations...
1334  // can't include them from here in order not to
1335  // create a package dependence...
1336  int dets[kMaxDetectorId][3];
1337  track->getAllPointCount(dets,kMaxDetectorId-1);
1338  for (int i=1;i<kMaxDetectorId;i++) {
1339  if(!dets[i][0]) continue;
1340  gTrack->setNumberOfPossiblePoints((unsigned char)dets[i][0],(StDetectorId)i);
1341  }
1342  fillGeometry(gTrack, track, false); // inner geometry
1343  fillGeometry(gTrack, track, true ); // outer geometry
1344  fillFitTraits(gTrack, track);
1345  gTrack->setDetectorInfo(detInfo);
1346  StuFixTopoMap(gTrack);
1347  fillFlags(gTrack);
1348  if (!track->isPrimary()) fillDca(gTrack,track);
1349  return;
1350 }
1351 //_____________________________________________________________________________
1352 bool StiStEventFiller::accept(StiKalmanTrack* track)
1353 {
1354 // int nPossiblePoints = track->getMaxPointCount(0);
1355 // int nMeasuredPoints = track->getPointCount (0);
1356  int nFittedPoints = track->getFitPointCount(0);
1357  if (nFittedPoints < 5 ) return 0;
1358 #if 0
1359  if (nFittedPoints < 10 && nFittedPoints*2 < nPossiblePoints)return 0;
1360  if(track->getPt()<=0.1) return 0;
1361 #endif
1362  if(track->getTrackLength()<=0) return 0;
1363  if(track->getChi2()>100) return 0;
1364  // insert other filters for riff-raff we don't want in StEvent here.
1365 
1366 
1367  return 1;
1368 }
1369 //_____________________________________________________________________________
1370 double StiStEventFiller::impactParameter(StiKalmanTrack* track
1371  ,StThreeVectorD &vertexPosition)
1372 {
1373  StiKalmanTrackNode* node;
1374 
1375  node = track->getInnerMostNode(2); // ...
1376 
1377 
1378  originD->setX(node->x_g());
1379  originD->setY(node->y_g());
1380  originD->setZ(node->z_g());
1381 
1382 
1383  physicalHelix->setParameters(fabs(node->getCurvature()),
1384  node->getDipAngle(),
1385  node->getPhase(),
1386  *originD,
1387  node->getHelicity());
1388 
1389 
1390  //cout <<"PHelix: "<<*physicalHelix<<endl;
1391  return physicalHelix->distance(vertexPosition);
1392 }
1393 //_____________________________________________________________________________
1394 double StiStEventFiller::impactParameter(StTrack* track, StThreeVectorD &vertex)
1395 {
1396  StPhysicalHelixD helix = track->geometry()->helix();
1397 
1398  //cout <<"PHelix: "<<helix<<endl;
1399  return helix.distance(vertex);
1400 }
1401 //_____________________________________________________________________________
1402  void StiStEventFiller::fillResHack(StHit *hh,const StiHit *stiHit, const StiKalmanTrackNode *node)
1403  {
1404 
1405  if (!mAux) return;
1406  StiAux_t aux;
1407 // local frame
1408  aux.xnl[0] = node->getX();
1409  aux.xnl[1] = node->getY();
1410  aux.xnl[2] = node->getZ();
1411 
1412  aux.xhl[0] = stiHit->x();
1413  aux.xhl[1] = stiHit->y();
1414  aux.xhl[2] = stiHit->z();
1415 
1416  aux.ca = node->getEta();
1417  aux.rho = node->getCurvature();
1418  aux.nYY = node->getCyy();
1419  aux.nZZ = node->getCzz();
1420  aux.hYY = node->getEyy();
1421  aux.hZZ = node->getEzz();
1422 
1423  aux.unl[0] = node->getX();
1424  aux.unl[1] = node->unTouched().mPar[0];
1425  aux.unl[2] = node->unTouched().mPar[1];
1426  aux.uYY = sqrt(node->unTouched().mErr[0]);
1427  aux.uZZ = sqrt(node->unTouched().mErr[2]);
1428 
1429 
1430  // global frame
1431  aux.xng[0] = node->x_g();
1432  aux.xng[1] = node->y_g();
1433  aux.xng[2] = node->z_g();
1434 
1435  aux.xhg[0] = stiHit->x_g();
1436  aux.xhg[1] = stiHit->y_g();
1437  aux.xhg[2] = stiHit->z_g();
1438  aux.psi = node->getPsi();
1439  aux.dip = node->getDipAngle();
1440  // invariant
1441  double chi2 = node->getChi2();if (chi2>1000) chi2=1000;
1442  aux.chi2 = chi2;
1443  int id = mAux->AddIt(&aux);
1444  assert(id);
1445  hh->setId(id);
1446  assert(hh->id());
1447 //mAux->PrintIt(id);
1448 
1449 
1450 }
1451 //_____________________________________________________________________________
1452 void StiStEventFiller::fillDca(StTrack* stTrack, StiKalmanTrack* track)
1453 {
1454  StGlobalTrack *gTrack = dynamic_cast<StGlobalTrack*>(stTrack);
1455  assert(gTrack);
1456 
1457  StiKalmanTrackNode *tNode = track->getInnerMostNode();
1458  if (!tNode->isDca()) return;
1459  const StiNodePars &pars = tNode->fitPars();
1460  const StiNodeErrs &errs = tNode->fitErrs();
1461  float alfa = tNode->getAlpha();
1462  Float_t setp[7] = {(float)pars.y(), (float)pars.z(), (float)pars.eta()
1463  ,(float)pars.ptin(), (float)pars.tanl(), (float)pars.curv(), (float)pars.hz()};
1464  setp[2]+= alfa;
1465  Float_t sete[15];
1466  for (int i=1,li=1,jj=0;i< kNPars;li+=++i) {
1467  for (int j=1;j<=i;j++) {sete[jj++]=errs.G()[li+j];}}
1468  StDcaGeometry *dca = new StDcaGeometry;
1469  gTrack->setDcaGeometry(dca);
1470  dca->set(setp,sete);
1471 
1472 }
1473 //_____________________________________________________________________________
1474 void StiStEventFiller::FillTpcdX(const StiKalmanTrack* track, const StiKalmanTrackNode *node, StHit *hh)
1475 {
1476  StTpcHit *tpcHit = dynamic_cast<StTpcHit*>(hh);
1477  if (! tpcHit) return;
1478  if (! node || ! hh) return;
1479  originD->setX(node->x_g());
1480  originD->setY(node->y_g());
1481  originD->setZ(node->z_g());
1482 
1483  physicalHelix->setParameters(fabs(node->getCurvature()),
1484  node->getDipAngle(),
1485  node->getPhase(),
1486  *originD,
1487  node->getHelicity());
1488  StThreeVectorD upper(tpcHit->positionU().x(),tpcHit->positionU().y(),tpcHit->positionU().z());
1489  StThreeVectorD lower(tpcHit->positionL().x(),tpcHit->positionL().y(),tpcHit->positionL().z());
1490  StThreeVectorD middle(tpcHit->position().x(),tpcHit->position().y(),tpcHit->position().z());
1491  StThreeVectorD dif = upper - lower;
1492  StThreeVectorD normal = dif.unit();
1493  Double_t s[2];
1494  s[0] = physicalHelix->pathLength(upper, normal);
1495  s[1] = physicalHelix->pathLength(lower, normal);
1496  Double_t dx = TMath::Abs(s[0]) + TMath::Abs(s[1]);
1497  tpcHit->setdX(dx);
1498 }
1499 //_____________________________________________________________________________
1500 void StiStEventFiller::FillStHitErr(StHit *hh,const StiKalmanTrackNode *node)
1501 {
1502  double stiErr[6],stErr[6];
1503  memcpy(stiErr,node->hitErrs(),sizeof(stiErr));
1504  double alfa = node->getAlpha();
1505  double c = cos(alfa);
1506  double s = sin(alfa);
1507  double T[3][3]={{c,-s, 0}
1508  ,{s, c, 0}
1509  ,{0, 0, 1}};
1510 
1511  TCL::trasat(T[0],stiErr,stErr,3,3);
1512  StThreeVectorF f3(sqrt(stErr[0]),sqrt(stErr[2]),sqrt(stErr[5]));
1513  hh->setPositionError(f3);
1514 }
1515 //_____________________________________________________________________________
1516 void StiStEventFiller::fillPulls(StiKalmanTrack* track,const StGlobalTrack *gTrack, int gloPri)
1517 {
1518 enum dcaEmx {kImpImp,
1519  kZImp, kZZ,
1520  kPsiImp, kPsiZ, kPsiPsi,
1521  kPtiImp, kPtiZ, kPtiPsi, kPtiPti,
1522  kTanImp, kTanZ, kTanPsi, kTanPti, kTanTan};
1523 
1524  //cout << "StiStEventFiller::fillDetectorInfo() -I- Started"<<endl;
1525  if (!mPullEvent) return;
1526  if (gloPri && track->isPrimary()!=1) return;
1527  const StDcaGeometry *myDca = gTrack->dcaGeometry();
1528  if (!myDca) return;
1529 
1530  int dets[kMaxDetectorId][3];
1531  track->getAllPointCount(dets,kMaxDetectorId-1);
1532  StiPullTrk aux;
1533  aux.mVertex = (unsigned char)track->isPrimary();
1534  aux.mTrackNumber=track->getId();
1535  aux.nAllHits = dets[0][2];
1536  aux.nTpcHits = dets[kTpcId][2];
1537  aux.nSvtHits = dets[kSvtId][2];
1538  aux.nSsdHits = dets[kSsdId][2];
1539  aux.nPxlHits = dets[kPxlId][2];
1540  aux.nIstHits = dets[kIstId][2];
1541  aux.mL = (unsigned char)track->getTrackLength();
1542  aux.mChi2 = track->getChi2();
1543  aux.mCurv = myDca->curvature();
1544  aux.mPt = myDca->pt();
1545  aux.mPsi = myDca->psi();
1546  aux.mDip = myDca->dipAngle();
1547  StThreeVectorF v3 = myDca->origin();
1548  aux.mRxy = v3.perp();
1549  aux.mPhi = v3.phi();
1550  aux.mZ = v3.z();
1551 
1552  const float *errMx = myDca->errMatrix();
1553  aux.mPtErr = sqrt(errMx[kPtiPti])*aux.mPt*aux.mPt;
1554  double c2dip = myDca->tanDip(); c2dip = 1./(1.+c2dip*c2dip);
1555  aux.mPsiErr = sqrt(errMx[kPsiPsi]);
1556  aux.mDipErr = sqrt(errMx[kTanTan])*c2dip;
1557  aux.mRxyErr = sqrt(errMx[kImpImp]);
1558  aux.mZErr = sqrt(errMx[kZZ]);
1559 
1560  aux.mIdTruTk = gTrack->idTruth();
1561  aux.mQaTruTk = gTrack->qaTruth();
1562  mPullEvent->Add(aux,gloPri);
1563 
1564 
1565  StiKTNIterator tNode = track->rbegin();
1566  StiKTNIterator eNode = track->rend();
1567  for (;tNode!=eNode;++tNode)
1568  {
1569  StiKalmanTrackNode *node = &(*tNode);
1570  if(!node->isValid()) continue;
1571 
1572  StiHit *stiHit = node->getHit();
1573  if (!stiHit) continue;
1574 
1575  if (node->getChi2()>1000) continue;
1576  if (!node->isFitted()) continue;
1577 
1578  const StiDetector *detector = node->getDetector();
1579  assert(detector == stiHit->detector());
1580  assert(!detector || stiHit->timesUsed());
1581  StHit *hh = (StHit*)stiHit->stHit();
1582  fillPulls(hh,stiHit,node,track,dets,gloPri);
1583  if (gloPri) continue;
1584  fillPulls(hh,stiHit,node,track,dets,2);
1585  }
1586 }
1587 //_____________________________________________________________________________
1588  void StiStEventFiller::fillPulls(StHit *stHit,const StiHit *stiHit
1589  ,const StiKalmanTrackNode *node
1590  ,const StiKalmanTrack *track
1591  ,int dets[1][3],int gloPriRnd)
1592 {
1593  double x,y,z,r,xp,yp,zp,rp;
1594  float untErrs[3];
1595 
1596  const StiNodeInf *inf = 0;
1597  if (gloPriRnd==2) {
1598  inf = node->getInfo();
1599  if (!inf) return;
1600  }
1601  double timeFlight = node->getTime();
1602  const StiNodeErrs &mFE = (inf)? inf->mPE : node->fitErrs();
1603  const StiNodePars &mFP = (inf)? inf->mPP : node->fitPars();
1604  StiHitErrs mHrr;
1605  memcpy(mHrr.G(), (inf)? inf->mHrr.G() : node->hitErrs(),sizeof(StiHitErrs));
1606 
1607  StiPullHit aux;
1608 // local frame
1609 // local HIT
1610  aux.mIdTruth = stHit->idTruth();
1611  aux.mQaTruth = stHit->qaTruth();
1612 
1613  aux.mVertex = (unsigned char)track->isPrimary();
1614  aux.nHitCand = node->getHitCand();
1615  aux.iHitCand = node->getIHitCand();
1616  if (!aux.nHitCand) aux.nHitCand=1;
1617  aux.lXHit = stiHit->x();
1618  aux.lYHit = stiHit->y(timeFlight);
1619  aux.lZHit = stiHit->z(timeFlight);
1620  aux.lYHitErr = sqrt(mHrr.hYY);
1621  aux.lZHitErr = sqrt(mHrr.hZZ);
1622  aux.lHitEmx[0] = mHrr.hYY;
1623  aux.lHitEmx[1] = mHrr.hZY;
1624  aux.lHitEmx[2] = mHrr.hZZ;
1625 
1626 // local FIT
1627  aux.lXFit = mFP.x();
1628  aux.lYFit = mFP.y();
1629  aux.lZFit = mFP.z();
1630  aux.lYFitErr = sqrt(mFE._cYY);
1631  aux.lZFitErr = sqrt(mFE._cZZ);
1632  aux.lFitEmx[0] = mFE._cYY;
1633  aux.lFitEmx[1] = mFE._cZY;
1634  aux.lFitEmx[2] = mFE._cZZ;
1635 // assert(fabs(aux.lYFit-aux.lYHit)>1e-10 || fabs(aux.lXHit)<4);
1636 
1637 // local Pull
1638  xp = aux.lXHit;
1639  yp = (inf)? mFP.y(): (double)node->unTouched().mPar[0];
1640  zp = (inf)? mFP.z(): (double)node->unTouched().mPar[1];
1641  aux.lYPul = aux.lYHit-yp;
1642  aux.lZPul = aux.lZHit-zp;
1643  if (fabs(aux.lYPul)>10) StiDebug::Break(-1);
1644  if (fabs(aux.lZPul)>10) StiDebug::Break(-1);
1645  if (!inf) {TCL::ucopy(node->unTouched().mErr,untErrs,3);}
1646  else {TCL::ucopy(aux.lFitEmx ,untErrs,3);}
1647  //#ifdef YF /* I don't know why these parameters are not set */
1648  assert(untErrs[0]>=0);
1649  assert(untErrs[2]>=0);
1650  //#endif
1651  TCL::vadd(untErrs,aux.lHitEmx,aux.lPulEmx,3);
1652  aux.lYPulErr = sqrt(aux.lPulEmx[0]);
1653  aux.lZPulErr = sqrt(aux.lPulEmx[2]);
1654 
1655  aux.lPsi = mFP.eta();
1656  aux.lDip = atan(mFP.tanl());
1657 
1658 // global frame
1659  double alfa = node->getAlpha();
1660  float F[2][2];
1661 
1662 // global Hit
1663  x = stiHit->x(); y = stiHit->y(timeFlight); z = stiHit->z(timeFlight);
1664  r = sqrt(x*x+y*y);
1665 
1666  aux.gRHit = r;
1667  aux.gPHit = atan2(stiHit->y_g(),stiHit->x_g());
1668  aux.gZHit = stiHit->z_g();
1669  memset(F[0],0,sizeof(F));
1670  F[0][0]= x/(r*r);
1671  F[1][1]= 1;
1672  TCL::trasat(F[0],aux.lHitEmx,aux.gHitEmx,2,2);
1673  aux.gPHitErr = sqrt(aux.gHitEmx[0]);
1674  aux.gZHitErr = sqrt(aux.gHitEmx[2]);
1675 
1676 
1677 // global Fit
1678  x = mFP.x(); y = mFP.y();z = mFP.z();
1679  r = sqrt(x*x+y*y);
1680  aux.gRFit = r;
1681  aux.gPFit = NICE(atan2(y,x)+alfa);
1682  aux.gZFit = z;
1683 
1684  memset(F[0],0,sizeof(F));
1685  F[0][0]= x/(r*r);
1686  F[1][1]= 1;
1687  TCL::trasat(F[0],aux.lFitEmx,aux.gFitEmx,2,2);
1688  aux.gPFitErr = sqrt(aux.gFitEmx[0]);
1689  aux.gZFitErr = sqrt(aux.gFitEmx[2]);
1690 
1691 // global Pull
1692  rp = sqrt(xp*xp+yp*yp);
1693  aux.gPPul = ((aux.gPHit-alfa)-atan2(yp,xp))*rp;
1694  aux.gZPul = aux.lZHit-zp;
1695  memset(F[0],0,sizeof(F));
1696  F[0][0]= xp/(rp*rp);
1697  F[1][1]= 1;
1698  TCL::trasat(F[0],untErrs,aux.gPulEmx,2,2);
1699  TCL::vadd(aux.gHitEmx,aux.gPulEmx,aux.gPulEmx,3);
1700 // Now account that Phi ==> R*Phi
1701  aux.gPulEmx[0]*= rp*rp;
1702  aux.gPulEmx[1]*= rp;
1703  aux.gPPulErr = sqrt(aux.gPulEmx[0]);
1704  aux.gZPulErr = sqrt(aux.gPulEmx[2]);
1705 
1706  aux.gPsi = node->getPsi();
1707  aux.gDip = node->getDipAngle();
1708 
1709  // invariant
1710  aux.mCurv = mFP.curv();
1711  aux.mPt = fabs(1./mFP.ptin());
1712  aux.mCharge = stHit->charge();
1713  aux.mChi2 = node->getChi2();
1714  aux.mNormalRefAngle = alfa;
1715  aux.mHardwarePosition=0;
1716  aux.mDetector=0;
1717  aux.mTrackNumber=track->getId();
1718  aux.nAllHits = dets[0][2];
1719  aux.nTpcHits = dets[kTpcId][2];
1720  aux.nSvtHits = dets[kSvtId][2];
1721  aux.nSsdHits = dets[kSsdId][2];
1722  aux.nPxlHits = dets[kPxlId][2];
1723  aux.nIstHits = dets[kIstId][2];
1724  const StiDetector *stiDet = stiHit->detector();
1725  if (stiDet) {
1726  aux.mHardwarePosition=stHit->hardwarePosition();
1727  aux.mDetector=stHit->detector();
1728  const StiPlacement *place = stiDet->getPlacement();
1729  aux.mNormalRadius = place->getNormalRadius();
1730  aux.mNormalYOffset = place->getNormalYoffset();
1731  aux.mZCenter = 0;
1732  }
1733  mPullEvent->Add(aux,gloPriRnd);
1734 
1735 }
StiKalmanTrackNode * getInnOutMostNode(int inot, int qua) const
Same for getNNodes(qua)
void setParameters(double c, double dip, double phase, const StThreeVector< double > &o, int h)
starting point
Definition: StHelix.cc:139
StiKalmanTrackNode * getInnerMostHitNode(int qua=0) const
Accessor method returns the inner most hit node associated with the track.
Definition of Kalman Track.
static void hftHist(const char *tit, const StiKalmanTrack *tk)
Definition: StiHitTest.cxx:86
void fillFlags(StTrack *track)
Definition: StHit.h:125
StiKalmanTrackNode * getLastNode() const
Accessor method returns the last node associated with the track.
void getAllPointCount(int count[1][3], int maxDetId) const
Returns all the PointCount far all detectors and types of nodes.
Definition: StiHit.h:51
const Float_t & x() const
Return the local x, y, z values.
Definition: StiHit.h:67
StThreeVectorF getGlobalMomentumF() const
const StiDetector * detector() const
Definition: StiHit.h:96
double distance(const StThreeVector< double > &p, bool scanPeriods=true) const
minimal distance between point and helix
Definition: StHelix.cc:240
Float_t x_g() const
Return the global x, y, z values.
Definition: StiHit.h:73
pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)
Definition: StHelix.cc:351
int getFitPointCount(int detectorId=0) const
Returns the number of hits associated and used in the fit of this track.
StiKalmanTrackNode * getInnerMostNode(int qua=0) const
Accessor method returns the inner most node associated with the track.
int getPointCount(int detectorId=0) const
Return the number of hits associated with this track.
Definition of Kalman Track.
static float * trasat(const float *a, const float *s, float *r, int m, int n)
Definition: TCernLib.cxx:540
UInt_t timesUsed() const
Return the number of times this hit was assigned to a track.
Definition: StiHit.h:108
double getChi2() const
UShort_t getSeedHitCount() const
number of hits used to seed the track
int isPrimary() const
double evaluateChi2(const StiHit *hit)
double getTrackLength() const
double getCurvature() const
Calculates and returns the tangent of the track pitch angle at this node.
void fillEvent(StEvent *e, StiTrackContainer *t)
void getGlobalTpt(float x[6], float e[15])
Extract state information from this node in TPT representation.
const StMeasuredPoint * stHit() const
Definition: StiHit.h:104
double getPt() const
Calculates and returns the transverse momentum of the track at the inner most node.
int getCharge() const
void fillDetectorInfo(StTrackDetectorInfo *detInfo, StiKalmanTrack *kTrack, bool refCountIncr)