CMS 3D CMS Logo

Chi2ChargeMeasurementEstimatorESProducer.cc
Go to the documentation of this file.
1 
10 
12 
13 #include <limits>
14 
16 
18 
19 namespace {
20 
22  public:
28  template <typename... Args>
29  Chi2ChargeMeasurementEstimator(float minGoodPixelCharge,
30  float minGoodStripCharge,
32  Args&&... args)
34  minGoodPixelCharge_(minGoodPixelCharge),
35  minGoodStripCharge_(minGoodStripCharge),
36  pTChargeCutThreshold2_(pTChargeCutThreshold >= 0. ? pTChargeCutThreshold * pTChargeCutThreshold
37  : std::numeric_limits<float>::max()) {}
38 
39  bool preFilter(const TrajectoryStateOnSurface& ts, const MeasurementEstimator::OpaquePayload& opay) const override;
40 
41  Chi2ChargeMeasurementEstimator* clone() const override { return new Chi2ChargeMeasurementEstimator(*this); }
42 
43  private:
44  const float minGoodPixelCharge_;
45  const float minGoodStripCharge_;
46  const float pTChargeCutThreshold2_;
47 
48  bool checkClusterCharge(DetId id, SiStripCluster const& cluster, const TrajectoryStateOnSurface& ts) const {
49  return siStripClusterTools::chargePerCM(id, cluster, ts.localParameters()) > minGoodStripCharge_;
50  }
51  };
52 
54  const MeasurementEstimator::OpaquePayload& opay) const {
55  // what we got?
56  if (opay.tag != ClusterFilterPayload::myTag)
57  return true; // not mine...
58 
59  auto const& clf = reinterpret_cast<ClusterFilterPayload const&>(opay);
60 
61  if (ts.globalMomentum().perp2() > pTChargeCutThreshold2_)
62  return true;
63 
64  DetId detid = clf.detId;
65  uint32_t subdet = detid.subdetId();
66 
67  if (subdet > 2) {
68  return checkClusterCharge(detid, *clf.cluster[0], ts) &&
69  (nullptr == clf.cluster[1] || checkClusterCharge(detid, *clf.cluster[1], ts));
70  }
71 
72  /* pixel charge not implemented as not used...
73  auto const & thit = static_cast<const SiPixelRecHit &>(hit);
74  thit.cluster()->charge() ...
75 
76  */
77 
78  return true;
79  }
80 
81 } // namespace
82 
86 #include <memory>
87 
89 
90 namespace {
91 
92  class Chi2ChargeMeasurementEstimatorESProducer : public edm::ESProducer {
93  public:
94  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
95  Chi2ChargeMeasurementEstimatorESProducer(const edm::ParameterSet& p);
96  ~Chi2ChargeMeasurementEstimatorESProducer() override;
97  std::unique_ptr<Chi2MeasurementEstimatorBase> produce(const TrackingComponentsRecord&);
98 
99  private:
100  const double m_maxChi2;
101  const double m_nSigma;
102  const double m_maxDis;
103  const double m_maxSag;
104  const double m_minTol;
105  const double m_minpt;
106  const float m_minGoodStripCharge;
107  const double m_pTChargeCutThreshold;
108  };
109 
112  desc.add<std::string>("ComponentName", "Chi2Charge");
113  desc.add<double>("pTChargeCutThreshold", -1.);
115  desc.add<edm::ParameterSetDescription>("clusterChargeCut", descCCC);
116  descriptions.add("Chi2ChargeMeasurementEstimatorDefault", desc);
117  }
118 
119  Chi2ChargeMeasurementEstimatorESProducer::Chi2ChargeMeasurementEstimatorESProducer(const edm::ParameterSet& pset)
120  : m_maxChi2(pset.getParameter<double>("MaxChi2")),
121  m_nSigma(pset.getParameter<double>("nSigma")),
122  m_maxDis(pset.getParameter<double>("MaxDisplacement")),
123  m_maxSag(pset.getParameter<double>("MaxSagitta")),
124  m_minTol(pset.getParameter<double>("MinimalTolerance")),
125  m_minpt(pset.getParameter<double>("MinPtForHitRecoveryInGluedDet")),
126  m_minGoodStripCharge(clusterChargeCut(pset)),
127  m_pTChargeCutThreshold(pset.getParameter<double>("pTChargeCutThreshold")) {
128  std::string const& myname = pset.getParameter<std::string>("ComponentName");
129  setWhatProduced(this, myname);
130  }
131 
132  Chi2ChargeMeasurementEstimatorESProducer::~Chi2ChargeMeasurementEstimatorESProducer() {}
133 
134  std::unique_ptr<Chi2MeasurementEstimatorBase> Chi2ChargeMeasurementEstimatorESProducer::produce(
135  const TrackingComponentsRecord& iRecord) {
136  auto minGoodPixelCharge = 0;
137 
138  return std::make_unique<Chi2ChargeMeasurementEstimator>(minGoodPixelCharge,
139  m_minGoodStripCharge,
140  m_pTChargeCutThreshold,
141  m_maxChi2,
142  m_nSigma,
143  m_maxDis,
144  m_maxSag,
145  m_minTol,
146  m_minpt);
147  }
148 
149 } // namespace
150 
152 DEFINE_FWK_EVENTSETUP_MODULE(Chi2ChargeMeasurementEstimatorESProducer);
edm::ParameterSetDescription getConfigurationDescription4CCC(const CCC::OP &op)
float chargePerCM(DetId detid, Iter a, Iter b)
float clusterChargeCut(const edm::ParameterSet &conf, const char *name="clusterChargeCut")
virtual bool preFilter(const TrajectoryStateOnSurface &, OpaquePayload const &) const
const LocalTrajectoryParameters & localParameters() const
tuple preFilter
Definition: gather_cfg.py:51
edm::ParameterSetDescription getFilledConfigurationDescription()
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
ParameterDescriptionBase * add(U const &iLabel, T const &value)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:61
Definition: DetId.h:17
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
GlobalVector globalMomentum() const
T perp2() const
Definition: PV3DBase.h:68
static constexpr int myTag
Chi2MeasurementEstimator * clone() const override