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 // system include files
20 #include <cmath>
21 #include <memory>
22 
23 // user include files
24 
26 
32 
34 
36  InConeSize_ = conf.getParameter<double>("EcalInnerConeSize");
37  OutConeSize_ = conf.getParameter<double>("EcalOuterConeSize");
38  hitCountEthr_ = conf.getParameter<double>("ECHitCountEnergyThreshold");
39  hitEthr_ = conf.getParameter<double>("ECHitEnergyThreshold");
40  tok_l1tau_ = consumes<l1extra::L1JetParticleCollection>(conf.getParameter<edm::InputTag>("L1eTauJetsSource"));
41  tok_hlt_ = consumes<trigger::TriggerFilterObjectWithRefs>(conf.getParameter<edm::InputTag>("L1GTSeedLabel"));
42  tok_EB_ = consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("EBrecHitCollectionLabel"));
43  tok_EE_ = consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("EErecHitCollectionLabel"));
44 
45  //register your products
46  produces<reco::IsolatedPixelTrackCandidateCollection>();
47 }
48 
50  // do anything here that needs to be done at desctruction time
51  // (e.g. close files, deallocate resources etc.)
52 }
53 
54 //
55 // member functions
56 //
57 
58 // ------------ method called to produce the data ------------
61  const edm::EventSetup& iSetup) const {
62  // std::cout<<"get tau"<<std::endl;
63 
65  iEvent.getByToken(tok_l1tau_, l1Taus);
66 
67  // std::cout<<"get geom"<<std::endl;
68 
70  iSetup.get<CaloGeometryRecord>().get(pG);
71  const CaloGeometry* geo = pG.product();
72 
73  // std::cout<<" get ec rechit"<<std::endl;
74 
76  iEvent.getByToken(tok_EB_, ecalEB);
77 
79  iEvent.getByToken(tok_EE_, ecalEE);
80 
81  // std::cout<<"get l1 trig obj"<<std::endl;
82 
84  iEvent.getByToken(tok_hlt_, l1trigobj);
85 
86  std::vector<edm::Ref<l1t::TauBxCollection> > l1tauobjref;
87  std::vector<edm::Ref<l1t::JetBxCollection> > l1jetobjref;
88 
89  l1trigobj->getObjects(trigger::TriggerL1Tau, l1tauobjref);
90  l1trigobj->getObjects(trigger::TriggerL1Jet, l1jetobjref);
91 
92  double ptTriggered = -10;
93  double etaTriggered = -100;
94  double phiTriggered = -100;
95 
96  // std::cout<<"find highest pT triggered obj"<<std::endl;
97 
98  for (unsigned int p = 0; p < l1tauobjref.size(); p++) {
99  if (l1tauobjref[p]->pt() > ptTriggered) {
100  ptTriggered = l1tauobjref[p]->pt();
101  phiTriggered = l1tauobjref[p]->phi();
102  etaTriggered = l1tauobjref[p]->eta();
103  }
104  }
105  for (unsigned int p = 0; p < l1jetobjref.size(); p++) {
106  if (l1jetobjref[p]->pt() > ptTriggered) {
107  ptTriggered = l1jetobjref[p]->pt();
108  phiTriggered = l1jetobjref[p]->phi();
109  etaTriggered = l1jetobjref[p]->eta();
110  }
111  }
112 
113  auto iptcCollection = std::make_unique<reco::IsolatedPixelTrackCandidateCollection>();
114 
115  // std::cout<<"loop over l1taus"<<std::endl;
116 
117  for (l1extra::L1JetParticleCollection::const_iterator tit = l1Taus->begin(); tit != l1Taus->end(); tit++) {
118  double dphi = fabs(tit->phi() - phiTriggered);
119  if (dphi > M_PI)
120  dphi = 2 * M_PI - dphi;
121  double Rseed = sqrt(pow(etaTriggered - tit->eta(), 2) + dphi * dphi);
122  if (Rseed < 1.2)
123  continue;
124  int nhitOut = 0;
125  int nhitIn = 0;
126  double OutEnergy = 0;
127  double InEnergy = 0;
128  // std::cout<<" loops over rechits"<<std::endl;
129  for (EcalRecHitCollection::const_iterator eItr = ecalEB->begin(); eItr != ecalEB->end(); eItr++) {
130  double phiD, R;
131  const GlobalPoint& pos = geo->getPosition(eItr->detid());
132  double phihit = pos.phi();
133  double etahit = pos.eta();
134  phiD = fabs(phihit - tit->phi());
135  if (phiD > M_PI)
136  phiD = 2 * M_PI - phiD;
137  R = sqrt(pow(etahit - tit->eta(), 2) + phiD * phiD);
138 
139  if (R < OutConeSize_ && R > InConeSize_ && eItr->energy() > hitCountEthr_) {
140  nhitOut++;
141  }
142  if (R < InConeSize_ && eItr->energy() > hitCountEthr_) {
143  nhitIn++;
144  }
145 
146  if (R < OutConeSize_ && R > InConeSize_ && eItr->energy() > hitEthr_) {
147  OutEnergy += eItr->energy();
148  }
149  if (R < InConeSize_ && eItr->energy() > hitEthr_) {
150  InEnergy += eItr->energy();
151  }
152  }
153 
154  for (EcalRecHitCollection::const_iterator eItr = ecalEE->begin(); eItr != ecalEE->end(); eItr++) {
155  double phiD, R;
156  const GlobalPoint& pos = geo->getPosition(eItr->detid());
157  double phihit = pos.phi();
158  double etahit = pos.eta();
159  phiD = fabs(phihit - tit->phi());
160  if (phiD > M_PI)
161  phiD = 2 * M_PI - phiD;
162  R = sqrt(pow(etahit - tit->eta(), 2) + phiD * phiD);
163  if (R < OutConeSize_ && R > InConeSize_ && eItr->energy() > hitCountEthr_) {
164  nhitOut++;
165  }
166  if (R < InConeSize_ && eItr->energy() > hitCountEthr_) {
167  nhitIn++;
168  }
169  if (R < OutConeSize_ && R > InConeSize_ && eItr->energy() > hitEthr_) {
170  OutEnergy += eItr->energy();
171  }
172  if (R < InConeSize_ && eItr->energy() > hitEthr_) {
173  InEnergy += eItr->energy();
174  }
175  }
176  // std::cout<<"create and push_back candidate"<<std::endl;
178  l1extra::L1JetParticleRef(l1Taus, tit - l1Taus->begin()), InEnergy, OutEnergy, nhitIn, nhitOut);
179  iptcCollection->push_back(newca);
180  }
181 
182  //Use the ExampleData to create an ExampleData2 which
183  // is put into the Event
184 
185  // std::cout<<"put cand into event"<<std::endl;
186  iEvent.put(std::move(iptcCollection));
187 }
188 // ------------ method called once each job just before starting event loop ------------
190 
191 // ------------ method called once each job just after ending the event loop ------------
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
edm::StreamID
Definition: StreamID.h:30
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
EcalIsolatedParticleCandidateProducer::tok_EB_
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
Definition: EcalIsolatedParticleCandidateProducer.h:36
CaloGeometry::getPosition
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
EcalIsolatedParticleCandidateProducer::hitEthr_
double hitEthr_
Definition: EcalIsolatedParticleCandidateProducer.h:32
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
pos
Definition: PixelAliasList.h:18
EcalBarrelTopology.h
reco::IsolatedPixelTrackCandidate
Definition: IsolatedPixelTrackCandidate.h:23
edm::Handle
Definition: AssociativeIterator.h:50
EcalIsolatedParticleCandidateProducer::beginJob
void beginJob() override
Definition: EcalIsolatedParticleCandidateProducer.cc:189
trigger::TriggerRefsCollections::getObjects
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
Definition: TriggerRefsCollections.h:593
edm::Ref< L1JetParticleCollection >
EcalIsolatedParticleCandidateProducer::hitCountEthr_
double hitCountEthr_
Definition: EcalIsolatedParticleCandidateProducer.h:31
CaloGeometry
Definition: CaloGeometry.h:21
EcalIsolatedParticleCandidateProducer::endJob
void endJob() override
Definition: EcalIsolatedParticleCandidateProducer.cc:192
EcalIsolatedParticleCandidateProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: EcalIsolatedParticleCandidateProducer.cc:59
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
EcalIsolatedParticleCandidateProducer::tok_EE_
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
Definition: EcalIsolatedParticleCandidateProducer.h:37
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::ESHandle< CaloGeometry >
EcalIsolatedParticleCandidateProducer::tok_hlt_
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_hlt_
Definition: EcalIsolatedParticleCandidateProducer.h:35
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
Point3DBase< float, GlobalTag >
EcalIsolatedParticleCandidateProducer::~EcalIsolatedParticleCandidateProducer
~EcalIsolatedParticleCandidateProducer() override
Definition: EcalIsolatedParticleCandidateProducer.cc:49
CaloGeometryRecord.h
edm::ParameterSet
Definition: ParameterSet.h:36
trigger::TriggerL1Tau
Definition: TriggerTypeDefs.h:49
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
EcalIsolatedParticleCandidateProducer.h
EcalIsolatedParticleCandidateProducer::InConeSize_
double InConeSize_
Definition: EcalIsolatedParticleCandidateProducer.h:29
iEvent
int iEvent
Definition: GenABIO.cc:224
trigger::TriggerL1Jet
Definition: TriggerTypeDefs.h:48
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
Ref.h
DetId.h
CaloGeometry.h
EventSetup.h
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
EcalIsolatedParticleCandidateProducer::tok_l1tau_
edm::EDGetTokenT< l1extra::L1JetParticleCollection > tok_l1tau_
Definition: EcalIsolatedParticleCandidateProducer.h:34
edm::Event
Definition: Event.h:73
EcalIsolatedParticleCandidateProducer::OutConeSize_
double OutConeSize_
Definition: EcalIsolatedParticleCandidateProducer.h:30
dttmaxenums::R
Definition: DTTMax.h:29
edm::InputTag
Definition: InputTag.h:15
EcalIsolatedParticleCandidateProducer::EcalIsolatedParticleCandidateProducer
EcalIsolatedParticleCandidateProducer(const edm::ParameterSet &)
Definition: EcalIsolatedParticleCandidateProducer.cc:35