CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
ParticleTowerProducer< T > Class Template Reference

#include <RecoHI/HiJetAlgos/plugins/ParticleTowerProducer.cc>

Inheritance diagram for ParticleTowerProducer< T >:
edm::stream::EDProducer<>

Public Member Functions

 ParticleTowerProducer (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

int eta2ieta (double eta) const
 
double ieta2eta (int ieta) const
 
double iphi2phi (int iphi, int ieta) const
 
int phi2iphi (double phi, int ieta) const
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::EDGetTokenT< typename
edm::View< T > > 
src_
 
const bool useHF_
 

Static Private Attributes

static constexpr int ietaMax = 42
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

template<class T>
class ParticleTowerProducer< T >

Description: [one line class summary] Implementation: [Notes on implementation]

Definition at line 49 of file ParticleTowerProducer.cc.

Constructor & Destructor Documentation

template<class T >
ParticleTowerProducer< T >::ParticleTowerProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 72 of file ParticleTowerProducer.cc.

73  : src_(consumes<typename edm::View<T> >(iConfig.getParameter<edm::InputTag>("src"))),
74  useHF_(iConfig.getParameter<bool>("useHF")) {
75  produces<CaloTowerCollection>();
76 }
edm::EDGetTokenT< typename edm::View< T > > src_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303

Member Function Documentation

template<class T >
int ParticleTowerProducer< T >::eta2ieta ( double  eta) const
private

Definition at line 130 of file ParticleTowerProducer.cc.

References hi::etaedge.

130  {
131  // binary search in the array of towers eta edges
132 
133  int ieta = 1;
134  double xeta = fabs(eta);
135  while (xeta > hi::etaedge[ieta] && ieta < ietaMax - 1) {
136  ++ieta;
137  }
138 
139  if (eta < 0)
140  ieta = -ieta;
141  return ieta;
142 }
static constexpr int ietaMax
constexpr std::array< double, 42 > etaedge
Definition: HITowerHelper.h:5
template<class T >
void ParticleTowerProducer< T >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 194 of file ParticleTowerProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, and HLT_FULL_cff::InputTag.

194  {
196  desc.add<bool>("useHF", true);
197  if (typeid(T) == typeid(reco::PFCandidate)) {
198  desc.add<edm::InputTag>("src", edm::InputTag("particleFlow"));
199  descriptions.add("PFTowers", desc);
200  }
201  if (typeid(T) == typeid(pat::PackedCandidate)) {
202  desc.add<edm::InputTag>("src", edm::InputTag("packedPFCandidates"));
203  descriptions.add("PackedPFTowers", desc);
204  }
205 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
long double T
template<class T >
double ParticleTowerProducer< T >::ieta2eta ( int  ieta) const
private

Definition at line 182 of file ParticleTowerProducer.cc.

References PVValHelper::eta, hi::etaedge, and jetcorrextractor::sign().

182  {
183  int sign = 1;
184  if (ieta < 0) {
185  sign = -1;
186  ieta = -ieta;
187  }
188 
189  double eta = sign * (hi::etaedge[ieta] + hi::etaedge[ieta - 1]) / 2.;
190  return eta;
191 }
double sign(double x)
constexpr std::array< double, 42 > etaedge
Definition: HITowerHelper.h:5
template<class T >
double ParticleTowerProducer< T >::iphi2phi ( int  iphi,
int  ieta 
) const
private

Definition at line 162 of file ParticleTowerProducer.cc.

References funct::abs(), M_PI, dqmiodumpmetadata::n, nphi, and PVValHelper::phi.

162  {
163  double phi = 0;
164  int nphi = 72;
165 
166  int n = 1;
167  if (abs(ieta) > 20)
168  n = 2;
169  if (abs(ieta) >= 40)
170  n = 4;
171 
172  int myphi = (iphi - 1) / n + 1;
173 
174  phi = 2. * M_PI * (myphi - 0.5) / nphi * n;
175  while (phi > M_PI)
176  phi -= 2. * M_PI;
177 
178  return phi;
179 }
const int nphi
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define M_PI
template<class T >
int ParticleTowerProducer< T >::phi2iphi ( double  phi,
int  ieta 
) const
private

Definition at line 145 of file ParticleTowerProducer.cc.

References funct::abs(), reco::ceil(), M_PI, angle0to2pi::make0To2pi(), dqmiodumpmetadata::n, and nphi.

145  {
147  int nphi = 72;
148  int n = 1;
149  if (abs(ieta) > 20)
150  n = 2;
151  if (abs(ieta) >= 40)
152  n = 4;
153 
154  int iphi = (int)std::ceil(phi / 2.0 / M_PI * nphi / n);
155 
156  iphi = n * (iphi - 1) + 1;
157 
158  return iphi;
159 }
const int nphi
constexpr int32_t ceil(float num)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define M_PI
constexpr valType make0To2pi(valType angle)
Definition: deltaPhi.h:67
template<class T >
void ParticleTowerProducer< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 84 of file ParticleTowerProducer.cc.

References funct::abs(), PVValHelper::eta, edm::Event::get(), PixelMapPlotter::inputs, eostools::move(), point, edm::Event::put(), and hgcalTowerProducer_cfi::tower.

84  {
85  using namespace edm;
86 
87  typedef std::pair<int, int> EtaPhi;
88  typedef std::map<EtaPhi, double> EtaPhiMap;
89  EtaPhiMap towers_;
90  towers_.clear();
91 
92  auto const& inputs = iEvent.get(src_);
93  for (auto const& particle : inputs) {
94  double eta = particle.eta();
95 
96  int ieta = eta2ieta(eta);
97  int iphi = phi2iphi(particle.phi(), ieta);
98 
99  if (!useHF_ && abs(ieta) > 29)
100  continue;
101 
102  EtaPhi ep(ieta, iphi);
103  towers_[ep] += particle.et();
104  }
105 
106  auto prod = std::make_unique<CaloTowerCollection>();
107  prod->reserve(towers_.size());
108  for (auto const& tower : towers_) {
109  EtaPhi ep = tower.first;
110  double et = tower.second;
111 
112  int ieta = ep.first;
113  int iphi = ep.second;
114 
115  CaloTowerDetId newTowerId(ieta, iphi); // totally dummy id
116 
117  // currently sets et = pt, mass to zero
118  // pt, eta, phi, mass
119  reco::Particle::PolarLorentzVector p4(et, ieta2eta(ieta), iphi2phi(iphi, ieta), 0.);
120  GlobalPoint point(p4.x(), p4.y(), p4.z());
121  prod->emplace_back(newTowerId, p4.e(), 0, 0, 0, 0, p4, point, point);
122  }
123 
124  iEvent.put(std::move(prod));
125 }
int eta2ieta(double eta) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
double iphi2phi(int iphi, int ieta) const
int phi2iphi(double phi, int ieta) const
double ieta2eta(int ieta) const
edm::EDGetTokenT< typename edm::View< T > > src_
def move
Definition: eostools.py:511
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Particle.h:23
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5

Member Data Documentation

template<class T >
constexpr int ParticleTowerProducer< T >::ietaMax = 42
staticprivate

Definition at line 66 of file ParticleTowerProducer.cc.

template<class T >
edm::EDGetTokenT<typename edm::View<T> > ParticleTowerProducer< T >::src_
private

Definition at line 62 of file ParticleTowerProducer.cc.

template<class T >
const bool ParticleTowerProducer< T >::useHF_
private

Definition at line 63 of file ParticleTowerProducer.cc.