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 
27 
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  std::cout << "==============Inside IsolatedEcalPixelTrackCandidateProducer" << std::endl;
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  std::cout << "ecal Collections isValid: " << ecalEB.isValid() << "/" << ecalEE.isValid() << std::endl;
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  std::cout << "coneSize_ " << coneSizeEta0_ << "/"<< coneSizeEta1_ << " hitCountEthr_ " << hitCountEthr_ << " hitEthr_ " << hitEthr_ << std::endl;
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  std::cout << "Track: eta/phi " << etaPhi.first << "/" << etaPhi.second << " pt:" << isoPixTrackRefs[p]->track()->pt() << " cone " << coneSize_ << std::endl;
91  std::cout << "rechit size EB/EE : " << ecalEB->size() << "/" << ecalEE->size() << " coneSize_: " << coneSize_ << std::endl;
92 #endif
93  if (etaAbs<1.7) {
94  for (EcalRecHitCollection::const_iterator eItr=ecalEB->begin(); eItr!=ecalEB->end(); eItr++) {
95  GlobalPoint pos = geo->getPosition(eItr->detid());
96  double R = reco::deltaR(pos.eta(),pos.phi(),etaPhi.first,etaPhi.second);
97  if (R < coneSize_) {
98  nhitIn++;
99  inEnergy += (eItr->energy());
100  if (eItr->energy() > hitCountEthr_) nhitOut++;
101  if (eItr->energy() > hitEthr_) outEnergy += (eItr->energy());
102 #ifdef DebugLog
103  std::cout << "Rechit Close to the track has energy " << eItr->energy()
104  << " eta/phi: " << pos.eta() << "/" << pos.phi() << " deltaR: " << R << std::endl;
105 #endif
106  }
107  }
108  }
109  if (etaAbs>1.25) {
110  for (EcalRecHitCollection::const_iterator eItr=ecalEE->begin(); eItr!=ecalEE->end(); eItr++) {
111  GlobalPoint pos = geo->getPosition(eItr->detid());
112  double R = reco::deltaR(pos.eta(),pos.phi(),etaPhi.first,etaPhi.second);
113  if (R < coneSize_) {
114  nhitIn++;
115  inEnergy += (eItr->energy());
116  if (eItr->energy() > hitCountEthr_) nhitOut++;
117  if (eItr->energy() > hitEthr_) outEnergy += (eItr->energy());
118 #ifdef DebugLog
119  std::cout << "Rechit Close to the track has energy " << eItr->energy()
120  << " eta/phi: " << pos.eta() << "/" << pos.phi() << " deltaR: " << R << std::endl;
121 #endif
122  }
123  }
124  }
125 #ifdef DebugLog
126  std::cout << "nhitIn:" << nhitIn << " inEnergy:" << inEnergy << " nhitOut:" << nhitOut << " outEnergy:" << outEnergy << std::endl;
127 #endif
128  reco::IsolatedPixelTrackCandidate newca(*isoPixTrackRefs[p]);
129  newca.setEnergyIn(inEnergy);
130  newca.setEnergyOut(outEnergy);
131  newca.setNHitIn(nhitIn);
132  newca.setNHitOut(nhitOut);
133  iptcCollection->push_back(newca);
134  }
135 #ifdef DebugLog
136  std::cout << "ncand:" << nCand << " outcollction size:" << iptcCollection->size() << std::endl;
137 #endif
138  std::auto_ptr<reco::IsolatedPixelTrackCandidateCollection> outCollection(iptcCollection);
139  iEvent.put(outCollection);
140 }
141 // ------------ method called once each job just before starting event loop ------------
143 
144 // ------------ 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
tuple cout
Definition: gather_cfg.py:121
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_trigcand
Definition: DDAxes.h:10