CMS 3D CMS Logo

MuonPFIsolationWithConeVeto.cc
Go to the documentation of this file.
2 
8 
9 namespace pat {
11 }
12 
14 public:
16  : citk::IsolationConeDefinitionBase(c),
17  _vetoThreshold(c.getParameter<double>("VetoThreshold")),
18  _vetoConeSize2(std::pow(c.getParameter<double>("VetoConeSize"), 2.0)),
19  _miniAODVertexCodes(c.getParameter<std::vector<unsigned> >("miniAODVertexCodes")) {
20  char buf[50];
21  snprintf(buf, 49, "ThresholdVeto%03.0f-ConeVeto%03.0f", 100 * _vetoThreshold, 100 * std::sqrt(_vetoConeSize2));
22  _additionalCode = std::string(buf);
23  }
25  MuonPFIsolationWithConeVeto& operator=(const MuonPFIsolationWithConeVeto&) = delete;
26 
28 
29  bool isInIsolationCone(const reco::CandidatePtr& physob, const reco::CandidatePtr& other) const final;
30 
33 
34 private:
35  const double _vetoThreshold, _vetoConeSize2;
36  const std::vector<unsigned> _miniAODVertexCodes;
38 };
39 
41 
43  const reco::CandidatePtr& iso_obj) const {
44  const pat::PackedCandidatePtr aspacked(iso_obj);
45  const reco::PFCandidatePtr aspf(iso_obj);
46  const double deltar2 = reco::deltaR2(*physob, *iso_obj);
47 
48  bool result = true;
49  if (aspacked.isNonnull() && aspacked.get()) {
50  if (aspacked->charge() != 0) {
51  bool is_vertex_allowed = false;
52  for (const unsigned vtxtype : _miniAODVertexCodes) {
53  if (vtxtype == aspacked->fromPV()) {
54  is_vertex_allowed = true;
55  break;
56  }
57  }
58  result = result && (is_vertex_allowed);
59  }
60  result = result && (aspacked->pt() > _vetoThreshold && deltar2 > _vetoConeSize2 && deltar2 < _coneSize2);
61  } else if (aspf.isNonnull() && aspf.get()) {
62  result = result && (aspf->pt() > _vetoThreshold && deltar2 > _vetoConeSize2 && deltar2 < _coneSize2);
63  } else {
64  throw cms::Exception("InvalidIsolationInput") << "The supplied candidate to be used as isolation "
65  << "was neither a reco::PFCandidate nor a pat::PackedCandidate!";
66  }
67  return result;
68 }
void setConsumes(edm::ConsumesCollector) override
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
bool isInIsolationCone(const reco::CandidatePtr &physob, const reco::CandidatePtr &other) const final
edm::Ptr< pat::PackedCandidate > PackedCandidatePtr
Definition: HeavyIon.h:7
T sqrt(T t)
Definition: SSEVec.h:19
MuonPFIsolationWithConeVeto(const edm::ParameterSet &c)
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
~MuonPFIsolationWithConeVeto() override
Destructor.
#define DEFINE_EDM_PLUGIN(factory, type, name)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
const std::vector< unsigned > _miniAODVertexCodes
edm::EDGetTokenT< reco::VertexCollection > _vtxToken