Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:28:10

0001 /** \class Chi2ChargeMeasurementEstimatorESProducer
0002  *  ESProducer for Chi2ChargeMeasurementEstimator.
0003  *
0004  *  \author speer
0005  */
0006 
0007 #include "DataFormats/SiStripCluster/interface/SiStripClusterTools.h"
0008 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0009 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0010 
0011 #include "RecoTracker/MeasurementDet/interface/ClusterFilterPayload.h"
0012 
0013 #include <limits>
0014 
0015 #include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h"
0016 
0017 #include "RecoLocalTracker/SiStripClusterizer/interface/ClusterChargeCut.h"
0018 
0019 namespace {
0020 
0021   class Chi2ChargeMeasurementEstimator final : public Chi2MeasurementEstimator {
0022   public:
0023     /** Construct with cuts on chi2 and nSigma.
0024    *  The cut on Chi2 is used to define the acceptance of RecHits.
0025    *  The errors of the trajectory state are multiplied by nSigma 
0026    *  to define acceptance of Plane and maximalLocalDisplacement.
0027    */
0028     template <typename... Args>
0029     Chi2ChargeMeasurementEstimator(float minGoodPixelCharge,
0030                                    float minGoodStripCharge,
0031                                    float pTChargeCutThreshold,
0032                                    Args&&... args)
0033         : Chi2MeasurementEstimator(args...),
0034           minGoodPixelCharge_(minGoodPixelCharge),
0035           minGoodStripCharge_(minGoodStripCharge),
0036           pTChargeCutThreshold2_(pTChargeCutThreshold >= 0. ? pTChargeCutThreshold * pTChargeCutThreshold
0037                                                             : std::numeric_limits<float>::max()) {}
0038 
0039     bool preFilter(const TrajectoryStateOnSurface& ts, const MeasurementEstimator::OpaquePayload& opay) const override;
0040 
0041     Chi2ChargeMeasurementEstimator* clone() const override { return new Chi2ChargeMeasurementEstimator(*this); }
0042 
0043   private:
0044     const float minGoodPixelCharge_;
0045     const float minGoodStripCharge_;
0046     const float pTChargeCutThreshold2_;
0047 
0048     bool checkClusterCharge(DetId id, SiStripCluster const& cluster, const TrajectoryStateOnSurface& ts) const {
0049       return siStripClusterTools::chargePerCM(id, cluster, ts.localParameters()) > minGoodStripCharge_;
0050     }
0051   };
0052 
0053   bool Chi2ChargeMeasurementEstimator::preFilter(const TrajectoryStateOnSurface& ts,
0054                                                  const MeasurementEstimator::OpaquePayload& opay) const {
0055     // what we got?
0056     if (opay.tag != ClusterFilterPayload::myTag)
0057       return true;  // not mine...
0058 
0059     auto const& clf = reinterpret_cast<ClusterFilterPayload const&>(opay);
0060 
0061     if (ts.globalMomentum().perp2() > pTChargeCutThreshold2_)
0062       return true;
0063 
0064     DetId detid = clf.detId;
0065     uint32_t subdet = detid.subdetId();
0066 
0067     if (subdet > 2) {
0068       return checkClusterCharge(detid, *clf.cluster[0], ts) &&
0069              (nullptr == clf.cluster[1] || checkClusterCharge(detid, *clf.cluster[1], ts));
0070     }
0071 
0072     /*  pixel charge not implemented as not used...
0073      auto const & thit = static_cast<const SiPixelRecHit &>(hit);
0074      thit.cluster()->charge() ...
0075 
0076   */
0077 
0078     return true;
0079   }
0080 
0081 }  // namespace
0082 
0083 #include "FWCore/Framework/interface/ESProducer.h"
0084 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0085 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
0086 #include <memory>
0087 
0088 #include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimatorParams.h"
0089 
0090 namespace {
0091 
0092   class Chi2ChargeMeasurementEstimatorESProducer : public edm::ESProducer {
0093   public:
0094     static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0095     Chi2ChargeMeasurementEstimatorESProducer(const edm::ParameterSet& p);
0096     ~Chi2ChargeMeasurementEstimatorESProducer() override;
0097     std::unique_ptr<Chi2MeasurementEstimatorBase> produce(const TrackingComponentsRecord&);
0098 
0099   private:
0100     const double m_maxChi2;
0101     const double m_nSigma;
0102     const double m_maxDis;
0103     const double m_maxSag;
0104     const double m_minTol;
0105     const double m_minpt;
0106     const float m_minGoodStripCharge;
0107     const double m_pTChargeCutThreshold;
0108   };
0109 
0110   void Chi2ChargeMeasurementEstimatorESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0111     auto desc = chi2MeasurementEstimatorParams::getFilledConfigurationDescription();
0112     desc.add<std::string>("ComponentName", "Chi2Charge");
0113     desc.add<double>("pTChargeCutThreshold", -1.);
0114     edm::ParameterSetDescription descCCC = getConfigurationDescription4CCC(CCC::kLoose);
0115     desc.add<edm::ParameterSetDescription>("clusterChargeCut", descCCC);
0116     descriptions.add("Chi2ChargeMeasurementEstimatorDefault", desc);
0117   }
0118 
0119   Chi2ChargeMeasurementEstimatorESProducer::Chi2ChargeMeasurementEstimatorESProducer(const edm::ParameterSet& pset)
0120       : m_maxChi2(pset.getParameter<double>("MaxChi2")),
0121         m_nSigma(pset.getParameter<double>("nSigma")),
0122         m_maxDis(pset.getParameter<double>("MaxDisplacement")),
0123         m_maxSag(pset.getParameter<double>("MaxSagitta")),
0124         m_minTol(pset.getParameter<double>("MinimalTolerance")),
0125         m_minpt(pset.getParameter<double>("MinPtForHitRecoveryInGluedDet")),
0126         m_minGoodStripCharge(clusterChargeCut(pset)),
0127         m_pTChargeCutThreshold(pset.getParameter<double>("pTChargeCutThreshold")) {
0128     std::string const& myname = pset.getParameter<std::string>("ComponentName");
0129     setWhatProduced(this, myname);
0130   }
0131 
0132   Chi2ChargeMeasurementEstimatorESProducer::~Chi2ChargeMeasurementEstimatorESProducer() {}
0133 
0134   std::unique_ptr<Chi2MeasurementEstimatorBase> Chi2ChargeMeasurementEstimatorESProducer::produce(
0135       const TrackingComponentsRecord& iRecord) {
0136     auto minGoodPixelCharge = 0;
0137 
0138     return std::make_unique<Chi2ChargeMeasurementEstimator>(minGoodPixelCharge,
0139                                                             m_minGoodStripCharge,
0140                                                             m_pTChargeCutThreshold,
0141                                                             m_maxChi2,
0142                                                             m_nSigma,
0143                                                             m_maxDis,
0144                                                             m_maxSag,
0145                                                             m_minTol,
0146                                                             m_minpt);
0147   }
0148 
0149 }  // namespace
0150 
0151 #include "FWCore/Framework/interface/ModuleFactory.h"
0152 DEFINE_FWK_EVENTSETUP_MODULE(Chi2ChargeMeasurementEstimatorESProducer);