Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DTrackCandidate_factory.h
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DTrackCandidate_factory.h
4 // Created: Mon Jul 18 15:23:04 EDT 2005
5 // Creator: davidl (on Darwin wire129.jlab.org 7.8.0 powerpc)
6 //
7 
8 #ifndef _DTrackCandidate_factory_
9 #define _DTrackCandidate_factory_
10 
11 
12 #include <JANA/JFactory.h>
13 #include <JANA/JEventLoop.h>
14 using namespace jana;
15 #include <TH2F.h>
16 #include <TH1F.h>
17 #include "DTrackCandidate.h"
18 #include <DVector3.h>
19 #include "CDC/DCDCTrackHit.h"
21 #include "FDC/DFDCSegment.h"
22 #include "DHelicalFit.h"
23 #include "DMagneticFieldStepper.h"
24 #include "PID/DParticleID.h"
25 
26 class DMagneticFieldMap;
27 class DParticleID;
28 
29 /// \htmlonly
30 /// <A href="index.html#legend">
31 /// <IMG src="CORE.png" width="100">
32 /// </A>
33 /// \endhtmlonly
34 
35 /// Form complete list of DTrackCandidate objects using the lists formed
36 /// from the CDC and FDCCathodes candidate factories (DTrackCandidate_factory_CDC
37 /// and DTrackCandidate_factory_FDCCathodes).
38 ///
39 /// Track finding starts by looking for candidates independently in the CDC
40 /// and FDC. The results of those first passes are used as input here where
41 /// a single list is made containijng all candidates.
42 ///
43 /// This will attempt to identify any candidates that should be merged into a
44 /// single candidate, mainly if a both a CDC and FDC candidate were found for
45 /// the same track.
46 ///
47 /// In addition, stray CDC hits that did not belong to any candidate are
48 /// merged into existing candidates if possible.
49 
50 class DTrackCandidate_factory:public JFactory<DTrackCandidate>{
51  public:
53  DEBUG_HISTS=false;
54  //DEBUG_HISTS=true;
55  };
57 
58  protected:
59  virtual jerror_t init(void);
60  virtual jerror_t evnt(JEventLoop *loop, uint64_t eventnumber); ///< Invoked via JEventProcessor virtual method
61  virtual jerror_t brun(JEventLoop* eventLoop,int32_t runnumber);
62  virtual jerror_t erun(void);
63  virtual jerror_t fini(void);
64 
65  double DocaToHelix(const DCDCTrackHit *hit,double q,const DVector3 &pos,
66  const DVector3 &mom);
67  double GetSenseOfRotation(DHelicalFit &fit,const DFDCPseudo *fdchit,const DVector3 &pos);
68  jerror_t DoRefit(DHelicalFit &fit,
69  vector<const DFDCSegment *>segments,
70  vector<const DCDCTrackHit *>cdchits,
71  double &Bz);
72  void ProjectHelixToZ(const double z,const double q,const DVector3 &mom,
73  DVector3 &pos);
74 
75  void GetPositionAndMomentum(const DFDCSegment *segment,DVector3 &pos,
76  DVector3 &mom) const;
77  jerror_t GetPositionAndMomentum(DHelicalFit &fit,double Bz,
78  const DVector3 &origin,DVector3 &pos,
79  DVector3 &mom) const;
80  void GetPositionAndMomentum(double z,const DHelicalFit &fit,
81  double Bz,DVector3 &pos,DVector3 &mom) const;
82  void GetPositionAndMomentum(const DHelicalFit &fit,double Bz,DVector3 &pos,
83  DVector3 &mom) const;
84  void UpdatePositionAndMomentum(DHelicalFit &fit,double Bz,
85  const DVector3 &origin,DVector3 &pos,
86  DVector3 &mom) const;
87  bool CheckZPosition(const DTrackCandidate *fdccan) const;
88 
89  // Various methods for matching CDC and FDC candidates
90  bool MatchMethod1(const DTrackCandidate *fdccan,
91  vector<unsigned int> &cdc_forward_ids,
92  vector<DVector3>&cdc_endplate_projections,
93  vector<int>&cdc_forward_matches
94  );
95  bool MatchMethod2(const DTrackCandidate *fdccan,const DTrackCandidate *cdccan
96  );
97  bool MatchMethod3(const DTrackCandidate *cdccan,vector<int> &forward_matches
98  );
99  bool MatchMethod4(const DTrackCandidate *srccan,vector<int> &forward_matches,
100  int &num_fdc_cands_remaining);
101  bool MatchMethod5(DTrackCandidate *can,
102  vector<const DCDCTrackHit *>&cdchits,
103  vector<int> &forward_matches);
104  void MatchMethod6(DTrackCandidate *can,
105  vector<const DFDCPseudo *>&fdchits,
106  vector<unsigned int>&used_cdc_hits,
107  unsigned int &num_unmatched_cdcs
108  );
109  bool MatchMethod7(DTrackCandidate *srccan,vector<int> &forward_matches,
110  int &num_fdc_cands_remaining);
111  bool MatchMethod8(const DTrackCandidate *cdccan,vector<int> &forward_matches);
112  bool MatchMethod9(unsigned int src_index,const DTrackCandidate *srccan,
113  const DFDCSegment *segment,
114  vector<const DTrackCandidate*>&cands,
115  vector<int> &forward_matches);
116  bool MatchMethod10(unsigned int src_index,const DTrackCandidate *srccan,
117  const DFDCSegment *segment,
118  vector<const DTrackCandidate*>&cands,
119  vector<int> &forward_matches);
120  bool MatchMethod11(double q,DVector3 &mypos,DVector3 &mymom,
121  DHelicalFit &fit2,const DFDCSegment *segment1,
122  const DFDCSegment *segment2);
123  bool MatchMethod12(DTrackCandidate *srccan,vector<int> &forward_matches,
124  int &num_fdc_cands_remaining);
125  bool MatchMethod13(unsigned int src_index,const DTrackCandidate *srccan,
126  const DFDCSegment *segment,
127  vector<const DTrackCandidate*>&cands,
128  vector<int> &forward_matches);
129  bool TryToFlipDirection(vector<const DSCHit *>&scihits,
130  DVector3 &mom,DVector3 &pos) const;
131  bool MatchStraySegments(vector<int> &forward_matches,
132  int &num_fdc_cands_remaining);
133  bool MakeCandidateFromMethod1(double theta,
134  vector<const DFDCSegment *>&segments,
135  const DTrackCandidate *cdccan);
136 
137  private:
142 
143  vector<const DTrackCandidate*>cdctrackcandidates;
144  vector<const DTrackCandidate*>fdctrackcandidates;
145  vector<const DCDCTrackHit*>mycdchits;
146  vector<DTrackCandidate *>trackcandidates;
147 
148  int DEBUG_LEVEL,MIN_NUM_HITS;
150  TH2F *match_dist,*match_dist_vs_p;
151 // TH2F *match_center_dist2;
152 
156  double TARGET_Z;
157  int MAX_NUM_TRACK_CANDIDATES; //used to avoid memory spikes: if this # is exceeded, delete all tracks //to disable, set = -1!!
158 
159  vector<vector<DVector3> >sc_pos;
160  vector<vector<DVector3> >sc_norm;
161 
162 };
163 
164 #endif // _DTrackCandidate_factory_
165 
const DMagneticFieldMap * bfield
vector< const DCDCTrackHit * > mycdchits
TVector3 DVector3
Definition: DVector3.h:14
vector< DTrackCandidate * > trackcandidates
class DFDCPseudo: definition for a reconstructed point in the FDC
Definition: DFDCPseudo.h:74
DMagneticFieldStepper class.
vector< vector< DVector3 > > sc_norm
&lt;A href=&quot;index.html#legend&quot;&gt; &lt;IMG src=&quot;CORE.png&quot; width=&quot;100&quot;&gt; &lt;/A&gt;
DMagneticFieldStepper * stepper
vector< const DTrackCandidate * > fdctrackcandidates
vector< vector< DVector3 > > sc_pos
class DFDCSegment: definition for a track segment in the FDC
Definition: DFDCSegment.h:31
vector< const DTrackCandidate * > cdctrackcandidates
&lt;A href=&quot;index.html#legend&quot;&gt; &lt;IMG src=&quot;CORE.png&quot; width=&quot;100&quot;&gt; &lt;/A&gt;