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  int nin(0), nout(0);
155  for (auto eItr : *(ecalEB.product())) {
156  const GlobalPoint& pos = geo->getPosition(eItr.detid());
157  double R = reco::deltaR(pos.eta(), pos.phi(), etaPhi.first, etaPhi.second);
158  if (R < coneSize_) {
159  nhitIn++;
160  inEnergy += (eItr.energy());
161  ++nin;
162  if (eItr.energy() > hitCountEthrEB_)
163  nhitOut++;
164  if (eItr.energy() > hitEthrEB_) {
165  outEnergy += (eItr.energy());
166  ++nout;
167  }
168 #ifdef EDM_ML_DEBUG
169  edm::LogVerbatim("HcalIsoTrack") << "EBRechit close to the track has E " << eItr.energy()
170  << " eta/phi: " << pos.eta() << "/" << pos.phi() << " deltaR: " << R;
171 #endif
172  }
173  }
174  }
175  if (etaAbs > 1.25) {
176  int nin(0), nout(0);
177  for (auto eItr : *(ecalEE.product())) {
178  const GlobalPoint& pos = geo->getPosition(eItr.detid());
179  double R = reco::deltaR(pos.eta(), pos.phi(), etaPhi.first, etaPhi.second);
180  if (R < coneSize_) {
181  double eta = std::abs(pos.eta());
182  double hitEthr = (((eta * hitEthrEE3_ + hitEthrEE2_) * eta + hitEthrEE1_) * eta + hitEthrEE0_);
183  if (hitEthr < hitEthrEB_)
184  hitEthr = hitEthrEB_;
185  nhitIn++;
186  inEnergy += (eItr.energy());
187  ++nin;
188  if (eItr.energy() > fachitCountEE_ * hitEthr)
189  nhitOut++;
190  if (eItr.energy() > hitEthr) {
191  outEnergy += (eItr.energy());
192  ++nout;
193  }
194 #ifdef EDM_ML_DEBUG
195  edm::LogVerbatim("HcalIsoTrack") << "EERechit close to the track has E " << eItr.energy()
196  << " eta/phi: " << pos.eta() << "/" << pos.phi() << " deltaR: " << R;
197 #endif
198  }
199  }
200  }
201 #ifdef EDM_ML_DEBUG
202  edm::LogVerbatim("HcalIsoTrack") << "nhitIn:" << nhitIn << " inEnergy:" << inEnergy << " nhitOut:" << nhitOut
203  << " outEnergy:" << outEnergy;
204 #endif
205  reco::IsolatedPixelTrackCandidate newca(*isoPixTrackRefs[p]);
206  newca.setEnergyIn(inEnergy);
207  newca.setEnergyOut(outEnergy);
208  newca.setNHitIn(nhitIn);
209  newca.setNHitOut(nhitOut);
210  iptcCollection->push_back(newca);
211  }
212 #ifdef EDM_ML_DEBUG
213  edm::LogVerbatim("HcalIsoTrack") << "ncand:" << nCand << " outcollction size:" << iptcCollection->size();
214 #endif
215  iEvent.put(std::move(iptcCollection));
216 }
217 
220 
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
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
bool getData(T &iHolder) const
Definition: EventSetup.h:122
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