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 }
41 
43 
45  const edm::EventSetup & iSetup, const reco::Candidate &emObject ) const {
46 
47  //Get MetaRecHit collection
48  edm::Handle<HBHERecHitCollection> hcalRecHitHandle;
49  iEvent.getByToken(hcalRecHitProducerToken_, hcalRecHitHandle);
50 
51  //Get Calo Geometry
53  iSetup.get<CaloGeometryRecord>().get(pG);
54  const CaloGeometry* caloGeom = pG.product();
56 
57  //Take the SC position
59  math::XYZPoint caloPosition = sc->position();
60  GlobalPoint point(caloPosition.x(), caloPosition.y() , caloPosition.z());
61  // needed: coneSel.select(eta,phi,hits) is not the same!
62 
63  Direction candDir(caloPosition.eta(), caloPosition.phi());
64  reco::IsoDeposit deposit( candDir );
65  deposit.setVeto( reco::IsoDeposit::Veto(candDir, intRadius_) );
66  double sinTheta = sin(2*atan(exp(-sc->eta())));
67  deposit.addCandEnergy(sc->energy()*sinTheta);
68 
69  //Compute the HCAL energy behind ECAL
70  coneSel.selectCallback(point, *hcalRecHitHandle, [&](const HBHERecHit& i) {
71  const GlobalPoint & hcalHit_position = caloGeom->getPosition(i.detid());
72  double hcalHit_eta = hcalHit_position.eta();
73  double hcalHit_Et = i.energy()*sin(2*atan(exp(-hcalHit_eta)));
74  if ( hcalHit_Et > etLow_) {
75  deposit.addDeposit( Direction(hcalHit_eta, hcalHit_position.phi()), hcalHit_Et);
76  }
77  });
78 
79  return deposit;
80 }
const DetId & detid() const
Definition: CaloRecHit.h:21
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
edm::EDGetTokenT< HBHERecHitCollection > hcalRecHitProducerToken_
int iEvent
Definition: GenABIO.cc:230
float energy() const
Definition: CaloRecHit.h:17
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:70
virtual reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const T & get() const
Definition: EventSetup.h:55
void selectCallback(double eta, double phi, const edm::SortedCollection< T > &inputCollection, std::function< void(const T &)> callback)
T eta() const
Definition: PV3DBase.h:76
HLT enums.
T get() const
get a component
Definition: Candidate.h:217
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