Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:22:05

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   // also new interface returning the start Trajectory...
0049   TempTrajectory buildTrajectories(const TrajectorySeed& seed,
0050                                    TrajectoryContainer& ret,
0051                                    unsigned int& nCandPerSeed,
0052                                    const TrajectoryFilter*) const override;
0053 
0054   /** trajectories re-building in the seeding region.
0055       It looks for additional measurements in the seeding region of the 
0056       intial trajectories.
0057       Only valid trajectories are returned. Invalid ones are dropped from the input
0058       collection.
0059   **/
0060   void rebuildSeedingRegion(const TrajectorySeed&, TrajectoryContainer& result) const override;
0061 
0062   // same as above using the precomputed startingTraj..
0063   void rebuildTrajectories(TempTrajectory const& startingTraj,
0064                            const TrajectorySeed&,
0065                            TrajectoryContainer& result) const override;
0066 
0067   // Access to lower level components
0068   const TrajectoryStateUpdator& updator() const { return *theUpdator; }
0069   const Chi2MeasurementEstimatorBase& estimator() const { return *theEstimator; }
0070 
0071   //   PropagationDirection        direction() const  {return theDirection;}
0072 
0073   /** Chi**2 Cut on the new Trajectory Measurements to consider */
0074   double chiSquareCut() { return theChiSquareCut; }
0075 
0076   /** Maximum number of trajectory candidates to propagate to the next layer. */
0077   int maxCand() { return theMaxCand; }
0078 
0079   /** Chi**2 Penalty for each lost hit. */
0080   float lostHitPenalty() { return theLostHitPenalty; }
0081 
0082   //   /** Tells whether an intermediary cleaning stage should take place during TB. */
0083   //   bool         intermediateCleaning()  {return theIntermediateCleaning;}
0084 
0085   /// Pt cut
0086   double ptCut() { return theptCut; }
0087 
0088   /// Mass hypothesis used for propagation
0089   double mass() { return theMass; }
0090 
0091 protected:
0092   void setEvent_(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
0093 
0094   virtual void analyseSeed(const TrajectorySeed& seed) const {}
0095 
0096   virtual void analyseMeasurements(const std::vector<TM>& meas, const Trajectory& traj) const {}
0097   virtual void analyseResult(const TrajectoryContainer& result) const {}
0098 
0099 private:
0100   //  /// no copy constructor
0101   //  GroupedCkfTrajectoryBuilder (const GroupedCkfTrajectoryBuilder&)  = default;
0102   //
0103   //  /// no assignment operator
0104   //  GroupedCkfTrajectoryBuilder& operator= (const GroupedCkfTrajectoryBuilder&)  dso_internal;
0105 
0106   inline bool tkxor(bool a, bool b) const dso_internal { return (a || b) && !(a && b); }
0107   // to be ported later
0108 
0109   bool advanceOneLayer(const TrajectorySeed& seed,
0110                        TempTrajectory& traj,
0111                        const TrajectoryFilter* regionalCondition,
0112                        const Propagator* propagator,
0113                        bool inOut,
0114                        TempTrajectoryContainer& newCand,
0115                        TempTrajectoryContainer& result) const dso_internal;
0116 
0117   unsigned int groupedLimitedCandidates(const TrajectorySeed& seed,
0118                                         TempTrajectory const& startingTraj,
0119                                         const TrajectoryFilter* regionalCondition,
0120                                         const Propagator* propagator,
0121                                         bool inOut,
0122                                         TempTrajectoryContainer& result) const dso_internal;
0123 
0124   /// try to find additional hits in seeding region
0125   void rebuildSeedingRegion(const TrajectorySeed& seed,
0126                             TempTrajectory const& startingTraj,
0127                             TempTrajectoryContainer& result) const dso_internal;
0128 
0129   //** try to find additional hits in seeding region for a candidate
0130   //* (returns number of trajectories added) *
0131   int rebuildSeedingRegion(const TrajectorySeed& seed,
0132                            const std::vector<const TrackingRecHit*>& seedHits,
0133                            TempTrajectory& candidate,
0134                            TempTrajectoryContainer& result) const dso_internal;
0135 
0136   // ** Backward fit of trajectory candidate except seed. Fit result is returned. invalid if fit failed
0137   // *  remaining hits are returned  remainingHits.
0138   TempTrajectory backwardFit(TempTrajectory& candidate,
0139                              unsigned int nSeed,
0140                              const TrajectoryFitter& fitter,
0141                              std::vector<const TrackingRecHit*>& remainingHits) const dso_internal;
0142 
0143   /// Verifies presence of a RecHits in a range of TrajectoryMeasurements.
0144   bool verifyHits(TempTrajectory::DataContainer::const_iterator rbegin,
0145                   size_t maxDepth,
0146                   const std::vector<const TrackingRecHit*>& hits) const dso_internal;
0147 
0148   /// intermediate cleaning in the case of grouped measurements
0149   void groupedIntermediaryClean(TempTrajectoryContainer& theTrajectories) const dso_internal;
0150 
0151   /// change of propagation direction
0152   static inline PropagationDirection oppositeDirection(PropagationDirection dir) {
0153     if (dir == alongMomentum)
0154       return oppositeToMomentum;
0155     if (dir == oppositeToMomentum)
0156       return alongMomentum;
0157     return dir;
0158   }
0159 
0160 private:
0161   TrajectoryFilter* theConfigurableCondition;
0162 
0163   //   typedef deque< const TrajectoryFilter*>   StopCondContainer;
0164   //   StopCondContainer              theStopConditions;
0165 
0166   double theChiSquareCut; /**< Chi**2 Cut on the new Trajectory Measurements to consider */
0167 
0168   double theptCut; /**< ptCut */
0169 
0170   double theMass; /**< Mass hypothesis used for propagation */
0171 
0172   int theMaxCand;               /**< Maximum number of trajectory candidates 
0173                              to propagate to the next layer. */
0174   float theLostHitPenalty;      /**< Chi**2 Penalty for each lost hit. */
0175   float theFoundHitBonus;       /**< Chi**2 bonus for each found hit (favours candidates with
0176                      more measurements) */
0177   bool theIntermediateCleaning; /**< Tells whether an intermediary cleaning stage 
0178                                      should take place during TB. */
0179 
0180   bool theAlwaysUseInvalid;
0181 
0182   bool theLockHits;    /**< Lock hits when building segments in a layer */
0183   bool theBestHitOnly; /**< Use only best hit / group when building segments */
0184 
0185   bool theRequireSeedHitsInRebuild;
0186   /**< Only accept rebuilt trajectories if they contain the seed hits. */
0187   unsigned int theMinNrOfHitsForRebuild;
0188   /**< Minimum nr. of non-seed hits required for rebuild. 
0189                                      If ==0 the seeding part will remain untouched. */
0190   unsigned int theMinNrOf2dHitsForRebuild;
0191   /**< Minimum nr. of non-seed 2D hits required for rebuild. */
0192   bool theKeepOriginalIfRebuildFails;
0193   /**< Keep original trajectory if rebuilding fails. */
0194 
0195   /** If the value is greater than zero, the reconstructions for looper is turned on for
0196       candidates with pt greater than maxPtForLooperReconstruction */
0197   float maxPt2ForLooperReconstruction;
0198 
0199   float maxDPhiForLooperReconstruction;
0200 
0201   //  mutable TempTrajectoryContainer work_; // Better here than alloc every time
0202   enum work_MaxSize_Size_ {
0203     work_MaxSize_ = 50
0204   };  // if it grows above this number, it is forced to resize to half this amount when cleared
0205 };
0206 
0207 #endif