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