CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  {
21  char buf[50];
22  snprintf(buf,49,"ThresholdVeto%03.0f-ConeVeto%03.0f", 100*_vetoThreshold, 100*std::sqrt(_vetoConeSize2));
24  }
27 
29 
30  bool isInIsolationCone(const reco::CandidatePtr& physob,
31  const reco::CandidatePtr& other) const override 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 *= ( is_vertex_allowed );
63  }
64  result *= aspacked->pt() > _vetoThreshold && deltar2 > _vetoConeSize2 && deltar2 < _coneSize2 ;
65  } else if ( aspf.isNonnull() && aspf.get() ) {
66  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 }
IsolationConeDefinitionBase(const edm::ParameterSet &c)
MuonPFIsolationWithConeVeto & operator=(const MuonPFIsolationWithConeVeto &)=delete
virtual ~MuonPFIsolationWithConeVeto()
Destructor.
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:160
void setConsumes(edm::ConsumesCollector)
edm::Ptr< pat::PackedCandidate > PackedCandidatePtr
tuple result
Definition: mps_fire.py:95
bool isInIsolationCone(const reco::CandidatePtr &physob, const reco::CandidatePtr &other) const overridefinal
T sqrt(T t)
Definition: SSEVec.h:18
MuonPFIsolationWithConeVeto(const edm::ParameterSet &c)
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:169
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
#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