CMS 3D CMS Logo

BitwisePFAlgo.cc
Go to the documentation of this file.
4 
5 //#define REG_HGCal
6 #include "ref/pfalgo2hgc_ref.h"
7 #include "ref/pfalgo3_ref.h"
10 
11 using namespace l1tpf_impl;
12 
13 BitwisePFAlgo::BitwisePFAlgo(const edm::ParameterSet &iConfig) : PFAlgoBase(iConfig), config_(nullptr) {
14  const edm::ParameterSet &bitwiseConfig = iConfig.getParameter<edm::ParameterSet>("bitwiseConfig");
15  const std::string &algo = iConfig.getParameter<std::string>("bitwiseAlgo");
16  debug_ = iConfig.getUntrackedParameter<int>("debugBitwisePFAlgo", iConfig.getUntrackedParameter<int>("debug", 0));
17  if (algo == "pfalgo3") {
19  config_ = std::make_shared<pfalgo3_config>(bitwiseConfig.getParameter<uint32_t>("NTRACK"),
20  bitwiseConfig.getParameter<uint32_t>("NEMCALO"),
21  bitwiseConfig.getParameter<uint32_t>("NCALO"),
22  bitwiseConfig.getParameter<uint32_t>("NMU"),
23  bitwiseConfig.getParameter<uint32_t>("NPHOTON"),
24  bitwiseConfig.getParameter<uint32_t>("NSELCALO"),
25  bitwiseConfig.getParameter<uint32_t>("NALLNEUTRAL"),
26  bitwiseConfig.getParameter<uint32_t>("DR2MAX_TK_MU"),
27  bitwiseConfig.getParameter<uint32_t>("DR2MAX_TK_EM"),
28  bitwiseConfig.getParameter<uint32_t>("DR2MAX_EM_CALO"),
29  bitwiseConfig.getParameter<uint32_t>("DR2MAX_TK_CALO"),
30  bitwiseConfig.getParameter<uint32_t>("TK_MAXINVPT_LOOSE"),
31  bitwiseConfig.getParameter<uint32_t>("TK_MAXINVPT_TIGHT"));
33  } else if (algo == "pfalgo2hgc") {
35  config_ = std::make_shared<pfalgo_config>(bitwiseConfig.getParameter<uint32_t>("NTRACK"),
36  bitwiseConfig.getParameter<uint32_t>("NCALO"),
37  bitwiseConfig.getParameter<uint32_t>("NMU"),
38  bitwiseConfig.getParameter<uint32_t>("NSELCALO"),
39  bitwiseConfig.getParameter<uint32_t>("DR2MAX_TK_MU"),
40  bitwiseConfig.getParameter<uint32_t>("DR2MAX_TK_CALO"),
41  bitwiseConfig.getParameter<uint32_t>("TK_MAXINVPT_LOOSE"),
42  bitwiseConfig.getParameter<uint32_t>("TK_MAXINVPT_TIGHT"));
44  } else {
45  throw cms::Exception("Configuration", "Unsupported bitwiseAlgo " + algo);
46  }
47 }
48 
50 
52  initRegion(r);
53 
54  std::unique_ptr<HadCaloObj[]> calo(new HadCaloObj[config_->nCALO]);
55  std::unique_ptr<TkObj[]> track(new TkObj[config_->nTRACK]);
56  std::unique_ptr<MuObj[]> mu(new MuObj[config_->nMU]);
57  std::unique_ptr<PFChargedObj[]> outch(new PFChargedObj[config_->nTRACK]);
58  std::unique_ptr<PFNeutralObj[]> outne(new PFNeutralObj[config_->nSELCALO]);
59  std::unique_ptr<PFChargedObj[]> outmu(new PFChargedObj[config_->nMU]);
60 
61  dpf2fw::convert(config_->nTRACK, r.track, track.get());
62  dpf2fw::convert(config_->nCALO, r.calo, calo.get());
63  dpf2fw::convert(config_->nMU, r.muon, mu.get());
64 
65  if (debug_) {
66  dbgPrintf(
67  "BitwisePF\nBitwisePF region eta [ %+5.2f , %+5.2f ], phi [ %+5.2f , %+5.2f ], fiducial eta [ %+5.2f , %+5.2f "
68  "], phi [ %+5.2f , %+5.2f ], algo = %d\n",
69  r.etaMin - r.etaExtra,
70  r.etaMax + r.etaExtra,
71  r.phiCenter - r.phiHalfWidth - r.phiExtra,
72  r.phiCenter + r.phiHalfWidth + r.phiExtra,
73  r.etaMin,
74  r.etaMax,
75  r.phiCenter - r.phiHalfWidth,
76  r.phiCenter + r.phiHalfWidth,
77  static_cast<int>(algo_));
78  dbgPrintf("BitwisePF \t N(track) %3lu N(em) %3lu N(calo) %3lu N(mu) %3lu\n",
79  r.track.size(),
80  r.emcalo.size(),
81  r.calo.size(),
82  r.muon.size());
83  for (int itk = 0, ntk = r.track.size(); itk < ntk; ++itk) {
84  const auto &tk = r.track[itk];
85  dbgPrintf(
86  "BitwisePF \t track %3d: pt %7.2f +- %5.2f vtx eta %+5.2f vtx phi %+5.2f calo eta %+5.2f calo phi %+5.2f "
87  " fid %1d calo ptErr %7.2f stubs %2d chi2 %7.1f\n",
88  itk,
89  tk.floatPt(),
90  tk.floatPtErr(),
91  tk.floatVtxEta(),
92  tk.floatVtxPhi(),
93  tk.floatEta(),
94  tk.floatPhi(),
95  int(r.fiducialLocal(tk.floatEta(), tk.floatPhi())),
96  tk.floatCaloPtErr(),
97  int(tk.hwStubs),
98  tk.hwChi2 * 0.1f);
99  }
100  for (int iem = 0, nem = r.emcalo.size(); iem < nem; ++iem) {
101  const auto &em = r.emcalo[iem];
102  dbgPrintf(
103  "BitwisePF \t EM %3d: pt %7.2f +- %5.2f vtx eta %+5.2f vtx phi %+5.2f calo eta %+5.2f calo phi %+5.2f "
104  " fid %1d calo ptErr %7.2f\n",
105  iem,
106  em.floatPt(),
107  em.floatPtErr(),
108  em.floatEta(),
109  em.floatPhi(),
110  em.floatEta(),
111  em.floatPhi(),
112  int(r.fiducialLocal(em.floatEta(), em.floatPhi())),
113  em.floatPtErr());
114  }
115  for (int ic = 0, nc = r.calo.size(); ic < nc; ++ic) {
116  auto &calo = r.calo[ic];
117  dbgPrintf(
118  "BitwisePF \t calo %3d: pt %7.2f +- %5.2f vtx eta %+5.2f vtx phi %+5.2f calo eta %+5.2f calo phi %+5.2f "
119  " fid %1d calo ptErr %7.2f em pt %7.2f \n",
120  ic,
121  calo.floatPt(),
122  calo.floatPtErr(),
123  calo.floatEta(),
124  calo.floatPhi(),
125  calo.floatEta(),
126  calo.floatPhi(),
127  int(r.fiducialLocal(calo.floatEta(), calo.floatPhi())),
128  calo.floatPtErr(),
129  calo.floatEmPt());
130  }
131  for (int im = 0, nm = r.muon.size(); im < nm; ++im) {
132  auto &mu = r.muon[im];
133  dbgPrintf(
134  "BitwisePF \t muon %3d: pt %7.2f vtx eta %+5.2f vtx phi %+5.2f calo eta %+5.2f calo phi %+5.2f "
135  " fid %1d \n",
136  im,
137  mu.floatPt(),
138  mu.floatEta(),
139  mu.floatPhi(),
140  mu.floatEta(),
141  mu.floatPhi(),
142  int(r.fiducialLocal(mu.floatEta(), mu.floatPhi())));
143  }
144  }
145  switch (algo_) {
146  case AlgoChoice::algo3: {
147  pfalgo3_config *config3 = static_cast<pfalgo3_config *>(config_.get());
148  std::unique_ptr<EmCaloObj[]> emcalo(new EmCaloObj[config3->nEMCALO]);
149  std::unique_ptr<PFNeutralObj[]> outpho(new PFNeutralObj[config3->nPHOTON]);
150 
151  dpf2fw::convert(config3->nEMCALO, r.emcalo, emcalo.get());
152  pfalgo3_ref(*config3,
153  emcalo.get(),
154  calo.get(),
155  track.get(),
156  mu.get(),
157  outch.get(),
158  outpho.get(),
159  outne.get(),
160  outmu.get());
161 
162  fw2dpf::convert(config3->nTRACK, outch.get(), r.track, r.pf); // FIXME works only with a 1-1 mapping
163  fw2dpf::convert(config3->nPHOTON, outpho.get(), r.pf);
164  fw2dpf::convert(config3->nSELCALO, outne.get(), r.pf);
165  } break;
166  case AlgoChoice::algo2hgc: {
167  pfalgo2hgc_ref(*config_, calo.get(), track.get(), mu.get(), outch.get(), outne.get(), outmu.get());
168  fw2dpf::convert(config_->nTRACK, outch.get(), r.track, r.pf); // FIXME works only with a 1-1 mapping
169  fw2dpf::convert(config_->nSELCALO, outne.get(), r.pf);
170  } break;
171  };
172 
173  if (debug_) {
174  dbgPrintf("BitwisePF \t Output N(ch) %3u/%3u N(nh) %3u/%3u N(ph) %3u/%u [all/fiducial]\n",
175  r.nOutput(l1tpf_impl::Region::charged_type, false, false),
176  r.nOutput(l1tpf_impl::Region::charged_type, false, true),
177  r.nOutput(l1tpf_impl::Region::neutral_hadron_type, false, false),
178  r.nOutput(l1tpf_impl::Region::neutral_hadron_type, false, true),
179  r.nOutput(l1tpf_impl::Region::photon_type, false, false),
180  r.nOutput(l1tpf_impl::Region::photon_type, false, true));
181  for (int ipf = 0, npf = r.pf.size(); ipf < npf; ++ipf) {
182  const auto &pf = r.pf[ipf];
183  dbgPrintf(
184  "BitwisePF \t pf %3d: pt %7.2f pid %d vtx eta %+5.2f vtx phi %+5.2f calo eta %+5.2f calo phi %+5.2f "
185  "fid %1d\n",
186  ipf,
187  pf.floatPt(),
188  int(pf.hwId),
189  pf.floatVtxEta(),
190  pf.floatVtxPhi(),
191  pf.floatEta(),
192  pf.floatPhi(),
193  int(r.fiducialLocal(pf.floatEta(), pf.floatPhi())));
194  }
195  }
196 }
pfalgo3_config
Definition: pfalgo3_ref.h:7
l1tpf_impl
Definition: BitwisePFAlgo.h:8
L1TowerCalibrationProducer_cfi.calo
calo
Definition: L1TowerCalibrationProducer_cfi.py:59
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
l1tpf_impl::BitwisePFAlgo::~BitwisePFAlgo
~BitwisePFAlgo() override
Definition: BitwisePFAlgo.cc:49
pfalgo3_ref_set_debug
void pfalgo3_ref_set_debug(int debug)
l1tpf_impl::BitwisePFAlgo::AlgoChoice::algo2hgc
fw2dpf::convert
void convert(const PFChargedObj &src, const l1tpf_impl::PropagatedTrack &track, std::vector< l1tpf_impl::PFParticle > &out)
Definition: Firmware2DiscretePF.h:13
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
l1tpf_impl::Region::photon_type
Definition: Region.h:56
DiscretePF2Firmware.h
pfalgo3_ref
void pfalgo3_ref(const pfalgo3_config &cfg, const EmCaloObj emcalo[], const HadCaloObj hadcalo[], const TkObj track[], const MuObj mu[], PFChargedObj outch[], PFNeutralObj outpho[], PFNeutralObj outne[], PFChargedObj outmu[])
cmsdt::algo
algo
Definition: constants.h:164
pfalgo2hgc_ref_set_debug
void pfalgo2hgc_ref_set_debug(int debug)
pfalgo3_config::nEMCALO
unsigned int nEMCALO
Definition: pfalgo3_ref.h:8
EmCaloObj
Definition: data.h:132
BitwisePFAlgo.h
l1tpf_impl::Region::neutral_hadron_type
Definition: Region.h:55
l1tpf_impl::BitwisePFAlgo::algo_
enum l1tpf_impl::BitwisePFAlgo::AlgoChoice algo_
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PFChargedObj
Definition: data.h:169
l1tpf_impl::Region
Definition: Region.h:8
edm::ParameterSet
Definition: ParameterSet.h:36
PFNeutralObj
Definition: data.h:183
TkObj
Definition: data.h:143
pfalgo_config::nSELCALO
unsigned int nSELCALO
Definition: pfalgo_common_ref.h:21
createfilelist.int
int
Definition: createfilelist.py:10
l1tpf_impl::Region::charged_type
Definition: Region.h:50
l1tpf_impl::PFAlgoBase::initRegion
void initRegion(Region &r) const
Definition: PFAlgoBase.cc:11
MuObj
Definition: data.h:158
pfalgo2hgc_ref.h
l1tpf_impl::BitwisePFAlgo::config_
std::shared_ptr< pfalgo_config > config_
Definition: BitwisePFAlgo.h:17
l1tpf_impl::PFAlgoBase
Definition: PFAlgoBase.h:11
alignCSCRings.r
r
Definition: alignCSCRings.py:93
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
l1tpf_impl::BitwisePFAlgo::BitwisePFAlgo
BitwisePFAlgo(const edm::ParameterSet &)
Definition: BitwisePFAlgo.cc:13
dbgPrintf
void dbgPrintf(const char *formatString, Args &&... args)
Definition: dbgPrintf.h:5
pfalgo3_ref.h
pfalgo_config::nTRACK
unsigned int nTRACK
Definition: pfalgo_common_ref.h:20
packedPFCandidateRefMixer_cfi.pf
pf
Definition: packedPFCandidateRefMixer_cfi.py:4
l1tpf_impl::PFAlgoBase::debug_
int debug_
Definition: PFAlgoBase.h:18
Exception
Definition: hltDiff.cc:246
dpf2fw::convert
void convert(const l1tpf_impl::PropagatedTrack &in, TkObj &out)
Definition: DiscretePF2Firmware.h:12
dbgPrintf.h
Exception.h
HadCaloObj
Definition: data.h:120
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
pfalgo2hgc_ref
void pfalgo2hgc_ref(const pfalgo_config &cfg, const HadCaloObj calo[], const TkObj track[], const MuObj mu[], PFChargedObj outch[], PFNeutralObj outne[], PFChargedObj outmu[])
l1tpf_impl::BitwisePFAlgo::runPF
void runPF(Region &r) const override
Definition: BitwisePFAlgo.cc:51
l1tpf_impl::BitwisePFAlgo::AlgoChoice::algo3
Firmware2DiscretePF.h
pfalgo3_config::nPHOTON
unsigned int nPHOTON
Definition: pfalgo3_ref.h:8