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