CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 DebugLog
21 // system include files
22 #include <memory>
23 
24 // user include files
25 
34 
36 
38 
39  coneSizeEta0_ = conf.getParameter<double>("EcalConeSizeEta0");
40  coneSizeEta1_ = conf.getParameter<double>("EcalConeSizeEta1");
41  hitCountEthr_ = conf.getParameter<double>("ECHitCountEnergyThreshold");
42  hitEthr_ = conf.getParameter<double>("ECHitEnergyThreshold");
43  tok_trigcand = consumes<trigger::TriggerFilterObjectWithRefs>(conf.getParameter<edm::InputTag>("filterLabel"));
44  tok_eb = consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("EBRecHitSource"));
45  tok_ee = consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("EERecHitSource"));
46 
47  //register your products
48  produces< reco::IsolatedPixelTrackCandidateCollection >();
49 }
50 
52 
53 // ------------ method called to produce the data ------------
55 #ifdef DebugLog
56  edm::LogInfo("HcalIsoTrack") << "==============Inside IsolatedEcalPixelTrackCandidateProducer";
57 #endif
59  iSetup.get<CaloGeometryRecord>().get(pG);
60  const CaloGeometry* geo = pG.product();
61 
63  iEvent.getByToken(tok_eb,ecalEB);
64 
66  iEvent.getByToken(tok_ee,ecalEE);
67 #ifdef DebugLog
68  edm::LogInfo("HcalIsoTrack") << "ecal Collections isValid: " << ecalEB.isValid() << "/" << ecalEE.isValid();
69 #endif
70 
72  iEvent.getByToken(tok_trigcand,trigCand);
73 
74  std::vector< edm::Ref<reco::IsolatedPixelTrackCandidateCollection> > isoPixTrackRefs;
75  trigCand->getObjects(trigger::TriggerTrack, isoPixTrackRefs);
76  int nCand=isoPixTrackRefs.size();
77 
79 #ifdef DebugLog
80  edm::LogInfo("HcalIsoTrack") << "coneSize_ " << coneSizeEta0_ << "/"<< coneSizeEta1_ << " hitCountEthr_ " << hitCountEthr_ << " hitEthr_ " << hitEthr_;
81 #endif
82  for (int p=0; p<nCand; p++) {
83  int nhitIn(0), nhitOut(0);
84  double inEnergy(0), outEnergy(0);
85  std::pair<double,double> etaPhi(isoPixTrackRefs[p]->track()->eta(), isoPixTrackRefs[p]->track()->phi());
86  if (isoPixTrackRefs[p]->etaPhiEcalValid()) etaPhi = isoPixTrackRefs[p]->etaPhiEcal();
87  double etaAbs = std::abs(etaPhi.first);
88  double coneSize_ = (etaAbs > 1.5) ? coneSizeEta1_ : (coneSizeEta0_*(1.5-etaAbs)+coneSizeEta1_*etaAbs)/1.5;
89 #ifdef DebugLog
90  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_;
91 #endif
92  if (etaAbs<1.7) {
93  for (EcalRecHitCollection::const_iterator eItr=ecalEB->begin(); eItr!=ecalEB->end(); eItr++) {
94  GlobalPoint pos = geo->getPosition(eItr->detid());
95  double R = reco::deltaR(pos.eta(),pos.phi(),etaPhi.first,etaPhi.second);
96  if (R < coneSize_) {
97  nhitIn++;
98  inEnergy += (eItr->energy());
99  if (eItr->energy() > hitCountEthr_) nhitOut++;
100  if (eItr->energy() > hitEthr_) outEnergy += (eItr->energy());
101 #ifdef DebugLog
102  edm::LogInfo("HcalIsoTrack") << "Rechit Close to the track has energy " << eItr->energy() << " eta/phi: " << pos.eta() << "/" << pos.phi() << " deltaR: " << R;
103 #endif
104  }
105  }
106  }
107  if (etaAbs>1.25) {
108  for (EcalRecHitCollection::const_iterator eItr=ecalEE->begin(); eItr!=ecalEE->end(); eItr++) {
109  GlobalPoint pos = geo->getPosition(eItr->detid());
110  double R = reco::deltaR(pos.eta(),pos.phi(),etaPhi.first,etaPhi.second);
111  if (R < coneSize_) {
112  nhitIn++;
113  inEnergy += (eItr->energy());
114  if (eItr->energy() > hitCountEthr_) nhitOut++;
115  if (eItr->energy() > hitEthr_) outEnergy += (eItr->energy());
116 #ifdef DebugLog
117  edm::LogInfo("HcalIsoTrack") << "Rechit Close to the track has energy " << eItr->energy() << " eta/phi: " << pos.eta() << "/" << pos.phi() << " deltaR: " << R;
118 #endif
119  }
120  }
121  }
122 #ifdef DebugLog
123  edm::LogInfo("HcalIsoTrack") << "nhitIn:" << nhitIn << " inEnergy:" << inEnergy << " nhitOut:" << nhitOut << " outEnergy:" << outEnergy;
124 #endif
125  reco::IsolatedPixelTrackCandidate newca(*isoPixTrackRefs[p]);
126  newca.setEnergyIn(inEnergy);
127  newca.setEnergyOut(outEnergy);
128  newca.setNHitIn(nhitIn);
129  newca.setNHitOut(nhitOut);
130  iptcCollection->push_back(newca);
131  }
132 #ifdef DebugLog
133  edm::LogInfo("HcalIsoTrack") << "ncand:" << nCand << " outcollction size:" << iptcCollection->size();
134 #endif
135  std::auto_ptr<reco::IsolatedPixelTrackCandidateCollection> outCollection(iptcCollection);
136  iEvent.put(outCollection);
137 }
138 // ------------ method called once each job just before starting event loop ------------
140 
141 // ------------ method called once each job just after ending the event loop ------------
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
std::vector< EcalRecHit >::const_iterator const_iterator
virtual void produce(edm::Event &, const edm::EventSetup &)
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
T eta() const
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:68
std::vector< IsolatedPixelTrackCandidate > IsolatedPixelTrackCandidateCollection
collectin of IsolatedPixelTrackCandidate objects
bool isValid() const
Definition: HandleBase.h:75
tuple conf
Definition: dbtoconf.py:185
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
T eta() const
Definition: PV3DBase.h:76
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_trigcand
Definition: DDAxes.h:10