// $Id$ // // File: DParticleID.h // Created: Mon Feb 28 13:47:49 EST 2011 // Creator: staylor (on Linux ifarml1 2.6.18-128.el5 x86_64) // #ifndef _DParticleID_ #define _DParticleID_ #include #include #include #include #include #include #include "HDGEOMETRY/DRootGeom.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include class DTrackTimeBased; class DParticleID:public jana::JObject{ public: JOBJECT_PUBLIC(DParticleID); // Constructor and destructor DParticleID(JEventLoop *loop); // require JEventLoop in constructor virtual ~DParticleID(void){} class dedx_t{ public: dedx_t(double dE,double dx, double p):dE(dE),dx(dx),p(p){dEdx = dE/dx;} double dE; // energy loss in layer double dx; // path length in layer double dEdx; // ratio dE/dx double p; // momentum at this dE/dx measurement }; virtual jerror_t CalcDCdEdxChiSq(DChargedTrackHypothesis *locChargedTrackHypothesis) const = 0; jerror_t GetDCdEdxHits(const DTrackTimeBased *track, vector& dEdxHits_CDC, vector& dEdxHits_FDC) const; jerror_t CalcDCdEdx(const DTrackTimeBased *locTrackTimeBased, double& locdEdx_FDC, double& locdx_FDC, double& locdEdx_CDC, double& locdx_CDC, unsigned int& locNumHitsUsedFordEdx_FDC, unsigned int& locNumHitsUsedFordEdx_CDC) const; jerror_t CalcDCdEdx(const DTrackTimeBased *locTrackTimeBased, const vector& locdEdxHits_CDC, const vector& locdEdxHits_FDC, double& locdEdx_FDC, double& locdx_FDC, double& locdEdx_CDC, double& locdx_CDC, unsigned int& locNumHitsUsedFordEdx_FDC, unsigned int& locNumHitsUsedFordEdx_CDC) const; jerror_t CalcdEdxHit(const DVector3 &mom, const DVector3 &pos, const DCDCTrackHit *hit, pair &dedx) const; jerror_t GroupTracks(vector &tracks, vector >&grouped_tracks) const; void GetScintMPdEandSigma(double p,double M,double x,double &most_prob_dE, double &sigma_dE) const; //called by track reconstruction bool MatchToTOF(const DReferenceTrajectory* rt, const vector& locTOFPoints, double& locStartTime, double& locTimeVariance) const; bool MatchToBCAL(const DReferenceTrajectory* rt, const vector& locBCALShowers, double& locStartTime, double& locTimeVariance) const; bool MatchToFCAL(const DReferenceTrajectory* rt, const vector& locFCALShowers, double& locStartTime, double& locTimeVariance) const; bool MatchToSC(const DReferenceTrajectory* rt, const vector& locSCHits, double& locStartTime, double& locTimeVariance, bool locIsTimeBased=false) const; // Routines to predict which detector elements should fire given a track unsigned int PredictSCSector(const DReferenceTrajectory* rt, const double dphi_cut) const; bool PredictTOFPaddles(const DReferenceTrajectory *rt, unsigned int &hbar,unsigned int &vbar, DVector3 *intersection=NULL) const; //matching tracks to hits/showers routines (can be called by DDetectorMatches factory) bool MatchToBCAL(const DKinematicData* locTrack, const DReferenceTrajectory* rt, const DBCALShower* locBCALShower, double locInputStartTime, DBCALShowerMatchParams& locShowerMatchParams) const; bool MatchToTOF(const DKinematicData* locTrack, const DReferenceTrajectory* rt, const DTOFPoint* locTOFPoint, double locInputStartTime, DTOFHitMatchParams& locTOFHitMatchParams) const; bool MatchToFCAL(const DKinematicData* locTrack, const DReferenceTrajectory* rt, const DFCALShower* locFCALShower, double locInputStartTime, DFCALShowerMatchParams& locShowerMatchParams) const; bool MatchToSC(const DKinematicData* locTrack, const DReferenceTrajectory* rt, const DSCHit* locSCHit, double locInputStartTime, DSCHitMatchParams& locSCHitMatchParams, bool locIsTimeBased=false, DVector3 *IntersectionPoint=NULL, DVector3 *IntersectionDir=NULL) const; // Alternate SC matching algorithm for straight line tracks bool MatchToSC(const DKinematicData *kd, const vector& locSCHits, vector& locSCHitMatchParams) const; //select "best" matches //called by several factories bool Get_BestSCMatchParams(const DKinematicData* locTrack, const DDetectorMatches* locDetectorMatches, DSCHitMatchParams& locBestMatchParams) const; void Get_BestSCMatchParams(vector& locSCHitMatchParams, DSCHitMatchParams& locBestMatchParams) const; bool Get_BestBCALMatchParams(const DKinematicData* locTrack, const DDetectorMatches* locDetectorMatches, DBCALShowerMatchParams& locBestMatchParams) const; void Get_BestBCALMatchParams(DVector3 locMomentum, vector& locShowerMatchParams, DBCALShowerMatchParams& locBestMatchParams) const; bool Get_BestTOFMatchParams(const DKinematicData* locTrack, const DDetectorMatches* locDetectorMatches, DTOFHitMatchParams& locBestMatchParams) const; void Get_BestTOFMatchParams(vector& locTOFHitMatchParams, DTOFHitMatchParams& locBestMatchParams) const; bool Get_BestFCALMatchParams(const DKinematicData* locTrack, const DDetectorMatches* locDetectorMatches, DFCALShowerMatchParams& locBestMatchParams) const; void Get_BestFCALMatchParams(vector& locShowerMatchParams, DFCALShowerMatchParams& locBestMatchParams) const; //matching showers to tracks routines (mostly called by DDetectorMatches factory) bool Distance_ToTrack(const DBCALShower* locBCALShower, const DReferenceTrajectory* rt, double locInputStartTime, double& locDistance, double& locDeltaPhi, double& locDeltaZ) const; bool Distance_ToTrack(const DFCALShower* locFCALShower, const DReferenceTrajectory* rt, double locInputStartTime, double& locDistance) const; bool Distance_ToTrack(const DTOFPoint* locTOFPoint, const DReferenceTrajectory* rt, double locInputStartTime, double& locDeltaX, double& locDeltaY) const; bool Distance_ToTrack(const DSCHit* locSCHit, const DReferenceTrajectory* rt, double locInputStartTime, double& locDeltaPhi) const; //select closest shower/hit to track //track MUST be either DTrackTimeBased or DTrackWireBased //NULL if no possibly-valid matches const DBCALShower* Get_ClosestToTrack_BCAL(const DKinematicData* locTrack, vector& locBCALShowers, double& locBestMatchDeltaPhi, double& locBestMatchDeltaZ) const; const DFCALShower* Get_ClosestToTrack_FCAL(const DKinematicData* locTrack, vector& locFCALShowers, double& locBestDistance) const; const DTOFPoint* Get_ClosestToTrack_TOF(const DKinematicData* locTrack, vector& locTOFPoints, double& locBestDeltaX, double& locBestDeltaY) const; const DSCHit* Get_ClosestToTrack_SC(const DKinematicData* locTrack, vector& locSCHits, double& locBestDeltaPhi) const; double Calc_BCALFlightTimePCorrelation(const DKinematicData* locTrack, DDetectorMatches* locDetectorMatches) const; double Calc_FCALFlightTimePCorrelation(const DKinematicData* locTrack, DDetectorMatches* locDetectorMatches) const; double Calc_TOFFlightTimePCorrelation(const DKinematicData* locTrack, DDetectorMatches* locDetectorMatches) const; double Calc_SCFlightTimePCorrelation(const DKinematicData* locTrack, const DDetectorMatches* locDetectorMatches) const; virtual Particle_t IDTrack(float locCharge, float locMass) const; double Calc_PropagatedRFTime(const DKinematicData* locKinematicData, const DEventRFBunch* locEventRFBunch) const; double Calc_TimingChiSq(const DKinematicData* locKinematicData, unsigned int &locNDF, double& locTimingPull) const; void Calc_ChargedPIDFOM(DChargedTrackHypothesis* locChargedTrackHypothesis, const DEventRFBunch* locEventRFBunch) const; unsigned int Get_CDCRingBitPattern(vector& locCDCTrackHits) const; unsigned int Get_FDCPlaneBitPattern(vector& locFDCPseudos) const; void Get_CDCRings(int locBitPattern, set& locCDCRings) const; void Get_FDCPlanes(int locBitPattern, set& locFDCPlanes) const; protected: // gas material properties double dKRhoZoverA_FDC, dRhoZoverA_FDC, dLnI_FDC; double dKRhoZoverA_Scint, dRhoZoverA_Scint, dLnI_Scint; double dKRhoZoverA_CDC, dRhoZoverA_CDC, dLnI_CDC; double dDensity_FDC; double dDensity_CDC; double dA_CDC; double dA_FDC; double BCAL_Z_CUT,BCAL_PHI_CUT_PAR1,BCAL_PHI_CUT_PAR2; double FCAL_CUT_PAR1,FCAL_CUT_PAR2; double DELTA_R_FCAL; double C_EFFECTIVE; // start counter light propagation speed double ATTEN_LENGTH; // Start counter attenuation length double OUT_OF_TIME_CUT; //for all matches private: int DEBUG_LEVEL; // Prohibit default constructor DParticleID(); // start counter geometry parameters double sc_leg_tcor; double sc_angle_cor; vector >sc_pos; vector >sc_norm; double dSCdphi; double dSCphi0; // start counter calibration parameters enum sc_region_t{ SC_STRAIGHT, SC_BEND, SC_NOSE, }; vectorsc_veff[3]; // TOF calibration constants // used to update hit energy & time when matching to un-matched, position-ill-defined bars const DTOFGeometry* dTOFGeometry; vector propagation_speed; double TOF_ATTEN_LENGTH; double ONESIDED_PADDLE_MIDPOINT_MAG; //+/- this number for North/South double dTargetZCenter; double dRFBunchFrequency; double SC_DPHI_CUT,SC_DPHI_CUT_WB; const DTrackFinder *finder; }; #endif // _DParticleID_