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< 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 writeEgSta_
 
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 43 of file L1TCorrelatorLayer1Producer.cc.

Member Typedef Documentation

◆ OutputType

Definition at line 139 of file L1TCorrelatorLayer1Producer.cc.

Member Enumeration Documentation

◆ InputType

Constructor & Destructor Documentation

◆ L1TCorrelatorLayer1Producer()

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

Definition at line 147 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, regionizer_, AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::tag, tkVtxEmu_, and trackInput_.

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

273 {}

Member Function Documentation

◆ addDecodedEmCalo()

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

Definition at line 701 of file L1TCorrelatorLayer1Producer.cc.

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

Referenced by addEmCalo().

702  {
704  calo.hwPt = l1ct::Scales::makePtFromFloat(c.pt());
705  calo.hwEta = l1ct::Scales::makeGlbEta(c.eta()) -
706  sec.region.hwEtaCenter; // important to enforce that the region boundary is on a discrete value
707  calo.hwPhi = l1ct::Scales::makePhi(sec.region.localPhi(c.phi()));
708  calo.hwPtErr = l1ct::Scales::makePtFromFloat(c.ptError());
709  calo.hwEmID = c.hwEmID();
710  calo.src = &c;
711  sec.obj.push_back(calo);
712 }
glbeta_t makeGlbEta(float eta)
Definition: datatypes.h:190
pt_t makePtFromFloat(float pt)
Definition: datatypes.h:170
phi_t makePhi(float phi)
Definition: datatypes.h:188
Definition: Common.h:9

◆ addDecodedHadCalo()

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

Definition at line 670 of file L1TCorrelatorLayer1Producer.cc.

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

Referenced by addHadCalo().

671  {
673  calo.hwPt = l1ct::Scales::makePtFromFloat(c.pt());
674  calo.hwEta = l1ct::Scales::makeGlbEta(c.eta()) -
675  sec.region.hwEtaCenter; // important to enforce that the region boundary is on a discrete value
676  calo.hwPhi = l1ct::Scales::makePhi(sec.region.localPhi(c.phi()));
677  calo.hwEmPt = l1ct::Scales::makePtFromFloat(c.emEt());
678  calo.hwEmID = c.hwEmID();
679  calo.src = &c;
680  sec.obj.push_back(calo);
681 }
glbeta_t makeGlbEta(float eta)
Definition: datatypes.h:190
pt_t makePtFromFloat(float pt)
Definition: datatypes.h:170
phi_t makePhi(float phi)
Definition: datatypes.h:188
Definition: Common.h:9

◆ addDecodedMuon()

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

Definition at line 651 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().

651  {
653  if (muonInput_) {
654  mu = muonInput_->decode(t.word());
655  } else {
656  mu.hwPt = l1ct::Scales::makePtFromFloat(t.pt());
657  mu.hwEta = l1ct::Scales::makeGlbEta(t.eta()); // IMPORTANT: input is in global coordinates!
658  mu.hwPhi = l1ct::Scales::makeGlbPhi(t.phi());
659  mu.hwCharge = !t.hwCharge();
660  mu.hwQuality = t.hwQual() / 2;
661  mu.hwDEta = 0;
662  mu.hwDPhi = 0;
663  mu.hwZ0 = l1ct::Scales::makeZ0(t.vertex().Z());
664  mu.hwDxy = 0; // Dxy not defined yet
665  }
666  mu.src = &t;
667  sec.obj.push_back(mu);
668 }
glbeta_t makeGlbEta(float eta)
Definition: datatypes.h:190
z0_t makeZ0(float z0)
Definition: datatypes.h:172
glbphi_t makeGlbPhi(float phi)
Definition: datatypes.h:193
pt_t makePtFromFloat(float pt)
Definition: datatypes.h:170
std::unique_ptr< l1ct::GMTMuonDecoderEmulator > muonInput_

◆ addDecodedTrack()

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

Definition at line 615 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().

615  {
616  std::pair<l1ct::TkObjEmu, bool> tkAndSel;
617  if (trackInput_) {
618  tkAndSel = trackInput_->decodeTrack(t.trackWord().getTrackWord(), sec.region);
619  } else {
620  tkAndSel.first.hwPt = l1ct::Scales::makePtFromFloat(t.pt());
621  tkAndSel.first.hwEta =
622  l1ct::Scales::makeGlbEta(t.caloEta()) -
623  sec.region.hwEtaCenter; // important to enforce that the region boundary is on a discrete value
624  tkAndSel.first.hwPhi = l1ct::Scales::makePhi(sec.region.localPhi(t.caloPhi()));
625  tkAndSel.first.hwCharge = t.charge() > 0;
626  tkAndSel.first.hwQuality = t.quality();
627  tkAndSel.first.hwDEta = l1ct::Scales::makeEta(t.eta() - t.caloEta());
628  tkAndSel.first.hwDPhi = l1ct::Scales::makePhi(std::abs(reco::deltaPhi(t.phi(), t.caloPhi())));
629  tkAndSel.first.hwZ0 = l1ct::Scales::makeZ0(t.vertex().Z());
630  tkAndSel.first.hwDxy = 0;
631  tkAndSel.second = t.quality() > 0;
632  }
633  // CMSSW-only extra info
634  tkAndSel.first.hwChi2 = round(t.chi2() * 10);
635  tkAndSel.first.hwStubs = t.nStubs();
636  tkAndSel.first.simPt = t.pt();
637  tkAndSel.first.simCaloEta = t.caloEta();
638  tkAndSel.first.simCaloPhi = t.caloPhi();
639  tkAndSel.first.simVtxEta = t.eta();
640  tkAndSel.first.simVtxPhi = t.phi();
641  tkAndSel.first.simZ0 = t.vertex().Z();
642  tkAndSel.first.simD0 = t.vertex().Rho();
643  tkAndSel.first.src = &t;
644  // If the track fails, we set its pT to zero, so that the decoded tracks are still aligned with the raw tracks
645  // Downstream, the regionizer will just ignore zero-momentum tracks
646  if (!tkAndSel.second)
647  tkAndSel.first.hwPt = 0;
648  sec.obj.push_back(tkAndSel.first);
649 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
glbeta_t makeGlbEta(float eta)
Definition: datatypes.h:190
z0_t makeZ0(float z0)
Definition: datatypes.h:172
pt_t makePtFromFloat(float pt)
Definition: datatypes.h:170
eta_t makeEta(float eta)
Definition: datatypes.h:189
std::unique_ptr< l1ct::TrackInputEmulator > trackInput_
phi_t makePhi(float phi)
Definition: datatypes.h:188
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 606 of file L1TCorrelatorLayer1Producer.cc.

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

Referenced by produce().

606  {
607  for (auto &sec : event_.decoded.emcalo) {
608  if (sec.region.contains(c.eta(), c.phi())) {
610  }
611  }
612  clusterRefMap_[&c] = ref;
613 }
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 594 of file L1TCorrelatorLayer1Producer.cc.

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

Referenced by produce().

594  {
595  int sidx = 0;
596  for (auto &sec : event_.decoded.hadcalo) {
597  if (sec.region.contains(c.eta(), c.phi())) {
601  }
602  sidx++;
603  }
604  clusterRefMap_[&c] = ref;
605 }
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 589 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().

589  {
590  event_.raw.muon.obj.emplace_back(mu.word());
592  muonRefMap_[&mu] = ref;
593 }
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 683 of file L1TCorrelatorLayer1Producer.cc.

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

Referenced by addHadCalo().

683  {
684  ap_uint<256> cwrd = 0;
685  ap_uint<14> w_pt = round(c.pt() / 0.25);
686  ap_uint<14> w_empt = round(c.emEt() / 0.25);
687  constexpr float ETAPHI_LSB = M_PI / 720;
688  ap_int<9> w_eta = round(sec.region.localEta(c.eta()) / ETAPHI_LSB);
689  ap_int<9> w_phi = round(sec.region.localPhi(c.phi()) / ETAPHI_LSB);
690  ap_uint<10> w_qual = c.hwQual();
691 
692  cwrd(13, 0) = w_pt;
693  cwrd(27, 14) = w_empt;
694  cwrd(72, 64) = w_eta;
695  cwrd(81, 73) = w_phi;
696  cwrd(115, 106) = w_qual;
697 
698  sec.obj.push_back(cwrd);
699 }
constexpr float ETAPHI_LSB
Definition: datatypes.h:148
#define M_PI

◆ addTrack()

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

Definition at line 580 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().

580  {
581  auto &rawsectors = event_.raw.track;
582  auto &sectors = event_.decoded.track;
583  assert(sectors.size() == 18 && rawsectors.size() == 18);
584  int isec = t.track()->phiSector() + (t.eta() >= 0 ? 9 : 0);
585  rawsectors[isec].obj.push_back(t.trackWord().getTrackWord());
586  addDecodedTrack(sectors[isec], t);
587  trackRefMap_[&t] = ref;
588 }
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 490 of file L1TCorrelatorLayer1Producer.cc.

References iEvent.

Referenced by produce().

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

◆ beginStream()

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

Definition at line 275 of file L1TCorrelatorLayer1Producer.cc.

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

275  {
276  if (!regionDumpName_.empty()) {
277  if (id == 0) {
278  fRegionDump_.open(regionDumpName_.c_str(), std::ios::out | std::ios::binary);
279  } else {
280  edm::LogWarning("L1TCorrelatorLayer1Producer")
281  << "Job running with multiple streams, but dump file will have only events on stream zero.";
282  }
283  }
284  if (!patternWriterConfigs_.empty()) {
285  if (id == 0) {
286  for (const auto &pset : patternWriterConfigs_) {
287  patternWriters_.emplace_back(std::make_unique<L1TCorrelatorLayer1PatternFileWriter>(pset, event_));
288  }
289  } else {
290  edm::LogWarning("L1TCorrelatorLayer1Producer")
291  << "Job running with multiple streams, but pattern files will be written only on stream zero.";
292  }
293  }
294 }
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 296 of file L1TCorrelatorLayer1Producer.cc.

References patternWriters_, and convertToRaw::writer.

296  {
297  for (auto &writer : patternWriters_) {
298  writer->flush();
299  }
300 }
std::vector< std::unique_ptr< L1TCorrelatorLayer1PatternFileWriter > > patternWriters_

◆ fetchEmCalo()

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

Definition at line 809 of file L1TCorrelatorLayer1Producer.cc.

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

Referenced by produce().

809  {
810  auto ret = std::make_unique<l1t::PFCandidateCollection>();
811  for (const auto &r : event_.pfinputs) {
812  const auto &reg = r.region;
813  for (const auto &p : r.emcalo) {
814  if (p.hwPt == 0 || !reg.isFiducial(p))
815  continue;
816  reco::Particle::PolarLorentzVector p4(p.floatPt(), reg.floatGlbEtaOf(p), reg.floatGlbPhiOf(p), 0.13f);
817  ret->emplace_back(l1t::PFCandidate::Photon, 0, p4, 1, p.intPt(), p.intEta(), p.intPhi());
818  ret->back().setHwEmID(p.hwEmID);
819  setRefs_(ret->back(), p);
820  }
821  }
822  return ret;
823 }
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 793 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().

793  {
794  auto ret = std::make_unique<l1t::PFCandidateCollection>();
795  for (const auto &r : event_.pfinputs) {
796  const auto &reg = r.region;
797  for (const auto &p : r.hadcalo) {
798  if (p.hwPt == 0 || !reg.isFiducial(p))
799  continue;
800  reco::Particle::PolarLorentzVector p4(p.floatPt(), reg.floatGlbEtaOf(p), reg.floatGlbPhiOf(p), 0.13f);
802  ret->emplace_back(type, 0, p4, 1, p.intPt(), p.intEta(), p.intPhi());
803  ret->back().setHwEmID(p.hwEmID);
804  setRefs_(ret->back(), p);
805  }
806  }
807  return ret;
808 }
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 840 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().

840  {
841  auto ret = std::make_unique<l1t::PFCandidateCollection>();
842  for (unsigned int ir = 0, nr = event_.pfinputs.size(); ir < nr; ++ir) {
843  const auto &reg = event_.pfinputs[ir].region;
844  for (const auto &p : event_.out[ir].pfcharged) {
845  if (p.hwPt == 0 || !reg.isFiducial(p))
846  continue;
848  p.floatPt(), reg.floatGlbEta(p.hwVtxEta()), reg.floatGlbPhi(p.hwVtxPhi()), 0.13f);
850  if (p.hwId.isMuon())
852  else if (p.hwId.isElectron())
854  ret->emplace_back(type, p.intCharge(), p4, 1, p.intPt(), p.intEta(), p.intPhi());
855  ret->back().setZ0(p.floatZ0());
856  ret->back().setDxy(p.floatDxy());
857  ret->back().setHwZ0(p.hwZ0);
858  ret->back().setHwDxy(p.hwDxy);
859  ret->back().setHwTkQuality(p.hwTkQuality);
860  setRefs_(ret->back(), p);
861  }
862  for (const auto &p : event_.out[ir].pfneutral) {
863  if (p.hwPt == 0 || !reg.isFiducial(p))
864  continue;
865  reco::Particle::PolarLorentzVector p4(p.floatPt(), reg.floatGlbEtaOf(p), reg.floatGlbPhiOf(p), 0.13f);
868  ret->emplace_back(type, 0, p4, 1, p.intPt(), p.intEta(), p.intPhi());
869  ret->back().setHwEmID(p.hwEmID);
870  setRefs_(ret->back(), p);
871  }
872  }
873  return ret;
874 }
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 824 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().

824  {
825  auto ret = std::make_unique<l1t::PFCandidateCollection>();
826  for (const auto &r : event_.pfinputs) {
827  const auto &reg = r.region;
828  for (const auto &p : r.track) {
829  if (p.hwPt == 0 || !reg.isFiducial(p))
830  continue;
832  p.floatPt(), reg.floatGlbEta(p.hwVtxEta()), reg.floatGlbPhi(p.hwVtxPhi()), 0.13f);
833  ret->emplace_back(l1t::PFCandidate::ChargedHadron, p.intCharge(), p4, 1, p.intPt(), p.intEta(), p.intPhi());
834  setRefs_(ret->back(), p);
835  }
836  }
837  return ret;
838 }
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 570 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().

570  {
571  event_.clear();
572  event_.run = iEvent.id().run();
573  event_.lumi = iEvent.id().luminosityBlock();
574  event_.event = iEvent.id().event();
575  clusterRefMap_.clear();
576  trackRefMap_.clear();
577  muonRefMap_.clear();
578 }
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 494 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, LEDCalibrationChannels::ieta, LEDCalibrationChannels::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().

494  {
495  // the track finder geometry is fixed
496  unsigned int TF_phiSlices = 9;
497  float TF_phiWidth = 2 * M_PI / TF_phiSlices;
498  event_.decoded.track.clear();
499  for (unsigned int ieta = 0, neta = 2; ieta < neta; ++ieta) {
500  for (unsigned int iphi = 0; iphi < TF_phiSlices; ++iphi) {
501  float phiCenter = reco::reduceRange(iphi * TF_phiWidth);
502  event_.decoded.track.emplace_back((ieta ? 0. : -2.5), (ieta ? 2.5 : 0.0), phiCenter, TF_phiWidth);
503  event_.raw.track.emplace_back((ieta ? 0. : -2.5), (ieta ? 2.5 : 0.0), phiCenter, TF_phiWidth);
504  }
505  }
506 
507  event_.decoded.emcalo.clear();
508  event_.decoded.hadcalo.clear();
509  event_.raw.hgcalcluster.clear();
510 
511  for (const edm::ParameterSet &preg : iConfig.getParameter<std::vector<edm::ParameterSet>>("caloSectors")) {
512  std::vector<double> etaBoundaries = preg.getParameter<std::vector<double>>("etaBoundaries");
513  if (!std::is_sorted(etaBoundaries.begin(), etaBoundaries.end()))
514  throw cms::Exception("Configuration", "caloSectors.etaBoundaries not sorted\n");
515  unsigned int phiSlices = preg.getParameter<uint32_t>("phiSlices");
516  float phiWidth = 2 * M_PI / phiSlices;
517  if (phiWidth > 2 * l1ct::Scales::maxAbsPhi())
518  throw cms::Exception("Configuration", "caloSectors phi range too large for phi_t data type");
519  double phiZero = preg.getParameter<double>("phiZero");
520  for (unsigned int ieta = 0, neta = etaBoundaries.size() - 1; ieta < neta; ++ieta) {
521  float etaWidth = etaBoundaries[ieta + 1] - etaBoundaries[ieta];
522  if (etaWidth > 2 * l1ct::Scales::maxAbsEta())
523  throw cms::Exception("Configuration", "caloSectors eta range too large for eta_t data type");
524  for (unsigned int iphi = 0; iphi < phiSlices; ++iphi) {
525  float phiCenter = reco::reduceRange(iphi * phiWidth + phiZero);
526  event_.decoded.hadcalo.emplace_back(etaBoundaries[ieta], etaBoundaries[ieta + 1], phiCenter, phiWidth);
527  event_.decoded.emcalo.emplace_back(etaBoundaries[ieta], etaBoundaries[ieta + 1], phiCenter, phiWidth);
528  event_.raw.hgcalcluster.emplace_back(etaBoundaries[ieta], etaBoundaries[ieta + 1], phiCenter, phiWidth);
529  }
530  }
531  }
532 
533  event_.decoded.muon.region = l1ct::PFRegionEmu(0., 0.); // centered at (0,0)
534  event_.raw.muon.region = l1ct::PFRegionEmu(0., 0.); // centered at (0,0)
535 
536  event_.pfinputs.clear();
537  for (const edm::ParameterSet &preg : iConfig.getParameter<std::vector<edm::ParameterSet>>("regions")) {
538  std::vector<double> etaBoundaries = preg.getParameter<std::vector<double>>("etaBoundaries");
539  if (!std::is_sorted(etaBoundaries.begin(), etaBoundaries.end()))
540  throw cms::Exception("Configuration", "regions.etaBoundaries not sorted\n");
541  unsigned int phiSlices = preg.getParameter<uint32_t>("phiSlices");
542  float etaExtra = preg.getParameter<double>("etaExtra");
543  float phiExtra = preg.getParameter<double>("phiExtra");
544  float phiWidth = 2 * M_PI / phiSlices;
545  for (unsigned int ieta = 0, neta = etaBoundaries.size() - 1; ieta < neta; ++ieta) {
546  for (unsigned int iphi = 0; iphi < phiSlices; ++iphi) {
547  float phiCenter = reco::reduceRange(iphi * phiWidth); //align with L1 TrackFinder phi sector indexing
548  event_.pfinputs.emplace_back(
550  }
551  }
552  }
553 
554  event_.board_out.clear();
555  const std::vector<edm::ParameterSet> &board_params = iConfig.getParameter<std::vector<edm::ParameterSet>>("boards");
556  event_.board_out.resize(board_params.size());
557  for (unsigned int bidx = 0; bidx < board_params.size(); bidx++) {
558  event_.board_out[bidx].region_index = board_params[bidx].getParameter<std::vector<unsigned int>>("regions");
559  float etaBoard = 0.;
560  float phiBoard = 0.;
561  for (auto ridx : event_.board_out[bidx].region_index) {
562  etaBoard += event_.pfinputs[ridx].region.floatEtaCenter();
563  phiBoard += event_.pfinputs[ridx].region.floatPhiCenter();
564  }
565  event_.board_out[bidx].eta = etaBoard / event_.board_out[bidx].region_index.size();
566  event_.board_out[bidx].phi = phiBoard / event_.board_out[bidx].region_index.size();
567  }
568 }
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:199
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:198
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 303 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_, 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(), tracks, trkPt_, vecOutput(), vecRegInput(), vecSecInput(), l1t::VertexWord::vertexWord(), extraflags_cff::vtx, l1ct::Event::write(), convertToRaw::writer, HLTMuonOfflineAnalyzer_cfi::z0, and l1t::VertexWord::z0().

303  {
304  // clear the regions also at the beginning, in case one event didn't complete but the job continues on
305  initEvent(iEvent);
306 
308  if (hasTracks_) {
310  iEvent.getByToken(tkCands_, htracks);
311  const auto &tracks = *htracks;
312  for (unsigned int itk = 0, ntk = tracks.size(); itk < ntk; ++itk) {
313  const auto &tk = tracks[itk];
314  // adding objects to PF
315  if (debugR_ > 0 && deltaR(tk.eta(), tk.phi(), debugEta_, debugPhi_) > debugR_)
316  continue;
317  if (tk.pt() > trkPt_) {
318  addTrack(tk, l1t::PFTrackRef(htracks, itk));
319  }
320  }
321  }
322 
325  iEvent.getByToken(muCands_, muons);
326  for (unsigned int i = 0, n = muons->size(); i < n; ++i) {
327  const l1t::SAMuon &mu = (*muons)[i];
328  if (debugR_ > 0 && deltaR(mu.eta(), mu.phi(), debugEta_, debugPhi_) > debugR_)
329  continue;
331  }
332  // ------ READ CALOS -----
334  for (const auto &tag : emCands_) {
335  iEvent.getByToken(tag, caloHandle);
336  const auto &calos = *caloHandle;
337  for (unsigned int ic = 0, nc = calos.size(); ic < nc; ++ic) {
338  const auto &calo = calos[ic];
339  if (debugR_ > 0 && deltaR(calo.eta(), calo.phi(), debugEta_, debugPhi_) > debugR_)
340  continue;
341  if (calo.pt() > emPtCut_)
342  addEmCalo(calo, l1t::PFClusterRef(caloHandle, ic));
343  }
344  }
345  for (const auto &tag : hadCands_) {
346  iEvent.getByToken(tag, caloHandle);
347  const auto &calos = *caloHandle;
348  for (unsigned int ic = 0, nc = calos.size(); ic < nc; ++ic) {
349  const auto &calo = calos[ic];
350  if (debugR_ > 0 && deltaR(calo.eta(), calo.phi(), debugEta_, debugPhi_) > debugR_)
351  continue;
352  if (calo.pt() > hadPtCut_)
353  addHadCalo(calo, l1t::PFClusterRef(caloHandle, ic));
354  }
355  }
356 
358 
359  // First, get a copy of the discretized and corrected inputs, and write them out
360  iEvent.put(fetchEmCalo(), "EmCalo");
361  iEvent.put(fetchHadCalo(), "Calo");
362  iEvent.put(fetchTracks(), "TK");
363 
364  // Then do the vertexing, and save it out
365  std::vector<float> z0s;
366  std::vector<std::pair<float, float>> ptsums;
367  float z0 = 0;
368  double ptsum = 0;
369  l1t::VertexWord pvwd;
370  // FIXME: collections seem to be already sorted
371  if (emuTkVtx_) {
373  iEvent.getByToken(tkVtxEmu_, vtxEmuHandle);
374  for (const auto &vtx : *vtxEmuHandle) {
375  ptsums.push_back(std::pair<float, float>(vtx.pt(), vtx.z0()));
376  if (ptsum == 0 || vtx.pt() > ptsum) {
377  ptsum = vtx.pt();
378  pvwd = vtx;
379  }
380  }
381  } else {
383  iEvent.getByToken(extTkVtx_, vtxHandle);
384  for (const auto &vtx : *vtxHandle) {
385  ptsums.push_back(std::pair<float, float>(vtx.pt(), vtx.z0()));
386  if (ptsum == 0 || vtx.pt() > ptsum) {
387  ptsum = vtx.pt();
388  z0 = vtx.z0();
389  }
390  }
391  pvwd = l1t::VertexWord(1, z0, 1, ptsum, 1, 1, 1);
392  }
393  l1ct::PVObjEmu hwpv;
394  hwpv.hwZ0 = l1ct::Scales::makeZ0(pvwd.z0());
395  event_.pvs.push_back(hwpv);
396  event_.pvs_emu.push_back(pvwd.vertexWord());
397  //Do a quick histogram vertexing to get multiple vertices (Hack for the taus)
398  if (nVtx_ > 1) {
399  std::stable_sort(ptsums.begin(), ptsums.end(), [](const auto &a, const auto &b) { return a.first > b.first; });
400  for (int i0 = 0; i0 < std::min(int(ptsums.size()), int(nVtx_)); i0++) {
401  z0s.push_back(ptsums[i0].second);
402  }
403  for (unsigned int i = 1; i < z0s.size(); ++i) {
404  l1ct::PVObjEmu hwpv;
405  hwpv.hwZ0 = l1ct::Scales::makeZ0(z0s[i]);
406  event_.pvs.push_back(hwpv); //Skip emu
407  }
408  }
409  // Then also save the tracks with a vertex cut
410 #if 0
411  iEvent.put(l1regions_.fetchTracks(/*ptmin=*/0.0, /*fromPV=*/true), "TKVtx");
412 #endif
413 
414  // Then run PF in each region
415  event_.out.resize(event_.pfinputs.size());
416  for (unsigned int ir = 0, nr = event_.pfinputs.size(); ir < nr; ++ir) {
417  l1pfalgo_->run(event_.pfinputs[ir], event_.out[ir]);
418  l1pfalgo_->mergeNeutrals(event_.out[ir]);
419  l1tkegalgo_->run(event_.pfinputs[ir], event_.out[ir]);
420  l1tkegalgo_->runIso(event_.pfinputs[ir], event_.pvs, event_.out[ir]);
421  }
422 
423  // Then run puppi (regionally)
424  for (unsigned int ir = 0, nr = event_.pfinputs.size(); ir < nr; ++ir) {
425  l1pualgo_->run(event_.pfinputs[ir], event_.pvs, event_.out[ir]);
426  //l1pualgo_->runNeutralsPU(l1region, z0, -1., puGlobals);
427  }
428 
429  // NOTE: This needs to happen before the EG sorting per board so that the EG objects
430  // get a global reference to the EGSta before being mixed among differente regions
431  std::vector<edm::Ref<BXVector<l1t::EGamma>>> egsta_refs;
432  if (l1tkegalgo_->writeEgSta()) {
433  putEgStaObjects(iEvent, "L1Eg", egsta_refs);
434  }
435 
436  // l1tkegsorter_->setDebug(true);
437  for (auto &board : event_.board_out) {
438  l1tkegsorter_->run(event_.pfinputs, event_.out, board.region_index, board.egphoton);
439  l1tkegsorter_->run(event_.pfinputs, event_.out, board.region_index, board.egelectron);
440  }
441 
442  // save PF into the event
443  iEvent.put(fetchPF(), "PF");
444 
445  // and save puppi
446  putPuppi(iEvent);
447 
448  // save the EG objects
449  putEgObjects(iEvent, l1tkegalgo_->writeEgSta(), egsta_refs, "L1TkEm", "L1TkEmPerBoard", "L1TkEle", "L1TkElePerBoard");
450 
451  // Then go do the multiplicities
452  for (int i = 0; i <= l1muType; ++i) {
453  auto vecInputs = vecSecInput(InputType(i));
454  auto tm = totAndMax(*vecInputs);
455  addUInt(tm.first, std::string("totNSec") + inputTypeName[i], iEvent);
456  addUInt(tm.second, std::string("maxNSec") + inputTypeName[i], iEvent);
457  iEvent.put(std::move(vecInputs), std::string("vecNSec") + inputTypeName[i]);
458  }
459  for (int i = 0; i <= l1muType; ++i) {
460  auto vecInputs = vecRegInput(InputType(i));
461  auto tm = totAndMax(*vecInputs);
462  addUInt(tm.first, std::string("totNReg") + inputTypeName[i], iEvent);
463  addUInt(tm.second, std::string("maxNReg") + inputTypeName[i], iEvent);
464  iEvent.put(std::move(vecInputs), std::string("vecNReg") + inputTypeName[i]);
465  }
466  for (int i = 0; i < l1ct::OutputRegion::nPFTypes; ++i) {
467  auto vecPF = vecOutput(OutputType(i), false);
468  auto tmPF = totAndMax(*vecPF);
469  addUInt(tmPF.first, std::string("totNPF") + l1ct::OutputRegion::objTypeName[i], iEvent);
470  addUInt(tmPF.second, std::string("maxNPF") + l1ct::OutputRegion::objTypeName[i], iEvent);
472  auto vecPuppi = vecOutput(OutputType(i), true);
473  auto tmPuppi = totAndMax(*vecPuppi);
474  addUInt(tmPuppi.first, std::string("totNPuppi") + l1ct::OutputRegion::objTypeName[i], iEvent);
475  addUInt(tmPuppi.second, std::string("maxNPuppi") + l1ct::OutputRegion::objTypeName[i], iEvent);
476  iEvent.put(std::move(vecPuppi), std::string("vecNPuppi") + l1ct::OutputRegion::objTypeName[i]);
477  }
478 
479  if (fRegionDump_.is_open()) {
481  }
482  for (auto &writer : patternWriters_) {
483  writer->write(event_);
484  }
485 
486  // finally clear the regions
487  event_.clear();
488 }
edm::EDGetTokenT< std::vector< l1t::VertexWord > > tkVtxEmu_
std::vector< PVObjEmu > pvs
z0_t makeZ0(float z0)
Definition: datatypes.h:172
edm::EDGetTokenT< std::vector< l1t::Vertex > > extTkVtx_
edm::EDGetTokenT< l1t::PFTrackCollection > tkCands_
std::vector< std::unique_ptr< L1TCorrelatorLayer1PatternFileWriter > > patternWriters_
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
auto const & tracks
cannot be loose
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:118
static constexpr const char * objTypeName[nObjTypes]
double z0() const
Definition: VertexWord.h:156
double a
Definition: hdecay.h:119
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:141
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 969 of file L1TCorrelatorLayer1Producer.cc.

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

Referenced by produce().

975  {
976  auto tkems = std::make_unique<l1t::TkEmCollection>();
977  auto tkemRefProd = iEvent.getRefBeforePut<l1t::TkEmCollection>(tkEmLabel);
978  auto tkemPerBoard = std::make_unique<l1t::TkEmRegionalOutput>(tkemRefProd);
979  auto tkeles = std::make_unique<l1t::TkElectronCollection>();
980  auto tkeleRefProd = iEvent.getRefBeforePut<l1t::TkElectronCollection>(tkEleLabel);
981  auto tkelePerBoard = std::make_unique<l1t::TkElectronRegionalOutput>(tkeleRefProd);
982 
983  // TkEG objects are written out after the per-board sorting.
984  // The mapping to each board is saved into the regionalmap for further (stage-2 consumption)
985  std::vector<int> nele_obj;
986  std::vector<int> npho_obj;
987 
988  for (const auto &board : event_.board_out) {
989  npho_obj.clear();
990  for (const auto &egiso : board.egphoton) {
991  if (egiso.hwPt == 0)
992  continue;
993 
995  if (writeEgSta) {
996  ref_egsta = egsta_refs[egiso.sta_idx];
997  } else {
998  auto egptr = egiso.srcCluster->constituentsAndFractions()[0].first;
999  ref_egsta =
1000  edm::Ref<BXVector<l1t::EGamma>>(egptr.id(), dynamic_cast<const l1t::EGamma *>(egptr.get()), egptr.key());
1001  }
1002 
1003  reco::Candidate::PolarLorentzVector mom(egiso.floatPt(), egiso.floatEta(), egiso.floatPhi(), 0.);
1004 
1006  ref_egsta,
1007  egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIso),
1008  egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::TkIsoPV));
1009  tkem.setHwQual(egiso.hwQual);
1010  tkem.setPFIsol(egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::PfIso));
1011  tkem.setPFIsolPV(egiso.floatRelIso(l1ct::EGIsoObjEmu::IsoType::PfIsoPV));
1012  tkem.setEgBinaryWord(egiso.pack());
1013  tkems->push_back(tkem);
1014  npho_obj.push_back(tkems->size() - 1);
1015  }
1016  tkemPerBoard->addRegion(npho_obj, board.eta, board.phi);
1017 
1018  nele_obj.clear();
1019  for (const auto &egele : board.egelectron) {
1020  if (egele.hwPt == 0)
1021  continue;
1022 
1023  edm::Ref<BXVector<l1t::EGamma>> ref_egsta;
1024  if (writeEgSta) {
1025  ref_egsta = egsta_refs[egele.sta_idx];
1026  } else {
1027  auto egptr = egele.srcCluster->constituentsAndFractions()[0].first;
1028  ref_egsta =
1029  edm::Ref<BXVector<l1t::EGamma>>(egptr.id(), dynamic_cast<const l1t::EGamma *>(egptr.get()), egptr.key());
1030  }
1031 
1032  reco::Candidate::PolarLorentzVector mom(egele.floatPt(), egele.floatEta(), egele.floatPhi(), 0.);
1033 
1035  ref_egsta,
1036  edm::refToPtr(egele.srcTrack->track()),
1037  egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::TkIso));
1038  tkele.setHwQual(egele.hwQual);
1039  tkele.setPFIsol(egele.floatRelIso(l1ct::EGIsoEleObjEmu::IsoType::PfIso));
1040  tkele.setEgBinaryWord(egele.pack());
1041  tkeles->push_back(tkele);
1042  nele_obj.push_back(tkeles->size() - 1);
1043  }
1044  tkelePerBoard->addRegion(nele_obj, board.eta, board.phi);
1045  }
1046 
1047  iEvent.put(std::move(tkems), tkEmLabel);
1048  iEvent.put(std::move(tkemPerBoard), tkEmPerBoardLabel);
1049  iEvent.put(std::move(tkeles), tkEleLabel);
1050  iEvent.put(std::move(tkelePerBoard), tkElePerBoardLabel);
1051 }
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 926 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().

928  {
929  auto egs = std::make_unique<BXVector<l1t::EGamma>>();
930  edm::RefProd<BXVector<l1t::EGamma>> ref_egs = iEvent.getRefBeforePut<BXVector<l1t::EGamma>>(egLablel);
931 
932  edm::Ref<BXVector<l1t::EGamma>>::key_type idx = 0;
933  // FIXME: in case more BXes are introduced shuld probably use egs->key(egs->end(bx));
934 
935  for (unsigned int ir = 0, nr = event_.pfinputs.size(); ir < nr; ++ir) {
936  const auto &reg = event_.pfinputs[ir].region;
937 
938  std::vector<unsigned int> ref_pos(event_.out[ir].egsta.size());
939 
940  // EG standalone objects
941  for (unsigned int ieg = 0, neg = event_.out[ir].egsta.size(); ieg < neg; ++ieg) {
942  const auto &p = event_.out[ir].egsta[ieg];
943  if (p.hwPt == 0 || !reg.isFiducial(p))
944  continue;
945  l1t::EGamma eg(
946  reco::Candidate::PolarLorentzVector(p.floatPt(), reg.floatGlbEta(p.hwEta), reg.floatGlbPhi(p.hwPhi), 0.));
947  eg.setHwQual(p.hwQual);
948  egs->push_back(0, eg);
949  egsta_refs.push_back(edm::Ref<BXVector<l1t::EGamma>>(ref_egs, idx++));
950  ref_pos[ieg] = egsta_refs.size() - 1;
951  }
952 
953  for (auto &egiso : event_.out[ir].egphoton) {
954  if (egiso.hwPt == 0)
955  continue;
956  egiso.sta_idx = ref_pos[egiso.sta_idx];
957  }
958 
959  for (auto &egele : event_.out[ir].egelectron) {
960  if (egele.hwPt == 0)
961  continue;
962  egele.sta_idx = ref_pos[egele.sta_idx];
963  }
964  }
965 
966  iEvent.put(std::move(egs), egLablel);
967 }
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 876 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().

876  {
877  auto refprod = iEvent.getRefBeforePut<l1t::PFCandidateCollection>("Puppi");
878  auto coll = std::make_unique<l1t::PFCandidateCollection>();
879  auto reg = std::make_unique<l1t::PFCandidateRegionalOutput>(refprod);
880  std::vector<int> nobj;
881  for (unsigned int ir = 0, nr = event_.pfinputs.size(); ir < nr; ++ir) {
882  nobj.clear();
883  for (const auto &p : event_.out[ir].puppi) {
884  if (p.hwPt == 0)
885  continue;
886  // note: Puppi candidates are already in global coordinates & fiducial-only!
888  float mass = 0.13f;
889  if (p.hwId.charged()) {
890  if (p.hwId.isMuon()) {
892  mass = 0.105;
893  } else if (p.hwId.isElectron()) {
895  mass = 0.005;
896  } else
898  } else {
900  mass = p.hwId.isPhoton() ? 0.0 : 0.5;
901  }
902  reco::Particle::PolarLorentzVector p4(p.floatPt(), p.floatEta(), p.floatPhi(), mass);
903  coll->emplace_back(type, p.intCharge(), p4, p.floatPuppiW(), p.intPt(), p.intEta(), p.intPhi());
904  if (p.hwId.charged()) {
905  coll->back().setZ0(p.floatZ0());
906  coll->back().setDxy(p.floatDxy());
907  coll->back().setHwZ0(p.hwZ0());
908  coll->back().setHwDxy(p.hwDxy());
909  coll->back().setHwTkQuality(p.hwTkQuality());
910  } else {
911  coll->back().setHwPuppiWeight(p.hwPuppiW());
912  coll->back().setHwEmID(p.hwEmID());
913  }
914  coll->back().setEncodedPuppi64(p.pack().to_uint64());
915  setRefs_(coll->back(), p);
916  nobj.push_back(coll->size() - 1);
917  }
918  reg->addRegion(nobj, event_.pfinputs[ir].region.floatEtaCenter(), event_.pfinputs[ir].region.floatPhiCenter());
919  }
920  iEvent.put(std::move(coll), "Puppi");
921  iEvent.put(std::move(reg), "PuppiRegional");
922 }
void setRefs_(l1t::PFCandidate &pf, const T &p) const
std::vector< l1t::PFCandidate > PFCandidateCollection
Definition: PFCandidate.h:82
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 715 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().

715  {
716  if (p.srcCluster) {
717  auto match = clusterRefMap_.find(p.srcCluster);
718  if (match == clusterRefMap_.end()) {
719  throw cms::Exception("CorruptData") << "Invalid cluster pointer in PF candidate id " << p.intId() << " pt "
720  << p.floatPt() << " eta " << p.floatEta() << " phi " << p.floatPhi();
721  }
722  pf.setPFCluster(match->second);
723  }
724  if (p.srcTrack) {
725  auto match = trackRefMap_.find(p.srcTrack);
726  if (match == trackRefMap_.end()) {
727  throw cms::Exception("CorruptData") << "Invalid track pointer in PF candidate id " << p.intId() << " pt "
728  << p.floatPt() << " eta " << p.floatEta() << " phi " << p.floatPhi();
729  }
730  pf.setPFTrack(match->second);
731  }
732  if (p.srcMu) {
733  auto match = muonRefMap_.find(p.srcMu);
734  if (match == muonRefMap_.end()) {
735  throw cms::Exception("CorruptData") << "Invalid muon pointer in PF candidate id " << p.intId() << " pt "
736  << p.floatPt() << " eta " << p.floatEta() << " phi " << p.floatPhi();
737  }
738  pf.setMuon(match->second);
739  }
740 }
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 1105 of file L1TCorrelatorLayer1Producer.cc.

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

Referenced by produce().

1106  {
1107  unsigned int ntot = 0, nmax = 0;
1108  for (unsigned ni : perRegion) {
1109  ntot += ni;
1110  nmax = std::max(nmax, ni);
1111  }
1112  return std::make_pair(ntot, nmax);
1113 }
__shared__ uint32_t ntot

◆ vecOutput()

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

Definition at line 1098 of file L1TCorrelatorLayer1Producer.cc.

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

Referenced by produce().

1098  {
1099  auto v = std::make_unique<std::vector<unsigned>>();
1100  for (const auto &reg : event_.out) {
1101  v->push_back(reg.nObj(i, usePuppi));
1102  }
1103  return v;
1104 }
std::vector< OutputRegion > out

◆ vecRegInput()

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

Definition at line 1077 of file L1TCorrelatorLayer1Producer.cc.

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

Referenced by produce().

1077  {
1078  auto v = std::make_unique<std::vector<unsigned>>();
1079  for (const auto &reg : event_.pfinputs) {
1080  switch (t) {
1081  case caloType:
1082  v->push_back(reg.hadcalo.size());
1083  break;
1084  case emcaloType:
1085  v->push_back(reg.emcalo.size());
1086  break;
1087  case trackType:
1088  v->push_back(reg.track.size());
1089  break;
1090  case l1muType:
1091  v->push_back(reg.muon.size());
1092  break;
1093  }
1094  }
1095  return v;
1096 }
std::vector< PFInputRegion > pfinputs

◆ vecSecInput()

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

Definition at line 1053 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().

1053  {
1054  auto v = std::make_unique<std::vector<unsigned>>();
1055  {
1056  switch (t) {
1057  case caloType:
1058  for (const auto &s : event_.decoded.hadcalo)
1059  v->push_back(s.size());
1060  break;
1061  case emcaloType:
1062  for (const auto &s : event_.decoded.emcalo)
1063  v->push_back(s.size());
1064  break;
1065  case trackType:
1066  for (const auto &s : event_.decoded.track)
1067  v->push_back(s.size());
1068  break;
1069  case l1muType:
1070  v->push_back(event_.decoded.muon.size());
1071  break;
1072  }
1073  }
1074  return v;
1075 }
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 49 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 61 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ emPtCut_

float L1TCorrelatorLayer1Producer::emPtCut_
private

Definition at line 64 of file L1TCorrelatorLayer1Producer.cc.

Referenced by produce().

◆ emuTkVtx_

bool L1TCorrelatorLayer1Producer::emuTkVtx_
private

Definition at line 54 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 55 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 62 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ hadPtCut_

float L1TCorrelatorLayer1Producer::hadPtCut_
private

Definition at line 64 of file L1TCorrelatorLayer1Producer.cc.

Referenced by produce().

◆ hasTracks_

bool L1TCorrelatorLayer1Producer::hasTracks_
private

Definition at line 51 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 136 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ l1pfalgo_

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

Definition at line 70 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ l1pualgo_

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

Definition at line 71 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ l1tkegalgo_

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

Definition at line 72 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ l1tkegsorter_

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

Definition at line 73 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ muCands_

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

Definition at line 59 of file L1TCorrelatorLayer1Producer.cc.

Referenced by produce().

◆ muonInput_

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

Definition at line 68 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 57 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 69 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ tkCands_

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

Definition at line 52 of file L1TCorrelatorLayer1Producer.cc.

Referenced by produce().

◆ tkVtxEmu_

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

Definition at line 56 of file L1TCorrelatorLayer1Producer.cc.

Referenced by L1TCorrelatorLayer1Producer(), and produce().

◆ trackInput_

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

Definition at line 67 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 53 of file L1TCorrelatorLayer1Producer.cc.

Referenced by produce().

◆ writeEgSta_

bool L1TCorrelatorLayer1Producer::writeEgSta_
private

Definition at line 75 of file L1TCorrelatorLayer1Producer.cc.

◆ writeRawHgcalCluster_

bool L1TCorrelatorLayer1Producer::writeRawHgcalCluster_
private

Definition at line 78 of file L1TCorrelatorLayer1Producer.cc.

Referenced by addHadCalo().