Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-14 02:34:10

0001 #ifndef RECOPIXELVERTEXING_PIXELTRIPLETS_CAHITTRIPLETGENERATOR_H
0002 #define RECOPIXELVERTEXING_PIXELTRIPLETS_CAHITTRIPLETGENERATOR_H
0003 
0004 #include "RecoTracker/TkSeedingLayers/interface/SeedComparitorFactory.h"
0005 #include "RecoTracker/TkSeedingLayers/interface/SeedComparitor.h"
0006 #include "RecoPixelVertexing/PixelTrackFitting/interface/RZLine.h"
0007 
0008 #include "RecoTracker/TkMSParametrization/interface/PixelRecoUtilities.h"
0009 #include "RecoTracker/TkMSParametrization/interface/LongitudinalBendingCorrection.h"
0010 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0011 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0012 
0013 #include "RecoTracker/TkHitPairs/interface/HitPairGeneratorFromLayerPair.h"
0014 #include "RecoTracker/TkHitPairs/interface/LayerHitMapCache.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 #include "FWCore/Utilities/interface/EDGetToken.h"
0017 
0018 #include "RecoTracker/TkHitPairs/interface/IntermediateHitDoublets.h"
0019 
0020 #include "RecoPixelVertexing/PixelTriplets/interface/OrderedHitSeeds.h"
0021 #include "RecoPixelVertexing/PixelTriplets/interface/CACut.h"
0022 class TrackingRegion;
0023 class SeedingLayerSetsHits;
0024 
0025 namespace edm {
0026   class Event;
0027   class EventSetup;
0028   class ParameterSetDescription;
0029 }  // namespace edm
0030 
0031 class CAHitTripletGenerator {
0032 public:
0033   typedef LayerHitMapCache LayerCacheType;
0034 
0035   static constexpr unsigned int minLayers = 3;
0036   typedef OrderedHitSeeds ResultType;
0037 
0038 public:
0039   CAHitTripletGenerator(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC) : CAHitTripletGenerator(cfg, iC) {}
0040   CAHitTripletGenerator(const edm::ParameterSet& cfg, edm::ConsumesCollector& iC);
0041 
0042   ~CAHitTripletGenerator() = default;
0043 
0044   static void fillDescriptions(edm::ParameterSetDescription& desc);
0045   static const char* fillDescriptionsLabel() { return "caHitTriplet"; }
0046 
0047   void initEvent(const edm::Event& ev, const edm::EventSetup& es);
0048 
0049   void hitNtuplets(const IntermediateHitDoublets& regionDoublets,
0050                    std::vector<OrderedHitSeeds>& result,
0051                    const SeedingLayerSetsHits& layers);
0052 
0053 private:
0054   LayerCacheType theLayerCache;
0055 
0056   std::unique_ptr<SeedComparitor> theComparitor;
0057 
0058   const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theFieldToken;
0059   const MagneticField* theField = nullptr;
0060 
0061   class QuantityDependsPtEval {
0062   public:
0063     QuantityDependsPtEval(float v1, float v2, float c1, float c2)
0064         : value1_(v1), value2_(v2), curvature1_(c1), curvature2_(c2) {}
0065 
0066     float value(float curvature) const {
0067       if (value1_ == value2_)  // not enabled
0068         return value1_;
0069 
0070       if (curvature1_ < curvature)
0071         return value1_;
0072       if (curvature2_ < curvature && curvature <= curvature1_)
0073         return value2_ + (curvature - curvature2_) / (curvature1_ - curvature2_) * (value1_ - value2_);
0074       return value2_;
0075     }
0076 
0077   private:
0078     const float value1_;
0079     const float value2_;
0080     const float curvature1_;
0081     const float curvature2_;
0082   };
0083 
0084   // Linear interpolation (in curvature) between value1 at pt1 and
0085   // value2 at pt2. If disabled, value2 is given (the point is to
0086   // allow larger/smaller values of the quantity at low pt, so it
0087   // makes more sense to have the high-pt value as the default).
0088 
0089   class QuantityDependsPt {
0090   public:
0091     explicit QuantityDependsPt(const edm::ParameterSet& pset)
0092         : value1_(pset.getParameter<double>("value1")),
0093           value2_(pset.getParameter<double>("value2")),
0094           pt1_(pset.getParameter<double>("pt1")),
0095           pt2_(pset.getParameter<double>("pt2")),
0096           enabled_(pset.getParameter<bool>("enabled")) {
0097       if (enabled_ && pt1_ >= pt2_)
0098         throw cms::Exception("Configuration") << "CAHitTripletGenerator::QuantityDependsPt: pt1 (" << pt1_
0099                                               << ") needs to be smaller than pt2 (" << pt2_ << ")";
0100       if (pt1_ <= 0)
0101         throw cms::Exception("Configuration")
0102             << "CAHitTripletGenerator::QuantityDependsPt: pt1 needs to be > 0; is " << pt1_;
0103       if (pt2_ <= 0)
0104         throw cms::Exception("Configuration")
0105             << "CAHitTripletGenerator::QuantityDependsPt: pt2 needs to be > 0; is " << pt2_;
0106     }
0107 
0108     QuantityDependsPtEval evaluator(const MagneticField& field) const {
0109       if (enabled_) {
0110         return QuantityDependsPtEval(value1_,
0111                                      value2_,
0112                                      PixelRecoUtilities::curvature(1.f / pt1_, field),
0113                                      PixelRecoUtilities::curvature(1.f / pt2_, field));
0114       }
0115       return QuantityDependsPtEval(value2_, value2_, 0.f, 0.f);
0116     }
0117 
0118   private:
0119     const float value1_;
0120     const float value2_;
0121     const float pt1_;
0122     const float pt2_;
0123     const bool enabled_;
0124   };
0125 
0126   const float extraHitRPhitolerance;
0127 
0128   const QuantityDependsPt maxChi2;
0129   const bool useBendingCorrection;
0130 
0131   CACut caThetaCut;
0132   CACut caPhiCut;
0133   const float caHardPtCut = 0.f;
0134 };
0135 
0136 #endif