CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronPFIsolationWithConeVeto.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  _isolateAgainst(c.getParameter<std::string>("isolateAgainst")) {
44  char buf[50];
45  sprintf(buf,"BarVeto%.2f-EndVeto%.2f",
49  auto decimal = _additionalCode.find('.');
50  while( decimal != std::string::npos ) {
51  _additionalCode.erase(decimal,1);
52  decimal = _additionalCode.find('.');
53  }
54  }
57 
59 
60  bool isInIsolationCone(const reco::CandidatePtr& physob,
61  const reco::CandidatePtr& other) const override final;
62 
65 
66 private:
67  const float _vetoConeSize2EB, _vetoConeSize2EE;
68  const std::vector<unsigned> _miniAODVertexCodes;
71 };
72 
75  "ElectronPFIsolationWithConeVeto");
76 
79  const reco::CandidatePtr& iso_obj ) const {
80  reco::GsfElectronPtr eleref(physob);
81  pat::PackedCandidatePtr aspacked(iso_obj);
82  reco::PFCandidatePtr aspf(iso_obj);
83  const reco::CaloClusterPtr& seed = eleref->superCluster()->seed();
84  bool isEB = ( seed->seed().subdetId() == EcalBarrel );
85  const float deltar2 = reco::deltaR2(*physob,*iso_obj);
86  const float vetoConeSize2 = ( isEB ? _vetoConeSize2EB : _vetoConeSize2EE );
87  bool result = true;
88  if( aspacked.isNonnull() && aspacked.get() ) {
89  if( aspacked->charge() != 0 ) {
90  bool is_vertex_allowed = false;
91  for( const unsigned vtxtype : _miniAODVertexCodes ) {
92  if( vtxtype == aspacked->fromPV() ) {
93  is_vertex_allowed = true;
94  break;
95  }
96  }
97  result *= ( is_vertex_allowed );
98  }
99  result *= deltar2 > vetoConeSize2 && deltar2 < _coneSize2 ;
100  } else if ( aspf.isNonnull() && aspf.get() ) {
101  result *= deltar2 > vetoConeSize2 && deltar2 < _coneSize2;
102  } else {
103  throw cms::Exception("InvalidIsolationInput")
104  << "The supplied candidate to be used as isolation "
105  << "was neither a reco::PFCandidate nor a pat::PackedCandidate!";
106  }
107  return result;
108 }
IsolationConeDefinitionBase(const edm::ParameterSet &c)
ElectronPFIsolationWithConeVeto & operator=(const ElectronPFIsolationWithConeVeto &)=delete
bool isInIsolationCone(const reco::CandidatePtr &physob, const reco::CandidatePtr &other) const overridefinal
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:143
edm::EDGetTokenT< reco::VertexCollection > _vtxToken
edm::Ptr< reco::GsfElectron > GsfElectronPtr
T sqrt(T t)
Definition: SSEVec.h:48
tuple result
Definition: query.py:137
ElectronPFIsolationWithConeVeto(const edm::ParameterSet &c)
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:152
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:58
const std::vector< unsigned > _miniAODVertexCodes
edm::Ptr< pat::PackedCandidate > PackedCandidatePtr
#define DEFINE_EDM_PLUGIN(factory, type, name)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40