CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PhotonPFIsolationWithConeVeto.cc
Go to the documentation of this file.
2 
5 
8 
11 
13 
16 
19 
22 
24 
25 
26 #include <unordered_map>
27 
28 namespace reco {
30 }
31 
32 namespace pat {
34 }
35 
37 public:
40  _vetoConeSize2EB(std::pow(c.getParameter<double>("VetoConeSizeBarrel"),2.0)),
41  _vetoConeSize2EE(std::pow(c.getParameter<double>("VetoConeSizeEndcaps"),2.0)),
42  _miniAODVertexCodes(c.getParameter<std::vector<unsigned> >("miniAODVertexCodes")),
43  _vertexIndex(c.getParameter<int> ("vertexIndex")),
44  _isolateAgainst(c.getParameter<std::string>("isolateAgainst")) {
45  char buf[50];
46  sprintf(buf,"BarVeto%.2f-EndVeto%.2f",
50  auto decimal = _additionalCode.find('.');
51  while( decimal != std::string::npos ) {
52  _additionalCode.erase(decimal,1);
53  decimal = _additionalCode.find('.');
54  }
55  }
58 
60 
61  bool isInIsolationCone(const reco::CandidatePtr& photon,
62  const reco::CandidatePtr& pfCandidate) const override final;
63 
66 
67 private:
68  const float _vetoConeSize2EB, _vetoConeSize2EE;
69  const std::vector<unsigned> _miniAODVertexCodes;
70  const unsigned _vertexIndex;
73 };
74 
77  "PhotonPFIsolationWithConeVeto");
78 
81  const reco::CandidatePtr& pfCandidate ) const {
82  reco::recoPhotonPtr photonref(photon);
83  pat::PackedCandidatePtr aspacked(pfCandidate);
84  reco::PFCandidatePtr aspf(pfCandidate);
85  const reco::CaloClusterPtr& seed = photonref->superCluster()->seed();
86  bool isEB = ( seed->seed().subdetId() == EcalBarrel );
87  const float deltar2 = reco::deltaR2(*photon,*pfCandidate);
88  const float vetoConeSize2 = ( isEB ? _vetoConeSize2EB : _vetoConeSize2EE );
89  bool result = true;
90  if( aspacked.isNonnull() && aspacked.get() ) {
91  if( aspacked->charge() != 0 ) {
92  bool is_vertex_allowed = false;
93  for( const unsigned vtxtype : _miniAODVertexCodes ) {
94  if( vtxtype == aspacked->fromPV(_vertexIndex) ) {
95  is_vertex_allowed = true;
96  break;
97  }
98  }
99  result &= ( is_vertex_allowed );
100  }
101  result &= deltar2 > vetoConeSize2 && deltar2 < _coneSize2 ;
102  } else if ( aspf.isNonnull() && aspf.get() ) {
103  result &= deltar2 > vetoConeSize2 && deltar2 < _coneSize2;
104  } else {
105  throw cms::Exception("InvalidIsolationInput")
106  << "The supplied candidate to be used as isolation "
107  << "was neither a reco::PFCandidate nor a pat::PackedCandidate!";
108  }
109  return result;
110 }
IsolationConeDefinitionBase(const edm::ParameterSet &c)
void setConsumes(edm::ConsumesCollector)
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:160
bool isInIsolationCone(const reco::CandidatePtr &photon, const reco::CandidatePtr &pfCandidate) const overridefinal
const std::vector< unsigned > _miniAODVertexCodes
virtual ~PhotonPFIsolationWithConeVeto()
Destructor.
edm::Ptr< pat::PackedCandidate > PackedCandidatePtr
PhotonPFIsolationWithConeVeto & operator=(const PhotonPFIsolationWithConeVeto &)=delete
T sqrt(T t)
Definition: SSEVec.h:48
tuple result
Definition: query.py:137
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
edm::EDGetTokenT< reco::VertexCollection > _vtxToken
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:169
edm::Ptr< reco::Photon > recoPhotonPtr
#define DEFINE_EDM_PLUGIN(factory, type, name)
PhotonPFIsolationWithConeVeto(const edm::ParameterSet &c)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40