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
25 
34 
36 
38  : tok_ee(consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("EERecHitSource"))),
39  tok_eb(consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("EBRecHitSource"))),
40  tok_trigcand(consumes<trigger::TriggerFilterObjectWithRefs>(conf.getParameter<edm::InputTag>("filterLabel"))),
41  coneSizeEta0_(conf.getParameter<double>("EcalConeSizeEta0")),
42  coneSizeEta1_(conf.getParameter<double>("EcalConeSizeEta1")),
43  hitCountEthrEB_(conf.getParameter<double>("EBHitCountEnergyThreshold")),
44  hitEthrEB_(conf.getParameter<double>("EBHitEnergyThreshold")),
45  fachitCountEE_(conf.getParameter<double>("EEFacHitCountEnergyThreshold")),
46  hitEthrEE0_(conf.getParameter<double>("EEHitEnergyThreshold0")),
47  hitEthrEE1_(conf.getParameter<double>("EEHitEnergyThreshold1")),
48  hitEthrEE2_(conf.getParameter<double>("EEHitEnergyThreshold2")),
49  hitEthrEE3_(conf.getParameter<double>("EEHitEnergyThreshold3")) {
50  // register the products
51  produces<reco::IsolatedPixelTrackCandidateCollection>();
52 }
53 
55 
58  desc.add<edm::InputTag>("filterLabel", edm::InputTag("hltIsolPixelTrackL2Filter"));
59  desc.add<edm::InputTag>("EBRecHitSource", edm::InputTag("hltEcalRecHit", "EcalRecHitsEB"));
60  desc.add<edm::InputTag>("EERecHitSource", edm::InputTag("hltEcalRecHit", "EcalRecHitsEE"));
61  desc.add<double>("EBHitEnergyThreshold", 0.10);
62  desc.add<double>("EBHitCountEnergyThreshold", 0.5);
63  desc.add<double>("EEHitEnergyThreshold0", -41.0664);
64  desc.add<double>("EEHitEnergyThreshold1", 68.7950);
65  desc.add<double>("EEHitEnergyThreshold2", -38.1483);
66  desc.add<double>("EEHitEnergyThreshold3", 7.04303);
67  desc.add<double>("EEFacHitCountEnergyThreshold", 10.0);
68  desc.add<double>("EcalConeSizeEta0", 0.09);
69  desc.add<double>("EcalConeSizeEta1", 0.14);
70  descriptions.add("isolEcalPixelTrackProd", desc);
71 }
72 
73 // ------------ method called to produce the data ------------
76  const edm::EventSetup& iSetup) const {
77 #ifdef EDM_ML_DEBUG
78  edm::LogInfo("HcalIsoTrack") << "==============Inside IsolatedEcalPixelTrackCandidateProducer";
79 #endif
81  iSetup.get<CaloGeometryRecord>().get(pG);
82  const CaloGeometry* geo = pG.product();
83 
85  iEvent.getByToken(tok_eb, ecalEB);
86 
88  iEvent.getByToken(tok_ee, ecalEE);
89 #ifdef EDM_ML_DEBUG
90  edm::LogInfo("HcalIsoTrack") << "ecal Collections isValid: " << ecalEB.isValid() << "/" << ecalEE.isValid();
91 #endif
92 
94  iEvent.getByToken(tok_trigcand, trigCand);
95 
96  std::vector<edm::Ref<reco::IsolatedPixelTrackCandidateCollection> > isoPixTrackRefs;
97  trigCand->getObjects(trigger::TriggerTrack, isoPixTrackRefs);
98  int nCand = isoPixTrackRefs.size();
99 
100  auto iptcCollection = std::make_unique<reco::IsolatedPixelTrackCandidateCollection>();
101 #ifdef EDM_ML_DEBUG
102  edm::LogInfo("HcalIsoTrack") << "coneSize_ " << coneSizeEta0_ << "/" << coneSizeEta1_ << " hitCountEthrEB_ "
103  << hitCountEthrEB_ << " hitEthrEB_ " << hitEthrEB_ << " fachitCountEE_ "
104  << fachitCountEE_ << " hitEthrEE " << hitEthrEE0_ << ":" << hitEthrEE1_ << ":"
105  << hitEthrEE2_ << ":" << hitEthrEE3_;
106 #endif
107  for (int p = 0; p < nCand; p++) {
108  int nhitIn(0), nhitOut(0);
109  double inEnergy(0), outEnergy(0);
110  std::pair<double, double> etaPhi(isoPixTrackRefs[p]->track()->eta(), isoPixTrackRefs[p]->track()->phi());
111  if (isoPixTrackRefs[p]->etaPhiEcalValid())
112  etaPhi = isoPixTrackRefs[p]->etaPhiEcal();
113  double etaAbs = std::abs(etaPhi.first);
114  double coneSize_ = (etaAbs > 1.5) ? coneSizeEta1_ : (coneSizeEta0_ * (1.5 - etaAbs) + coneSizeEta1_ * etaAbs) / 1.5;
115 #ifdef EDM_ML_DEBUG
116  edm::LogInfo("HcalIsoTrack") << "Track: eta/phi " << etaPhi.first << "/" << etaPhi.second
117  << " pt:" << isoPixTrackRefs[p]->track()->pt() << " cone " << coneSize_ << "\n"
118  << "rechit size EB/EE : " << ecalEB->size() << "/" << ecalEE->size()
119  << " coneSize_: " << coneSize_;
120 #endif
121  if (etaAbs < 1.7) {
122  int nin(0), nout(0);
123  for (auto eItr : *(ecalEB.product())) {
124  const GlobalPoint& pos = geo->getPosition(eItr.detid());
125  double R = reco::deltaR(pos.eta(), pos.phi(), etaPhi.first, etaPhi.second);
126  if (R < coneSize_) {
127  nhitIn++;
128  inEnergy += (eItr.energy());
129  ++nin;
130  if (eItr.energy() > hitCountEthrEB_)
131  nhitOut++;
132  if (eItr.energy() > hitEthrEB_) {
133  outEnergy += (eItr.energy());
134  ++nout;
135  }
136 #ifdef EDM_ML_DEBUG
137  edm::LogInfo("HcalIsoTrack") << "EBRechit close to the track has E " << eItr.energy()
138  << " eta/phi: " << pos.eta() << "/" << pos.phi() << " deltaR: " << R;
139 #endif
140  }
141  }
142  }
143  if (etaAbs > 1.25) {
144  int nin(0), nout(0);
145  for (auto eItr : *(ecalEE.product())) {
146  const GlobalPoint& pos = geo->getPosition(eItr.detid());
147  double R = reco::deltaR(pos.eta(), pos.phi(), etaPhi.first, etaPhi.second);
148  if (R < coneSize_) {
149  double eta = std::abs(pos.eta());
150  double hitEthr = (((eta * hitEthrEE3_ + hitEthrEE2_) * eta + hitEthrEE1_) * eta + hitEthrEE0_);
151  if (hitEthr < hitEthrEB_)
152  hitEthr = hitEthrEB_;
153  nhitIn++;
154  inEnergy += (eItr.energy());
155  ++nin;
156  if (eItr.energy() > fachitCountEE_ * hitEthr)
157  nhitOut++;
158  if (eItr.energy() > hitEthr) {
159  outEnergy += (eItr.energy());
160  ++nout;
161  }
162 #ifdef EDM_ML_DEBUG
163  edm::LogInfo("HcalIsoTrack") << "EERechit close to the track has E " << eItr.energy()
164  << " eta/phi: " << pos.eta() << "/" << pos.phi() << " deltaR: " << R;
165 #endif
166  }
167  }
168  }
169 #ifdef EDM_ML_DEBUG
170  edm::LogInfo("HcalIsoTrack") << "nhitIn:" << nhitIn << " inEnergy:" << inEnergy << " nhitOut:" << nhitOut
171  << " outEnergy:" << outEnergy;
172 #endif
173  reco::IsolatedPixelTrackCandidate newca(*isoPixTrackRefs[p]);
174  newca.setEnergyIn(inEnergy);
175  newca.setEnergyOut(outEnergy);
176  newca.setNHitIn(nhitIn);
177  newca.setNHitOut(nhitOut);
178  iptcCollection->push_back(newca);
179  }
180 #ifdef EDM_ML_DEBUG
181  edm::LogInfo("HcalIsoTrack") << "ncand:" << nCand << " outcollction size:" << iptcCollection->size();
182 #endif
183  iEvent.put(std::move(iptcCollection));
184 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
const edm::EDGetTokenT< EcalRecHitCollection > tok_eb
int nin
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:74
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_trigcand
T const * product() const
Definition: Handle.h:74
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
T eta() const
Definition: PV3DBase.h:76
int nout
HLT enums.
size_type size() const
T get() const
Definition: EventSetup.h:71
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511