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:
35  const double _vetoThreshold, _vetoConeSize2;
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 }
pat::PackedCandidatePtr
edm::Ptr< pat::PackedCandidate > PackedCandidatePtr
Definition: PATMuonMerger.cc:18
MuonPFIsolationWithConeVeto
Definition: MuonPFIsolationWithConeVeto.cc:13
MuonPFIsolationWithConeVeto::isInIsolationCone
bool isInIsolationCone(const reco::CandidatePtr &physob, const reco::CandidatePtr &other) const final
Definition: MuonPFIsolationWithConeVeto.cc:42
PFCandidate.h
edm::EDGetTokenT< reco::VertexCollection >
MuonPFIsolationWithConeVeto::setConsumes
void setConsumes(edm::ConsumesCollector) override
Definition: MuonPFIsolationWithConeVeto.cc:27
edm::Ptr::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
MuonPFIsolationWithConeVeto::~MuonPFIsolationWithConeVeto
~MuonPFIsolationWithConeVeto() override
Destructor.
Definition: MuonPFIsolationWithConeVeto.cc:32
citk
Definition: CITKIsolationConeDefinitionBase.h:16
MuonPFIsolationWithConeVeto::_vetoConeSize2
const double _vetoConeSize2
Definition: MuonPFIsolationWithConeVeto.cc:32
citk::IsolationConeDefinitionBase
Definition: CITKIsolationConeDefinitionBase.h:17
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
trackingPlots.other
other
Definition: trackingPlots.py:1460
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
MuonPFIsolationWithConeVeto::_miniAODVertexCodes
const std::vector< unsigned > _miniAODVertexCodes
Definition: MuonPFIsolationWithConeVeto.cc:36
MuonPFIsolationWithConeVeto::_vtxToken
edm::EDGetTokenT< reco::VertexCollection > _vtxToken
Definition: MuonPFIsolationWithConeVeto.cc:37
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
CITKIsolationConeDefinitionBase.h
deltaR.h
edmplugin::PluginFactory
Definition: PluginFactory.h:34
PackedCandidate.h
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
pat
Definition: HeavyIon.h:7
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
edm::Ptr
Definition: AssociationVector.h:31
citk::IsolationConeDefinitionBase::_coneSize2
const float _coneSize2
Definition: CITKIsolationConeDefinitionBase.h:36
std
Definition: JetResolutionObject.h:76
citk::IsolationConeDefinitionBase::_additionalCode
std::string _additionalCode
Definition: CITKIsolationConeDefinitionBase.h:40
MuonPFIsolationWithConeVeto::operator=
MuonPFIsolationWithConeVeto & operator=(const MuonPFIsolationWithConeVeto &)=delete
Exception
Definition: hltDiff.cc:245
MuonPFIsolationWithConeVeto::MuonPFIsolationWithConeVeto
MuonPFIsolationWithConeVeto(const edm::ParameterSet &c)
Definition: MuonPFIsolationWithConeVeto.cc:15
edm::Ptr::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
mps_fire.result
result
Definition: mps_fire.py:311
ConsumesCollector.h
MuonPFIsolationWithConeVeto::_vetoThreshold
const double _vetoThreshold
Definition: MuonPFIsolationWithConeVeto.cc:32
ParameterSet.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
citk::IsolationConeDefinitionBase::IsolationConeDefinitionBase
IsolationConeDefinitionBase(const edm::ParameterSet &c)
Definition: CITKIsolationConeDefinitionBase.h:19