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