#ifndef _DKinFitResults_factory_ #define _DKinFitResults_factory_ #include #include #include #include #include "TString.h" #include "JANA/JFactory.h" #include "JANA/JEventLoop.h" #include "HDGEOMETRY/DMagneticFieldMap.h" #include "PID/DChargedTrackHypothesis.h" #include "PID/DChargedTrack.h" #include "PID/DNeutralShower.h" #include "PID/DKinematicData.h" #include "PID/DBeamPhoton.h" #include "ANALYSIS/DParticleCombo.h" #include "ANALYSIS/DKinFitResults.h" #include "ANALYSIS/DAnalysisUtilities.h" #include "ANALYSIS/DKinFitter_GlueX.h" #include "ANALYSIS/DAnalysisResults.h" using namespace std; using namespace jana; class DKinFitResults_factory : public jana::JFactory { public: DKinFitResults_factory(){}; ~DKinFitResults_factory(){}; void Reset_NewEvent(void); private: jerror_t init(void); ///< Called once at program start. jerror_t brun(jana::JEventLoop* locEventLoop, int runnumber); ///< Called everytime a new run number is detected. jerror_t evnt(jana::JEventLoop* locEventLoop, int eventnumber); ///< Called every event. jerror_t erun(void); ///< Called everytime run number changes, provided brun has been called. jerror_t fini(void); ///< Called after last event of last event source has been processed. bool Create_KinFitConstraints(const DParticleCombo* locParticleCombo, map > >& locDecayingKinFitParticles, deque& locOriginalConstraints, deque > >& locSortedConstraints); void Setup_P4Constraint(const DParticleCombo* locParticleCombo, size_t locStepIndex, const deque >& locInitialKinFitParticles, const deque >& locFinalKinFitParticles, deque& locInitialKinFitParticles_P4, deque& locFinalKinFitParticles_P4, deque& locIncludedStepIndices, bool& locConstrainMassFlag); void Setup_VertexConstraint(const DParticleCombo* locParticleCombo, size_t locStepIndex, const deque >& locInitialKinFitParticles, const deque >& locFinalKinFitParticles, deque& locInitialKinFitParticles_Vertex, deque& locFinalKinFitParticles_Vertex, deque& locIncludedStepIndices); bool Handle_IfKinFitResultsWillBeIdentical(const DParticleCombo* locParticleCombo, deque locConstraints_ToCheck, const DEventRFBunch* locRFBunch_ToCheck, map > > locDecayingKinFitParticles_ToCheck); bool Check_IfKinFitResultsWillBeIdentical(map > > locDecayingKinFitParticles_ToCheck, map > > locDecayingKinFitParticles_CheckAgainst); bool Check_IfKinFitResultsWillBeIdentical(deque locConstraints_ToCheck, deque locConstraints_CheckAgainst, const DEventRFBunch* locRFBunch_ToCheck, const DEventRFBunch* locRFBunch_CheckAgainst); bool Check_IfKinFitResultsWillBeIdentical(DKinFitConstraint_P4* locConstraint_ToCheck, const DKinFitConstraint_P4* locConstraint_CheckAgainst); bool Check_IfKinFitResultsWillBeIdentical(DKinFitConstraint_VertexBase* locConstraint_ToCheck, const DKinFitConstraint_VertexBase* locConstraint_CheckAgainst); bool Check_IfKinFitResultsWillBeIdentical(DKinFitConstraint_Spacetime* locConstraint_ToCheck, const DKinFitConstraint_Spacetime* locConstraint_CheckAgainst, const DEventRFBunch* locRFBunch_ToCheck, const DEventRFBunch* locRFBunch_CheckAgainst); bool Check_IfKinFitResultsWillBeIdentical(deque locParticles_ToCheck, deque locParticles_CheckAgainst); bool Setup_KinFit(DKinFitType locKinFitType, const deque& locOriginalConstraints, const DEventRFBunch* locEventRFBunch, deque > >& locSortedConstraints); double Calc_TimeGuess(const DKinFitConstraint_Spacetime* locConstraint, DVector3 locVertexGuess, double locRFTime); void Build_KinFitResults(const DParticleCombo* locParticleCombo, const map > >& locInitDecayingKinFitParticles, deque& locOriginalConstraints); const DAnalysisUtilities* dAnalysisUtilities; DKinFitter_GlueX dKinFitter; unsigned int dDebugLevel; unsigned int dKinFitDebugLevel; bool dLinkVerticesFlag; double dTargetZCenter; class DPreviousFitInfo { public: DPreviousFitInfo(const DEventRFBunch* locEventRFBunch, deque& locOriginalConstraints, map > >& locDecayingParticles) : dEventRFBunch(locEventRFBunch), dOriginalConstraints(locOriginalConstraints), dDecayingParticles(locDecayingParticles) {} const DEventRFBunch* dEventRFBunch; deque dOriginalConstraints; //post skim after sort map > > dDecayingParticles; private: DPreviousFitInfo(void); }; deque dPreviouslyFailedFits; }; #endif // _DKinFitResults_factory_