Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-23 03:13:33

0001 #ifndef GroupedCkfTrajectoryBuilder_H
0002 #define GroupedCkfTrajectoryBuilder_H
0003 
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 
0008 #include "RecoTracker/CkfPattern/interface/BaseCkfTrajectoryBuilder.h"
0009 #include "DataFormats/TrajectorySeed/interface/PropagationDirection.h"
0010 
0011 #include "TrackingTools/PatternTools/interface/TempTrajectory.h"
0012 
0013 #include <vector>
0014 
0015 #include "FWCore/Utilities/interface/Visibility.h"
0016 
0017 /** A highly configurable trajectory builder that allows full
0018  *  exploration of the combinatorial tree of possible continuations,
0019  *  and provides efficient ways of trimming the combinatorial tree.
0020  */
0021 
0022 class dso_internal GroupedCkfTrajectoryBuilder final : public BaseCkfTrajectoryBuilder {
0023 public:
0024   /// constructor from ParameterSet
0025   GroupedCkfTrajectoryBuilder(const edm::ParameterSet& conf, edm::ConsumesCollector& iC);
0026 
0027   /// destructor
0028   ~GroupedCkfTrajectoryBuilder() override {}
0029 
0030   static void fillPSetDescription(edm::ParameterSetDescription& iDesc);
0031 
0032   /// set Event for the internal MeasurementTracker data member
0033   //  virtual void setEvent(const edm::Event& event) const;
0034 
0035   /// trajectories building starting from a seed
0036   TrajectoryContainer trajectories(const TrajectorySeed&) const override;
0037 
0038   /// trajectories building starting from a seed, return in an already allocated vector
0039   void trajectories(const TrajectorySeed&, TrajectoryContainer& ret) const override;
0040 
0041   /// trajectories building starting from a seed with a region
0042   TrajectoryContainer trajectories(const TrajectorySeed&, const TrackingRegion&) const;
0043 
0044   /// trajectories building starting from a seed with a region
0045   void trajectories(const TrajectorySeed&, TrajectoryContainer& ret, const TrackingRegion&) const;
0046 
0047   /// common part of both public trajectory building methods
0048   void buildTrajectories(const TrajectorySeed& seed,
0049                          TrajectoryContainer& ret,
0050                          unsigned int& nCandPerSeed,
0051                          const TrajectoryFilter*) const override;
0052 
0053   /** trajectories re-building in the seeding region.
0054       It looks for additional measurements in the seeding region of the 
0055       intial trajectories.
0056       Only valid trajectories are returned. Invalid ones are dropped from the input
0057       collection.
0058   **/
0059   void rebuildSeedingRegion(const TrajectorySeed&, TrajectoryContainer& result) const override;
0060   // same as above FIXME
0061   void rebuildTrajectories(const TrajectorySeed&, TrajectoryContainer& result) const override;
0062 
0063   // Access to lower level components
0064   const TrajectoryStateUpdator& updator() const { return *theUpdator; }
0065   const Chi2MeasurementEstimatorBase& estimator() const { return *theEstimator; }
0066 
0067   //   PropagationDirection        direction() const  {return theDirection;}
0068 
0069   /** Chi**2 Cut on the new Trajectory Measurements to consider */
0070   double chiSquareCut() { return theChiSquareCut; }
0071 
0072   /** Maximum number of trajectory candidates to propagate to the next layer. */
0073   int maxCand() { return theMaxCand; }
0074 
0075   /** Chi**2 Penalty for each lost hit. */
0076   float lostHitPenalty() { return theLostHitPenalty; }
0077 
0078   //   /** Tells whether an intermediary cleaning stage should take place during TB. */
0079   //   bool         intermediateCleaning()  {return theIntermediateCleaning;}
0080 
0081   /// Pt cut
0082   double ptCut() { return theptCut; }
0083 
0084   /// Mass hypothesis used for propagation
0085   double mass() { return theMass; }
0086 
0087 protected:
0088   void setEvent_(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
0089 
0090   virtual void analyseSeed(const TrajectorySeed& seed) const {}
0091 
0092   virtual void analyseMeasurements(const std::vector<TM>& meas, const Trajectory& traj) const {}
0093   virtual void analyseResult(const TrajectoryContainer& result) const {}
0094 
0095 private:
0096   //  /// no copy constructor
0097   //  GroupedCkfTrajectoryBuilder (const GroupedCkfTrajectoryBuilder&)  = default;
0098   //
0099   //  /// no assignment operator
0100   //  GroupedCkfTrajectoryBuilder& operator= (const GroupedCkfTrajectoryBuilder&)  dso_internal;
0101 
0102   inline bool tkxor(bool a, bool b) const dso_internal { return (a || b) && !(a && b); }
0103   // to be ported later
0104 
0105   bool advanceOneLayer(const TrajectorySeed& seed,
0106                        TempTrajectory& traj,
0107                        const TrajectoryFilter* regionalCondition,
0108                        const Propagator* propagator,
0109                        bool inOut,
0110                        TempTrajectoryContainer& newCand,
0111                        TempTrajectoryContainer& result) const dso_internal;
0112 
0113   unsigned int groupedLimitedCandidates(const TrajectorySeed& seed,
0114                                         TempTrajectory const& startingTraj,
0115                                         const TrajectoryFilter* regionalCondition,
0116                                         const Propagator* propagator,
0117                                         bool inOut,
0118                                         TempTrajectoryContainer& result) const dso_internal;
0119 
0120   /// try to find additional hits in seeding region
0121   void rebuildSeedingRegion(const TrajectorySeed& seed, TempTrajectoryContainer& result) const dso_internal;
0122 
0123   // ** try to find additional hits in seeding region for a candidate
0124   // * (returns number of trajectories added) *
0125   int rebuildSeedingRegion(const TrajectorySeed& seed,
0126                            const std::vector<const TrackingRecHit*>& seedHits,
0127                            TempTrajectory& candidate,
0128                            TempTrajectoryContainer& result) const dso_internal;
0129 
0130   // ** Backward fit of trajectory candidate except seed. Fit result is returned. invalid if fit failed
0131   // *  remaining hits are returned  remainingHits.
0132   TempTrajectory backwardFit(TempTrajectory& candidate,
0133                              unsigned int nSeed,
0134                              const TrajectoryFitter& fitter,
0135                              std::vector<const TrackingRecHit*>& remainingHits) const dso_internal;
0136 
0137   /// Verifies presence of a RecHits in a range of TrajectoryMeasurements.
0138   bool verifyHits(TempTrajectory::DataContainer::const_iterator rbegin,
0139                   size_t maxDepth,
0140                   const std::vector<const TrackingRecHit*>& hits) const dso_internal;
0141 
0142   /// intermediate cleaning in the case of grouped measurements
0143   void groupedIntermediaryClean(TempTrajectoryContainer& theTrajectories) const dso_internal;
0144 
0145   /// change of propagation direction
0146   static inline PropagationDirection oppositeDirection(PropagationDirection dir) {
0147     if (dir == alongMomentum)
0148       return oppositeToMomentum;
0149     if (dir == oppositeToMomentum)
0150       return alongMomentum;
0151     return dir;
0152   }
0153 
0154 private:
0155   TrajectoryFilter* theConfigurableCondition;
0156 
0157   //   typedef deque< const TrajectoryFilter*>   StopCondContainer;
0158   //   StopCondContainer              theStopConditions;
0159 
0160   double theChiSquareCut; /**< Chi**2 Cut on the new Trajectory Measurements to consider */
0161 
0162   double theptCut; /**< ptCut */
0163 
0164   double theMass; /**< Mass hypothesis used for propagation */
0165 
0166   int theMaxCand;               /**< Maximum number of trajectory candidates 
0167                              to propagate to the next layer. */
0168   float theLostHitPenalty;      /**< Chi**2 Penalty for each lost hit. */
0169   float theFoundHitBonus;       /**< Chi**2 bonus for each found hit (favours candidates with
0170                      more measurements) */
0171   bool theIntermediateCleaning; /**< Tells whether an intermediary cleaning stage 
0172                                      should take place during TB. */
0173 
0174   bool theAlwaysUseInvalid;
0175 
0176   bool theLockHits;    /**< Lock hits when building segments in a layer */
0177   bool theBestHitOnly; /**< Use only best hit / group when building segments */
0178 
0179   bool theRequireSeedHitsInRebuild;
0180   /**< Only accept rebuilt trajectories if they contain the seed hits. */
0181   unsigned int theMinNrOfHitsForRebuild;
0182   /**< Minimum nr. of non-seed hits required for rebuild. 
0183                                      If ==0 the seeding part will remain untouched. */
0184   unsigned int theMinNrOf2dHitsForRebuild;
0185   /**< Minimum nr. of non-seed 2D hits required for rebuild. */
0186   bool theKeepOriginalIfRebuildFails;
0187   /**< Keep original trajectory if rebuilding fails. */
0188 
0189   /** If the value is greater than zero, the reconstructions for looper is turned on for
0190       candidates with pt greater than maxPtForLooperReconstruction */
0191   float maxPt2ForLooperReconstruction;
0192 
0193   float maxDPhiForLooperReconstruction;
0194 
0195   //  mutable TempTrajectoryContainer work_; // Better here than alloc every time
0196   enum work_MaxSize_Size_ {
0197     work_MaxSize_ = 50
0198   };  // if it grows above this number, it is forced to resize to half this amount when cleared
0199 };
0200 
0201 #endif