CMS 3D CMS Logo

EgammaTowerExtractor.cc
Go to the documentation of this file.
1 //*****************************************************************************
2 // File: EgammaTowerExtractor.cc
3 // ----------------------------------------------------------------------------
4 // OrigAuth: Matthias Mozer
5 // Institute: IIHE-VUB
6 //=============================================================================
7 //*****************************************************************************
8 
26 
27 #include <Math/VectorUtil.h>
28 
29 #include <vector>
30 #include <functional>
31 #include <cmath>
32 
33 namespace egammaisolation {
34 
36  public:
37  enum HcalDepth { AllDepths = -1, Undefined = 0, Depth1 = 1, Depth2 = 2 };
38 
39  public:
42  : extRadius2_(par.getParameter<double>("extRadius")),
43  intRadius_(par.getParameter<double>("intRadius")),
44  etLow_(par.getParameter<double>("etMin")),
45  caloTowerToken(iC.consumes<CaloTowerCollection>(par.getParameter<edm::InputTag>("caloTowers"))),
46  depth_(par.getParameter<int>("hcalDepth")) {
48  //lets just check we have a valid depth
49  //should we throw an exception or just warn and then fail gracefully later?
50  if (depth_ != AllDepths && depth_ != Depth1 && depth_ != Depth2) {
51  throw cms::Exception("Configuration Error")
52  << "hcalDepth passed to EgammaTowerExtractor is invalid " << std::endl;
53  }
54  }
55 
56  ~EgammaTowerExtractor() override;
57 
58  void fillVetos(const edm::Event& ev, const edm::EventSetup& evSetup, const reco::TrackCollection& tracks) override {
59  }
61  const edm::EventSetup& evSetup,
62  const reco::Track& track) const override {
63  throw cms::Exception("Configuration Error")
64  << "This extractor " << (typeid(this).name()) << " is not made for tracks";
65  }
67  const edm::EventSetup& evSetup,
68  const reco::Candidate& c) const override;
69 
70  private:
71  double extRadius2_;
72  double intRadius_;
73  double etLow_;
74 
76  int depth_;
77  //const CaloTowerCollection *towercollection_ ;
78  };
79 } // namespace egammaisolation
80 
84 
85 using namespace ROOT::Math::VectorUtil;
86 
87 using namespace egammaisolation;
88 using namespace reco::isodeposit;
89 
90 EgammaTowerExtractor::~EgammaTowerExtractor() {}
91 
92 reco::IsoDeposit EgammaTowerExtractor::deposit(const edm::Event& iEvent,
93  const edm::EventSetup& iSetup,
94  const reco::Candidate& emObject) const {
95  //Take the SC position
97  math::XYZPoint caloPosition = sc->position();
98 
99  Direction candDir(caloPosition.eta(), caloPosition.phi());
100  reco::IsoDeposit deposit(candDir);
101  deposit.setVeto(reco::IsoDeposit::Veto(candDir, intRadius_));
102  deposit.addCandEnergy(sc->energy() * sin(2 * atan(exp(-sc->eta()))));
103 
104  //loop over tracks
105  for (auto const& trItr : iEvent.get(caloTowerToken)) {
106  double depEt = 0;
107  //the hcal can be seperated into different depths
108  //currently it is setup to check that the depth is valid in constructor
109  //if the depth is not valid it fails gracefully
110  //small bug fix, hadEnergyHeInnerLater returns zero for towers which are only depth 1
111  //but we want Depth1 isolation to include these so we have to manually check for this
112  if (depth_ == AllDepths)
113  depEt = trItr.hadEt();
114  else if (depth_ == Depth1)
115  depEt = trItr.ietaAbs() < 18 || trItr.ietaAbs() > 29 ? trItr.hadEt()
116  : trItr.hadEnergyHeInnerLayer() * sin(trItr.p4().theta());
117  else if (depth_ == Depth2)
118  depEt = trItr.hadEnergyHeOuterLayer() * sin(trItr.p4().theta());
119 
120  if (depEt < etLow_)
121  continue;
122 
123  Direction towerDir(trItr.eta(), trItr.phi());
124  double dR2 = candDir.deltaR2(towerDir);
125 
126  if (dR2 < extRadius2_) {
127  deposit.addDeposit(towerDir, depEt);
128  }
129 
130  } //end loop over tracks
131 
132  return deposit;
133 }
T get() const
get a component
Definition: Candidate.h:221
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
int iEvent
Definition: GenABIO.cc:224
EgammaTowerExtractor(const edm::ParameterSet &par, edm::ConsumesCollector &&iC)
void fillVetos(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackCollection &tracks) override
EgammaTowerExtractor(const edm::ParameterSet &par, edm::ConsumesCollector &iC)
auto const & tracks
cannot be loose
double deltaR2(const Direction &dir2) const
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
HLT enums.
edm::EDGetTokenT< CaloTowerCollection > caloTowerToken
#define DEFINE_EDM_PLUGIN(factory, type, name)
reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const override