CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Chi2ChargeMeasurementEstimatorESProducer.cc
Go to the documentation of this file.
1 
12 
14 
15 #include<limits>
16 
18 
20 
21 
22 namespace {
23 
25 public:
26 
32  template<typename... Args>
34  float minGoodPixelCharge, float minGoodStripCharge,
36  Args && ...args) :
38  minGoodPixelCharge_(minGoodPixelCharge),
39  minGoodStripCharge_(minGoodStripCharge),
40  pTChargeCutThreshold2_( pTChargeCutThreshold>=0.? pTChargeCutThreshold*pTChargeCutThreshold :std::numeric_limits<float>::max())
41  {}
42 
43 
44  bool preFilter(const TrajectoryStateOnSurface& ts,
45  const MeasurementEstimator::OpaquePayload & opay) const override;
46 
47 
48  virtual Chi2ChargeMeasurementEstimator* clone() const {
49  return new Chi2ChargeMeasurementEstimator(*this);
50  }
51 private:
52 
53  const float minGoodPixelCharge_;
54  const float minGoodStripCharge_;
55  const float pTChargeCutThreshold2_;
56 
57  bool checkClusterCharge(DetId id, SiStripCluster const & cluster, const TrajectoryStateOnSurface& ts) const {
58  return siStripClusterTools::chargePerCM(id, cluster, ts.localParameters() ) > minGoodStripCharge_;
59 
60  }
61 
62 
63 };
64 
66  const MeasurementEstimator::OpaquePayload & opay) const {
67 
68  // what we got?
69  if (opay.tag != ClusterFilterPayload::myTag) return true; // not mine...
70 
71  auto const & clf = reinterpret_cast<ClusterFilterPayload const &>(opay);
72 
73  if (ts.globalMomentum().perp2()>pTChargeCutThreshold2_) return true;
74 
75  DetId detid = clf.detId;
76  uint32_t subdet = detid.subdetId();
77 
78  if (subdet>2) {
79  return checkClusterCharge(detid, *clf.cluster[0],ts) && ( nullptr==clf.cluster[1] || checkClusterCharge(detid, *clf.cluster[1],ts) ) ;
80 
81  }
82 
83  /* pixel charge not implemented as not used...
84  auto const & thit = static_cast<const SiPixelRecHit &>(hit);
85  thit.cluster()->charge() ...
86 
87  */
88 
89  return true;
90 }
91 
92 }
93 
94 
95 
99 #include <boost/shared_ptr.hpp>
100 
103 
104 
105 namespace {
106 
107 
108 class Chi2ChargeMeasurementEstimatorESProducer: public edm::ESProducer{
109  public:
110  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
111  Chi2ChargeMeasurementEstimatorESProducer(const edm::ParameterSet & p);
112  virtual ~Chi2ChargeMeasurementEstimatorESProducer();
113  boost::shared_ptr<Chi2MeasurementEstimatorBase> produce(const TrackingComponentsRecord &);
114 
115  private:
116  boost::shared_ptr<Chi2MeasurementEstimatorBase> m_estimator;
117  const edm::ParameterSet m_pset;
118 };
119 
120 void
121 Chi2ChargeMeasurementEstimatorESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
122 
123  // edm::ParameterSetDescription desc = Chi2MeasurementEstimatorESProducer::getFilledConfigurationDescription();
125  desc.add<double>("MaxChi2",30);
126  desc.add<double>("nSigma",3);
127  desc.add<double>("MaxDisplacement",0.5);
128  desc.add<double>("MaxSagitta",2.);
129  desc.add<double>("MinimalTolerance",0.5);
130  desc.add<std::string>("ComponentName","Chi2Charge");
131  desc.add<double>("pTChargeCutThreshold",-1.);
133  desc.add<edm::ParameterSetDescription>("clusterChargeCut", descCCC);
134  descriptions.add("Chi2ChargeMeasurementEstimatorDefault", desc);
135 }
136 
137 
138 
139 Chi2ChargeMeasurementEstimatorESProducer::Chi2ChargeMeasurementEstimatorESProducer(const edm::ParameterSet & pset) :
140  m_pset(pset)
141 {
142  std::string const & myname = pset.getParameter<std::string>("ComponentName");
143  setWhatProduced(this,myname);
144 }
145 
146 Chi2ChargeMeasurementEstimatorESProducer::~Chi2ChargeMeasurementEstimatorESProducer() {}
147 
148 boost::shared_ptr<Chi2MeasurementEstimatorBase>
149 Chi2ChargeMeasurementEstimatorESProducer::produce(const TrackingComponentsRecord & iRecord){
150 
151  auto maxChi2 = m_pset.getParameter<double>("MaxChi2");
152  auto nSigma = m_pset.getParameter<double>("nSigma");
153  auto maxDis = m_pset.getParameter<double>("MaxDisplacement");
154  auto maxSag = m_pset.getParameter<double>("MaxSagitta");
155  auto minTol = m_pset.getParameter<double>("MinimalTolerance");
156  auto minGoodPixelCharge = 0;
157  auto minGoodStripCharge = clusterChargeCut(m_pset);
158  auto pTChargeCutThreshold= m_pset.getParameter<double>("pTChargeCutThreshold");
159 
160  m_estimator = boost::shared_ptr<Chi2MeasurementEstimatorBase>(
162  maxChi2,nSigma, maxDis, maxSag, minTol) );
163 
164  return m_estimator;
165 }
166 
167 }
168 
169 
171 DEFINE_FWK_EVENTSETUP_MODULE(Chi2ChargeMeasurementEstimatorESProducer);
172 
T getParameter(std::string const &) const
virtual Chi2MeasurementEstimator * clone() const
virtual bool preFilter(const TrajectoryStateOnSurface &, OpaquePayload const &) const
const LocalTrajectoryParameters & localParameters() const
float chargePerCM(DetId detid, Iter a, Iter b)
float clusterChargeCut(const edm::ParameterSet &conf, const char *name="clusterChargeCut")
T perp2() const
Definition: PV3DBase.h:71
edm::ParameterSetDescription getFilledConfigurationDescription4CCC()
tuple preFilter
Definition: gather_cfg.py:50
ParameterDescriptionBase * add(U const &iLabel, T const &value)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
GlobalVector globalMomentum() const
static constexpr int myTag