CMS 3D CMS Logo

ParticleTowerProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: RecoHI/HiJetAlgos
4 // Class: ParticleTowerProducer
5 //
11 //
12 // Original Author: Yetkin Yilmaz,32 4-A08,+41227673039,
13 // Created: Thu Jan 20 19:53:58 CET 2011
14 //
15 //
16 
39 
40 #include <cmath>
41 #include <cstdlib>
42 #include <memory>
43 #include <string>
44 #include <vector>
45 #include <map>
46 #include <utility>
47 
49 public:
51  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
52 
53 private:
54  void produce(edm::Event&, const edm::EventSetup&) override;
55  int eta2ieta(double eta) const;
56  int phi2iphi(double phi, int ieta) const;
57  double ieta2eta(int ieta) const;
58  double iphi2phi(int iphi, int ieta) const;
59  // ----------member data ---------------------------
60 
62  const bool useHF_;
63 
64  // tower edges from fast sim, used starting at index 30 for the HF
65  static constexpr int ietaMax = 42;
66 };
67 //
68 // constructors and destructor
69 //
71  : src_(consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("src"))),
72  useHF_(iConfig.getParameter<bool>("useHF")) {
73  produces<CaloTowerCollection>();
74 }
75 
76 //
77 // member functions
78 //
79 
80 // ------------ method called to produce the data ------------
82  using namespace edm;
83 
84  typedef std::pair<int, int> EtaPhi;
85  typedef std::map<EtaPhi, double> EtaPhiMap;
86  EtaPhiMap towers_;
87  towers_.clear();
88 
89  auto const& inputs = iEvent.get(src_);
90  for (auto const& particle : inputs) {
91  double eta = particle.eta();
92 
93  int ieta = eta2ieta(eta);
94  int iphi = phi2iphi(particle.phi(), ieta);
95 
96  if (!useHF_ && abs(ieta) > 29)
97  continue;
98 
99  EtaPhi ep(ieta, iphi);
100  towers_[ep] += particle.et();
101  }
102 
103  auto prod = std::make_unique<CaloTowerCollection>();
104  prod->reserve(towers_.size());
105  for (auto const& tower : towers_) {
106  EtaPhi ep = tower.first;
107  double et = tower.second;
108 
109  int ieta = ep.first;
110  int iphi = ep.second;
111 
112  CaloTowerDetId newTowerId(ieta, iphi); // totally dummy id
113 
114  // currently sets et = pt, mass to zero
115  // pt, eta, phi, mass
117  GlobalPoint point(p4.x(), p4.y(), p4.z());
118  prod->emplace_back(newTowerId, p4.e(), 0, 0, 0, 0, p4, point, point);
119  }
120 
121  iEvent.put(std::move(prod));
122 }
123 
124 // Taken from FastSimulation/CalorimeterProperties/src/HCALProperties.cc
125 // Note this returns an abs(ieta)
127  // binary search in the array of towers eta edges
128 
129  int ieta = 1;
130  double xeta = fabs(eta);
131  while (xeta > hi::etaedge[ieta] && ieta < ietaMax - 1) {
132  ++ieta;
133  }
134 
135  if (eta < 0)
136  ieta = -ieta;
137  return ieta;
138 }
139 
140 int ParticleTowerProducer::phi2iphi(double phi, int ieta) const {
142  int nphi = 72;
143  int n = 1;
144  if (abs(ieta) > 20)
145  n = 2;
146  if (abs(ieta) >= 40)
147  n = 4;
148 
149  int iphi = (int)std::ceil(phi / 2.0 / M_PI * nphi / n);
150 
151  iphi = n * (iphi - 1) + 1;
152 
153  return iphi;
154 }
155 
156 double ParticleTowerProducer::iphi2phi(int iphi, int ieta) const {
157  double phi = 0;
158  int nphi = 72;
159 
160  int n = 1;
161  if (abs(ieta) > 20)
162  n = 2;
163  if (abs(ieta) >= 40)
164  n = 4;
165 
166  int myphi = (iphi - 1) / n + 1;
167 
168  phi = 2. * M_PI * (myphi - 0.5) / nphi * n;
169  while (phi > M_PI)
170  phi -= 2. * M_PI;
171 
172  return phi;
173 }
174 
176  int sign = 1;
177  if (ieta < 0) {
178  sign = -1;
179  ieta = -ieta;
180  }
181 
182  double eta = sign * (hi::etaedge[ieta] + hi::etaedge[ieta - 1]) / 2.;
183  return eta;
184 }
185 
187  // particleTowerProducer
189  desc.add<edm::InputTag>("src", edm::InputTag("particleFlow"));
190  desc.add<bool>("useHF", true);
191  descriptions.add("particleTowerProducer", desc);
192 }
193 
194 // define this as a plug-in
ConfigurationDescriptions.h
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:393
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
ESHandle.h
ParticleTowerProducer::eta2ieta
int eta2ieta(double eta) const
Definition: ParticleTowerProducer.cc:126
PFCandidate.h
ParticleTowerProducer
Definition: ParticleTowerProducer.cc:48
deltaPhi.h
edm::EDGetTokenT< reco::PFCandidateCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
ParticleTowerProducer::iphi2phi
double iphi2phi(int iphi, int ieta) const
Definition: ParticleTowerProducer.cc:156
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
hgcalTowerProducer_cfi.tower
tower
Definition: hgcalTowerProducer_cfi.py:4
ParticleTowerProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: ParticleTowerProducer.cc:186
ParticleTowerProducer::ietaMax
static constexpr int ietaMax
Definition: ParticleTowerProducer.cc:65
EDProducer.h
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
WorkerMaker.h
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
ParticleTowerProducer::src_
edm::EDGetTokenT< reco::PFCandidateCollection > src_
Definition: ParticleTowerProducer.cc:61
nphi
const int nphi
Definition: CMTRawAnalyzer.h:424
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
PVValHelper::eta
Definition: PVValidationHelpers.h:69
hi::etaedge
constexpr std::array< double, 42 > etaedge
Definition: HITowerHelper.h:5
ParticleTowerProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: ParticleTowerProducer.cc:81
dumpMFGeometry_cfg.prod
prod
Definition: dumpMFGeometry_cfg.py:24
CaloTowerDefs.h
Particle.h
reco::Particle::PolarLorentzVector
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Particle.h:23
Point3DBase< float, GlobalTag >
ParameterSetDescription.h
EDGetToken.h
ParticleTowerProducer::useHF_
const bool useHF_
Definition: ParticleTowerProducer.cc:62
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
ParticleTowerProducer::ieta2eta
double ieta2eta(int ieta) const
Definition: ParticleTowerProducer.cc:175
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
p4
double p4[4]
Definition: TauolaWrapper.h:92
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
PixelMapPlotter.inputs
inputs
Definition: PixelMapPlotter.py:490
edm::stream::EDProducer
Definition: EDProducer.h:38
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
CaloTowerDetId.h
edm::EventSetup
Definition: EventSetup.h:57
l1t::PFCandidateCollection
std::vector< l1t::PFCandidate > PFCandidateCollection
Definition: PFCandidate.h:57
angle0to2pi::make0To2pi
constexpr valType make0To2pi(valType angle)
Definition: deltaPhi.h:67
DDAxes::phi
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
DetId.h
SortedCollection.h
EventSetup.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
ParameterSetDescriptionFiller.h
HITowerHelper.h
ParticleTowerProducer::phi2iphi
int phi2iphi(double phi, int ieta) const
Definition: ParticleTowerProducer.cc:140
point
*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
edm::Event
Definition: Event.h:73
GlobalPoint.h
SiStripBadComponentsDQMServiceTemplate_cfg.ep
ep
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:86
edm::InputTag
Definition: InputTag.h:15
PFCandidateFwd.h
ParticleTowerProducer::ParticleTowerProducer
ParticleTowerProducer(const edm::ParameterSet &)
Definition: ParticleTowerProducer.cc:70
CaloTowerDetId
Definition: CaloTowerDetId.h:12