CMS 3D CMS Logo

EcalIsolatedParticleCandidateProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EcalIsolatedParticleCandidateProducer
4 // Class: EcalIsolatedParticleCandidateProducer
5 //
13 //
14 // Original Author: Grigory Safronov
15 // Created: Thu Jun 7 17:21:58 MSD 2007
16 //
17 //
18 
19 
20 // system include files
21 #include <cmath>
22 #include <memory>
23 
24 // user include files
25 
27 
28 
34 
36 
38 {
39  InConeSize_ = conf.getParameter<double>("EcalInnerConeSize");
40  OutConeSize_= conf.getParameter<double>("EcalOuterConeSize");
41  hitCountEthr_= conf.getParameter<double>("ECHitCountEnergyThreshold");
42  hitEthr_=conf.getParameter<double>("ECHitEnergyThreshold");
43  tok_l1tau_ = consumes<l1extra::L1JetParticleCollection>(conf.getParameter<edm::InputTag>("L1eTauJetsSource"));
44  tok_hlt_ = consumes<trigger::TriggerFilterObjectWithRefs>(conf.getParameter<edm::InputTag>("L1GTSeedLabel"));
45  tok_EB_ = consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("EBrecHitCollectionLabel"));
46  tok_EE_ = consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("EErecHitCollectionLabel"));
47 
48  //register your products
49  produces< reco::IsolatedPixelTrackCandidateCollection >();
50 
51 }
52 
53 
55 {
56 
57  // do anything here that needs to be done at desctruction time
58  // (e.g. close files, deallocate resources etc.)
59 
60 }
61 
62 
63 //
64 // member functions
65 //
66 
67 // ------------ method called to produce the data ------------
68 void
70 
71 // std::cout<<"get tau"<<std::endl;
72 
74  iEvent.getByToken(tok_l1tau_,l1Taus);
75 
76 // std::cout<<"get geom"<<std::endl;
77 
79  iSetup.get<CaloGeometryRecord>().get(pG);
80  const CaloGeometry* geo = pG.product();
81 
82 // std::cout<<" get ec rechit"<<std::endl;
83 
85  iEvent.getByToken(tok_EB_,ecalEB);
86 
88  iEvent.getByToken(tok_EE_,ecalEE);
89 
90 // std::cout<<"get l1 trig obj"<<std::endl;
91 
93  iEvent.getByToken(tok_hlt_, l1trigobj);
94 
95  std::vector< edm::Ref<l1t::TauBxCollection> > l1tauobjref;
96  std::vector< edm::Ref<l1t::JetBxCollection> > l1jetobjref;
97 
98  l1trigobj->getObjects(trigger::TriggerL1Tau, l1tauobjref);
99  l1trigobj->getObjects(trigger::TriggerL1Jet, l1jetobjref);
100 
101  double ptTriggered=-10;
102  double etaTriggered=-100;
103  double phiTriggered=-100;
104 
105 // std::cout<<"find highest pT triggered obj"<<std::endl;
106 
107  for (unsigned int p=0; p<l1tauobjref.size(); p++) {
108  if (l1tauobjref[p]->pt()>ptTriggered) {
109  ptTriggered=l1tauobjref[p]->pt();
110  phiTriggered=l1tauobjref[p]->phi();
111  etaTriggered=l1tauobjref[p]->eta();
112  }
113  }
114  for (unsigned int p=0; p<l1jetobjref.size(); p++) {
115  if (l1jetobjref[p]->pt()>ptTriggered) {
116  ptTriggered=l1jetobjref[p]->pt();
117  phiTriggered=l1jetobjref[p]->phi();
118  etaTriggered=l1jetobjref[p]->eta();
119  }
120  }
121 
122  auto iptcCollection = std::make_unique<reco::IsolatedPixelTrackCandidateCollection>();
123 
124 // std::cout<<"loop over l1taus"<<std::endl;
125 
126  for (l1extra::L1JetParticleCollection::const_iterator tit=l1Taus->begin(); tit!=l1Taus->end(); tit++) {
127  double dphi=fabs(tit->phi()-phiTriggered);
128  if (dphi>M_PI) dphi=2*M_PI-dphi;
129  double Rseed=sqrt(pow(etaTriggered-tit->eta(),2)+dphi*dphi);
130  if (Rseed<1.2) continue;
131  int nhitOut=0;
132  int nhitIn=0;
133  double OutEnergy=0;
134  double InEnergy=0;
135 // std::cout<<" loops over rechits"<<std::endl;
136  for (EcalRecHitCollection::const_iterator eItr=ecalEB->begin(); eItr!=ecalEB->end(); eItr++) {
137  double phiD, R;
138  const GlobalPoint& pos = geo->getPosition(eItr->detid());
139  double phihit = pos.phi();
140  double etahit = pos.eta();
141  phiD=fabs(phihit-tit->phi());
142  if (phiD>M_PI) phiD=2*M_PI-phiD;
143  R=sqrt(pow(etahit-tit->eta(),2)+phiD*phiD);
144 
145  if (R<OutConeSize_&&R>InConeSize_&&eItr->energy()>hitCountEthr_) {
146  nhitOut++;
147  }
148  if (R<InConeSize_&&eItr->energy()>hitCountEthr_) {
149  nhitIn++;
150  }
151 
152  if (R<OutConeSize_&&R>InConeSize_&&eItr->energy()>hitEthr_) {
153  OutEnergy+=eItr->energy();
154  }
155  if (R<InConeSize_&&eItr->energy()>hitEthr_) {
156  InEnergy+=eItr->energy();
157  }
158 
159  }
160 
161  for (EcalRecHitCollection::const_iterator eItr=ecalEE->begin(); eItr!=ecalEE->end(); eItr++) {
162  double phiD, R;
163  const GlobalPoint& pos = geo->getPosition(eItr->detid());
164  double phihit = pos.phi();
165  double etahit = pos.eta();
166  phiD=fabs(phihit-tit->phi());
167  if (phiD>M_PI) phiD=2*M_PI-phiD;
168  R=sqrt(pow(etahit-tit->eta(),2)+phiD*phiD);
169  if (R<OutConeSize_&&R>InConeSize_&&eItr->energy()>hitCountEthr_) {
170  nhitOut++;
171  }
172  if (R<InConeSize_&&eItr->energy()>hitCountEthr_) {
173  nhitIn++;
174  }
175  if (R<OutConeSize_&&R>InConeSize_&&eItr->energy()>hitEthr_) {
176  OutEnergy+=eItr->energy();
177  }
178  if (R<InConeSize_&&eItr->energy()>hitEthr_) {
179  InEnergy+=eItr->energy();
180  }
181 
182  }
183 // std::cout<<"create and push_back candidate"<<std::endl;
184  reco::IsolatedPixelTrackCandidate newca(l1extra::L1JetParticleRef(l1Taus,tit-l1Taus->begin()), InEnergy, OutEnergy, nhitIn, nhitOut);
185  iptcCollection->push_back(newca);
186  }
187 
188 
189 
190  //Use the ExampleData to create an ExampleData2 which
191  // is put into the Event
192 
193 // std::cout<<"put cand into event"<<std::endl;
194  iEvent.put(std::move(iptcCollection));
195 
196 }
197 // ------------ method called once each job just before starting event loop ------------
198 void
200 }
201 
202 // ------------ method called once each job just after ending the event loop ------------
203 void
205 }
206 
T getParameter(std::string const &) const
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
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
edm::EDGetTokenT< l1extra::L1JetParticleCollection > tok_l1tau_
int iEvent
Definition: GenABIO.cc:230
T sqrt(T t)
Definition: SSEVec.h:18
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:69
#define M_PI
const_iterator end() const
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_hlt_
const T & get() const
Definition: EventSetup.h:58
T eta() const
Definition: PV3DBase.h:76
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
T const * product() const
Definition: ESHandle.h:86
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
def move(src, dest)
Definition: eostools.py:510
const_iterator begin() const