// $Id$ // // File: DTrackCandidate_factory.cc // Created: Mon Jul 18 15:23:04 EDT 2005 // Creator: davidl (on Darwin wire129.jlab.org 7.8.0 powerpc) // #include #include using namespace std; #include #include #include "DTrackCandidate_factory_FDC.h" #include "DANA/DApplication.h" #include "DQuickFit.h" #include "JANA/JGeometry.h" #include "HDGEOMETRY/DMagneticFieldMap.h" #include "DVector2.h" #include "FDC/DFDCGeometry.h" #include "DHoughFind.h" bool FDCSortByZincreasing(DTrackCandidate_factory_FDC::DFDCTrkHit* const &hit1, DTrackCandidate_factory_FDC::DFDCTrkHit* const &hit2) { return hit1->hit->pos.Z() < hit2->hit->pos.Z(); } //------------------ // DTrackCandidate_factory_FDC //------------------ DTrackCandidate_factory_FDC::DTrackCandidate_factory_FDC() { #if 0 // Set defaults MAX_SEED_DIST = 5.0; gPARMS->SetDefaultParameter("TRKFIND:MAX_SEED_DIST", MAX_SEED_DIST); #endif } //------------------ // init //------------------ jerror_t DTrackCandidate_factory_FDC::init(void) { TARGET_Z_MIN = 65.0 - 15.0; TARGET_Z_MAX = 65.0 + 15.0; MAX_HIT_DIST = 5.0; MAX_HIT_DIST2 = MAX_HIT_DIST*MAX_HIT_DIST; return NOERROR; } //------------------ // brun //------------------ jerror_t DTrackCandidate_factory_FDC::brun(JEventLoop *loop, int runnumber) { return NOERROR; } //------------------ // fini //------------------ jerror_t DTrackCandidate_factory_FDC::fini(void) { return NOERROR; } //------------------ // evnt //------------------ jerror_t DTrackCandidate_factory_FDC::evnt(JEventLoop *loop, int eventnumber) { // Get the hits into the trkhits vector GetTrkHits(loop); // Find seeds from X/Y projections vector seeds; FindSeeds(seeds); // Loop over seeds and fit in phi-z plane to find z and theta for(unsigned int i=0; i3)_DBG_<<"----- Seed "<3)_DBG_<<"p_trans="<flags & NOISE))continue; // this hit already has noise flag cleared double d2 = trkhit1->Dist2(trkhit2); double deltaz = fabs(trkhit1->hit->pos.Z() - trkhit2->hit->pos.Z()); if(debug_level>4)_DBG_<<" -- Dist hits "<hit->pos; // Calculate phi. We do this trivially for now DVector2 p(pos.X() , pos.Y()); DVector2 p_minus_Ro = p - Ro; p_minus_Ro/=p_minus_Ro.Mod(); double delta_phi = p_minus_Ro.Phi() - last_dir.Phi(); while(delta_phi>+M_PI)delta_phi-=2.0*M_PI; while(delta_phi<-M_PI)delta_phi+=2.0*M_PI; fdctrkhit->phi_hit = last_phi + delta_phi; last_phi = fdctrkhit->phi_hit; last_dir = p_minus_Ro; if(debug_level>3)_DBG_<<"phi_hit="<phi_hit<<" z="<hit->pos.Z()<<" phi_hit/z="<phi_hit/(fdctrkhit->hit->pos.Z()-65.0)<<" delta_phi="<hit->wire2->layer<=6){ Nq += fdctrkhit->phi_hit>0.0 ? +1:-1; } } // If Nq has too few entries, then look to the second package if(abs(Nq)<2){ for(unsigned int i=0; ihit->wire2->layer<=12){ Nq += fdctrkhit->phi_hit>0.0 ? +1:-1; } } } if(Nq<0)seed.q = -seed.q; } //------------------ // NumAvailableHits //------------------ unsigned int DTrackCandidate_factory_FDC::NumAvailableHits(void) { // Loop over all hits and count the ones that are still // available for making a new seed. unsigned int N=0; for(unsigned int i=0; iflags&USED)continue; if(fdctrkhit->flags&NOISE)continue; if(fdctrkhit->flags&OUT_OF_TIME)continue; if(fdctrkhit->flags&CANT_BE_IN_SEED)continue; N++; } return N; } //------------------ // FindThetaZ //------------------ void DTrackCandidate_factory_FDC::FindThetaZ(DFDCSeed &seed) { FindTheta(seed, TARGET_Z_MIN, TARGET_Z_MAX); FindZ(seed, seed.theta_min, seed.theta_max); // If z_vertex is not inside the target limits, then flag this // seed as invalid. if(seed.z_vertexTARGET_Z_MAX){ if(debug_level>3)_DBG_<<"Seed z-vertex outside of target range (z="<3)_DBG_<<" - No entries in theta hist. Seed aborted."<3)_DBG_<<"istart="<3)_DBG_<<" - No entries in z-vertex hist. Seed aborted."<3)_DBG_<<"istart="<