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 }
egammaisolation::EgammaTowerExtractor::Depth2
Definition: EgammaTowerExtractor.cc:37
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
CaloTower.h
egammaisolation::EgammaTowerExtractor::etLow_
double etLow_
Definition: EgammaTowerExtractor.cc:73
egammaisolation
Definition: EgammaTrackSelector.h:11
egammaisolation::EgammaTowerExtractor::extRadius2_
double extRadius2_
Definition: EgammaTowerExtractor.cc:71
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::SortedCollection< CaloTower >
egammaisolation::EgammaTowerExtractor::deposit
reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const override
Definition: EgammaTowerExtractor.cc:60
reco::Candidate::get
T get() const
get a component
Definition: Candidate.h:221
reco::IsoDeposit::Veto
Definition: IsoDeposit.h:59
egammaisolation::EgammaTowerExtractor::depth_
int depth_
Definition: EgammaTowerExtractor.cc:76
RecoCandidate.h
edm::Ref< SuperClusterCollection >
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
MakerMacros.h
reco::isodeposit::Direction::deltaR2
double deltaR2(const Direction &dir2) const
Definition: IsoDepositDirection.h:46
Track.h
TrackFwd.h
egammaisolation::EgammaTowerExtractor::~EgammaTowerExtractor
~EgammaTowerExtractor() override
Definition: EgammaTowerExtractor.cc:90
egammaisolation::EgammaTowerExtractor::EgammaTowerExtractor
EgammaTowerExtractor(const edm::ParameterSet &par, edm::ConsumesCollector &&iC)
Definition: EgammaTowerExtractor.cc:40
reco::isodeposit
Definition: IsoDeposit.h:31
reco::Track
Definition: Track.h:27
egammaisolation::EgammaTowerExtractor::caloTowerToken
edm::EDGetTokenT< CaloTowerCollection > caloTowerToken
Definition: EgammaTowerExtractor.cc:75
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
egammaisolation::EgammaTowerExtractor::HcalDepth
HcalDepth
Definition: EgammaTowerExtractor.cc:37
IsoDeposit.h
IsoDepositExtractor.h
edm::ParameterSet
Definition: ParameterSet.h:47
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
edmplugin::PluginFactory
Definition: PluginFactory.h:34
egammaisolation::EgammaTowerExtractor::EgammaTowerExtractor
EgammaTowerExtractor(const edm::ParameterSet &par, edm::ConsumesCollector &iC)
Definition: EgammaTowerExtractor.cc:41
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
egammaisolation::EgammaTowerExtractor
Definition: EgammaTowerExtractor.cc:35
egammaisolation::EgammaTowerExtractor::AllDepths
Definition: EgammaTowerExtractor.cc:37
edm::EventSetup
Definition: EventSetup.h:58
InputTag.h
reco::Candidate
Definition: Candidate.h:27
CaloTowerCollection.h
egammaisolation::EgammaTowerExtractor::Depth1
Definition: EgammaTowerExtractor.cc:37
egammaisolation::EgammaTowerExtractor::intRadius_
double intRadius_
Definition: EgammaTowerExtractor.cc:72
SuperClusterFwd.h
reco::isodeposit::Direction
Definition: IsoDepositDirection.h:19
SuperCluster.h
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
Exception
Definition: hltDiff.cc:245
IsoDepositExtractorFactory.h
GlobalVector.h
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
reco::IsoDeposit
Definition: IsoDeposit.h:49
ConsumesCollector.h
Candidate.h
egammaisolation::EgammaTowerExtractor::Undefined
Definition: EgammaTowerExtractor.cc:37
ParameterSet.h
reco::isodeposit::IsoDepositExtractor
Definition: IsoDepositExtractor.h:24
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
edm::Event
Definition: Event.h:73
GlobalPoint.h
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
egammaisolation::EgammaTowerExtractor::fillVetos
void fillVetos(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackCollection &tracks) override
Definition: EgammaTowerExtractor.cc:58