CMS 3D CMS Logo

PhotonPFIsolationWithConeVeto.cc
Go to the documentation of this file.
2 
5 
8 
11 
13 
16 
19 
22 
24 
25 #include <unordered_map>
26 
27 namespace reco {
29 }
30 
31 namespace pat {
33 }
34 
36 public:
39  _vetoConeSize2EB(std::pow(c.getParameter<double>("VetoConeSizeBarrel"), 2.0)),
40  _vetoConeSize2EE(std::pow(c.getParameter<double>("VetoConeSizeEndcaps"), 2.0)),
41  _miniAODVertexCodes(c.getParameter<std::vector<unsigned> >("miniAODVertexCodes")),
42  _vertexIndex(c.getParameter<int>("vertexIndex")),
43  _isolateAgainst(c.getParameter<std::string>("isolateAgainst")) {
44  char buf[50];
45  sprintf(buf, "BarVeto%.2f-EndVeto%.2f", std::sqrt(_vetoConeSize2EB), std::sqrt(_vetoConeSize2EE));
47  auto decimal = _additionalCode.find('.');
48  while (decimal != std::string::npos) {
49  _additionalCode.erase(decimal, 1);
50  decimal = _additionalCode.find('.');
51  }
52  }
55 
57 
58  bool isInIsolationCone(const reco::CandidatePtr& photon, const reco::CandidatePtr& pfCandidate) const final;
59 
62 
63 private:
65  const std::vector<unsigned> _miniAODVertexCodes;
66  const unsigned _vertexIndex;
69 };
70 
72 
74  const reco::CandidatePtr& pfCandidate) const {
75  reco::recoPhotonPtr photonref(photon);
76  pat::PackedCandidatePtr aspacked(pfCandidate);
77  reco::PFCandidatePtr aspf(pfCandidate);
78  const reco::CaloClusterPtr& seed = photonref->superCluster()->seed();
79  bool isEB = (seed->seed().subdetId() == EcalBarrel);
80  const float deltar2 = reco::deltaR2(*photon, *pfCandidate);
81  const float vetoConeSize2 = (isEB ? _vetoConeSize2EB : _vetoConeSize2EE);
82  bool result = true;
83  if (aspacked.isNonnull() && aspacked.get()) {
84  if (aspacked->charge() != 0) {
85  bool is_vertex_allowed = false;
86  for (const unsigned vtxtype : _miniAODVertexCodes) {
87  if (vtxtype == aspacked->fromPV(_vertexIndex)) {
88  is_vertex_allowed = true;
89  break;
90  }
91  }
92  result &= (is_vertex_allowed);
93  }
94  result &= deltar2 > vetoConeSize2 && deltar2 < _coneSize2;
95  } else if (aspf.isNonnull() && aspf.get()) {
96  result &= deltar2 > vetoConeSize2 && deltar2 < _coneSize2;
97  } else {
98  throw cms::Exception("InvalidIsolationInput") << "The supplied candidate to be used as isolation "
99  << "was neither a reco::PFCandidate nor a pat::PackedCandidate!";
100  }
101  return result;
102 }
pat::PackedCandidatePtr
edm::Ptr< pat::PackedCandidate > PackedCandidatePtr
Definition: PATMuonMerger.cc:18
muons2muons_cfi.photon
photon
Definition: muons2muons_cfi.py:28
IsoDepositVetos.h
PFCandidate.h
PhotonPFIsolationWithConeVeto::_vertexIndex
const unsigned _vertexIndex
Definition: PhotonPFIsolationWithConeVeto.cc:66
edm::EDGetTokenT< reco::VertexCollection >
IsoDepositVetoFactory.h
PhotonFwd.h
edm::Ptr::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
PhotonPFIsolationWithConeVeto::_miniAODVertexCodes
const std::vector< unsigned > _miniAODVertexCodes
Definition: PhotonPFIsolationWithConeVeto.cc:65
EcalBarrel
Definition: EcalSubdetector.h:10
citk
Definition: CITKIsolationConeDefinitionBase.h:16
PhotonPFIsolationWithConeVeto::_isolateAgainst
const std::string _isolateAgainst
Definition: PhotonPFIsolationWithConeVeto.cc:67
PhotonPFIsolationWithConeVeto::setConsumes
void setConsumes(edm::ConsumesCollector) override
Definition: PhotonPFIsolationWithConeVeto.cc:56
CandidateFwd.h
deltaR.h
PhotonPFIsolationWithConeVeto::_vetoConeSize2EB
const float _vetoConeSize2EB
Definition: PhotonPFIsolationWithConeVeto.cc:61
citk::IsolationConeDefinitionBase
Definition: CITKIsolationConeDefinitionBase.h:17
Photon.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
PhotonPFIsolationWithConeVeto::operator=
PhotonPFIsolationWithConeVeto & operator=(const PhotonPFIsolationWithConeVeto &)=delete
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
PhotonPFIsolationWithConeVeto::_vetoConeSize2EE
const float _vetoConeSize2EE
Definition: PhotonPFIsolationWithConeVeto.cc:61
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalSubdetector.h
PhotonPFIsolationWithConeVeto::_vtxToken
edm::EDGetTokenT< reco::VertexCollection > _vtxToken
Definition: PhotonPFIsolationWithConeVeto.cc:68
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
CITKIsolationConeDefinitionBase.h
reco::recoPhotonPtr
edm::Ptr< reco::Photon > recoPhotonPtr
Definition: PhotonPFIsolationWithConeVeto.cc:28
PhotonPFIsolationWithConeVeto::~PhotonPFIsolationWithConeVeto
~PhotonPFIsolationWithConeVeto() override
Destructor.
Definition: PhotonPFIsolationWithConeVeto.cc:61
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
createfilelist.int
int
Definition: createfilelist.py:10
PhotonPFIsolationWithConeVeto
Definition: PhotonPFIsolationWithConeVeto.cc:35
pat
Definition: HeavyIon.h:7
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
edm::Ptr
Definition: AssociationVector.h:31
PhotonPFIsolationWithConeVeto::isInIsolationCone
bool isInIsolationCone(const reco::CandidatePtr &photon, const reco::CandidatePtr &pfCandidate) const final
Definition: PhotonPFIsolationWithConeVeto.cc:73
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
Exception
Definition: hltDiff.cc:246
PhotonPFIsolationWithConeVeto::PhotonPFIsolationWithConeVeto
PhotonPFIsolationWithConeVeto(const edm::ParameterSet &c)
Definition: PhotonPFIsolationWithConeVeto.cc:37
EventSetup.h
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:30
mps_fire.result
result
Definition: mps_fire.py:303
ConsumesCollector.h
Candidate.h
ParameterSet.h
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
SurveyInfoScenario_cff.seed
seed
Definition: SurveyInfoScenario_cff.py:295
citk::IsolationConeDefinitionBase::IsolationConeDefinitionBase
IsolationConeDefinitionBase(const edm::ParameterSet &c)
Definition: CITKIsolationConeDefinitionBase.h:19