CMS 3D CMS Logo

EgammaHcalExtractor.cc
Go to the documentation of this file.
1 //*****************************************************************************
2 // File: EgammaHcalExtractor.cc
3 // ----------------------------------------------------------------------------
4 // OrigAuth: Matthias Mozer
5 // Institute: IIHE-VUB
6 //=============================================================================
7 //*****************************************************************************
8 //C++ includes
9 #include <vector>
10 #include <functional>
11 
12 //ROOT includes
13 #include <Math/VectorUtil.h>
14 
15 //CMSSW includes
29 
30 using namespace std;
31 
32 using namespace egammaisolation;
33 using namespace reco::isodeposit;
34 
35 EgammaHcalExtractor::EgammaHcalExtractor(const edm::ParameterSet& par, edm::ConsumesCollector& iC)
36  : extRadius_(par.getParameter<double>("extRadius")),
37  intRadius_(par.getParameter<double>("intRadius")),
38  etLow_(par.getParameter<double>("etMin")),
39  hcalRecHitProducerToken_(iC.consumes<HBHERecHitCollection>(par.getParameter<edm::InputTag>("hcalRecHits"))) {}
40 
42 
44  const edm::EventSetup& iSetup,
45  const reco::Candidate& emObject) const {
46  //Get MetaRecHit collection
47  edm::Handle<HBHERecHitCollection> hcalRecHitHandle;
48  iEvent.getByToken(hcalRecHitProducerToken_, hcalRecHitHandle);
49 
50  //Get Calo Geometry
52  iSetup.get<CaloGeometryRecord>().get(pG);
53  const CaloGeometry* caloGeom = pG.product();
55 
56  //Take the SC position
58  math::XYZPoint caloPosition = sc->position();
59  GlobalPoint point(caloPosition.x(), caloPosition.y(), caloPosition.z());
60  // needed: coneSel.select(eta,phi,hits) is not the same!
61 
62  Direction candDir(caloPosition.eta(), caloPosition.phi());
63  reco::IsoDeposit deposit(candDir);
64  deposit.setVeto(reco::IsoDeposit::Veto(candDir, intRadius_));
65  double sinTheta = sin(2 * atan(exp(-sc->eta())));
66  deposit.addCandEnergy(sc->energy() * sinTheta);
67 
68  //Compute the HCAL energy behind ECAL
69  coneSel.selectCallback(point, *hcalRecHitHandle, [&](const HBHERecHit& i) {
70  const GlobalPoint& hcalHit_position = caloGeom->getPosition(i.detid());
71  double hcalHit_eta = hcalHit_position.eta();
72  double hcalHit_Et = i.energy() * sin(2 * atan(exp(-hcalHit_eta)));
73  if (hcalHit_Et > etLow_) {
74  deposit.addDeposit(Direction(hcalHit_eta, hcalHit_position.phi()), hcalHit_Et);
75  }
76  });
77 
78  return deposit;
79 }
constexpr float energy() const
Definition: CaloRecHit.h:29
reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
constexpr const DetId & detid() const
Definition: CaloRecHit.h:33
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
edm::EDGetTokenT< HBHERecHitCollection > hcalRecHitProducerToken_
int iEvent
Definition: GenABIO.cc:224
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void selectCallback(double eta, double phi, const edm::SortedCollection< T > &inputCollection, std::function< void(const T &)> callback)
T eta() const
Definition: PV3DBase.h:73
HLT enums.
T get() const
Definition: EventSetup.h:73
T get() const
get a component
Definition: Candidate.h:222
T const * product() const
Definition: ESHandle.h:86
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5