// $Id$ // // File: DTrackCandidate_factory.h // Created: Mon Jul 18 15:23:04 EDT 2005 // Creator: davidl (on Darwin wire129.jlab.org 7.8.0 powerpc) // #ifndef _DTrackCandidate_factory_ #define _DTrackCandidate_factory_ #include #include using namespace jana; #include #include #include "DTrackCandidate.h" #include #include "CDC/DCDCTrackHit.h" #include "FDC/DFDCSegment.h" #include "DHelicalFit.h" #include "DMagneticFieldStepper.h" class DMagneticFieldMap; /// \htmlonly /// /// /// /// \endhtmlonly /// Form complete list of DTrackCandidate objects using the lists formed /// from the CDC and FDCCathodes candidate factories (DTrackCandidate_factory_CDC /// and DTrackCandidate_factory_FDCCathodes). /// /// Track finding starts by looking for candidates independently in the CDC /// and FDC. The results of those first passes are used as input here where /// a single list is made containijng all candidates. /// /// This will attempt to identify any candidates that should be merged into a /// single candidate, mainly if a both a CDC and FDC candidate were found for /// the same track. /// /// In addition, stray CDC hits that did not belong to any candidate are /// merged into existing candidates if possible. class DTrackCandidate_factory:public JFactory{ public: DTrackCandidate_factory(){ DEBUG_HISTS=false; //DEBUG_HISTS=true; }; ~DTrackCandidate_factory(){}; protected: virtual jerror_t init(void); virtual jerror_t evnt(JEventLoop *loop, int eventnumber); ///< Invoked via JEventProcessor virtual method virtual jerror_t brun(JEventLoop* eventLoop,int runnumber); virtual jerror_t erun(void); virtual jerror_t fini(void); double DocaToHelix(const DCDCTrackHit *hit,double q,const DVector3 &pos, const DVector3 &mom); double GetSenseOfRotation(DHelicalFit &fit,const DFDCPseudo *fdchit,const DVector3 &pos); jerror_t DoRefit(DHelicalFit &fit, vectorsegments, vectorcdchits, double &Bz); void ProjectHelixToZ(const double z,const double q,const DVector3 &mom, DVector3 &pos); jerror_t GetPositionAndMomentum(const DFDCSegment *segment, DVector3 &pos, DVector3 &mom); jerror_t GetPositionAndMomentum(DHelicalFit &fit,double Bz, const DVector3 &origin, DVector3 &pos, DVector3 &mom); jerror_t GetPositionAndMomentum(DHelicalFit &fit,double Bz,DVector3 &pos, DVector3 &mom); jerror_t GetPositionAndMomentum(double z,DHelicalFit &fit, double Bz,DVector3 &pos,DVector3 &mom); void UpdatePositionAndMomentum(DTrackCandidate *can,const DFDCPseudo *fdchit, DHelicalFit &fit,double Bz_avg,int axial_id); // Various methods for matching CDC and FDC candidates bool MatchMethod1(const DTrackCandidate *fdccan, vector &cdc_forward_ids, vector&cdc_endplate_projections, vector&used_cdc_hits ); bool MatchMethod2(const DTrackCandidate *fdccan, vector &cdc_forward_ids, vector&used_cdc_hits ); bool MatchMethod3(const DTrackCandidate *cdccan,vector &forward_matches, vector&used_cdc_hits ); bool MatchMethod4(const DTrackCandidate *srccan,vector &forward_matches, int &num_fdc_cands_remaining); bool MatchMethod5(DTrackCandidate *can, vector&cdchits, vector &forward_matches); void MatchMethod6(DTrackCandidate *can, vector&segments, vector&used_cdc_hits, unsigned int &num_unmatched_cdcs ); bool MatchMethod7(DTrackCandidate *srccan,vector &forward_matches, int &num_fdc_cands_remaining); bool MatchMethod8(const DTrackCandidate *cdccan,vector &forward_matches, vector&used_cdc_hits); private: const DMagneticFieldMap *bfield; DMagneticFieldStepper *stepper; vectorcdctrackcandidates; vectorfdctrackcandidates; vectormycdchits; vectortrackcandidates; int DEBUG_LEVEL,MIN_NUM_HITS; bool DEBUG_HISTS; TH2F *match_dist,*match_dist_vs_p; TH2F *match_center_dist2; double FactorForSenseOfRotation; DVector3 cdc_endplate; double endplate_rmax; double TARGET_Z; int MAX_NUM_TRACK_CANDIDATES; //used to avoid memory spikes: if this # is exceeded, delete all tracks //to disable, set = -1!! }; #endif // _DTrackCandidate_factory_