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 
38 
39 #include <cmath>
40 #include <cstdlib>
41 #include <memory>
42 #include <string>
43 #include <vector>
44 #include <map>
45 #include <utility>
46 
48 public:
50  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
51 
52 private:
53  void produce(edm::Event&, const edm::EventSetup&) override;
54  int eta2ieta(double eta) const;
55  int phi2iphi(double phi, int ieta) const;
56  double ieta2eta(int ieta) const;
57  double iphi2phi(int iphi, int ieta) const;
58  // ----------member data ---------------------------
59 
61  const bool useHF_;
62 
63  // tower edges from fast sim, used starting at index 30 for the HF
64  static constexpr int ietaMax = 42;
65 };
66 //
67 // constructors and destructor
68 //
70  : src_(consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("src"))),
71  useHF_(iConfig.getParameter<bool>("useHF")) {
72  produces<CaloTowerCollection>();
73 }
74 
75 //
76 // member functions
77 //
78 
79 // ------------ method called to produce the data ------------
81  using namespace edm;
82 
83  typedef std::pair<int, int> EtaPhi;
84  typedef std::map<EtaPhi, double> EtaPhiMap;
85  EtaPhiMap towers_;
86  towers_.clear();
87 
88  auto const& inputs = iEvent.get(src_);
89  for (auto const& particle : inputs) {
90  double eta = particle.eta();
91 
92  int ieta = eta2ieta(eta);
93  int iphi = phi2iphi(particle.phi(), ieta);
94 
95  if (!useHF_ && abs(ieta) > 29)
96  continue;
97 
98  EtaPhi ep(ieta, iphi);
99  towers_[ep] += particle.et();
100  }
101 
102  auto prod = std::make_unique<CaloTowerCollection>();
103  prod->reserve(towers_.size());
104  for (auto const& tower : towers_) {
105  EtaPhi ep = tower.first;
106  double et = tower.second;
107 
108  int ieta = ep.first;
109  int iphi = ep.second;
110 
111  CaloTowerDetId newTowerId(ieta, iphi); // totally dummy id
112 
113  // currently sets et = pt, mass to zero
114  // pt, eta, phi, mass
116  GlobalPoint point(p4.x(), p4.y(), p4.z());
117  prod->emplace_back(newTowerId, p4.e(), 0, 0, 0, 0, p4, point, point);
118  }
119 
120  iEvent.put(std::move(prod));
121 }
122 
123 // Taken from FastSimulation/CalorimeterProperties/src/HCALProperties.cc
124 // Note this returns an abs(ieta)
126  // binary search in the array of towers eta edges
127 
128  int ieta = 1;
129  double xeta = fabs(eta);
130  while (xeta > hi::etaedge[ieta] && ieta < ietaMax - 1) {
131  ++ieta;
132  }
133 
134  if (eta < 0)
135  ieta = -ieta;
136  return ieta;
137 }
138 
139 int ParticleTowerProducer::phi2iphi(double phi, int ieta) const {
141  int nphi = 72;
142  int n = 1;
143  if (abs(ieta) > 20)
144  n = 2;
145  if (abs(ieta) >= 40)
146  n = 4;
147 
148  int iphi = (int)std::ceil(phi / 2.0 / M_PI * nphi / n);
149 
150  iphi = n * (iphi - 1) + 1;
151 
152  return iphi;
153 }
154 
155 double ParticleTowerProducer::iphi2phi(int iphi, int ieta) const {
156  double phi = 0;
157  int nphi = 72;
158 
159  int n = 1;
160  if (abs(ieta) > 20)
161  n = 2;
162  if (abs(ieta) >= 40)
163  n = 4;
164 
165  int myphi = (iphi - 1) / n + 1;
166 
167  phi = 2. * M_PI * (myphi - 0.5) / nphi * n;
168  while (phi > M_PI)
169  phi -= 2. * M_PI;
170 
171  return phi;
172 }
173 
175  int sign = 1;
176  if (ieta < 0) {
177  sign = -1;
178  ieta = -ieta;
179  }
180 
181  double eta = sign * (hi::etaedge[ieta] + hi::etaedge[ieta - 1]) / 2.;
182  return eta;
183 }
184 
186  // particleTowerProducer
188  desc.add<edm::InputTag>("src", edm::InputTag("particleFlow"));
189  desc.add<bool>("useHF", true);
190  descriptions.add("particleTowerProducer", desc);
191 }
192 
193 // define this as a plug-in
ConfigurationDescriptions.h
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
ESHandle.h
ParticleTowerProducer::eta2ieta
int eta2ieta(double eta) const
Definition: ParticleTowerProducer.cc:125
PFCandidate.h
ParticleTowerProducer
Definition: ParticleTowerProducer.cc:47
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:155
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
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:185
ParticleTowerProducer::ietaMax
static constexpr int ietaMax
Definition: ParticleTowerProducer.cc:64
EDProducer.h
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
ParticleTowerProducer::src_
edm::EDGetTokenT< reco::PFCandidateCollection > src_
Definition: ParticleTowerProducer.cc:60
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:70
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:80
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:61
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
ParticleTowerProducer::ieta2eta
double ieta2eta(int ieta) const
Definition: ParticleTowerProducer.cc:174
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:36
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
CaloTowerDetId.h
edm::EventSetup
Definition: EventSetup.h:58
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:139
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:69
CaloTowerDetId
Definition: CaloTowerDetId.h:12