CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
L1TCorrelatorLayer1Producer Class Reference
Inheritance diagram for L1TCorrelatorLayer1Producer:
edm::stream::EDProducer<>

Public Member Functions

 L1TCorrelatorLayer1Producer (const edm::ParameterSet &)
 
 ~L1TCorrelatorLayer1Producer () override
 
- 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
 

Private Types

enum  InputType { caloType = 0, emcaloType = 1, trackType = 2, l1muType = 3 }
 
typedef l1ct::OutputRegion::ObjType OutputType
 

Private Member Functions

void addDecodedEmCalo (l1ct::DetectorSector< l1ct::EmCaloObjEmu > &sec, const l1t::PFCluster &t)
 
void addDecodedHadCalo (l1ct::DetectorSector< l1ct::HadCaloObjEmu > &sec, const l1t::PFCluster &t)
 
void addDecodedMuon (l1ct::DetectorSector< l1ct::MuObjEmu > &sec, const l1t::SAMuon &t)
 
void addDecodedTrack (l1ct::DetectorSector< l1ct::TkObjEmu > &sec, const l1t::PFTrack &t)
 
void addEmCalo (const l1t::PFCluster &t, l1t::PFClusterRef ref)
 
void addHadCalo (const l1t::PFCluster &t, l1t::PFClusterRef ref)
 
void addMuon (const l1t::SAMuon &t, l1t::PFCandidate::MuonRef ref)
 
void addRawHgcalCluster (l1ct::DetectorSector< ap_uint< 256 >> &sec, const l1t::PFCluster &c)
 
void addTrack (const l1t::PFTrack &t, l1t::PFTrackRef ref)
 
void addUInt (unsigned int value, std::string iLabel, edm::Event &iEvent)
 
void beginStream (edm::StreamID) override
 
void doVertexings (std::vector< float > &pvdz) const
 
void endStream () override
 
std::unique_ptr< std::vector< l1t::PFTrack > > fetchDecodedTracks () const
 
std::unique_ptr< l1t::PFCandidateCollectionfetchEmCalo () const
 
std::unique_ptr< l1t::PFCandidateCollectionfetchHadCalo () const
 
std::unique_ptr< l1t::PFCandidateCollectionfetchPF () const
 
std::unique_ptr< l1t::PFCandidateCollectionfetchTracks () const
 
void initEvent (const edm::Event &e)
 
void initSectorsAndRegions (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void putEgObjects (edm::Event &iEvent, const bool writeEgSta, const std::vector< edm::Ref< BXVector< l1t::EGamma >>> &egsta_refs, const std::string &tkEmLabel, const std::string &tkEmPerBoardLabel, const std::string &tkEleLabel, const std::string &tkElePerBoardLabel) const
 
void putEgStaObjects (edm::Event &iEvent, const std::string &egLablel, std::vector< edm::Ref< BXVector< l1t::EGamma >>> &egsta_refs)
 
void putPuppi (edm::Event &iEvent) const
 
template<typename T >
void setRefs_ (l1t::PFCandidate &pf, const T &p) const
 
std::pair< unsigned int, unsigned int > totAndMax (const std::vector< unsigned > &perRegion) const
 
std::unique_ptr< std::vector< unsigned > > vecOutput (OutputType i, bool usePuppi) const
 
std::unique_ptr< std::vector< unsigned > > vecRegInput (InputType i) const
 
std::unique_ptr< std::vector< unsigned > > vecSecInput (InputType i) const
 

Private Attributes

std::unordered_map< const l1t::PFCluster *, l1t::PFClusterRefclusterRefMap_
 
edm::ParameterSet config_
 
float debugEta_
 
float debugPhi_
 
float debugR_
 
std::vector< edm::EDGetTokenT< l1t::PFClusterCollection > > emCands_
 
float emPtCut_
 
bool emuTkVtx_
 
l1ct::Event event_
 
edm::EDGetTokenT< std::vector< l1t::Vertex > > extTkVtx_
 
std::fstream fRegionDump_
 
std::vector< edm::EDGetTokenT< l1t::PFClusterCollection > > hadCands_
 
float hadPtCut_
 
bool hasTracks_
 
std::unique_ptr< l1ct::PFAlgoEmulatorBasel1pfalgo_
 
std::unique_ptr< l1ct::LinPuppiEmulatorl1pualgo_
 
std::unique_ptr< l1ct::PFTkEGAlgoEmulatorl1tkegalgo_
 
std::unique_ptr< l1ct::PFTkEGSorterEmulatorl1tkegsorter_
 
edm::EDGetTokenT< l1t::SAMuonCollectionmuCands_
 
std::unique_ptr< l1ct::GMTMuonDecoderEmulatormuonInput_
 
std::unordered_map< const l1t::SAMuon *, l1t::PFCandidate::MuonRefmuonRefMap_
 
int nVtx_
 
const std::vector< edm::ParameterSetpatternWriterConfigs_
 
std::vector< std::unique_ptr< L1TCorrelatorLayer1PatternFileWriter > > patternWriters_
 
const std::string regionDumpName_
 
std::unique_ptr< l1ct::RegionizerEmulatorregionizer_
 
edm::EDGetTokenT< l1t::PFTrackCollectiontkCands_
 
edm::EDGetTokenT< std::vector< l1t::VertexWord > > tkVtxEmu_
 
std::unique_ptr< l1ct::TrackInputEmulatortrackInput_
 
std::unordered_map< const l1t::PFTrack *, l1t::PFTrackReftrackRefMap_
 
float trkPt_
 
bool writeRawHgcalCluster_
 

Static Private Attributes

static constexpr const char * inputTypeName [l1muType+1] = {"Calo", "EmCalo", "TK", "Mu"}
 

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

Definition at line 44 of file L1TCorrelatorLayer1Producer.cc.

Member Typedef Documentation

◆ OutputType

Definition at line 140 of file L1TCorrelatorLayer1Producer.cc.

Member Enumeration Documentation

◆ InputType

Constructor & Destructor Documentation

◆ L1TCorrelatorLayer1Producer()

L1TCorrelatorLayer1Producer::L1TCorrelatorLayer1Producer ( const edm::ParameterSet iConfig)
explicit

Definition at line 148 of file L1TCorrelatorLayer1Producer.cc.

References emCands_, emuTkVtx_, Exception, extTkVtx_, edm::ParameterSet::getParameter(), hadCands_, hasTracks_, mps_fire::i, initSectorsAndRegions(), inputTypeName, l1muType, l1pfalgo_, l1pualgo_, l1tkegalgo_, l1tkegsorter_, muonInput_, l1ct::OutputRegion::nPFTypes, nVtx_, l1ct::OutputRegion::objTypeName, muonDTDigis_cfi::pset, regionizer_, AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::tag, tkVtxEmu_, and trackInput_.

149  : config_(iConfig),
150  hasTracks_(!iConfig.getParameter<edm::InputTag>("tracks").label().empty()),
151  tkCands_(hasTracks_ ? consumes<l1t::PFTrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"))
152  : edm::EDGetTokenT<l1t::PFTrackCollection>()),
153  trkPt_(iConfig.getParameter<double>("trkPtCut")),
154  muCands_(consumes<l1t::SAMuonCollection>(iConfig.getParameter<edm::InputTag>("muons"))),
155  emPtCut_(iConfig.getParameter<double>("emPtCut")),
156  hadPtCut_(iConfig.getParameter<double>("hadPtCut")),
157  regionizer_(nullptr),
158  l1pfalgo_(nullptr),
159  l1pualgo_(nullptr),
160  l1tkegalgo_(nullptr),
161  l1tkegsorter_(nullptr),
162  regionDumpName_(iConfig.getUntrackedParameter<std::string>("dumpFileName", "")),
163  writeRawHgcalCluster_(iConfig.getUntrackedParameter<bool>("writeRawHgcalCluster", false)),
164  patternWriterConfigs_(iConfig.getUntrackedParameter<std::vector<edm::ParameterSet>>(
165  "patternWriters", std::vector<edm::ParameterSet>())),
166  debugEta_(iConfig.getUntrackedParameter<double>("debugEta", 0)),
167  debugPhi_(iConfig.getUntrackedParameter<double>("debugPhi", 0)),
168  debugR_(iConfig.getUntrackedParameter<double>("debugR", -1)) {
169  produces<l1t::PFCandidateCollection>("PF");
170  produces<l1t::PFCandidateCollection>("Puppi");
171  produces<l1t::PFCandidateRegionalOutput>("PuppiRegional");
172 
173  produces<l1t::PFCandidateCollection>("EmCalo");
174  produces<l1t::PFCandidateCollection>("Calo");
175  produces<l1t::PFCandidateCollection>("TK");
176 #if 0 // LATER
177  produces<l1t::PFCandidateCollection>("TKVtx");
178 #endif
179  produces<std::vector<l1t::PFTrack>>("DecodedTK");
180 
181  for (const auto &tag : iConfig.getParameter<std::vector<edm::InputTag>>("emClusters")) {
182  emCands_.push_back(consumes<l1t::PFClusterCollection>(tag));
183  }
184  for (const auto &tag : iConfig.getParameter<std::vector<edm::InputTag>>("hadClusters")) {
185  hadCands_.push_back(consumes<l1t::PFClusterCollection>(tag));
186  }
187 
188  if (hasTracks_) {
189  const std::string &tkInAlgo = iConfig.getParameter<std::string>("trackInputConversionAlgo");
190  if (tkInAlgo == "Emulator") {
191  trackInput_ = std::make_unique<l1ct::TrackInputEmulator>(
192  iConfig.getParameter<edm::ParameterSet>("trackInputConversionParameters"));
193  } else if (tkInAlgo != "Ideal")
194  throw cms::Exception("Configuration", "Unsupported trackInputConversionAlgo");
195  }
196 
197  const std::string &muInAlgo = iConfig.getParameter<std::string>("muonInputConversionAlgo");
198  if (muInAlgo == "Emulator") {
199  muonInput_ = std::make_unique<l1ct::GMTMuonDecoderEmulator>(
200  iConfig.getParameter<edm::ParameterSet>("muonInputConversionParameters"));
201  } else if (muInAlgo != "Ideal")
202  throw cms::Exception("Configuration", "Unsupported muonInputConversionAlgo");
203 
204  const std::string &regalgo = iConfig.getParameter<std::string>("regionizerAlgo");
205  if (regalgo == "Ideal") {
206  regionizer_ =
207  std::make_unique<l1ct::RegionizerEmulator>(iConfig.getParameter<edm::ParameterSet>("regionizerAlgoParameters"));
208  } else if (regalgo == "Multififo") {
209  regionizer_ = std::make_unique<l1ct::MultififoRegionizerEmulator>(
210  iConfig.getParameter<edm::ParameterSet>("regionizerAlgoParameters"));
211  } else if (regalgo == "MultififoBarrel") {
212  const auto &pset = iConfig.getParameter<edm::ParameterSet>("regionizerAlgoParameters");
213  regionizer_ =
214  std::make_unique<l1ct::MultififoRegionizerEmulator>(pset.getParameter<std::string>("barrelSetup"), pset);
215  } else if (regalgo == "TDR") {
216  regionizer_ = std::make_unique<l1ct::TDRRegionizerEmulator>(
217  iConfig.getParameter<edm::ParameterSet>("regionizerAlgoParameters"));
218  } else
219  throw cms::Exception("Configuration", "Unsupported regionizerAlgo");
220 
221  const std::string &algo = iConfig.getParameter<std::string>("pfAlgo");
222  if (algo == "PFAlgo3") {
223  l1pfalgo_ = std::make_unique<l1ct::PFAlgo3Emulator>(iConfig.getParameter<edm::ParameterSet>("pfAlgoParameters"));
224  } else if (algo == "PFAlgo2HGC") {
225  l1pfalgo_ = std::make_unique<l1ct::PFAlgo2HGCEmulator>(iConfig.getParameter<edm::ParameterSet>("pfAlgoParameters"));
226  } else if (algo == "PFAlgoDummy") {
227  l1pfalgo_ =
228  std::make_unique<l1ct::PFAlgoDummyEmulator>(iConfig.getParameter<edm::ParameterSet>("pfAlgoParameters"));
229  } else
230  throw cms::Exception("Configuration", "Unsupported pfAlgo");
231 
232  const std::string &pualgo = iConfig.getParameter<std::string>("puAlgo");
233  if (pualgo == "LinearizedPuppi") {
234  l1pualgo_ = std::make_unique<l1ct::LinPuppiEmulator>(iConfig.getParameter<edm::ParameterSet>("puAlgoParameters"));
235  } else
236  throw cms::Exception("Configuration", "Unsupported puAlgo");
237 
238  l1tkegalgo_ = std::make_unique<l1ct::PFTkEGAlgoEmulator>(
239  l1ct::PFTkEGAlgoEmuConfig(iConfig.getParameter<edm::ParameterSet>("tkEgAlgoParameters")));
240 
241  const std::string &egsortalgo = iConfig.getParameter<std::string>("tkEgSorterAlgo");
242  if (egsortalgo == "Barrel") {
243  l1tkegsorter_ = std::make_unique<l1ct::PFTkEGSorterBarrelEmulator>(
244  iConfig.getParameter<edm::ParameterSet>("tkEgSorterParameters"));
245  } else if (egsortalgo == "Endcap") {
246  l1tkegsorter_ =
247  std::make_unique<l1ct::PFTkEGSorterEmulator>(iConfig.getParameter<edm::ParameterSet>("tkEgSorterParameters"));
248  } else
249  throw cms::Exception("Configuration", "Unsupported tkEgSorterAlgo");
250 
251  if (l1tkegalgo_->writeEgSta())
252  produces<BXVector<l1t::EGamma>>("L1Eg");
253  produces<l1t::TkElectronCollection>("L1TkEle");
254  produces<l1t::TkElectronRegionalOutput>("L1TkElePerBoard");
255  produces<l1t::TkEmCollection>("L1TkEm");
256  produces<l1t::TkEmRegionalOutput>("L1TkEmPerBoard");
257 
258  emuTkVtx_ = iConfig.getParameter<bool>("vtxCollectionEmulation");
259  if (emuTkVtx_) {
260  tkVtxEmu_ = consumes<std::vector<l1t::VertexWord>>(iConfig.getParameter<edm::InputTag>("vtxCollection"));
261  } else {
262  extTkVtx_ = consumes<std::vector<l1t::Vertex>>(iConfig.getParameter<edm::InputTag>("vtxCollection"));
263  }
264  nVtx_ = iConfig.getParameter<int>("nVtx");
265 
266  const char *iprefix[4] = {"totNReg", "maxNReg", "totNSec", "maxNSec"};
267  for (int i = 0; i <= l1muType; ++i) {
268  for (int ip = 0; ip < 4; ++ip) {
269  produces<unsigned int>(std::string(iprefix[ip]) + inputTypeName[i]);
270  }
271  produces<std::vector<unsigned>>(std::string("vecNReg") + inputTypeName[i]);
272  produces<std::vector<unsigned>>(std::string("vecNSec") + inputTypeName[i]);
273  }
274  const char *oprefix[4] = {"totNPF", "maxNPF", "totNPuppi", "maxNPuppi"};
275  for (int i = 0; i < l1ct::OutputRegion::nPFTypes; ++i) {
276  for (int ip = 0; ip < 4; ++ip) {
277  produces<unsigned int>(std::string(oprefix[ip]) + l1ct::OutputRegion::objTypeName[i]);
278  }
279  produces<std::vector<unsigned>>(std::string("vecNPF") + l1ct::OutputRegion::objTypeName[i]);
280  produces<std::vector<unsigned>>(std::string("vecNPuppi") + l1ct::OutputRegion::objTypeName[i]);
281  }
282 
283  initSectorsAndRegions(iConfig);
284 }
edm::EDGetTokenT< std::vector< l1t::VertexWord > > tkVtxEmu_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< std::vector< l1t::Vertex > > extTkVtx_
edm::EDGetTokenT< l1t::PFTrackCollection > tkCands_
const std::vector< edm::ParameterSet > patternWriterConfigs_
delete x;
Definition: CaloConfig.h:22
std::string const & label() const
Definition: InputTag.h:36
std::vector< edm::EDGetTokenT< l1t::PFClusterCollection > > hadCands_
std::unique_ptr< l1ct::PFAlgoEmulatorBase > l1pfalgo_
std::unique_ptr< l1ct::PFTkEGAlgoEmulator > l1tkegalgo_
std::unique_ptr< l1ct::TrackInputEmulator > trackInput_
void initSectorsAndRegions(const edm::ParameterSet &iConfig)
std::unique_ptr< l1ct::RegionizerEmulator > regionizer_
std::vector< edm::EDGetTokenT< l1t::PFClusterCollection > > emCands_
edm::EDGetTokenT< l1t::SAMuonCollection > muCands_
static constexpr const char * inputTypeName[l1muType+1]
std::unique_ptr< l1ct::LinPuppiEmulator > l1pualgo_
std::vector< SAMuon > SAMuonCollection
Definition: SAMuon.h:14
std::unique_ptr< l1ct::PFTkEGSorterEmulator > l1tkegsorter_
static constexpr const char * objTypeName[nObjTypes]
std::unique_ptr< l1ct::GMTMuonDecoderEmulator > muonInput_
std::vector< l1t::PFTrack > PFTrackCollection
Definition: PFTrack.h:89
HLT enums.

◆ ~L1TCorrelatorLayer1Producer()

L1TCorrelatorLayer1Producer::~L1TCorrelatorLayer1Producer ( )
override

Definition at line 286 of file L1TCorrelatorLayer1Producer.cc.

286 {}

Member Function Documentation

◆ addDecodedEmCalo()

void L1TCorrelatorLayer1Producer::addDecodedEmCalo ( l1ct::DetectorSector< l1ct::EmCaloObjEmu > &  sec,
const l1t::PFCluster t 
)
private

Definition at line 733 of file L1TCorrelatorLayer1Producer.cc.

References HltBtagPostValidation_cff::c, l1tTowerCalibrationProducer_cfi::calo, l1ct::Scales::makeGlbEta(), l1ct::Scales::makePhi(), l1ct::Scales::makePtFromFloat(), and fileinputsource_cfi::sec.

Referenced by addEmCalo().

734  {
736  // set the endcap-sepcific variables to default value:
737  calo.clear();
738  calo.hwPt = l1ct::Scales::makePtFromFloat(c.pt());
739  calo.hwEta = l1ct::Scales::makeGlbEta(c.eta()) -
740  sec.region.hwEtaCenter; // important to enforce that the region boundary is on a discrete value
741  calo.hwPhi = l1ct::Scales::makePhi(sec.region.localPhi(c.phi()));
742  calo.hwPtErr = l1ct::Scales::makePtFromFloat(c.ptError());
743  calo.hwEmID = c.hwEmID();
744  calo.src = &c;
745  sec.obj.push_back(calo);
746 }
glbeta_t makeGlbEta(float eta)
Definition: datatypes.h:202
pt_t makePtFromFloat(float pt)
Definition: datatypes.h:182
phi_t makePhi(float phi)
Definition: datatypes.h:200
Definition: Common.h:9

◆ addDecodedHadCalo()

void L1TCorrelatorLayer1Producer::addDecodedHadCalo ( l1ct::DetectorSector< l1ct::HadCaloObjEmu > &  sec,
const l1t::PFCluster t 
)
private

Definition at line 684 of file L1TCorrelatorLayer1Producer.cc.

References HltBtagPostValidation_cff::c, l1tTowerCalibrationProducer_cfi::calo, l1ct::Scales::makeGlbEta(), l1ct::Scales::makeHoe(), l1ct::Scales::makeMeanZ(), l1ct::Scales::makePhi(), l1ct::Scales::makePtFromFloat(), l1ct::Scales::makeSrrTot(), and fileinputsource_cfi::sec.

Referenced by addHadCalo().

685  {
687  calo.hwPt = l1ct::Scales::makePtFromFloat(c.pt());
688  calo.hwEta = l1ct::Scales::makeGlbEta(c.eta()) -
689  sec.region.hwEtaCenter; // important to enforce that the region boundary is on a discrete value
690  calo.hwPhi = l1ct::Scales::makePhi(sec.region.localPhi(c.phi()));
691  calo.hwEmPt = l1ct::Scales::makePtFromFloat(c.emEt());
692  calo.hwEmID = c.hwEmID();
693  calo.hwSrrTot = l1ct::Scales::makeSrrTot(c.sigmaRR());
694  calo.hwMeanZ = c.absZBarycenter() < 320. ? l1ct::meanz_t(0) : l1ct::Scales::makeMeanZ(c.absZBarycenter());
695  calo.hwHoe = l1ct::Scales::makeHoe(c.hOverE());
696  calo.src = &c;
697  sec.obj.push_back(calo);
698 }
glbeta_t makeGlbEta(float eta)
Definition: datatypes.h:202
ap_uint< 8 > meanz_t
Definition: datatypes.h:42
srrtot_t makeSrrTot(float var)
Definition: datatypes.h:209
pt_t makePtFromFloat(float pt)
Definition: datatypes.h:182
hoe_t makeHoe(float var)
Definition: datatypes.h:211
meanz_t makeMeanZ(float var)
Definition: datatypes.h:210
phi_t makePhi(float phi)
Definition: datatypes.h:200
Definition: Common.h:9
Definition: datatypes.h:17

◆ addDecodedMuon()

void L1TCorrelatorLayer1Producer::addDecodedMuon ( l1ct::DetectorSector< l1ct::MuObjEmu > &  sec,
const l1t::SAMuon t 
)
private

Definition at line 665 of file L1TCorrelatorLayer1Producer.cc.

References l1ct::Scales::makeGlbEta(), l1ct::Scales::makeGlbPhi(), l1ct::Scales::makePtFromFloat(), l1ct::Scales::makeZ0(), amptDefaultParameters_cff::mu, muonInput_, fileinputsource_cfi::sec, and submitPVValidationJobs::t.

Referenced by addMuon().

665  {
667  if (muonInput_) {
668  mu = muonInput_->decode(t.word());
669  } else {
670  mu.hwPt = l1ct::Scales::makePtFromFloat(t.pt());
671  mu.hwEta = l1ct::Scales::makeGlbEta(t.eta()); // IMPORTANT: input is in global coordinates!
672  mu.hwPhi = l1ct::Scales::makeGlbPhi(t.phi());
673  mu.hwCharge = !t.hwCharge();
674  mu.hwQuality = t.hwQual() / 2;
675  mu.hwDEta = 0;
676  mu.hwDPhi = 0;
677  mu.hwZ0 = l1ct::Scales::makeZ0(t.vertex().Z());
678  mu.hwDxy = 0; // Dxy not defined yet
679  }
680  mu.src = &t;
681  sec.obj.push_back(mu);
682 }
glbeta_t makeGlbEta(float eta)
Definition: datatypes.h:202
z0_t makeZ0(float z0)
Definition: datatypes.h:184
glbphi_t makeGlbPhi(float phi)
Definition: datatypes.h:205
pt_t makePtFromFloat(float pt)
Definition: datatypes.h:182
std::unique_ptr< l1ct::GMTMuonDecoderEmulator > muonInput_

◆ addDecodedTrack()

void L1TCorrelatorLayer1Producer::addDecodedTrack ( l1ct::DetectorSector< l1ct::TkObjEmu > &  sec,
const l1t::PFTrack t 
)
private

Definition at line 629 of file L1TCorrelatorLayer1Producer.cc.

References funct::abs(), reco::deltaPhi(), l1ct::Scales::makeEta(), l1ct::Scales::makeGlbEta(), l1ct::Scales::makePhi(), l1ct::Scales::makePtFromFloat(), l1ct::Scales::makeZ0(), fileinputsource_cfi::sec, submitPVValidationJobs::t, and trackInput_.

Referenced by addTrack().

629  {
630  std::pair<l1ct::TkObjEmu, bool> tkAndSel;
631  if (trackInput_) {
632  tkAndSel = trackInput_->decodeTrack(t.trackWord().getTrackWord(), sec.region);
633  } else {
634  tkAndSel.first.hwPt = l1ct::Scales::makePtFromFloat(t.pt());
635  tkAndSel.first.hwEta =
636  l1ct::Scales::makeGlbEta(t.caloEta()) -
637  sec.region.hwEtaCenter; // important to enforce that the region boundary is on a discrete value
638  tkAndSel.first.hwPhi = l1ct::Scales::makePhi(sec.region.localPhi(t.caloPhi()));
639  tkAndSel.first.hwCharge = t.charge() > 0;
640  tkAndSel.first.hwQuality = t.quality();
641  tkAndSel.first.hwDEta = l1ct::Scales::makeEta(t.eta() - t.caloEta());
642  tkAndSel.first.hwDPhi = l1ct::Scales::makePhi(std::abs(reco::deltaPhi(t.phi(), t.caloPhi())));
643  tkAndSel.first.hwZ0 = l1ct::Scales::makeZ0(t.vertex().Z());
644  tkAndSel.first.hwDxy = 0;
645  tkAndSel.second = t.quality() > 0;
646  }
647  // CMSSW-only extra info
648  tkAndSel.first.hwChi2 = round(t.chi2() * 10);
649  tkAndSel.first.simPt = t.pt();
650  tkAndSel.first.simCaloEta = t.caloEta();
651  tkAndSel.first.simCaloPhi = t.caloPhi();
652  tkAndSel.first.simVtxEta = t.eta();
653  tkAndSel.first.simVtxPhi = t.phi();
654  tkAndSel.first.simZ0 = t.vertex().Z();
655  tkAndSel.first.simD0 = t.vertex().Rho();
656  tkAndSel.first.src = &t;
657 
658  // If the track fails, we set its pT to zero, so that the decoded tracks are still aligned with the raw tracks
659  // Downstream, the regionizer will just ignore zero-momentum tracks
660  if (!tkAndSel.second)
661  tkAndSel.first.hwPt = 0;
662  sec.obj.push_back(tkAndSel.first);
663 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
glbeta_t makeGlbEta(float eta)
Definition: datatypes.h:202
z0_t makeZ0(float z0)
Definition: datatypes.h:184
pt_t makePtFromFloat(float pt)
Definition: datatypes.h:182
eta_t makeEta(float eta)
Definition: datatypes.h:201
std::unique_ptr< l1ct::TrackInputEmulator > trackInput_
phi_t makePhi(float phi)
Definition: datatypes.h:200
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ addEmCalo()

void L1TCorrelatorLayer1Producer::addEmCalo ( const l1t::PFCluster t,
l1t::PFClusterRef  ref 
)
private

Definition at line 620 of file L1TCorrelatorLayer1Producer.cc.

References addDecodedEmCalo(), HltBtagPostValidation_cff::c, clusterRefMap_, l1ct::Event::decoded, l1ct::RegionizerDecodedInputs::emcalo, event_, and fileinputsource_cfi::sec.

Referenced by produce().

620  {
621  for (auto &sec : event_.decoded.emcalo) {
622  if (sec.region.contains(c.eta(), c.phi())) {
624  }
625  }
626  clusterRefMap_[&c] = ref;
627 }
void addDecodedEmCalo(l1ct::DetectorSector< l1ct::EmCaloObjEmu > &sec, const l1t::PFCluster &t)
RegionizerDecodedInputs decoded
std::vector< DetectorSector< EmCaloObjEmu > > emcalo
std::unordered_map< const l1t::PFCluster *, l1t::PFClusterRef > clusterRefMap_

◆ addHadCalo()

void L1TCorrelatorLayer1Producer::addHadCalo ( const l1t::PFCluster t,
l1t::PFClusterRef  ref 
)
private

Definition at line 608 of file L1TCorrelatorLayer1Producer.cc.

References addDecodedHadCalo(), addRawHgcalCluster(), HltBtagPostValidation_cff::c, clusterRefMap_, l1ct::Event::decoded, event_, l1ct::RegionizerDecodedInputs::hadcalo, l1ct::RawInputs::hgcalcluster, l1ct::Event::raw, fileinputsource_cfi::sec, and writeRawHgcalCluster_.

Referenced by produce().

608  {
609  int sidx = 0;
610  for (auto &sec : event_.decoded.hadcalo) {
611  if (sec.region.contains(c.eta(), c.phi())) {
615  }
616  sidx++;
617  }
618  clusterRefMap_[&c] = ref;
619 }
RawInputs raw
std::vector< DetectorSector< HadCaloObjEmu > > hadcalo
RegionizerDecodedInputs decoded
void addRawHgcalCluster(l1ct::DetectorSector< ap_uint< 256 >> &sec, const l1t::PFCluster &c)
std::vector< DetectorSector< ap_uint< 256 > > > hgcalcluster
void addDecodedHadCalo(l1ct::DetectorSector< l1ct::HadCaloObjEmu > &sec, const l1t::PFCluster &t)
std::unordered_map< const l1t::PFCluster *, l1t::PFClusterRef > clusterRefMap_

◆ addMuon()

void L1TCorrelatorLayer1Producer::addMuon ( const l1t::SAMuon t,
l1t::PFCandidate::MuonRef  ref 
)
private

Definition at line 603 of file L1TCorrelatorLayer1Producer.cc.

References addDecodedMuon(), l1ct::Event::decoded, event_, amptDefaultParameters_cff::mu, l1ct::RawInputs::muon, l1ct::RegionizerDecodedInputs::muon, muonRefMap_, l1ct::DetectorSector< T >::obj, and l1ct::Event::raw.

Referenced by produce().

603  {
604  event_.raw.muon.obj.emplace_back(mu.word());
606  muonRefMap_[&mu] = ref;
607 }
DetectorSector< ap_uint< 64 > > muon
std::vector< T > obj
void addDecodedMuon(l1ct::DetectorSector< l1ct::MuObjEmu > &sec, const l1t::SAMuon &t)
RawInputs raw
RegionizerDecodedInputs decoded
std::unordered_map< const l1t::SAMuon *, l1t::PFCandidate::MuonRef > muonRefMap_
DetectorSector< MuObjEmu > muon

◆ addRawHgcalCluster()

void L1TCorrelatorLayer1Producer::addRawHgcalCluster ( l1ct::DetectorSector< ap_uint< 256 >> &  sec,
const l1t::PFCluster c 
)
private

Definition at line 700 of file L1TCorrelatorLayer1Producer.cc.

References HltBtagPostValidation_cff::c, l1ct::Scales::ETAPHI_LSB, M_PI, fileinputsource_cfi::sec, l1ct::Scales::SRRTOT_LSB, and l1ct::Scales::SRRTOT_SCALE.

Referenced by addHadCalo().

700  {
701  ap_uint<256> cwrd = 0;
702  ap_ufixed<14, 12, AP_RND_CONV, AP_SAT> w_pt = c.pt();
703  ap_uint<14> w_empt = round(c.emEt() / 0.25);
704  constexpr float ETAPHI_LSB = M_PI / 720;
705  ap_int<9> w_eta = round(sec.region.localEta(c.eta()) / ETAPHI_LSB);
706  ap_int<9> w_phi = round(sec.region.localPhi(c.phi()) / ETAPHI_LSB);
707  ap_uint<10> w_qual = c.hwQual();
708  // NOTE: this is an arbitrary choice to keep the rounding consistent with the "addDecodedHadCalo" one
709  ap_uint<13> w_srrtot = round(c.sigmaRR() * l1ct::Scales::SRRTOT_SCALE / l1ct::Scales::SRRTOT_LSB);
710  ap_uint<12> w_meanz = round(c.absZBarycenter());
711  // NOTE: the calibration can actually make hoe become negative....we add a small protection for now
712  // We use ap_ufixed to handle saturation and rounding
713  ap_ufixed<10, 5, AP_RND_CONV, AP_SAT> w_hoe = c.hOverE();
714 
715  cwrd(13, 0) = w_pt.range();
716  cwrd(27, 14) = w_empt;
717  cwrd(72, 64) = w_eta;
718  cwrd(81, 73) = w_phi;
719  cwrd(115, 106) = w_qual;
720 
721  // FIXME: we add the variables use by composite-ID. The definitin will have to be reviewd once the
722  // hgc format is better defined. For now we use
723  // hwMeanZ = word 1 bits 30-19
724  // hwSrrTot = word 3 bits 21 - 9
725  // hoe = word 1 bits 63-52 (currently spare in the interface)
726  cwrd(213, 201) = w_srrtot;
727  cwrd(94, 83) = w_meanz;
728  cwrd(127, 116) = w_hoe.range();
729 
730  sec.obj.push_back(cwrd);
731 }
constexpr float SRRTOT_LSB
Definition: datatypes.h:157
constexpr float ETAPHI_LSB
Definition: datatypes.h:152
#define M_PI
constexpr unsigned int SRRTOT_SCALE
Definition: datatypes.h:158

◆ addTrack()

void L1TCorrelatorLayer1Producer::addTrack ( const l1t::PFTrack t,
l1t::PFTrackRef  ref 
)
private

Definition at line 594 of file L1TCorrelatorLayer1Producer.cc.

References addDecodedTrack(), cms::cuda::assert(), l1ct::Event::decoded, event_, l1ct::Event::raw, volumeBasedMagneticField_160812_cfi::sectors, submitPVValidationJobs::t, l1ct::RawInputs::track, l1ct::RegionizerDecodedInputs::track, and trackRefMap_.

Referenced by produce().

594  {
595  auto &rawsectors = event_.raw.track;
596  auto &sectors = event_.decoded.track;
597  assert(sectors.size() == 18 && rawsectors.size() == 18);
598  int isec = t.track()->phiSector() + (t.eta() >= 0 ? 9 : 0);
599  rawsectors[isec].obj.push_back(t.trackWord().getTrackWord());
600  addDecodedTrack(sectors[isec], t);
601  trackRefMap_[&t] = ref;
602 }
std::unordered_map< const l1t::PFTrack *, l1t::PFTrackRef > trackRefMap_
void addDecodedTrack(l1ct::DetectorSector< l1ct::TkObjEmu > &sec, const l1t::PFTrack &t)
assert(be >=bs)
RawInputs raw
std::vector< DetectorSector< ap_uint< 96 > > > track
RegionizerDecodedInputs decoded
std::vector< DetectorSector< TkObjEmu > > track

◆ addUInt()

void L1TCorrelatorLayer1Producer::addUInt ( unsigned int  value,
std::string  iLabel,
edm::Event iEvent 
)
private

Definition at line 504 of file L1TCorrelatorLayer1Producer.cc.

References iEvent.

Referenced by produce().

504  {
505  iEvent.put(std::make_unique<unsigned>(value), iLabel);
506 }
int iEvent
Definition: GenABIO.cc:224
Definition: value.py:1

◆ beginStream()

void L1TCorrelatorLayer1Producer::beginStream ( edm::StreamID  id)
overrideprivate

Definition at line 288 of file L1TCorrelatorLayer1Producer.cc.

References event_, fRegionDump_, MillePedeFileConverter_cfg::out, patternWriterConfigs_, patternWriters_, muonDTDigis_cfi::pset, and regionDumpName_.

288  {
289  if (!regionDumpName_.empty()) {
290  if (id == 0) {
291  fRegionDump_.open(regionDumpName_.c_str(), std::ios::out | std::ios::binary);
292  } else {
293  edm::LogWarning("L1TCorrelatorLayer1Producer")
294  << "Job running with multiple streams, but dump file will have only events on stream zero.";
295  }
296  }
297  if (!patternWriterConfigs_.empty()) {
298  if (id == 0) {
299  for (const auto &pset : patternWriterConfigs_) {
300  patternWriters_.emplace_back(std::make_unique<L1TCorrelatorLayer1PatternFileWriter>(pset, event_));
301  }
302  } else {
303  edm::LogWarning("L1TCorrelatorLayer1Producer")
304  << "Job running with multiple streams, but pattern files will be written only on stream zero.";
305  }
306  }
307 }
const std::vector< edm::ParameterSet > patternWriterConfigs_
std::vector< std::unique_ptr< L1TCorrelatorLayer1PatternFileWriter > > patternWriters_
Log< level::Warning, false > LogWarning

◆ doVertexings()

void L1TCorrelatorLayer1Producer::doVertexings ( std::vector< float > &  pvdz) const
private

◆ endStream()

void L1TCorrelatorLayer1Producer::endStream ( )
overrideprivate

Definition at line 309 of file L1TCorrelatorLayer1Producer.cc.

References patternWriters_, and convertToRaw::writer.

309  {
310  for (auto &writer : patternWriters_) {
311  writer->flush();
312  }
313 }
std::vector< std::unique_ptr< L1TCorrelatorLayer1PatternFileWriter > > patternWriters_

◆ fetchDecodedTracks()

std::unique_ptr< std::vector< l1t::PFTrack > > L1TCorrelatorLayer1Producer::fetchDecodedTracks ( ) const
private

Definition at line 874 of file L1TCorrelatorLayer1Producer.cc.

References l1ct::Event::decoded, event_, AlCaHLTBitMon_ParallelJobs::p, alignCSCRings::r, runTheMatrix::ret, l1ct::RegionizerDecodedInputs::track, and L1BJetProducer_cff::vtx.

Referenced by produce().

874  {
875  auto ret = std::make_unique<std::vector<l1t::PFTrack>>();
876  for (const auto &r : event_.decoded.track) {
877  const auto &reg = r.region;
878  for (const auto &p : r.obj) {
879  if (p.hwPt == 0 || !reg.isFiducial(p))
880  continue;
882  p.floatPt(), reg.floatGlbEta(p.hwVtxEta()), reg.floatGlbPhi(p.hwVtxPhi()), 0);
883 
884  reco::Particle::Point vtx(0, 0, p.floatZ0());
885 
886  ret->emplace_back(l1t::PFTrack(p.intCharge(),
888  vtx,
889  p.src->track(),
890  0,
891  reg.floatGlbEta(p.hwEta),
892  reg.floatGlbPhi(p.hwPhi),
893  -1,
894  -1,
895  p.hwQuality.to_int(),
896  false,
897  p.intPt(),
898  p.intEta(),
899  p.intPhi()));
900  }
901  }
902  return ret;
903 }
ret
prodAgent to be discontinued
math::XYZPoint Point
point in the space
Definition: Particle.h:25
RegionizerDecodedInputs decoded
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Particle.h:23
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
std::vector< DetectorSector< TkObjEmu > > track

◆ fetchEmCalo()

std::unique_ptr< l1t::PFCandidateCollection > L1TCorrelatorLayer1Producer::fetchEmCalo ( ) const
private

Definition at line 843 of file L1TCorrelatorLayer1Producer.cc.

References event_, AlCaHLTBitMon_ParallelJobs::p, l1ct::Event::pfinputs, l1t::PFCandidate::Photon, alignCSCRings::r, runTheMatrix::ret, and setRefs_().

Referenced by produce().

843  {
844  auto ret = std::make_unique<l1t::PFCandidateCollection>();
845  for (const auto &r : event_.pfinputs) {
846  const auto &reg = r.region;
847  for (const auto &p : r.emcalo) {
848  if (p.hwPt == 0 || !reg.isFiducial(p))
849  continue;
850  reco::Particle::PolarLorentzVector p4(p.floatPt(), reg.floatGlbEtaOf(p), reg.floatGlbPhiOf(p), 0.13f);
851  ret->emplace_back(l1t::PFCandidate::Photon, 0, p4, 1, p.intPt(), p.intEta(), p.intPhi());
852  ret->back().setHwEmID(p.hwEmID);
853  setRefs_(ret->back(), p);
854  }
855  }
856  return ret;
857 }
void setRefs_(l1t::PFCandidate &pf, const T &p) const
ret
prodAgent to be discontinued
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Particle.h:23
std::vector< PFInputRegion > pfinputs

◆ fetchHadCalo()

std::unique_ptr< l1t::PFCandidateCollection > L1TCorrelatorLayer1Producer::fetchHadCalo ( ) const
private

Definition at line 827 of file L1TCorrelatorLayer1Producer.cc.

References event_, l1t::PFCandidate::NeutralHadron, AlCaHLTBitMon_ParallelJobs::p, l1ct::Event::pfinputs, l1t::PFCandidate::Photon, alignCSCRings::r, runTheMatrix::ret, and setRefs_().

Referenced by produce().

827  {
828  auto ret = std::make_unique<l1t::PFCandidateCollection>();
829  for (const auto &r : event_.pfinputs) {
830  const auto &reg = r.region;
831  for (const auto &p : r.hadcalo) {
832  if (p.hwPt == 0 || !reg.isFiducial(p))
833  continue;
834  reco::Particle::PolarLorentzVector p4(p.floatPt(), reg.floatGlbEtaOf(p), reg.floatGlbPhiOf(p), 0.13f);
836  ret->emplace_back(type, 0, p4, 1, p.intPt(), p.intEta(), p.intPhi());
837  ret->back().setHwEmID(p.hwEmID);
838  setRefs_(ret->back(), p);
839  }
840  }
841  return ret;
842 }
void setRefs_(l1t::PFCandidate &pf, const T &p) const
ret
prodAgent to be discontinued
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Particle.h:23
std::vector< PFInputRegion > pfinputs

◆ fetchPF()

std::unique_ptr< l1t::PFCandidateCollection > L1TCorrelatorLayer1Producer::fetchPF ( ) const
private

Definition at line 905 of file L1TCorrelatorLayer1Producer.cc.

References l1t::PFCandidate::ChargedHadron, l1t::PFCandidate::Electron, event_, f, l1t::PFCandidate::Muon, l1t::PFCandidate::NeutralHadron, EgHLTOffHistBins_cfi::nr, l1ct::Event::out, AlCaHLTBitMon_ParallelJobs::p, l1ct::Event::pfinputs, l1t::PFCandidate::Photon, runTheMatrix::ret, and setRefs_().

Referenced by produce().

905  {
906  auto ret = std::make_unique<l1t::PFCandidateCollection>();
907  for (unsigned int ir = 0, nr = event_.pfinputs.size(); ir < nr; ++ir) {
908  const auto &reg = event_.pfinputs[ir].region;
909  for (const auto &p : event_.out[ir].pfcharged) {
910  if (p.hwPt == 0 || !reg.isFiducial(p))
911  continue;
913  p.floatPt(), reg.floatGlbEta(p.hwVtxEta()), reg.floatGlbPhi(p.hwVtxPhi()), 0.13f);
915  if (p.hwId.isMuon())
917  else if (p.hwId.isElectron())
919  ret->emplace_back(type, p.intCharge(), p4, 1, p.intPt(), p.intEta(), p.intPhi());
920  ret->back().setZ0(p.floatZ0());
921  ret->back().setDxy(p.floatDxy());
922  ret->back().setHwZ0(p.hwZ0);
923  ret->back().setHwDxy(p.hwDxy);
924  ret->back().setHwTkQuality(p.hwTkQuality);
925  ret->back().setCaloEta(reg.floatGlbEtaOf(p));
926  ret->back().setCaloPhi(reg.floatGlbPhiOf(p));
927 
928  setRefs_(ret->back(), p);
929  }
930  for (const auto &p : event_.out[ir].pfneutral) {
931  if (p.hwPt == 0 || !reg.isFiducial(p))
932  continue;
933  reco::Particle::PolarLorentzVector p4(p.floatPt(), reg.floatGlbEtaOf(p), reg.floatGlbPhiOf(p), 0.13f);
936  ret->emplace_back(type, 0, p4, 1, p.intPt(), p.intEta(), p.intPhi());
937  ret->back().setHwEmID(p.hwEmID);
938  ret->back().setCaloEta(reg.floatGlbEtaOf(p));
939  ret->back().setCaloPhi(reg.floatGlbPhiOf(p));
940  setRefs_(ret->back(), p);
941  }
942  }
943  return ret;
944 }
void setRefs_(l1t::PFCandidate &pf, const T &p) const
ret
prodAgent to be discontinued
std::vector< OutputRegion > out
double f[11][100]
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Particle.h:23
std::vector< PFInputRegion > pfinputs

◆ fetchTracks()

std::unique_ptr< l1t::PFCandidateCollection > L1TCorrelatorLayer1Producer::fetchTracks ( ) const
private

Definition at line 858 of file L1TCorrelatorLayer1Producer.cc.

References l1t::PFCandidate::ChargedHadron, event_, f, AlCaHLTBitMon_ParallelJobs::p, l1ct::Event::pfinputs, alignCSCRings::r, runTheMatrix::ret, and setRefs_().

Referenced by produce().

858  {
859  auto ret = std::make_unique<l1t::PFCandidateCollection>();
860  for (const auto &r : event_.pfinputs) {
861  const auto &reg = r.region;
862  for (const auto &p : r.track) {
863  if (p.hwPt == 0 || !reg.isFiducial(p))
864  continue;
866  p.floatPt(), reg.floatGlbEta(p.hwVtxEta()), reg.floatGlbPhi(p.hwVtxPhi()), 0.13f);
867  ret->emplace_back(l1t::PFCandidate::ChargedHadron, p.intCharge(), p4, 1, p.intPt(), p.intEta(), p.intPhi());
868  setRefs_(ret->back(), p);
869  }
870  }
871  return ret;
872 }
void setRefs_(l1t::PFCandidate &pf, const T &p) const
ret
prodAgent to be discontinued
double f[11][100]
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Particle.h:23
std::vector< PFInputRegion > pfinputs

◆ initEvent()

void L1TCorrelatorLayer1Producer::initEvent ( const edm::Event e)
private

Definition at line 584 of file L1TCorrelatorLayer1Producer.cc.

References l1ct::Event::clear(), clusterRefMap_, l1ct::Event::event, event_, iEvent, l1ct::Event::lumi, muonRefMap_, l1ct::Event::run, and trackRefMap_.

Referenced by produce().

584  {
585  event_.clear();
586  event_.run = iEvent.id().run();
587  event_.lumi = iEvent.id().luminosityBlock();
588  event_.event = iEvent.id().event();
589  clusterRefMap_.clear();
590  trackRefMap_.clear();
591  muonRefMap_.clear();
592 }
std::unordered_map< const l1t::PFTrack *, l1t::PFTrackRef > trackRefMap_
uint64_t event
int iEvent
Definition: GenABIO.cc:224
std::unordered_map< const l1t::SAMuon *, l1t::PFCandidate::MuonRef > muonRefMap_
void clear()
std::unordered_map< const l1t::PFCluster *, l1t::PFClusterRef > clusterRefMap_

◆ initSectorsAndRegions()

void L1TCorrelatorLayer1Producer::initSectorsAndRegions ( const edm::ParameterSet iConfig)
private

Definition at line 508 of file L1TCorrelatorLayer1Producer.cc.

References l1ct::Event::board_out, l1ct::Event::decoded, l1ct::RegionizerDecodedInputs::emcalo, hltEgammaEleL1TrkIsoL1Seeded_cfi::etaBoundaries, l1pfProducerBarrel_cfi::etaExtra, photons_cff::etaWidth, event_, Exception, edm::ParameterSet::getParameter(), l1ct::RegionizerDecodedInputs::hadcalo, l1ct::RawInputs::hgcalcluster, hcalRecHitTable_cff::ieta, hcalRecHitTable_cff::iphi, M_PI, l1ct::Scales::maxAbsEta(), l1ct::Scales::maxAbsPhi(), l1ct::RawInputs::muon, l1ct::RegionizerDecodedInputs::muon, neta, l1ct::Event::pfinputs, l1pfProducerBarrel_cfi::phiExtra, l1pfProducerBarrel_cfi::phiSlices, photons_cff::phiWidth, l1ctLayer1_cff::phiZero, l1ct::Event::raw, reco::reduceRange(), l1ct::DetectorSector< T >::region, l1ct::RawInputs::track, and l1ct::RegionizerDecodedInputs::track.

Referenced by L1TCorrelatorLayer1Producer().

508  {
509  // the track finder geometry is fixed
510  unsigned int TF_phiSlices = 9;
511  float TF_phiWidth = 2 * M_PI / TF_phiSlices;
512  event_.decoded.track.clear();
513  for (unsigned int ieta = 0, neta = 2; ieta < neta; ++ieta) {
514  for (unsigned int iphi = 0; iphi < TF_phiSlices; ++iphi) {
515  float phiCenter = reco::reduceRange(iphi * TF_phiWidth);
516  event_.decoded.track.emplace_back((ieta ? 0. : -2.5), (ieta ? 2.5 : 0.0), phiCenter, TF_phiWidth);
517  event_.raw.track.emplace_back((ieta ? 0. : -2.5), (ieta ? 2.5 : 0.0), phiCenter, TF_phiWidth);
518  }
519  }
520 
521  event_.decoded.emcalo.clear();
522  event_.decoded.hadcalo.clear();
523  event_.raw.hgcalcluster.clear();
524 
525  for (const edm::ParameterSet &preg : iConfig.getParameter<std::vector<edm::ParameterSet>>("caloSectors")) {
526  std::vector<double> etaBoundaries = preg.getParameter<std::vector<double>>("etaBoundaries");
527  if (!std::is_sorted(etaBoundaries.begin(), etaBoundaries.end()))
528  throw cms::Exception("Configuration", "caloSectors.etaBoundaries not sorted\n");
529  unsigned int phiSlices = preg.getParameter<uint32_t>("phiSlices");
530  float phiWidth = 2 * M_PI / phiSlices;
531  if (phiWidth > 2 * l1ct::Scales::maxAbsPhi())
532  throw cms::Exception("Configuration", "caloSectors phi range too large for phi_t data type");
533  double phiZero = preg.getParameter<double>("phiZero");
534  for (unsigned int ieta = 0, neta = etaBoundaries.size() - 1; ieta < neta; ++ieta) {
535  float etaWidth = etaBoundaries[ieta + 1] - etaBoundaries[ieta];
536  if (etaWidth > 2 * l1ct::Scales::maxAbsEta())
537  throw cms::Exception("Configuration", "caloSectors eta range too large for eta_t data type");
538  for (unsigned int iphi = 0; iphi < phiSlices; ++iphi) {
539  float phiCenter = reco::reduceRange(iphi * phiWidth + phiZero);
540  event_.decoded.hadcalo.emplace_back(etaBoundaries[ieta], etaBoundaries[ieta + 1], phiCenter, phiWidth);
541  event_.decoded.emcalo.emplace_back(etaBoundaries[ieta], etaBoundaries[ieta + 1], phiCenter, phiWidth);
542  event_.raw.hgcalcluster.emplace_back(etaBoundaries[ieta], etaBoundaries[ieta + 1], phiCenter, phiWidth);
543  }
544  }
545  }
546 
547  event_.decoded.muon.region = l1ct::PFRegionEmu(0., 0.); // centered at (0,0)
548  event_.raw.muon.region = l1ct::PFRegionEmu(0., 0.); // centered at (0,0)
549 
550  event_.pfinputs.clear();
551  for (const edm::ParameterSet &preg : iConfig.getParameter<std::vector<edm::ParameterSet>>("regions")) {
552  std::vector<double> etaBoundaries = preg.getParameter<std::vector<double>>("etaBoundaries");
553  if (!std::is_sorted(etaBoundaries.begin(), etaBoundaries.end()))
554  throw cms::Exception("Configuration", "regions.etaBoundaries not sorted\n");
555  unsigned int phiSlices = preg.getParameter<uint32_t>("phiSlices");
556  float etaExtra = preg.getParameter<double>("etaExtra");
557  float phiExtra = preg.getParameter<double>("phiExtra");
558  float phiWidth = 2 * M_PI / phiSlices;
559  for (unsigned int ieta = 0, neta = etaBoundaries.size() - 1; ieta < neta; ++ieta) {
560  for (unsigned int iphi = 0; iphi < phiSlices; ++iphi) {
561  float phiCenter = reco::reduceRange(iphi * phiWidth); //align with L1 TrackFinder phi sector indexing
562  event_.pfinputs.emplace_back(
564  }
565  }
566  }
567 
568  event_.board_out.clear();
569  const std::vector<edm::ParameterSet> &board_params = iConfig.getParameter<std::vector<edm::ParameterSet>>("boards");
570  event_.board_out.resize(board_params.size());
571  for (unsigned int bidx = 0; bidx < board_params.size(); bidx++) {
572  event_.board_out[bidx].region_index = board_params[bidx].getParameter<std::vector<unsigned int>>("regions");
573  float etaBoard = 0.;
574  float phiBoard = 0.;
575  for (auto ridx : event_.board_out[bidx].region_index) {
576  etaBoard += event_.pfinputs[ridx].region.floatEtaCenter();
577  phiBoard += event_.pfinputs[ridx].region.floatPhiCenter();
578  }
579  event_.board_out[bidx].eta = etaBoard / event_.board_out[bidx].region_index.size();
580  event_.board_out[bidx].phi = phiBoard / event_.board_out[bidx].region_index.size();
581  }
582 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
DetectorSector< ap_uint< 64 > > muon
constexpr T reduceRange(T x)
Definition: deltaPhi.h:18
float maxAbsPhi()
Definition: datatypes.h:214
const int neta
RawInputs raw
std::vector< DetectorSector< HadCaloObjEmu > > hadcalo
std::vector< DetectorSector< ap_uint< 96 > > > track
RegionizerDecodedInputs decoded
#define M_PI
std::vector< DetectorSector< EmCaloObjEmu > > emcalo
DetectorSector< MuObjEmu > muon
std::vector< DetectorSector< ap_uint< 256 > > > hgcalcluster
std::vector< DetectorSector< TkObjEmu > > track
float maxAbsEta()
Definition: datatypes.h:213
std::vector< PFInputRegion > pfinputs
std::vector< OutputBoard > board_out

◆ produce()

void L1TCorrelatorLayer1Producer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

—— READ TRACKS -—

---— READ MUONS -—

Definition at line 316 of file L1TCorrelatorLayer1Producer.cc.

References a, addEmCalo(), addHadCalo(), addMuon(), addTrack(), addUInt(), b, l1ct::Event::board_out, l1ct::Event::clear(), debugEta_, debugPhi_, debugR_, l1ct::Event::decoded, PbPb_ZMuSkimMuonDPG_cff::deltaR, emCands_, emPtCut_, emuTkVtx_, event_, extTkVtx_, fetchDecodedTracks(), fetchEmCalo(), fetchHadCalo(), fetchPF(), fetchTracks(), fRegionDump_, hadCands_, hadPtCut_, hasTracks_, l1ct::PVObj::hwZ0, mps_fire::i, iEvent, initEvent(), inputTypeName, l1muType, l1pfalgo_, l1pualgo_, l1tkegalgo_, l1tkegsorter_, l1ct::Scales::makeZ0(), SiStripPI::min, eostools::move(), amptDefaultParameters_cff::mu, muCands_, PDWG_BPHSkim_cff::muons, dqmiodumpmetadata::n, l1ct::OutputRegion::nPFTypes, EgHLTOffHistBins_cfi::nr, nVtx_, l1ct::OutputRegion::objTypeName, l1ct::Event::out, patternWriters_, l1ct::Event::pfinputs, putEgObjects(), putEgStaObjects(), putPuppi(), l1ct::Event::pvs, l1ct::Event::pvs_emu, regionizer_, edm::second(), AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::tag, tkCands_, tkVtxEmu_, totAndMax(), pwdgSkimBPark_cfi::tracks, trkPt_, vecOutput(), vecRegInput(), vecSecInput(), l1t::VertexWord::vertexWord(), L1BJetProducer_cff::vtx, l1ct::Event::write(), convertToRaw::writer, HLTMuonOfflineAnalyzer_cfi::z0, and l1t::VertexWord::z0().

316  {
317  // clear the regions also at the beginning, in case one event didn't complete but the job continues on
318  initEvent(iEvent);
319 
321  if (hasTracks_) {
323  iEvent.getByToken(tkCands_, htracks);
324  const auto &tracks = *htracks;
325  for (unsigned int itk = 0, ntk = tracks.size(); itk < ntk; ++itk) {
326  const auto &tk = tracks[itk];
327  // adding objects to PF
328  if (debugR_ > 0 && deltaR(tk.eta(), tk.phi(), debugEta_, debugPhi_) > debugR_)
329  continue;
330  if (tk.pt() > trkPt_) {
331  addTrack(tk, l1t::PFTrackRef(htracks, itk));
332  }
333  }
334  }
335 
338  iEvent.getByToken(muCands_, muons);
339  for (unsigned int i = 0, n = muons->size(); i < n; ++i) {
340  const l1t::SAMuon &mu = (*muons)[i];
341  if (debugR_ > 0 && deltaR(mu.eta(), mu.phi(), debugEta_, debugPhi_) > debugR_)
342  continue;
344  }
345  // ------ READ CALOS -----
347  for (const auto &tag : emCands_) {
348  iEvent.getByToken(tag, caloHandle);
349  const auto &calos = *caloHandle;
350  for (unsigned int ic = 0, nc = calos.size(); ic < nc; ++ic) {
351  const auto &calo = calos[ic];
352  if (debugR_ > 0 && deltaR(calo.eta(), calo.phi(), debugEta_, debugPhi_) > debugR_)
353  continue;
354  if (calo.pt() > emPtCut_)
355  addEmCalo(calo, l1t::PFClusterRef(caloHandle, ic));
356  }
357  }
358  for (const auto &tag : hadCands_) {
359  iEvent.getByToken(tag, caloHandle);
360  const auto &calos = *caloHandle;
361  for (unsigned int ic = 0, nc = calos.size(); ic < nc; ++ic) {
362  const auto &calo = calos[ic];
363  if (debugR_ > 0 && deltaR(calo.eta(), calo.phi(), debugEta_, debugPhi_) > debugR_)
364  continue;
365  if (calo.pt() > hadPtCut_)
366  addHadCalo(calo, l1t::PFClusterRef(caloHandle, ic));
367  }
368  }
369 
371 
372  // First, get a copy of the discretized and corrected inputs, and write them out
373  iEvent.put(fetchEmCalo(), "EmCalo");
374  iEvent.put(fetchHadCalo(), "Calo");
375  iEvent.put(fetchTracks(), "TK");
376  iEvent.put(fetchDecodedTracks(), "DecodedTK");
377 
378  // Then do the vertexing, and save it out
379  std::vector<float> z0s;
380  std::vector<std::pair<float, float>> ptsums;
381  float z0 = 0;
382  double ptsum = 0;
383  l1t::VertexWord pvwd;
384  // FIXME: collections seem to be already sorted
385  if (emuTkVtx_) {
387  iEvent.getByToken(tkVtxEmu_, vtxEmuHandle);
388  for (const auto &vtx : *vtxEmuHandle) {
389  ptsums.push_back(std::pair<float, float>(vtx.pt(), vtx.z0()));
390  if (ptsum == 0 || vtx.pt() > ptsum) {
391  ptsum = vtx.pt();
392  pvwd = vtx;
393  }
394  }
395  } else {
397  iEvent.getByToken(extTkVtx_, vtxHandle);
398  for (const auto &vtx : *vtxHandle) {
399  ptsums.push_back(std::pair<float, float>(vtx.pt(), vtx.z0()));
400  if (ptsum == 0 || vtx.pt() > ptsum) {
401  ptsum = vtx.pt();
402  z0 = vtx.z0();
403  }
404  }
405  pvwd = l1t::VertexWord(1, z0, 1, ptsum, 1, 1, 1);
406  }
407  l1ct::PVObjEmu hwpv;
408  hwpv.hwZ0 = l1ct::Scales::makeZ0(pvwd.z0());
409  event_.pvs.push_back(hwpv);
410  event_.pvs_emu.push_back(pvwd.vertexWord());
411  //Do a quick histogram vertexing to get multiple vertices (Hack for the taus)
412  if (nVtx_ > 1) {
413  std::stable_sort(ptsums.begin(), ptsums.end(), [](const auto &a, const auto &b) { return a.first > b.first; });
414  for (int i0 = 0; i0 < std::min(int(ptsums.size()), int(nVtx_)); i0++) {
415  z0s.push_back(ptsums[i0].second);
416  }
417  for (unsigned int i = 1; i < z0s.size(); ++i) {
418  l1ct::PVObjEmu hwpv;
419  hwpv.hwZ0 = l1ct::Scales::makeZ0(z0s[i]);
420  event_.pvs.push_back(hwpv); //Skip emu
421  }
422  }
423  // Then also save the tracks with a vertex cut
424 #if 0
425  iEvent.put(l1regions_.fetchTracks(/*ptmin=*/0.0, /*fromPV=*/true), "TKVtx");
426 #endif
427 
428  // Then run PF in each region
429  event_.out.resize(event_.pfinputs.size());
430  for (unsigned int ir = 0, nr = event_.pfinputs.size(); ir < nr; ++ir) {
431  l1pfalgo_->run(event_.pfinputs[ir], event_.out[ir]);
432  l1pfalgo_->mergeNeutrals(event_.out[ir]);
433  l1tkegalgo_->run(event_.pfinputs[ir], event_.out[ir]);
434  l1tkegalgo_->runIso(event_.pfinputs[ir], event_.pvs, event_.out[ir]);
435  }
436 
437  // Then run puppi (regionally)
438  for (unsigned int ir = 0, nr = event_.pfinputs.size(); ir < nr; ++ir) {
439  l1pualgo_->run(event_.pfinputs[ir], event_.pvs, event_.out[ir]);
440  //l1pualgo_->runNeutralsPU(l1region, z0, -1., puGlobals);
441  }
442 
443  // NOTE: This needs to happen before the EG sorting per board so that the EG objects
444  // get a global reference to the EGSta before being mixed among differente regions
445  std::vector<edm::Ref<BXVector<l1t::EGamma>>> egsta_refs;
446  if (l1tkegalgo_->writeEgSta()) {
447  putEgStaObjects(iEvent, "L1Eg", egsta_refs);
448  }
449 
450  // l1tkegsorter_->setDebug(true);
451  for (auto &board : event_.board_out) {
452  l1tkegsorter_->runPho(event_.pfinputs, event_.out, board.region_index, board.egphoton);
453  l1tkegsorter_->runEle(event_.pfinputs, event_.out, board.region_index, board.egelectron);
454  }
455 
456  // save PF into the event
457  iEvent.put(fetchPF(), "PF");
458 
459  // and save puppi
460  putPuppi(iEvent);
461 
462  // save the EG objects
463  putEgObjects(iEvent, l1tkegalgo_->writeEgSta(), egsta_refs, "L1TkEm", "L1TkEmPerBoard", "L1TkEle", "L1TkElePerBoard");
464 
465  // Then go do the multiplicities
466  for (int i = 0; i <= l1muType; ++i) {
467  auto vecInputs = vecSecInput(InputType(i));
468  auto tm = totAndMax(*vecInputs);
469  addUInt(tm.first, std::string("totNSec") + inputTypeName[i], iEvent);
470  addUInt(tm.second, std::string("maxNSec") + inputTypeName[i], iEvent);
471  iEvent.put(std::move(vecInputs), std::string("vecNSec") + inputTypeName[i]);
472  }
473  for (int i = 0; i <= l1muType; ++i) {
474  auto vecInputs = vecRegInput(InputType(i));
475  auto tm = totAndMax(*vecInputs);
476  addUInt(tm.first, std::string("totNReg") + inputTypeName[i], iEvent);
477  addUInt(tm.second, std::string("maxNReg") + inputTypeName[i], iEvent);
478  iEvent.put(std::move(vecInputs), std::string("vecNReg") + inputTypeName[i]);
479  }
480  for (int i = 0; i < l1ct::OutputRegion::nPFTypes; ++i) {
481  auto vecPF = vecOutput(OutputType(i), false);
482  auto tmPF = totAndMax(*vecPF);
483  addUInt(tmPF.first, std::string("totNPF") + l1ct::OutputRegion::objTypeName[i], iEvent);
484  addUInt(tmPF.second, std::string("maxNPF") + l1ct::OutputRegion::objTypeName[i], iEvent);
486  auto vecPuppi = vecOutput(OutputType(i), true);
487  auto tmPuppi = totAndMax(*vecPuppi);
488  addUInt(tmPuppi.first, std::string("totNPuppi") + l1ct::OutputRegion::objTypeName[i], iEvent);
489  addUInt(tmPuppi.second, std::string("maxNPuppi") + l1ct::OutputRegion::objTypeName[i], iEvent);
490  iEvent.put(std::move(vecPuppi), std::string("vecNPuppi") + l1ct::OutputRegion::objTypeName[i]);
491  }
492 
493  if (fRegionDump_.is_open()) {
495  }
496  for (auto &writer : patternWriters_) {
497  writer->write(event_);
498  }
499 
500  // finally clear the regions
501  event_.clear();
502 }
edm::EDGetTokenT< std::vector< l1t::VertexWord > > tkVtxEmu_
std::vector< PVObjEmu > pvs
z0_t makeZ0(float z0)
Definition: datatypes.h:184
edm::EDGetTokenT< std::vector< l1t::Vertex > > extTkVtx_
edm::EDGetTokenT< l1t::PFTrackCollection > tkCands_
std::vector< std::unique_ptr< L1TCorrelatorLayer1PatternFileWriter > > patternWriters_
std::unique_ptr< std::vector< l1t::PFTrack > > fetchDecodedTracks() const
std::vector< OutputRegion > out
l1ct::OutputRegion::ObjType OutputType
std::vector< edm::EDGetTokenT< l1t::PFClusterCollection > > hadCands_
std::unique_ptr< l1ct::PFAlgoEmulatorBase > l1pfalgo_
std::unique_ptr< l1ct::PFTkEGAlgoEmulator > l1tkegalgo_
void putPuppi(edm::Event &iEvent) const
void addEmCalo(const l1t::PFCluster &t, l1t::PFClusterRef ref)
U second(std::pair< T, U > const &p)
std::unique_ptr< l1t::PFCandidateCollection > fetchTracks() const
void addMuon(const l1t::SAMuon &t, l1t::PFCandidate::MuonRef ref)
int iEvent
Definition: GenABIO.cc:224
void addTrack(const l1t::PFTrack &t, l1t::PFTrackRef ref)
bool write(std::fstream &to) const
std::unique_ptr< l1ct::RegionizerEmulator > regionizer_
std::vector< edm::EDGetTokenT< l1t::PFClusterCollection > > emCands_
edm::EDGetTokenT< l1t::SAMuonCollection > muCands_
static constexpr const char * inputTypeName[l1muType+1]
std::unique_ptr< l1t::PFCandidateCollection > fetchHadCalo() const
std::unique_ptr< l1ct::LinPuppiEmulator > l1pualgo_
void addHadCalo(const l1t::PFCluster &t, l1t::PFClusterRef ref)
std::unique_ptr< std::vector< unsigned > > vecRegInput(InputType i) const
RegionizerDecodedInputs decoded
std::unique_ptr< l1t::PFCandidateCollection > fetchEmCalo() const
std::unique_ptr< l1t::PFCandidateCollection > fetchPF() const
void putEgObjects(edm::Event &iEvent, const bool writeEgSta, const std::vector< edm::Ref< BXVector< l1t::EGamma >>> &egsta_refs, const std::string &tkEmLabel, const std::string &tkEmPerBoardLabel, const std::string &tkEleLabel, const std::string &tkElePerBoardLabel) const
std::unique_ptr< std::vector< unsigned > > vecOutput(OutputType i, bool usePuppi) const
void putEgStaObjects(edm::Event &iEvent, const std::string &egLablel, std::vector< edm::Ref< BXVector< l1t::EGamma >>> &egsta_refs)
std::unique_ptr< l1ct::PFTkEGSorterEmulator > l1tkegsorter_
double b
Definition: hdecay.h:120
static constexpr const char * objTypeName[nObjTypes]
double z0() const
Definition: VertexWord.h:158
double a
Definition: hdecay.h:121
std::pair< unsigned int, unsigned int > totAndMax(const std::vector< unsigned > &perRegion) const
std::vector< ap_uint< 64 > > pvs_emu
vtxword_t vertexWord() const
Definition: VertexWord.h:143
def move(src, dest)
Definition: eostools.py:511
void clear()
Definition: Common.h:9
std::unique_ptr< std::vector< unsigned > > vecSecInput(InputType i) const
void addUInt(unsigned int value, std::string iLabel, edm::Event &iEvent)
std::vector< PFInputRegion > pfinputs
std::vector< OutputBoard > board_out

◆ putEgObjects()

void L1TCorrelatorLayer1Producer::putEgObjects ( edm::Event iEvent,
const bool  writeEgSta,
const std::vector< edm::Ref< BXVector< l1t::EGamma >>> &  egsta_refs,
const std::string &  tkEmLabel,
const std::string &  tkEmPerBoardLabel,
const std::string &  tkEleLabel,
const std::string &  tkElePerBoardLabel 
) const
private

Definition at line 1039 of file L1TCorrelatorLayer1Producer.cc.

References l1ct::Event::board_out, event_, iEvent, eostools::move(), edm::refToPtr(), and l1t::L1Candidate::setHwQual().

Referenced by produce().

1045  {
1046  auto tkems = std::make_unique<l1t::TkEmCollection>();
1047  auto tkemRefProd = iEvent.getRefBeforePut<l1t::TkEmCollection>(tkEmLabel);
1048  auto tkemPerBoard = std::make_unique<l1t::TkEmRegionalOutput>(tkemRefProd);
1049  auto tkeles = std::make_unique<l1t::TkElectronCollection>();
1050  auto tkeleRefProd = iEvent.getRefBeforePut<l1t::TkElectronCollection>(tkEleLabel);
1051  auto tkelePerBoard = std::make_unique<l1t::TkElectronRegionalOutput>(tkeleRefProd);
1052 
1053  // TkEG objects are written out after the per-board sorting.
1054  // The mapping to each board is saved into the regionalmap for further (stage-2 consumption)
1055  std::vector<int> nele_obj;
1056  std::vector<int> npho_obj;
1057 
1058  for (const auto &board : event_.board_out) {
1059  npho_obj.clear();
1060  for (const auto &egiso : board.egphoton) {
1061  if (egiso.hwPt == 0)
1062  continue;
1063 
1064  edm::Ref<BXVector<l1t::EGamma>> ref_egsta;
1065  if (writeEgSta) {
1066  ref_egsta = egsta_refs[egiso.sta_idx];
1067  } else {
1068  auto egptr = egiso.srcCluster->constituentsAndFractions()[0].first;
1069  ref_egsta =
1070  edm::Ref<BXVector<l1t::EGamma>>(egptr.id(), dynamic_cast<const l1t::EGamma *>(egptr.get()), egptr.key());
1071  }
1072 
1073  reco::Candidate::PolarLorentzVector mom(egiso.floatPt(), egiso.floatEta(), egiso.floatPhi(), 0.);
1074 
1076  ref_egsta,
1077  egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIso),
1078  egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIsoPV));
1079  tkem.setHwQual(egiso.hwQual);
1080  tkem.setPFIsol(egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::PfIso));
1081  tkem.setPFIsolPV(egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::PfIsoPV));
1082  tkem.setEgBinaryWord(egiso.pack());
1083  tkems->push_back(tkem);
1084  npho_obj.push_back(tkems->size() - 1);
1085  }
1086  tkemPerBoard->addRegion(npho_obj, board.eta, board.phi);
1087 
1088  nele_obj.clear();
1089  for (const auto &egele : board.egelectron) {
1090  if (egele.hwPt == 0)
1091  continue;
1092 
1093  edm::Ref<BXVector<l1t::EGamma>> ref_egsta;
1094  if (writeEgSta) {
1095  ref_egsta = egsta_refs[egele.sta_idx];
1096  } else {
1097  auto egptr = egele.srcCluster->constituentsAndFractions()[0].first;
1098  ref_egsta =
1099  edm::Ref<BXVector<l1t::EGamma>>(egptr.id(), dynamic_cast<const l1t::EGamma *>(egptr.get()), egptr.key());
1100  }
1101 
1102  reco::Candidate::PolarLorentzVector mom(egele.floatPt(), egele.floatEta(), egele.floatPhi(), 0.);
1103 
1105  ref_egsta,
1106  edm::refToPtr(egele.srcTrack->track()),
1107  egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::TkIso));
1108  tkele.setHwQual(egele.hwQual);
1109  tkele.setPFIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PfIso));
1110  tkele.setEgBinaryWord(egele.pack());
1111  tkele.setIdScore(egele.idScore);
1112  tkeles->push_back(tkele);
1113  nele_obj.push_back(tkeles->size() - 1);
1114  }
1115  tkelePerBoard->addRegion(nele_obj, board.eta, board.phi);
1116  }
1117 
1118  iEvent.put(std::move(tkems), tkEmLabel);
1119  iEvent.put(std::move(tkemPerBoard), tkEmPerBoardLabel);
1120  iEvent.put(std::move(tkeles), tkEleLabel);
1121  iEvent.put(std::move(tkelePerBoard), tkElePerBoardLabel);
1122 }
std::vector< TkElectron > TkElectronCollection
Definition: TkElectronFwd.h:16
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
void setHwQual(int qual)
Definition: L1Candidate.h:31
std::vector< TkEm > TkEmCollection
Definition: TkEmFwd.h:17
int iEvent
Definition: GenABIO.cc:224
Definition: TkEm.h:20
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
def move(src, dest)
Definition: eostools.py:511
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38
std::vector< OutputBoard > board_out

◆ putEgStaObjects()

void L1TCorrelatorLayer1Producer::putEgStaObjects ( edm::Event iEvent,
const std::string &  egLablel,
std::vector< edm::Ref< BXVector< l1t::EGamma >>> &  egsta_refs 
)
private

Definition at line 996 of file L1TCorrelatorLayer1Producer.cc.

References event_, heavyIonCSV_trainingSettings::idx, iEvent, eostools::move(), EgHLTOffHistBins_cfi::nr, l1ct::Event::out, AlCaHLTBitMon_ParallelJobs::p, l1ct::Event::pfinputs, and l1t::L1Candidate::setHwQual().

Referenced by produce().

998  {
999  auto egs = std::make_unique<BXVector<l1t::EGamma>>();
1000  edm::RefProd<BXVector<l1t::EGamma>> ref_egs = iEvent.getRefBeforePut<BXVector<l1t::EGamma>>(egLablel);
1001 
1002  edm::Ref<BXVector<l1t::EGamma>>::key_type idx = 0;
1003  // FIXME: in case more BXes are introduced shuld probably use egs->key(egs->end(bx));
1004 
1005  for (unsigned int ir = 0, nr = event_.pfinputs.size(); ir < nr; ++ir) {
1006  const auto &reg = event_.pfinputs[ir].region;
1007 
1008  std::vector<unsigned int> ref_pos(event_.out[ir].egsta.size());
1009 
1010  // EG standalone objects
1011  for (unsigned int ieg = 0, neg = event_.out[ir].egsta.size(); ieg < neg; ++ieg) {
1012  const auto &p = event_.out[ir].egsta[ieg];
1013  if (p.hwPt == 0 || !reg.isFiducial(p))
1014  continue;
1015  l1t::EGamma eg(
1016  reco::Candidate::PolarLorentzVector(p.floatPt(), reg.floatGlbEta(p.hwEta), reg.floatGlbPhi(p.hwPhi), 0.));
1017  eg.setHwQual(p.hwQual);
1018  egs->push_back(0, eg);
1019  egsta_refs.push_back(edm::Ref<BXVector<l1t::EGamma>>(ref_egs, idx++));
1020  ref_pos[ieg] = egsta_refs.size() - 1;
1021  }
1022 
1023  for (auto &egiso : event_.out[ir].egphoton) {
1024  if (egiso.hwPt == 0)
1025  continue;
1026  egiso.sta_idx = ref_pos[egiso.sta_idx];
1027  }
1028 
1029  for (auto &egele : event_.out[ir].egelectron) {
1030  if (egele.hwPt == 0)
1031  continue;
1032  egele.sta_idx = ref_pos[egele.sta_idx];
1033  }
1034  }
1035 
1036  iEvent.put(std::move(egs), egLablel);
1037 }
void setHwQual(int qual)
Definition: L1Candidate.h:31
std::vector< OutputRegion > out
int iEvent
Definition: GenABIO.cc:224
def move(src, dest)
Definition: eostools.py:511
std::vector< PFInputRegion > pfinputs
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38

◆ putPuppi()

void L1TCorrelatorLayer1Producer::putPuppi ( edm::Event iEvent) const
private

Definition at line 946 of file L1TCorrelatorLayer1Producer.cc.

References l1t::PFCandidate::ChargedHadron, l1t::PFCandidate::Electron, event_, iEvent, EgHLTOffHistBins_cfi::mass, eostools::move(), l1t::PFCandidate::Muon, l1t::PFCandidate::NeutralHadron, EgHLTOffHistBins_cfi::nr, l1ct::Event::out, AlCaHLTBitMon_ParallelJobs::p, l1ct::Event::pfinputs, l1t::PFCandidate::Photon, and setRefs_().

Referenced by produce().

946  {
947  auto refprod = iEvent.getRefBeforePut<l1t::PFCandidateCollection>("Puppi");
948  auto coll = std::make_unique<l1t::PFCandidateCollection>();
949  auto reg = std::make_unique<l1t::PFCandidateRegionalOutput>(refprod);
950  std::vector<int> nobj;
951  for (unsigned int ir = 0, nr = event_.pfinputs.size(); ir < nr; ++ir) {
952  nobj.clear();
953  for (const auto &p : event_.out[ir].puppi) {
954  if (p.hwPt == 0)
955  continue;
956  // note: Puppi candidates are already in global coordinates & fiducial-only!
958  float mass = 0.13f;
959  if (p.hwId.charged()) {
960  if (p.hwId.isMuon()) {
962  mass = 0.105;
963  } else if (p.hwId.isElectron()) {
965  mass = 0.005;
966  } else
968  } else {
970  mass = p.hwId.isPhoton() ? 0.0 : 0.5;
971  }
972  reco::Particle::PolarLorentzVector p4(p.floatPt(), p.floatEta(), p.floatPhi(), mass);
973  coll->emplace_back(type, p.intCharge(), p4, p.floatPuppiW(), p.intPt(), p.intEta(), p.intPhi());
974  if (p.hwId.charged()) {
975  coll->back().setZ0(p.floatZ0());
976  coll->back().setDxy(p.floatDxy());
977  coll->back().setHwZ0(p.hwZ0());
978  coll->back().setHwDxy(p.hwDxy());
979  coll->back().setHwTkQuality(p.hwTkQuality());
980  } else {
981  coll->back().setHwPuppiWeight(p.hwPuppiW());
982  coll->back().setHwEmID(p.hwEmID());
983  }
984  coll->back().setEncodedPuppi64(p.pack().to_uint64());
985  setRefs_(coll->back(), p);
986  nobj.push_back(coll->size() - 1);
987  }
988  reg->addRegion(nobj, event_.pfinputs[ir].region.floatEtaCenter(), event_.pfinputs[ir].region.floatPhiCenter());
989  }
990  iEvent.put(std::move(coll), "Puppi");
991  iEvent.put(std::move(reg), "PuppiRegional");
992 }
void setRefs_(l1t::PFCandidate &pf, const T &p) const
std::vector< l1t::PFCandidate > PFCandidateCollection
Definition: PFCandidate.h:86
std::vector< OutputRegion > out
int iEvent
Definition: GenABIO.cc:224
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Particle.h:23
def move(src, dest)
Definition: eostools.py:511
std::vector< PFInputRegion > pfinputs

◆ setRefs_()

template<typename T >
void L1TCorrelatorLayer1Producer::setRefs_ ( l1t::PFCandidate pf,
const T p 
) const
private

Definition at line 749 of file L1TCorrelatorLayer1Producer.cc.

References clusterRefMap_, Exception, match(), muonRefMap_, AlCaHLTBitMon_ParallelJobs::p, packedPFCandidateRefMixer_cfi::pf, and trackRefMap_.

Referenced by fetchEmCalo(), fetchHadCalo(), fetchPF(), fetchTracks(), and putPuppi().

749  {
750  if (p.srcCluster) {
751  auto match = clusterRefMap_.find(p.srcCluster);
752  if (match == clusterRefMap_.end()) {
753  throw cms::Exception("CorruptData") << "Invalid cluster pointer in PF candidate id " << p.intId() << " pt "
754  << p.floatPt() << " eta " << p.floatEta() << " phi " << p.floatPhi();
755  }
756  pf.setPFCluster(match->second);
757  }
758  if (p.srcTrack) {
759  auto match = trackRefMap_.find(p.srcTrack);
760  if (match == trackRefMap_.end()) {
761  throw cms::Exception("CorruptData") << "Invalid track pointer in PF candidate id " << p.intId() << " pt "
762  << p.floatPt() << " eta " << p.floatEta() << " phi " << p.floatPhi();
763  }
764  pf.setPFTrack(match->second);
765  }
766  if (p.srcMu) {
767  auto match = muonRefMap_.find(p.srcMu);
768  if (match == muonRefMap_.end()) {
769  throw cms::Exception("CorruptData") << "Invalid muon pointer in PF candidate id " << p.intId() << " pt "
770  << p.floatPt() << " eta " << p.floatEta() << " phi " << p.floatPhi();
771  }
772  pf.setMuon(match->second);
773  }
774 }
std::unordered_map< const l1t::PFTrack *, l1t::PFTrackRef > trackRefMap_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
std::unordered_map< const l1t::SAMuon *, l1t::PFCandidate::MuonRef > muonRefMap_
std::unordered_map< const l1t::PFCluster *, l1t::PFClusterRef > clusterRefMap_

◆ totAndMax()

std::pair< unsigned int, unsigned int > L1TCorrelatorLayer1Producer::totAndMax ( const std::vector< unsigned > &  perRegion) const
private

Definition at line 1176 of file L1TCorrelatorLayer1Producer.cc.

References SiStripPI::max, and gpuPixelDoublets::ntot.

Referenced by produce().

1177  {
1178  unsigned int ntot = 0, nmax = 0;
1179  for (unsigned ni : perRegion) {
1180  ntot += ni;
1181  nmax = std::max(nmax, ni);
1182  }
1183  return std::make_pair(ntot, nmax);
1184 }
__shared__ uint32_t ntot

◆ vecOutput()

std::unique_ptr< std::vector< unsigned > > L1TCorrelatorLayer1Producer::vecOutput ( OutputType  i,
bool  usePuppi 
) const
private

Definition at line 1169 of file L1TCorrelatorLayer1Producer.cc.

References event_, mps_fire::i, l1ct::Event::out, and findQualityFiles::v.

Referenced by produce().

1169  {
1170  auto v = std::make_unique<std::vector<unsigned>>();
1171  for (const auto &reg : event_.out) {
1172  v->push_back(reg.nObj(i, usePuppi));
1173  }
1174  return v;
1175 }
std::vector< OutputRegion > out

◆ vecRegInput()

std::unique_ptr< std::vector< unsigned > > L1TCorrelatorLayer1Producer::vecRegInput ( InputType  i) const
private

Definition at line 1148 of file L1TCorrelatorLayer1Producer.cc.

References caloType, emcaloType, event_, l1muType, l1ct::Event::pfinputs, submitPVValidationJobs::t, trackType, and findQualityFiles::v.

Referenced by produce().

1148  {
1149  auto v = std::make_unique<std::vector<unsigned>>();
1150  for (const auto &reg : event_.pfinputs) {
1151  switch (t) {
1152  case caloType:
1153  v->push_back(reg.hadcalo.size());
1154  break;
1155  case emcaloType:
1156  v->push_back(reg.emcalo.size());
1157  break;
1158  case trackType:
1159  v->push_back(reg.track.size());
1160  break;
1161  case l1muType:
1162  v->push_back(reg.muon.size());
1163  break;
1164  }
1165  }
1166  return v;
1167 }
std::vector< PFInputRegion > pfinputs

◆ vecSecInput()

std::unique_ptr< std::vector< unsigned > > L1TCorrelatorLayer1Producer::vecSecInput ( InputType  i) const
private

Definition at line 1124 of file L1TCorrelatorLayer1Producer.cc.

References caloType, l1ct::Event::decoded, l1ct::RegionizerDecodedInputs::emcalo, emcaloType, event_, l1ct::RegionizerDecodedInputs::hadcalo, l1muType, l1ct::RegionizerDecodedInputs::muon, alignCSCRings::s, submitPVValidationJobs::t, l1ct::RegionizerDecodedInputs::track, trackType, and findQualityFiles::v.

Referenced by produce().

1124  {
1125  auto v = std::make_unique<std::vector<unsigned>>();
1126  {
1127  switch (t) {
1128  case caloType:
1129  for (const auto &s : event_.decoded.hadcalo)
1130  v->push_back(s.size());
1131  break;
1132  case emcaloType:
1133  for (const auto &s : event_.decoded.emcalo)
1134  v->push_back(s.size());
1135  break;
1136  case trackType:
1137  for (const auto &s : event_.decoded.track)
1138  v->push_back(s.size());
1139  break;
1140  case l1muType:
1141  v->push_back(event_.decoded.muon.size());
1142  break;
1143  }
1144  }
1145  return v;
1146 }
std::vector< DetectorSector< HadCaloObjEmu > > hadcalo
RegionizerDecodedInputs decoded
std::vector< DetectorSector< EmCaloObjEmu > > emcalo
DetectorSector< MuObjEmu > muon
std::vector< DetectorSector< TkObjEmu > > track

Member Data Documentation

◆ clusterRefMap_

std::unordered_map<const l1t::PFCluster *, l1t::PFClusterRef> L1TCorrelatorLayer1Producer::clusterRefMap_
private

Definition at line 87 of file L1TCorrelatorLayer1Producer.cc.

Referenced by addEmCalo(), addHadCalo(), initEvent(), and setRefs_().

◆ config_

edm::ParameterSet L1TCorrelatorLayer1Producer::config_
private

Definition at line 50 of file L1TCorrelatorLayer1Producer.cc.

◆ debugEta_

float L1TCorrelatorLayer1Producer::debugEta_
private

Definition at line 84 of file L1TCorrelatorLayer1Producer.cc.

Referenced by produce().

◆ debugPhi_

float L1TCorrelatorLayer1Producer::debugPhi_
private

Definition at line 84 of file L1TCorrelatorLayer1Producer.cc.

Referenced by produce().

◆ debugR_

float L1TCorrelatorLayer1Producer::debugR_
private

Definition at line 84 of file L1TCorrelatorLayer1Producer.cc.

Referenced by produce().

◆ emCands_

std::vector<edm::EDGetTokenT<l1t::PFClusterCollection> > L1TCorrelatorLayer1Producer::emCands_
private

Definition at line 62 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ emPtCut_

float L1TCorrelatorLayer1Producer::emPtCut_
private

Definition at line 65 of file L1TCorrelatorLayer1Producer.cc.

Referenced by produce().

◆ emuTkVtx_

bool L1TCorrelatorLayer1Producer::emuTkVtx_
private

Definition at line 55 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ event_

l1ct::Event L1TCorrelatorLayer1Producer::event_
private

◆ extTkVtx_

edm::EDGetTokenT<std::vector<l1t::Vertex> > L1TCorrelatorLayer1Producer::extTkVtx_
private

Definition at line 56 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ fRegionDump_

std::fstream L1TCorrelatorLayer1Producer::fRegionDump_
private

Definition at line 79 of file L1TCorrelatorLayer1Producer.cc.

Referenced by beginStream(), and produce().

◆ hadCands_

std::vector<edm::EDGetTokenT<l1t::PFClusterCollection> > L1TCorrelatorLayer1Producer::hadCands_
private

Definition at line 63 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ hadPtCut_

float L1TCorrelatorLayer1Producer::hadPtCut_
private

Definition at line 65 of file L1TCorrelatorLayer1Producer.cc.

Referenced by produce().

◆ hasTracks_

bool L1TCorrelatorLayer1Producer::hasTracks_
private

Definition at line 52 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ inputTypeName

constexpr const char* L1TCorrelatorLayer1Producer::inputTypeName[l1muType+1] = {"Calo", "EmCalo", "TK", "Mu"}
staticprivate

Definition at line 137 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ l1pfalgo_

std::unique_ptr<l1ct::PFAlgoEmulatorBase> L1TCorrelatorLayer1Producer::l1pfalgo_
private

Definition at line 71 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ l1pualgo_

std::unique_ptr<l1ct::LinPuppiEmulator> L1TCorrelatorLayer1Producer::l1pualgo_
private

Definition at line 72 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ l1tkegalgo_

std::unique_ptr<l1ct::PFTkEGAlgoEmulator> L1TCorrelatorLayer1Producer::l1tkegalgo_
private

Definition at line 73 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ l1tkegsorter_

std::unique_ptr<l1ct::PFTkEGSorterEmulator> L1TCorrelatorLayer1Producer::l1tkegsorter_
private

Definition at line 74 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ muCands_

edm::EDGetTokenT<l1t::SAMuonCollection> L1TCorrelatorLayer1Producer::muCands_
private

Definition at line 60 of file L1TCorrelatorLayer1Producer.cc.

Referenced by produce().

◆ muonInput_

std::unique_ptr<l1ct::GMTMuonDecoderEmulator> L1TCorrelatorLayer1Producer::muonInput_
private

Definition at line 69 of file L1TCorrelatorLayer1Producer.cc.

Referenced by addDecodedMuon(), and L1TCorrelatorLayer1Producer().

◆ muonRefMap_

std::unordered_map<const l1t::SAMuon *, l1t::PFCandidate::MuonRef> L1TCorrelatorLayer1Producer::muonRefMap_
private

Definition at line 89 of file L1TCorrelatorLayer1Producer.cc.

Referenced by addMuon(), initEvent(), and setRefs_().

◆ nVtx_

int L1TCorrelatorLayer1Producer::nVtx_
private

Definition at line 58 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ patternWriterConfigs_

const std::vector<edm::ParameterSet> L1TCorrelatorLayer1Producer::patternWriterConfigs_
private

Definition at line 80 of file L1TCorrelatorLayer1Producer.cc.

Referenced by beginStream().

◆ patternWriters_

std::vector<std::unique_ptr<L1TCorrelatorLayer1PatternFileWriter> > L1TCorrelatorLayer1Producer::patternWriters_
private

Definition at line 81 of file L1TCorrelatorLayer1Producer.cc.

Referenced by beginStream(), endStream(), and produce().

◆ regionDumpName_

const std::string L1TCorrelatorLayer1Producer::regionDumpName_
private

Definition at line 77 of file L1TCorrelatorLayer1Producer.cc.

Referenced by beginStream().

◆ regionizer_

std::unique_ptr<l1ct::RegionizerEmulator> L1TCorrelatorLayer1Producer::regionizer_
private

Definition at line 70 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ tkCands_

edm::EDGetTokenT<l1t::PFTrackCollection> L1TCorrelatorLayer1Producer::tkCands_
private

Definition at line 53 of file L1TCorrelatorLayer1Producer.cc.

Referenced by produce().

◆ tkVtxEmu_

edm::EDGetTokenT<std::vector<l1t::VertexWord> > L1TCorrelatorLayer1Producer::tkVtxEmu_
private

Definition at line 57 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ trackInput_

std::unique_ptr<l1ct::TrackInputEmulator> L1TCorrelatorLayer1Producer::trackInput_
private

Definition at line 68 of file L1TCorrelatorLayer1Producer.cc.

Referenced by addDecodedTrack(), and L1TCorrelatorLayer1Producer().

◆ trackRefMap_

std::unordered_map<const l1t::PFTrack *, l1t::PFTrackRef> L1TCorrelatorLayer1Producer::trackRefMap_
private

Definition at line 88 of file L1TCorrelatorLayer1Producer.cc.

Referenced by addTrack(), initEvent(), and setRefs_().

◆ trkPt_

float L1TCorrelatorLayer1Producer::trkPt_
private

Definition at line 54 of file L1TCorrelatorLayer1Producer.cc.

Referenced by produce().

◆ writeRawHgcalCluster_

bool L1TCorrelatorLayer1Producer::writeRawHgcalCluster_
private

Definition at line 78 of file L1TCorrelatorLayer1Producer.cc.

Referenced by addHadCalo().