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  {
21  char buf[50];
22  snprintf(buf,49,"ThresholdVeto%03.0f-ConeVeto%03.0f", 100*_vetoThreshold, 100*std::sqrt(_vetoConeSize2));
23  _additionalCode = std::string(buf);
24  }
27 
29 
30  bool isInIsolationCone(const reco::CandidatePtr& physob,
31  const reco::CandidatePtr& other) const final;
32 
35 
36 private:
37  const double _vetoThreshold, _vetoConeSize2;
38  const std::vector<unsigned> _miniAODVertexCodes;
40 };
41 
44  "MuonPFIsolationWithConeVeto");
45 
47  const reco::CandidatePtr& iso_obj ) const {
48  const pat::PackedCandidatePtr aspacked(iso_obj);
49  const reco::PFCandidatePtr aspf(iso_obj);
50  const double deltar2 = reco::deltaR2(*physob,*iso_obj);
51 
52  bool result = true;
53  if( aspacked.isNonnull() && aspacked.get() ) {
54  if( aspacked->charge() != 0 ) {
55  bool is_vertex_allowed = false;
56  for( const unsigned vtxtype : _miniAODVertexCodes ) {
57  if( vtxtype == aspacked->fromPV() ) {
58  is_vertex_allowed = true;
59  break;
60  }
61  }
62  result = result && ( is_vertex_allowed );
63  }
64  result = result &&( aspacked->pt() > _vetoThreshold && deltar2 > _vetoConeSize2 && deltar2 < _coneSize2 );
65  } else if ( aspf.isNonnull() && aspf.get() ) {
66  result = result && ( aspf->pt() > _vetoThreshold && deltar2 > _vetoConeSize2 && deltar2 < _coneSize2 );
67  } else {
68  throw cms::Exception("InvalidIsolationInput")
69  << "The supplied candidate to be used as isolation "
70  << "was neither a reco::PFCandidate nor a pat::PackedCandidate!";
71  }
72  return result;
73 }
void setConsumes(edm::ConsumesCollector) override
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:159
bool isInIsolationCone(const reco::CandidatePtr &physob, const reco::CandidatePtr &other) const final
edm::Ptr< pat::PackedCandidate > PackedCandidatePtr
Definition: HeavyIon.h:7
int charge() const override
electric charge
const PVAssoc fromPV(size_t ipv=0) const
T sqrt(T t)
Definition: SSEVec.h:18
MuonPFIsolationWithConeVeto(const edm::ParameterSet &c)
double pt() const override
transverse momentum
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:168
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:40
const std::vector< unsigned > _miniAODVertexCodes
edm::EDGetTokenT< reco::VertexCollection > _vtxToken