CMS 3D CMS Logo

MuonPFIsolationWithConeVeto.cc
Go to the documentation of this file.
2 
8 
9 namespace pat {
11 }
12 
14 public:
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));
23  }
26 
28 
29  bool isInIsolationCone(const reco::CandidatePtr& physob, const reco::CandidatePtr& other) const final;
30 
33 
34 private:
36  const std::vector<unsigned> _miniAODVertexCodes;
38 };
39 
41 
43  const reco::CandidatePtr& iso_obj) const {
44  if (iso_obj->pt() <= _vetoThreshold)
45  return false;
46  const double deltar2 = reco::deltaR2(*physob, *iso_obj);
47  if (deltar2 <= _vetoConeSize2 || deltar2 >= _coneSize2)
48  return false;
49 
50  //the rest will check the vertex selection
51  const pat::PackedCandidatePtr aspacked(iso_obj);
52  const reco::PFCandidatePtr aspf(iso_obj);
53 
54  bool result = true;
55  if (aspacked.isNonnull() && aspacked.get()) {
56  if (aspacked->charge() != 0) {
57  bool is_vertex_allowed = false;
58  for (const unsigned vtxtype : _miniAODVertexCodes) {
59  if (vtxtype == aspacked->fromPV()) {
60  is_vertex_allowed = true;
61  break;
62  }
63  }
64  result = result && (is_vertex_allowed);
65  }
66  } else if (aspf.isNonnull() && aspf.get()) {
67  } else {
68  throw cms::Exception("InvalidIsolationInput") << "The supplied candidate to be used as isolation "
69  << "was neither a reco::PFCandidate nor a pat::PackedCandidate!";
70  }
71  return result;
72 }
IsolationConeDefinitionBase(const edm::ParameterSet &c)
MuonPFIsolationWithConeVeto & operator=(const MuonPFIsolationWithConeVeto &)=delete
void setConsumes(edm::ConsumesCollector) override
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:23
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:148
MuonPFIsolationWithConeVeto(const edm::ParameterSet &c)
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:141
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:29
const std::vector< unsigned > _miniAODVertexCodes
edm::EDGetTokenT< reco::VertexCollection > _vtxToken