CMS 3D CMS Logo

IsolatedEcalPixelTrackCandidateProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: IsolatedEcalPixelTrackCandidateProducer
4 // Class: IsolatedEcalPixelTrackCandidateProducer
5 //
13 //
14 // Original Author: Ruchi Gupta
15 // Created: Thu Feb 11 17:21:58 MSD 2014
16 // $Id: IsolatedEcalPixelTrackCandidateProducer.cc,v 1.0 2014/02/11 22:25:52 wmtan Exp $
17 //
18 //
19 
20 //#define EDM_ML_DEBUG
21 // system include files
22 #include <memory>
23 
24 // user include files
31 
39 
42 
43 //#define EDM_ML_DEBUG
44 
45 //
46 // class decleration
47 //
48 
50 public:
53 
54  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
55 
56 private:
57  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
58 
63  const double coneSizeEta0_;
64  const double coneSizeEta1_;
65  const double hitCountEthrEB_;
66  const double hitEthrEB_;
67  const double fachitCountEE_;
68  const double hitEthrEE0_;
69  const double hitEthrEE1_;
70  const double hitEthrEE2_;
71  const double hitEthrEE3_;
72 };
73 
75  : tok_ee(consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("EERecHitSource"))),
76  tok_eb(consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("EBRecHitSource"))),
77  tok_trigcand(consumes<trigger::TriggerFilterObjectWithRefs>(conf.getParameter<edm::InputTag>("filterLabel"))),
79  coneSizeEta0_(conf.getParameter<double>("EcalConeSizeEta0")),
80  coneSizeEta1_(conf.getParameter<double>("EcalConeSizeEta1")),
81  hitCountEthrEB_(conf.getParameter<double>("EBHitCountEnergyThreshold")),
82  hitEthrEB_(conf.getParameter<double>("EBHitEnergyThreshold")),
83  fachitCountEE_(conf.getParameter<double>("EEFacHitCountEnergyThreshold")),
84  hitEthrEE0_(conf.getParameter<double>("EEHitEnergyThreshold0")),
85  hitEthrEE1_(conf.getParameter<double>("EEHitEnergyThreshold1")),
86  hitEthrEE2_(conf.getParameter<double>("EEHitEnergyThreshold2")),
87  hitEthrEE3_(conf.getParameter<double>("EEHitEnergyThreshold3")) {
88  // register the products
89  produces<reco::IsolatedPixelTrackCandidateCollection>();
90 }
91 
93 
96  desc.add<edm::InputTag>("filterLabel", edm::InputTag("hltIsolPixelTrackL2Filter"));
97  desc.add<edm::InputTag>("EBRecHitSource", edm::InputTag("hltEcalRecHit", "EcalRecHitsEB"));
98  desc.add<edm::InputTag>("EERecHitSource", edm::InputTag("hltEcalRecHit", "EcalRecHitsEE"));
99  desc.add<double>("EBHitEnergyThreshold", 0.10);
100  desc.add<double>("EBHitCountEnergyThreshold", 0.5);
101  desc.add<double>("EEHitEnergyThreshold0", -41.0664);
102  desc.add<double>("EEHitEnergyThreshold1", 68.7950);
103  desc.add<double>("EEHitEnergyThreshold2", -38.1483);
104  desc.add<double>("EEHitEnergyThreshold3", 7.04303);
105  desc.add<double>("EEFacHitCountEnergyThreshold", 10.0);
106  desc.add<double>("EcalConeSizeEta0", 0.09);
107  desc.add<double>("EcalConeSizeEta1", 0.14);
108  descriptions.add("isolEcalPixelTrackProd", desc);
109 }
110 
111 // ------------ method called to produce the data ------------
114  const edm::EventSetup& iSetup) const {
115 #ifdef EDM_ML_DEBUG
116  edm::LogVerbatim("HcalIsoTrack") << "==============Inside IsolatedEcalPixelTrackCandidateProducer";
117 #endif
118  const CaloGeometry* geo = &iSetup.getData(tok_geom_);
119 
120  const edm::Handle<EcalRecHitCollection>& ecalEB = iEvent.getHandle(tok_eb);
121  const edm::Handle<EcalRecHitCollection>& ecalEE = iEvent.getHandle(tok_ee);
122 #ifdef EDM_ML_DEBUG
123  edm::LogVerbatim("HcalIsoTrack") << "ecal Collections isValid: " << ecalEB.isValid() << "/" << ecalEE.isValid();
124 #endif
125 
127 
128  std::vector<edm::Ref<reco::IsolatedPixelTrackCandidateCollection> > isoPixTrackRefs;
129  trigCand->getObjects(trigger::TriggerTrack, isoPixTrackRefs);
130  int nCand = isoPixTrackRefs.size();
131 
132  auto iptcCollection = std::make_unique<reco::IsolatedPixelTrackCandidateCollection>();
133 #ifdef EDM_ML_DEBUG
134  edm::LogVerbatim("HcalIsoTrack") << "coneSize_ " << coneSizeEta0_ << "/" << coneSizeEta1_ << " hitCountEthrEB_ "
135  << hitCountEthrEB_ << " hitEthrEB_ " << hitEthrEB_ << " fachitCountEE_ "
136  << fachitCountEE_ << " hitEthrEE " << hitEthrEE0_ << ":" << hitEthrEE1_ << ":"
137  << hitEthrEE2_ << ":" << hitEthrEE3_;
138 #endif
139  for (int p = 0; p < nCand; p++) {
140  int nhitIn(0), nhitOut(0);
141  double inEnergy(0), outEnergy(0);
142  std::pair<double, double> etaPhi(isoPixTrackRefs[p]->track()->eta(), isoPixTrackRefs[p]->track()->phi());
143  if (isoPixTrackRefs[p]->etaPhiEcalValid())
144  etaPhi = isoPixTrackRefs[p]->etaPhiEcal();
145  double etaAbs = std::abs(etaPhi.first);
146  double coneSize_ = (etaAbs > 1.5) ? coneSizeEta1_ : (coneSizeEta0_ * (1.5 - etaAbs) + coneSizeEta1_ * etaAbs) / 1.5;
147 #ifdef EDM_ML_DEBUG
148  edm::LogVerbatim("HcalIsoTrack") << "Track: eta/phi " << etaPhi.first << "/" << etaPhi.second
149  << " pt:" << isoPixTrackRefs[p]->track()->pt() << " cone " << coneSize_ << "\n"
150  << "rechit size EB/EE : " << ecalEB->size() << "/" << ecalEE->size()
151  << " coneSize_: " << coneSize_;
152 #endif
153  if (etaAbs < 1.7) {
154  for (auto eItr : *(ecalEB.product())) {
155  const GlobalPoint& pos = geo->getPosition(eItr.detid());
156  double R = reco::deltaR(pos.eta(), pos.phi(), etaPhi.first, etaPhi.second);
157  if (R < coneSize_) {
158  nhitIn++;
159  inEnergy += (eItr.energy());
160  if (eItr.energy() > hitCountEthrEB_)
161  nhitOut++;
162  if (eItr.energy() > hitEthrEB_) {
163  outEnergy += (eItr.energy());
164  }
165 #ifdef EDM_ML_DEBUG
166  edm::LogVerbatim("HcalIsoTrack") << "EBRechit close to the track has E " << eItr.energy()
167  << " eta/phi: " << pos.eta() << "/" << pos.phi() << " deltaR: " << R;
168 #endif
169  }
170  }
171  }
172  if (etaAbs > 1.25) {
173  for (auto eItr : *(ecalEE.product())) {
174  const GlobalPoint& pos = geo->getPosition(eItr.detid());
175  double R = reco::deltaR(pos.eta(), pos.phi(), etaPhi.first, etaPhi.second);
176  if (R < coneSize_) {
177  double eta = std::abs(pos.eta());
178  double hitEthr = (((eta * hitEthrEE3_ + hitEthrEE2_) * eta + hitEthrEE1_) * eta + hitEthrEE0_);
179  if (hitEthr < hitEthrEB_)
180  hitEthr = hitEthrEB_;
181  nhitIn++;
182  inEnergy += (eItr.energy());
183  if (eItr.energy() > fachitCountEE_ * hitEthr)
184  nhitOut++;
185  if (eItr.energy() > hitEthr) {
186  outEnergy += (eItr.energy());
187  }
188 #ifdef EDM_ML_DEBUG
189  edm::LogVerbatim("HcalIsoTrack") << "EERechit close to the track has E " << eItr.energy()
190  << " eta/phi: " << pos.eta() << "/" << pos.phi() << " deltaR: " << R;
191 #endif
192  }
193  }
194  }
195 #ifdef EDM_ML_DEBUG
196  edm::LogVerbatim("HcalIsoTrack") << "nhitIn:" << nhitIn << " inEnergy:" << inEnergy << " nhitOut:" << nhitOut
197  << " outEnergy:" << outEnergy;
198 #endif
199  reco::IsolatedPixelTrackCandidate newca(*isoPixTrackRefs[p]);
200  newca.setEnergyIn(inEnergy);
201  newca.setEnergyOut(outEnergy);
202  newca.setNHitIn(nhitIn);
203  newca.setNHitOut(nhitOut);
204  iptcCollection->push_back(newca);
205  }
206 #ifdef EDM_ML_DEBUG
207  edm::LogVerbatim("HcalIsoTrack") << "ncand:" << nCand << " outcollction size:" << iptcCollection->size();
208 #endif
209  iEvent.put(std::move(iptcCollection));
210 }
211 
214 
Log< level::Info, true > LogVerbatim
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
size_type size() const
T const * product() const
Definition: Handle.h:70
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tok_geom_
const edm::EDGetTokenT< EcalRecHitCollection > tok_eb
const edm::EDGetTokenT< EcalRecHitCollection > tok_ee
int iEvent
Definition: GenABIO.cc:224
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_trigcand
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
def move(src, dest)
Definition: eostools.py:511