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 DebugLog
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  hitCountEthr_( conf.getParameter<double>("ECHitCountEnergyThreshold") ),
44  hitEthr_( conf.getParameter<double>("ECHitEnergyThreshold") )
45 {
46  // register the products
47  produces< reco::IsolatedPixelTrackCandidateCollection >();
48 }
49 
51 
52 // ------------ method called to produce the data ------------
54 #ifdef DebugLog
55  edm::LogInfo("HcalIsoTrack") << "==============Inside IsolatedEcalPixelTrackCandidateProducer";
56 #endif
58  iSetup.get<CaloGeometryRecord>().get(pG);
59  const CaloGeometry* geo = pG.product();
60 
62  iEvent.getByToken(tok_eb,ecalEB);
63 
65  iEvent.getByToken(tok_ee,ecalEE);
66 #ifdef DebugLog
67  edm::LogInfo("HcalIsoTrack") << "ecal Collections isValid: " << ecalEB.isValid() << "/" << ecalEE.isValid();
68 #endif
69 
71  iEvent.getByToken(tok_trigcand,trigCand);
72 
73  std::vector< edm::Ref<reco::IsolatedPixelTrackCandidateCollection> > isoPixTrackRefs;
74  trigCand->getObjects(trigger::TriggerTrack, isoPixTrackRefs);
75  int nCand=isoPixTrackRefs.size();
76 
77  auto iptcCollection = std::make_unique<reco::IsolatedPixelTrackCandidateCollection>();
78 #ifdef DebugLog
79  edm::LogInfo("HcalIsoTrack") << "coneSize_ " << coneSizeEta0_ << "/"<< coneSizeEta1_ << " hitCountEthr_ " << hitCountEthr_ << " hitEthr_ " << hitEthr_;
80 #endif
81  for (int p=0; p<nCand; p++) {
82  int nhitIn(0), nhitOut(0);
83  double inEnergy(0), outEnergy(0);
84  std::pair<double,double> etaPhi(isoPixTrackRefs[p]->track()->eta(), isoPixTrackRefs[p]->track()->phi());
85  if (isoPixTrackRefs[p]->etaPhiEcalValid()) etaPhi = isoPixTrackRefs[p]->etaPhiEcal();
86  double etaAbs = std::abs(etaPhi.first);
87  double coneSize_ = (etaAbs > 1.5) ? coneSizeEta1_ : (coneSizeEta0_*(1.5-etaAbs)+coneSizeEta1_*etaAbs)/1.5;
88 #ifdef DebugLog
89  edm::LogInfo("HcalIsoTrack") << "Track: eta/phi " << etaPhi.first << "/" << etaPhi.second << " pt:" << isoPixTrackRefs[p]->track()->pt() << " cone " << coneSize_ << "\n" << "rechit size EB/EE : " << ecalEB->size() << "/" << ecalEE->size() << " coneSize_: " << coneSize_;
90 #endif
91  if (etaAbs<1.7) {
92  for (EcalRecHitCollection::const_iterator eItr=ecalEB->begin(); eItr!=ecalEB->end(); eItr++) {
93  const GlobalPoint& pos = geo->getPosition(eItr->detid());
94  double R = reco::deltaR(pos.eta(),pos.phi(),etaPhi.first,etaPhi.second);
95  if (R < coneSize_) {
96  nhitIn++;
97  inEnergy += (eItr->energy());
98  if (eItr->energy() > hitCountEthr_) nhitOut++;
99  if (eItr->energy() > hitEthr_) outEnergy += (eItr->energy());
100 #ifdef DebugLog
101  edm::LogInfo("HcalIsoTrack") << "Rechit Close to the track has energy " << eItr->energy() << " eta/phi: " << pos.eta() << "/" << pos.phi() << " deltaR: " << R;
102 #endif
103  }
104  }
105  }
106  if (etaAbs>1.25) {
107  for (EcalRecHitCollection::const_iterator eItr=ecalEE->begin(); eItr!=ecalEE->end(); eItr++) {
108  const GlobalPoint& pos = geo->getPosition(eItr->detid());
109  double R = reco::deltaR(pos.eta(),pos.phi(),etaPhi.first,etaPhi.second);
110  if (R < coneSize_) {
111  nhitIn++;
112  inEnergy += (eItr->energy());
113  if (eItr->energy() > hitCountEthr_) nhitOut++;
114  if (eItr->energy() > hitEthr_) outEnergy += (eItr->energy());
115 #ifdef DebugLog
116  edm::LogInfo("HcalIsoTrack") << "Rechit Close to the track has energy " << eItr->energy() << " eta/phi: " << pos.eta() << "/" << pos.phi() << " deltaR: " << R;
117 #endif
118  }
119  }
120  }
121 #ifdef DebugLog
122  edm::LogInfo("HcalIsoTrack") << "nhitIn:" << nhitIn << " inEnergy:" << inEnergy << " nhitOut:" << nhitOut << " outEnergy:" << outEnergy;
123 #endif
124  reco::IsolatedPixelTrackCandidate newca(*isoPixTrackRefs[p]);
125  newca.setEnergyIn(inEnergy);
126  newca.setEnergyOut(outEnergy);
127  newca.setNHitIn(nhitIn);
128  newca.setNHitOut(nhitOut);
129  iptcCollection->push_back(newca);
130  }
131 #ifdef DebugLog
132  edm::LogInfo("HcalIsoTrack") << "ncand:" << nCand << " outcollction size:" << iptcCollection->size();
133 #endif
134  iEvent.put(std::move(iptcCollection));
135 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
std::vector< EcalRecHit >::const_iterator const_iterator
const edm::EDGetTokenT< EcalRecHitCollection > tok_eb
const edm::EDGetTokenT< EcalRecHitCollection > tok_ee
int iEvent
Definition: GenABIO.cc:230
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:69
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
bool isValid() const
Definition: HandleBase.h:74
const_iterator end() const
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_trigcand
const T & get() const
Definition: EventSetup.h:58
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
T eta() const
Definition: PV3DBase.h:76
HLT enums.
size_type size() const
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510
const_iterator begin() const