CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 <memory>
22 
23 // user include files
24 
26 
27 
32 
33 
35 
36 
37 
38 
40 {
41  InConeSize_ = conf.getParameter<double>("EcalInnerConeSize");
42  OutConeSize_= conf.getParameter<double>("EcalOuterConeSize");
43  hitCountEthr_= conf.getParameter<double>("ECHitCountEnergyThreshold");
44  hitEthr_=conf.getParameter<double>("ECHitEnergyThreshold");
45  tok_l1tau_ = consumes<l1extra::L1JetParticleCollection>(conf.getParameter<edm::InputTag>("L1eTauJetsSource"));
46  tok_hlt_ = consumes<trigger::TriggerFilterObjectWithRefs>(conf.getParameter<edm::InputTag>("L1GTSeedLabel"));
47  tok_EB_ = consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("EBrecHitCollectionLabel"));
48  tok_EE_ = consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("EErecHitCollectionLabel"));
49 
50  //register your products
51  produces< reco::IsolatedPixelTrackCandidateCollection >();
52 
53 }
54 
55 
57 {
58 
59  // do anything here that needs to be done at desctruction time
60  // (e.g. close files, deallocate resources etc.)
61 
62 }
63 
64 
65 //
66 // member functions
67 //
68 
69 // ------------ method called to produce the data ------------
70 void
72 {
73 
74  using namespace edm;
75 
76 // std::cout<<"get tau"<<std::endl;
77 
79  iEvent.getByToken(tok_l1tau_,l1Taus);
80 
81 // std::cout<<"get geom"<<std::endl;
82 
84  iSetup.get<CaloGeometryRecord>().get(pG);
85  geo = pG.product();
86 
87 // std::cout<<" get ec rechit"<<std::endl;
88 
90  iEvent.getByToken(tok_EB_,ecalEB);
91 
93  iEvent.getByToken(tok_EE_,ecalEE);
94 
95 // std::cout<<"get l1 trig obj"<<std::endl;
96 
98  iEvent.getByToken(tok_hlt_, l1trigobj);
99 
100  std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1tauobjref;
101  std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1jetobjref;
102 
103  l1trigobj->getObjects(trigger::TriggerL1TauJet, l1tauobjref);
104  l1trigobj->getObjects(trigger::TriggerL1CenJet, l1jetobjref);
105 
106  double ptTriggered=-10;
107  double etaTriggered=-100;
108  double phiTriggered=-100;
109 
110 // std::cout<<"find highest pT triggered obj"<<std::endl;
111 
112  for (unsigned int p=0; p<l1tauobjref.size(); p++)
113  {
114  if (l1tauobjref[p]->pt()>ptTriggered)
115  {
116  ptTriggered=l1tauobjref[p]->pt();
117  phiTriggered=l1tauobjref[p]->phi();
118  etaTriggered=l1tauobjref[p]->eta();
119  }
120  }
121  for (unsigned int p=0; p<l1jetobjref.size(); p++)
122  {
123  if (l1jetobjref[p]->pt()>ptTriggered)
124  {
125  ptTriggered=l1jetobjref[p]->pt();
126  phiTriggered=l1jetobjref[p]->phi();
127  etaTriggered=l1jetobjref[p]->eta();
128  }
129  }
130 
132 
133 // std::cout<<"loop over l1taus"<<std::endl;
134 
135  for (l1extra::L1JetParticleCollection::const_iterator tit=l1Taus->begin(); tit!=l1Taus->end(); tit++)
136  {
137  double dphi=fabs(tit->phi()-phiTriggered);
138  if (dphi>3.1415926535) dphi=2*3.1415926535-dphi;
139  double Rseed=sqrt(pow(etaTriggered-tit->eta(),2)+dphi*dphi);
140  if (Rseed<1.2) continue;
141  int nhitOut=0;
142  int nhitIn=0;
143  double OutEnergy=0;
144  double InEnergy=0;
145 // std::cout<<" loops over rechits"<<std::endl;
146  for (EcalRecHitCollection::const_iterator eItr=ecalEB->begin(); eItr!=ecalEB->end(); eItr++)
147  {
148  double phiD, R;
149  GlobalPoint pos = geo->getPosition(eItr->detid());
150  double phihit = pos.phi();
151  double etahit = pos.eta();
152  phiD=fabs(phihit-tit->phi());
153  if (phiD>3.1415926535) phiD=2*3.1415926535-phiD;
154  R=sqrt(pow(etahit-tit->eta(),2)+phiD*phiD);
155 
156  if (R<OutConeSize_&&R>InConeSize_&&eItr->energy()>hitCountEthr_)
157  {
158  nhitOut++;
159  }
160  if (R<InConeSize_&&eItr->energy()>hitCountEthr_)
161  {
162  nhitIn++;
163  }
164 
165  if (R<OutConeSize_&&R>InConeSize_&&eItr->energy()>hitEthr_)
166  {
167  OutEnergy+=eItr->energy();
168  }
169  if (R<InConeSize_&&eItr->energy()>hitEthr_)
170  {
171  InEnergy+=eItr->energy();
172  }
173 
174  }
175 
176  for (EcalRecHitCollection::const_iterator eItr=ecalEE->begin(); eItr!=ecalEE->end(); eItr++)
177  {
178  double phiD, R;
179  GlobalPoint pos = geo->getPosition(eItr->detid());
180  double phihit = pos.phi();
181  double etahit = pos.eta();
182  phiD=fabs(phihit-tit->phi());
183  if (phiD>3.1415926535) phiD=2*3.1415926535-phiD;
184  R=sqrt(pow(etahit-tit->eta(),2)+phiD*phiD);
185  if (R<OutConeSize_&&R>InConeSize_&&eItr->energy()>hitCountEthr_)
186  {
187  nhitOut++;
188  }
189  if (R<InConeSize_&&eItr->energy()>hitCountEthr_)
190  {
191  nhitIn++;
192  }
193  if (R<OutConeSize_&&R>InConeSize_&&eItr->energy()>hitEthr_)
194  {
195  OutEnergy+=eItr->energy();
196  }
197  if (R<InConeSize_&&eItr->energy()>hitEthr_)
198  {
199  InEnergy+=eItr->energy();
200  }
201 
202  }
203 // std::cout<<"create and push_back candidate"<<std::endl;
204  reco::IsolatedPixelTrackCandidate newca(l1extra::L1JetParticleRef(l1Taus,tit-l1Taus->begin()), InEnergy, OutEnergy, nhitIn, nhitOut);
205  iptcCollection->push_back(newca);
206  }
207 
208 
209 
210  //Use the ExampleData to create an ExampleData2 which
211  // is put into the Event
212 
213 // std::cout<<"put cand into event"<<std::endl;
214  std::auto_ptr<reco::IsolatedPixelTrackCandidateCollection> pOut(iptcCollection);
215  iEvent.put(pOut);
216 
217 }
218 // ------------ method called once each job just before starting event loop ------------
219 void
221 }
222 
223 // ------------ method called once each job just after ending the event loop ------------
224 void
226 }
227 
T getParameter(std::string const &) const
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
virtual void produce(edm::Event &, const edm::EventSetup &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
T sqrt(T t)
Definition: SSEVec.h:48
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
tuple conf
Definition: dbtoconf.py:185
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_hlt_
const T & get() const
Definition: EventSetup.h:55
T eta() const
Definition: PV3DBase.h:76
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40