CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
121  iEvent.getByToken(tok_eb, ecalEB);
122 
124  iEvent.getByToken(tok_ee, ecalEE);
125 #ifdef EDM_ML_DEBUG
126  edm::LogVerbatim("HcalIsoTrack") << "ecal Collections isValid: " << ecalEB.isValid() << "/" << ecalEE.isValid();
127 #endif
128 
130  iEvent.getByToken(tok_trigcand, trigCand);
131 
132  std::vector<edm::Ref<reco::IsolatedPixelTrackCandidateCollection> > isoPixTrackRefs;
133  trigCand->getObjects(trigger::TriggerTrack, isoPixTrackRefs);
134  int nCand = isoPixTrackRefs.size();
135 
136  auto iptcCollection = std::make_unique<reco::IsolatedPixelTrackCandidateCollection>();
137 #ifdef EDM_ML_DEBUG
138  edm::LogVerbatim("HcalIsoTrack") << "coneSize_ " << coneSizeEta0_ << "/" << coneSizeEta1_ << " hitCountEthrEB_ "
139  << hitCountEthrEB_ << " hitEthrEB_ " << hitEthrEB_ << " fachitCountEE_ "
140  << fachitCountEE_ << " hitEthrEE " << hitEthrEE0_ << ":" << hitEthrEE1_ << ":"
141  << hitEthrEE2_ << ":" << hitEthrEE3_;
142 #endif
143  for (int p = 0; p < nCand; p++) {
144  int nhitIn(0), nhitOut(0);
145  double inEnergy(0), outEnergy(0);
146  std::pair<double, double> etaPhi(isoPixTrackRefs[p]->track()->eta(), isoPixTrackRefs[p]->track()->phi());
147  if (isoPixTrackRefs[p]->etaPhiEcalValid())
148  etaPhi = isoPixTrackRefs[p]->etaPhiEcal();
149  double etaAbs = std::abs(etaPhi.first);
150  double coneSize_ = (etaAbs > 1.5) ? coneSizeEta1_ : (coneSizeEta0_ * (1.5 - etaAbs) + coneSizeEta1_ * etaAbs) / 1.5;
151 #ifdef EDM_ML_DEBUG
152  edm::LogVerbatim("HcalIsoTrack") << "Track: eta/phi " << etaPhi.first << "/" << etaPhi.second
153  << " pt:" << isoPixTrackRefs[p]->track()->pt() << " cone " << coneSize_ << "\n"
154  << "rechit size EB/EE : " << ecalEB->size() << "/" << ecalEE->size()
155  << " coneSize_: " << coneSize_;
156 #endif
157  if (etaAbs < 1.7) {
158  int nin(0), nout(0);
159  for (auto eItr : *(ecalEB.product())) {
160  const GlobalPoint& pos = geo->getPosition(eItr.detid());
161  double R = reco::deltaR(pos.eta(), pos.phi(), etaPhi.first, etaPhi.second);
162  if (R < coneSize_) {
163  nhitIn++;
164  inEnergy += (eItr.energy());
165  ++nin;
166  if (eItr.energy() > hitCountEthrEB_)
167  nhitOut++;
168  if (eItr.energy() > hitEthrEB_) {
169  outEnergy += (eItr.energy());
170  ++nout;
171  }
172 #ifdef EDM_ML_DEBUG
173  edm::LogVerbatim("HcalIsoTrack") << "EBRechit close to the track has E " << eItr.energy()
174  << " eta/phi: " << pos.eta() << "/" << pos.phi() << " deltaR: " << R;
175 #endif
176  }
177  }
178  }
179  if (etaAbs > 1.25) {
180  int nin(0), nout(0);
181  for (auto eItr : *(ecalEE.product())) {
182  const GlobalPoint& pos = geo->getPosition(eItr.detid());
183  double R = reco::deltaR(pos.eta(), pos.phi(), etaPhi.first, etaPhi.second);
184  if (R < coneSize_) {
185  double eta = std::abs(pos.eta());
186  double hitEthr = (((eta * hitEthrEE3_ + hitEthrEE2_) * eta + hitEthrEE1_) * eta + hitEthrEE0_);
187  if (hitEthr < hitEthrEB_)
188  hitEthr = hitEthrEB_;
189  nhitIn++;
190  inEnergy += (eItr.energy());
191  ++nin;
192  if (eItr.energy() > fachitCountEE_ * hitEthr)
193  nhitOut++;
194  if (eItr.energy() > hitEthr) {
195  outEnergy += (eItr.energy());
196  ++nout;
197  }
198 #ifdef EDM_ML_DEBUG
199  edm::LogVerbatim("HcalIsoTrack") << "EERechit close to the track has E " << eItr.energy()
200  << " eta/phi: " << pos.eta() << "/" << pos.phi() << " deltaR: " << R;
201 #endif
202  }
203  }
204  }
205 #ifdef EDM_ML_DEBUG
206  edm::LogVerbatim("HcalIsoTrack") << "nhitIn:" << nhitIn << " inEnergy:" << inEnergy << " nhitOut:" << nhitOut
207  << " outEnergy:" << outEnergy;
208 #endif
209  reco::IsolatedPixelTrackCandidate newca(*isoPixTrackRefs[p]);
210  newca.setEnergyIn(inEnergy);
211  newca.setEnergyOut(outEnergy);
212  newca.setNHitIn(nhitIn);
213  newca.setNHitOut(nhitOut);
214  iptcCollection->push_back(newca);
215  }
216 #ifdef EDM_ML_DEBUG
217  edm::LogVerbatim("HcalIsoTrack") << "ncand:" << nCand << " outcollction size:" << iptcCollection->size();
218 #endif
219  iEvent.put(std::move(iptcCollection));
220 }
221 
224 
Log< level::Info, true > LogVerbatim
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tok_geom_
const edm::EDGetTokenT< EcalRecHitCollection > tok_eb
int nin
const edm::EDGetTokenT< EcalRecHitCollection > tok_ee
bool getData(T &iHolder) const
Definition: EventSetup.h:128
int iEvent
Definition: GenABIO.cc:224
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
def move
Definition: eostools.py:511
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
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:70
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_trigcand
T const * product() const
Definition: Handle.h:70
void add(std::string const &label, ParameterSetDescription const &psetDescription)
T eta() const
Definition: PV3DBase.h:73
int nout
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
tok_geom_(esConsumes< CaloGeometry, CaloGeometryRecord, edm::Transition::BeginRun >())