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 //C++ includes
9 #include <vector>
10 #include <functional>
11 #include <cmath>
12 
13 //ROOT includes
14 #include <Math/VectorUtil.h>
15 
16 
17 //CMSSW includes
25 
26 using namespace ROOT::Math::VectorUtil ;
27 
28 using namespace egammaisolation;
29 using namespace reco::isodeposit;
30 
31 EgammaTowerExtractor::~EgammaTowerExtractor(){}
32 
33 reco::IsoDeposit EgammaTowerExtractor::deposit(const edm::Event & iEvent,
34  const edm::EventSetup & iSetup, const reco::Candidate &emObject ) const {
35 
36  edm::Handle<CaloTowerCollection> towercollectionH;
37  iEvent.getByToken(caloTowerToken, towercollectionH);
38 
39  //Take the SC position
41  math::XYZPoint caloPosition = sc->position();
42 
43  Direction candDir(caloPosition.eta(), caloPosition.phi());
44  reco::IsoDeposit deposit( candDir );
45  deposit.setVeto( reco::IsoDeposit::Veto(candDir, intRadius_) );
46  deposit.addCandEnergy(sc->energy()*sin(2*atan(exp(-sc->eta()))));
47 
48  //loop over tracks
49  for(CaloTowerCollection::const_iterator trItr = towercollectionH->begin(), trEnd = towercollectionH->end(); trItr != trEnd; ++trItr){
50  double depEt = 0;
51  //the hcal can be seperated into different depths
52  //currently it is setup to check that the depth is valid in constructor
53  //if the depth is not valid it fails gracefully
54  //small bug fix, hadEnergyHeInnerLater returns zero for towers which are only depth 1
55  //but we want Depth1 isolation to include these so we have to manually check for this
56  if(depth_==AllDepths) depEt = trItr->hadEt();
57  else if(depth_==Depth1) depEt = trItr->ietaAbs()<18 || trItr->ietaAbs()>29 ? trItr->hadEt() : trItr->hadEnergyHeInnerLayer()*sin(trItr->p4().theta());
58  else if(depth_==Depth2) depEt = trItr->hadEnergyHeOuterLayer()*sin(trItr->p4().theta());
59 
60  if ( depEt < etLow_ ) continue ;
61 
62 
63  Direction towerDir( trItr->eta(), trItr->phi() );
64  double dR2 = candDir.deltaR2(towerDir);
65 
66  if (dR2 < extRadius2_) {
67  deposit.addDeposit( towerDir, depEt);
68  }
69 
70  }//end loop over tracks
71 
72  return deposit;
73 }
74 
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< CaloTower >::const_iterator const_iterator
double deltaR2(const Direction &dir2) const
int iEvent
Definition: GenABIO.cc:230
const_iterator end() const
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
T get() const
get a component
Definition: Candidate.h:217
const_iterator begin() const