CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
L1TMuonProducer Class Reference

#include <L1Trigger/L1TMuon/src/L1TMuonProducer.cc>

Inheritance diagram for L1TMuonProducer:
edm::stream::EDProducer<>

Public Member Functions

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

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void addMuonsToCollections (MicroGMTConfiguration::InterMuonList &coll, MicroGMTConfiguration::InterMuonList &interout, std::unique_ptr< MuonBxCollection > &out, int bx) const
 
void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void calculateRank (MicroGMTConfiguration::InterMuonList &muons) const
 
void convertMuons (edm::Handle< MicroGMTConfiguration::InputCollection > const &in, MicroGMTConfiguration::InterMuonList &out, GMTInternalWedges &wedges, int bx) const
 
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void sortMuons (MicroGMTConfiguration::InterMuonList &, unsigned) const
 
void splitAndConvertMuons (edm::Handle< MicroGMTConfiguration::InputCollection > const &in, MicroGMTConfiguration::InterMuonList &out_pos, MicroGMTConfiguration::InterMuonList &out_neg, GMTInternalWedges &wedges_pos, GMTInternalWedges &wedges_neg, int bx) const
 

Static Private Member Functions

static bool compareMuons (const std::shared_ptr< MicroGMTConfiguration::InterMuon > &mu1, const std::shared_ptr< MicroGMTConfiguration::InterMuon > &mu2)
 

Private Attributes

bool m_autoBxRange
 
bool m_autoCancelMode
 
edm::InputTag m_barrelTfInputTag
 
edm::EDGetTokenT
< MicroGMTConfiguration::InputCollection
m_barrelTfInputToken
 
l1t::cancelmode m_bmtfCancelMode
 
std::bitset< 12 > m_bmtfInputsToDisable
 
int m_bxMax
 
int m_bxMin
 
std::bitset< 28 > m_caloInputsToDisable
 
edm::EDGetTokenT
< MicroGMTConfiguration::CaloInputCollection
m_caloTowerInputToken
 
MicroGMTCancelOutUnit m_cancelOutUnit
 
std::ofstream m_debugOut
 
l1t::cancelmode m_emtfCancelMode
 
std::bitset< 12 > m_emtfInputsToDisable
 
edm::InputTag m_endcapTfInputTag
 
edm::EDGetTokenT
< MicroGMTConfiguration::InputCollection
m_endcapTfInputToken
 
std::bitset< 72 > m_inputsToDisable
 
MicroGMTIsolationUnit m_isolationUnit
 
std::bitset< 12 > m_maskedBmtfInputs
 
std::bitset< 28 > m_maskedCaloInputs
 
std::bitset< 12 > m_maskedEmtfInputs
 
std::bitset< 72 > m_maskedInputs
 
std::bitset< 12 > m_maskedOmtfInputs
 
edm::ESGetToken
< L1TMuonGlobalParams,
L1TMuonGlobalParamsRcd
m_microGMTParamsToken
 
edm::ESGetToken
< L1TMuonGlobalParams,
L1TMuonGlobalParamsO2ORcd
m_o2oProtoToken
 
std::bitset< 12 > m_omtfInputsToDisable
 
edm::InputTag m_overlapTfInputTag
 
edm::EDGetTokenT
< MicroGMTConfiguration::InputCollection
m_overlapTfInputToken
 
std::shared_ptr
< MicroGMTRankPtQualLUT
m_rankPtQualityLUT
 
edm::InputTag m_trigTowerTag
 
std::unique_ptr
< L1TMuonGlobalParamsHelper
microGMTParamsHelper
 

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

Description: Takes txt-file input and produces barrel- / overlap- / forward TF muons

Implementation: [Notes on implementation]

Definition at line 59 of file L1TMuonProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 144 of file L1TMuonProducer.cc.

References edm::ParameterSet::getParameter(), l1t::kftracks, m_autoBxRange, m_autoCancelMode, m_barrelTfInputTag, m_barrelTfInputToken, m_bmtfCancelMode, m_bxMax, m_bxMin, m_caloTowerInputToken, m_emtfCancelMode, m_endcapTfInputTag, m_endcapTfInputToken, m_microGMTParamsToken, m_o2oProtoToken, m_overlapTfInputTag, m_overlapTfInputToken, m_trigTowerTag, AlCaHLTBitMon_QueryRunRegistry::string, and tracks.

145  : m_debugOut("test/debug/iso_debug.dat"),
148  // edm::InputTag barrelTfInputTag = iConfig.getParameter<edm::InputTag>("barrelTFInput");
149  // edm::InputTag overlapTfInputTag = iConfig.getParameter<edm::InputTag>("overlapTFInput");
150  // edm::InputTag forwardTfInputTag = iConfig.getParameter<edm::InputTag>("forwardTFInput");
151 
152  m_barrelTfInputTag = iConfig.getParameter<edm::InputTag>("barrelTFInput");
153  m_overlapTfInputTag = iConfig.getParameter<edm::InputTag>("overlapTFInput");
154  m_endcapTfInputTag = iConfig.getParameter<edm::InputTag>("forwardTFInput");
155  m_trigTowerTag = iConfig.getParameter<edm::InputTag>("triggerTowerInput");
156 
157  m_autoBxRange = iConfig.getParameter<bool>("autoBxRange");
158  m_bxMin = iConfig.getParameter<int>("bxMin");
159  m_bxMax = iConfig.getParameter<int>("bxMax");
160 
161  m_autoCancelMode = iConfig.getParameter<bool>("autoCancelMode");
162  if (!m_autoCancelMode) {
163  if (iConfig.getParameter<std::string>("bmtfCancelMode").find("kftracks") == 0) {
165  }
166  if (iConfig.getParameter<std::string>("emtfCancelMode").find("tracks") == 0) {
168  }
169  }
170 
171  m_barrelTfInputToken = consumes<MicroGMTConfiguration::InputCollection>(m_barrelTfInputTag);
172  m_overlapTfInputToken = consumes<MicroGMTConfiguration::InputCollection>(m_overlapTfInputTag);
173  m_endcapTfInputToken = consumes<MicroGMTConfiguration::InputCollection>(m_endcapTfInputTag);
174  m_caloTowerInputToken = consumes<MicroGMTConfiguration::CaloInputCollection>(m_trigTowerTag);
175  m_microGMTParamsToken = esConsumes<L1TMuonGlobalParams, L1TMuonGlobalParamsRcd, edm::Transition::BeginRun>();
176  m_o2oProtoToken = esConsumes<L1TMuonGlobalParams, L1TMuonGlobalParamsO2ORcd, edm::Transition::BeginRun>();
177 
178  //register your products
179  produces<MuonBxCollection>();
180  produces<MuonBxCollection>("imdMuonsBMTF");
181  produces<MuonBxCollection>("imdMuonsEMTFPos");
182  produces<MuonBxCollection>("imdMuonsEMTFNeg");
183  produces<MuonBxCollection>("imdMuonsOMTFPos");
184  produces<MuonBxCollection>("imdMuonsOMTFNeg");
185 }
std::ofstream m_debugOut
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_endcapTfInputToken
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_overlapTfInputToken
edm::EDGetTokenT< MicroGMTConfiguration::CaloInputCollection > m_caloTowerInputToken
auto const & tracks
cannot be loose
l1t::cancelmode m_emtfCancelMode
edm::ESGetToken< L1TMuonGlobalParams, L1TMuonGlobalParamsO2ORcd > m_o2oProtoToken
edm::InputTag m_overlapTfInputTag
edm::InputTag m_barrelTfInputTag
edm::InputTag m_endcapTfInputTag
edm::ESGetToken< L1TMuonGlobalParams, L1TMuonGlobalParamsRcd > m_microGMTParamsToken
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_barrelTfInputToken
l1t::cancelmode m_bmtfCancelMode
edm::InputTag m_trigTowerTag
L1TMuonProducer::~L1TMuonProducer ( )
override

Definition at line 187 of file L1TMuonProducer.cc.

References m_debugOut.

187 { m_debugOut.close(); }
std::ofstream m_debugOut

Member Function Documentation

void L1TMuonProducer::addMuonsToCollections ( MicroGMTConfiguration::InterMuonList coll,
MicroGMTConfiguration::InterMuonList interout,
std::unique_ptr< MuonBxCollection > &  out,
int  bx 
) const
private

Definition at line 433 of file L1TMuonProducer.cc.

References RPCpg::mu.

Referenced by produce().

436  {
437  for (auto& mu : coll) {
438  interout.push_back(mu);
439  math::PtEtaPhiMLorentzVector vec{(mu->hwPt() - 1) * 0.5, mu->hwEta() * 0.010875, mu->hwGlobalPhi() * 0.010908, 0.0};
440  int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(mu->hwQual(), mu->trackFinderType(), mu->hwHF());
441  // set tfMuonIndex and iso to 0 like in the FW
442  Muon outMu{vec,
443  mu->hwPt(),
444  mu->hwEta(),
445  mu->hwGlobalPhi(),
446  outMuQual,
447  mu->hwSign(),
448  mu->hwSignValid(),
449  0,
450  0,
451  0,
452  true,
453  0,
454  mu->hwDPhi(),
455  mu->hwDEta(),
456  mu->hwRank()};
457 
458  int hwPtUnconstrained{mu->hwPtUnconstrained()};
459  outMu.setPtUnconstrained(hwPtUnconstrained == 0
460  ? 0
461  : (hwPtUnconstrained - 1)); // Don't want negative pT, unconstr. pT has LSB of 1 GeV.
462  outMu.setHwPtUnconstrained(hwPtUnconstrained);
463  outMu.setHwDXY(mu->hwDXY());
464 
465  if (mu->hwSignValid()) {
466  outMu.setCharge(1 - 2 * mu->hwSign());
467  } else {
468  outMu.setCharge(0);
469  }
470 
471  out->push_back(bx, outMu);
472  }
473 }
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
const int mu
Definition: Constants.h:22
Definition: Muon.h:21
void L1TMuonProducer::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 613 of file L1TMuonProducer.cc.

613 {}
void L1TMuonProducer::beginRun ( edm::Run const &  run,
edm::EventSetup const &  iSetup 
)
overrideprivate

Definition at line 564 of file L1TMuonProducer.cc.

References cast_to_L1TMuonGlobalParams(), cast_to_L1TMuonGlobalParams_PUBLIC(), l1t::MicroGMTRankPtQualLUTFactory::create(), edm::EventSetup::getHandle(), l1t::MicroGMTCancelOutUnit::initialise(), l1t::MicroGMTIsolationUnit::initialise(), l1t::kftracks, m_autoCancelMode, m_bmtfCancelMode, m_bmtfInputsToDisable, m_caloInputsToDisable, m_cancelOutUnit, m_emtfInputsToDisable, m_inputsToDisable, m_isolationUnit, m_maskedBmtfInputs, m_maskedCaloInputs, m_maskedEmtfInputs, m_maskedInputs, m_maskedOmtfInputs, m_microGMTParamsToken, m_o2oProtoToken, m_omtfInputsToDisable, m_rankPtQualityLUT, microGMTParamsHelper, and edm::ESHandle< class >::product().

564  {
565  edm::ESHandle<L1TMuonGlobalParams> microGMTParamsHandle = iSetup.getHandle(m_microGMTParamsToken);
566 
567  std::unique_ptr<L1TMuonGlobalParams_PUBLIC> microGMTParams(
569  if (microGMTParams->pnodes_.empty()) {
570  edm::ESHandle<L1TMuonGlobalParams> o2oProtoHandle = iSetup.getHandle(m_o2oProtoToken);
571  microGMTParamsHelper = std::make_unique<L1TMuonGlobalParamsHelper>(*o2oProtoHandle.product());
572  } else
574  std::make_unique<L1TMuonGlobalParamsHelper>(cast_to_L1TMuonGlobalParams(*microGMTParams.get()));
575 
576  //microGMTParamsHelper->print(std::cout);
577  m_inputsToDisable = microGMTParamsHelper->inputsToDisable();
578  edm::LogVerbatim("L1TMuonProducer")
579  << "uGMT inputsToDisable: " << m_inputsToDisable
580  << "\n EMTF-|OMTF-| BMTF |OMTF+|EMTF+| CALO | res 0";
581  m_caloInputsToDisable = microGMTParamsHelper->caloInputsToDisable();
582  m_bmtfInputsToDisable = microGMTParamsHelper->bmtfInputsToDisable();
583  m_omtfInputsToDisable = microGMTParamsHelper->omtfInputsToDisable();
584  m_emtfInputsToDisable = microGMTParamsHelper->emtfInputsToDisable();
585  m_maskedInputs = microGMTParamsHelper->maskedInputs();
586  edm::LogVerbatim("L1TMuonProducer")
587  << "uGMT maskedInputs: " << m_maskedInputs
588  << "\n EMTF-|OMTF-| BMTF |OMTF+|EMTF+| CALO | res 0";
589  m_maskedCaloInputs = microGMTParamsHelper->maskedCaloInputs();
590  m_maskedBmtfInputs = microGMTParamsHelper->maskedBmtfInputs();
591  m_maskedOmtfInputs = microGMTParamsHelper->maskedOmtfInputs();
592  m_maskedEmtfInputs = microGMTParamsHelper->maskedEmtfInputs();
597 
598  if (m_autoCancelMode) {
599  if (microGMTParamsHelper->fwVersion() >= 0x6000000) {
601  }
602  // TODO: No decision yet on when to use EMTF track addresses for cancel-out.
603  // if (microGMTParamsHelper->fwVersion() > 0x5000000) {
604  // m_emtfCancelMode = cancelmode::tracks;
605  // }
606  }
607 }
const L1TMuonGlobalParams & cast_to_L1TMuonGlobalParams(const L1TMuonGlobalParams_PUBLIC &x)
Log< level::Info, true > LogVerbatim
void initialise(L1TMuonGlobalParamsHelper *)
Initialisation from ES record.
std::unique_ptr< L1TMuonGlobalParamsHelper > microGMTParamsHelper
std::bitset< 12 > m_bmtfInputsToDisable
MicroGMTIsolationUnit m_isolationUnit
edm::ESGetToken< L1TMuonGlobalParams, L1TMuonGlobalParamsO2ORcd > m_o2oProtoToken
std::shared_ptr< MicroGMTRankPtQualLUT > m_rankPtQualityLUT
static ReturnType create(const std::string &filename, const int fwVersion, const unsigned ptFactor, const unsigned qualFactor)
std::bitset< 12 > m_emtfInputsToDisable
std::bitset< 12 > m_maskedBmtfInputs
edm::ESGetToken< L1TMuonGlobalParams, L1TMuonGlobalParamsRcd > m_microGMTParamsToken
T const * product() const
Definition: ESHandle.h:86
std::bitset< 12 > m_maskedEmtfInputs
const L1TMuonGlobalParams_PUBLIC & cast_to_L1TMuonGlobalParams_PUBLIC(const L1TMuonGlobalParams &x)
l1t::cancelmode m_bmtfCancelMode
std::bitset< 72 > m_maskedInputs
std::bitset< 12 > m_maskedOmtfInputs
std::bitset< 72 > m_inputsToDisable
std::bitset< 28 > m_caloInputsToDisable
std::bitset< 12 > m_omtfInputsToDisable
MicroGMTCancelOutUnit m_cancelOutUnit
void initialise(L1TMuonGlobalParamsHelper *)
Initialisation from ES record.
std::bitset< 28 > m_maskedCaloInputs
void L1TMuonProducer::calculateRank ( MicroGMTConfiguration::InterMuonList muons) const
private

Definition at line 426 of file L1TMuonProducer.cc.

References m_rankPtQualityLUT.

Referenced by produce().

426  {
427  for (auto& mu1 : muons) {
428  int rank = m_rankPtQualityLUT->lookup(mu1->hwPt(), mu1->hwQual());
429  mu1->setHwRank(rank);
430  }
431 }
std::shared_ptr< MicroGMTRankPtQualLUT > m_rankPtQualityLUT
tuple muons
Definition: patZpeak.py:39
bool L1TMuonProducer::compareMuons ( const std::shared_ptr< MicroGMTConfiguration::InterMuon > &  mu1,
const std::shared_ptr< MicroGMTConfiguration::InterMuon > &  mu2 
)
staticprivate

Definition at line 384 of file L1TMuonProducer.cc.

Referenced by sortMuons().

385  {
386  return (mu1->hwWins() >= mu2->hwWins());
387 }
void L1TMuonProducer::convertMuons ( edm::Handle< MicroGMTConfiguration::InputCollection > const &  in,
MicroGMTConfiguration::InterMuonList out,
GMTInternalWedges wedges,
int  bx 
) const
private

Definition at line 525 of file L1TMuonProducer.cc.

References mps_fire::i, MainPageGenerator::link, m_inputsToDisable, m_maskedInputs, and findQualityFiles::size.

Referenced by produce().

528  {
529  // initialize the wedge collection:
530  for (int i = 0; i < 12; ++i) {
531  wedges[i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
532  wedges[i].reserve(3);
533  }
534  if (bx < in->getFirstBX() || bx > in->getLastBX())
535  return;
536  int muIdx = 0;
537  int currentLink = 0;
538  for (size_t i = 0; i < in->size(bx); ++i, ++muIdx) {
539  if (in->at(bx, i).hwPt() > 0) {
540  int link = in->at(bx, i).link();
541  if (m_inputsToDisable.test(link) || m_maskedInputs.test(link)) {
542  continue; // only process if input link is enabled and not masked
543  }
544  if (currentLink != link) {
545  muIdx = 0;
546  currentLink = link;
547  }
548  int gPhi = MicroGMTConfiguration::calcGlobalPhi(
549  in->at(bx, i).hwPhi(), in->at(bx, i).trackFinderType(), in->at(bx, i).processor());
550  int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
551  std::shared_ptr<GMTInternalMuon> outMu = std::make_shared<GMTInternalMuon>(in->at(bx, i), gPhi, tfMuonIdx);
552  out.emplace_back(outMu);
553  wedges[in->at(bx, i).processor()].push_back(outMu);
554  }
555  }
556  for (int i = 0; i < 12; ++i) {
557  if (wedges[i].size() > 3)
558  edm::LogWarning("Input Mismatch") << " too many inputs per processor for barrel. Wedge " << i << ": Size "
559  << wedges[i].size() << std::endl;
560  }
561 }
std::bitset< 72 > m_maskedInputs
std::bitset< 72 > m_inputsToDisable
Log< level::Warning, false > LogWarning
tuple size
Write out results.
void L1TMuonProducer::endLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 616 of file L1TMuonProducer.cc.

616 {}
void L1TMuonProducer::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 610 of file L1TMuonProducer.cc.

610 {}
void L1TMuonProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 619 of file L1TMuonProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), submitPVResolutionJobs::desc, and edm::ParameterSetDescription::setUnknown().

619  {
620  //The following says we do not know what parameters are allowed so do no validation
621  // Please change this to state exactly what you do use, even if it is no parameters
623  desc.setUnknown();
624  descriptions.addDefault(desc);
625 }
void addDefault(ParameterSetDescription const &psetDescription)
void L1TMuonProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 194 of file L1TMuonProducer.cc.

References addMuonsToCollections(), l1t::bmtf, makePileupJSON::bx, HLT_Fake1_cff::bxMax, HLT_Fake1_cff::bxMin, calculateRank(), convertMuons(), l1t::emtf_neg, l1t::emtf_pos, l1t::MicroGMTIsolationUnit::extrapolateMuons(), edm::Event::getByToken(), l1t::MicroGMTIsolationUnit::isolatePreSummed(), m_autoBxRange, m_barrelTfInputToken, m_bmtfCancelMode, m_bmtfInputsToDisable, m_bxMax, m_bxMin, m_caloInputsToDisable, m_caloTowerInputToken, m_cancelOutUnit, m_debugOut, m_emtfCancelMode, m_emtfInputsToDisable, m_endcapTfInputToken, m_isolationUnit, m_maskedBmtfInputs, m_maskedCaloInputs, m_maskedEmtfInputs, m_maskedOmtfInputs, m_omtfInputsToDisable, m_overlapTfInputToken, SiStripPI::max, min(), eostools::move(), RPCpg::mu, l1t::omtf_neg, l1t::omtf_pos, edm::Event::put(), l1t::MicroGMTCancelOutUnit::setCancelOutBits(), l1t::MicroGMTCancelOutUnit::setCancelOutBitsOverlapBarrel(), l1t::MicroGMTCancelOutUnit::setCancelOutBitsOverlapEndcap(), l1t::MicroGMTIsolationUnit::setTowerSums(), sortMuons(), and splitAndConvertMuons().

194  {
195  using namespace edm;
196  std::unique_ptr<MuonBxCollection> outMuons(new MuonBxCollection());
197  std::unique_ptr<MuonBxCollection> imdMuonsBMTF(new MuonBxCollection());
198  std::unique_ptr<MuonBxCollection> imdMuonsEMTFPos(new MuonBxCollection());
199  std::unique_ptr<MuonBxCollection> imdMuonsEMTFNeg(new MuonBxCollection());
200  std::unique_ptr<MuonBxCollection> imdMuonsOMTFPos(new MuonBxCollection());
201  std::unique_ptr<MuonBxCollection> imdMuonsOMTFNeg(new MuonBxCollection());
202 
207 
208  iEvent.getByToken(m_barrelTfInputToken, bmtfMuons);
209  iEvent.getByToken(m_endcapTfInputToken, emtfMuons);
210  iEvent.getByToken(m_overlapTfInputToken, omtfMuons);
211  iEvent.getByToken(m_caloTowerInputToken, trigTowers);
212 
213  // find out the BX range from the inputs
214  // the smallest BX window defines the output BX window
215  if (m_autoBxRange) {
216  int bxMin = -1000;
217  int bxMax = 1000;
218  if (!(m_caloInputsToDisable.all() || m_maskedCaloInputs.all())) {
219  bxMin = std::max(bxMin, trigTowers->getFirstBX());
220  bxMax = std::min(bxMax, trigTowers->getLastBX());
221  }
222  if (!(m_bmtfInputsToDisable.all() || m_maskedBmtfInputs.all())) {
223  bxMin = std::max(bxMin, bmtfMuons->getFirstBX());
224  bxMax = std::min(bxMax, bmtfMuons->getLastBX());
225  }
226  if (!(m_omtfInputsToDisable.all() || m_maskedOmtfInputs.all())) {
227  bxMin = std::max(bxMin, omtfMuons->getFirstBX());
228  bxMax = std::min(bxMax, omtfMuons->getLastBX());
229  }
230  if (!(m_emtfInputsToDisable.all() || m_maskedEmtfInputs.all())) {
231  bxMin = std::max(bxMin, emtfMuons->getFirstBX());
232  bxMax = std::min(bxMax, emtfMuons->getLastBX());
233  }
234  if (bxMin > 0) {
235  bxMin = 0;
236  }
237  if (bxMax < 0) {
238  bxMax = 0;
239  }
240  if (bxMin > -1000) {
241  m_bxMin = bxMin;
242  } else {
243  m_bxMin = 0;
244  }
245  if (bxMax < 1000) {
246  m_bxMax = bxMax;
247  } else {
248  m_bxMax = 0;
249  }
250  }
251 
252  // set BX range for outputs
253  outMuons->setBXRange(m_bxMin, m_bxMax);
254  imdMuonsBMTF->setBXRange(m_bxMin, m_bxMax);
255  imdMuonsEMTFPos->setBXRange(m_bxMin, m_bxMax);
256  imdMuonsEMTFNeg->setBXRange(m_bxMin, m_bxMax);
257  imdMuonsOMTFPos->setBXRange(m_bxMin, m_bxMax);
258  imdMuonsOMTFNeg->setBXRange(m_bxMin, m_bxMax);
259 
260  for (int bx = m_bxMin; bx <= m_bxMax; ++bx) {
261  m_isolationUnit.setTowerSums(*trigTowers, bx);
262  MicroGMTConfiguration::InterMuonList internMuonsBmtf;
263  MicroGMTConfiguration::InterMuonList internMuonsEmtfPos;
264  MicroGMTConfiguration::InterMuonList internMuonsEmtfNeg;
265  MicroGMTConfiguration::InterMuonList internMuonsOmtfPos;
266  MicroGMTConfiguration::InterMuonList internMuonsOmtfNeg;
267 
268  // These wedges contain shared pointers to the ones in the InterMuonList
269  GMTInternalWedges omtfNegWedges;
270  GMTInternalWedges bmtfWedges;
271  GMTInternalWedges emtfPosWedges;
272  GMTInternalWedges emtfNegWedges;
273  GMTInternalWedges omtfPosWedges;
274 
275  // this converts the InputMuon type to the InternalMuon type and splits them into
276  // positive / negative eta collections necessary as LUTs may differ for pos / neg.
277  convertMuons(bmtfMuons, internMuonsBmtf, bmtfWedges, bx);
278  splitAndConvertMuons(emtfMuons, internMuonsEmtfPos, internMuonsEmtfNeg, emtfPosWedges, emtfNegWedges, bx);
279  splitAndConvertMuons(omtfMuons, internMuonsOmtfPos, internMuonsOmtfNeg, omtfPosWedges, omtfNegWedges, bx);
280 
281  // cancel out within the track finders:
287 
288  // cancel out between track finder acceptance overlaps:
293 
294  m_isolationUnit.extrapolateMuons(internMuonsBmtf);
295  m_isolationUnit.extrapolateMuons(internMuonsEmtfNeg);
296  m_isolationUnit.extrapolateMuons(internMuonsEmtfPos);
297  m_isolationUnit.extrapolateMuons(internMuonsOmtfNeg);
298  m_isolationUnit.extrapolateMuons(internMuonsOmtfPos);
299 
300  // the rank calculated here is used in the sort below
301  calculateRank(internMuonsBmtf);
302  calculateRank(internMuonsEmtfNeg);
303  calculateRank(internMuonsEmtfPos);
304  calculateRank(internMuonsOmtfNeg);
305  calculateRank(internMuonsOmtfPos);
306 
307  // The sort function both sorts and removes all but best "nSurvivors"
308  sortMuons(internMuonsBmtf, 8);
309  sortMuons(internMuonsOmtfPos, 4);
310  sortMuons(internMuonsOmtfNeg, 4);
311  sortMuons(internMuonsEmtfPos, 4);
312  sortMuons(internMuonsEmtfNeg, 4);
313 
314  // This combines the 5 streams into one InternalMuon collection for
315  // the final global sort.
317  addMuonsToCollections(internMuonsEmtfPos, internalMuons, imdMuonsEMTFPos, bx);
318  addMuonsToCollections(internMuonsOmtfPos, internalMuons, imdMuonsOMTFPos, bx);
319  addMuonsToCollections(internMuonsBmtf, internalMuons, imdMuonsBMTF, bx);
320  addMuonsToCollections(internMuonsOmtfNeg, internalMuons, imdMuonsOMTFNeg, bx);
321  addMuonsToCollections(internMuonsEmtfNeg, internalMuons, imdMuonsEMTFNeg, bx);
322 
323  // sort internal muons and delete all but best 8
324  sortMuons(internalMuons, 8);
325 
326  m_isolationUnit.isolatePreSummed(internalMuons);
327  // copy muons to output collection...
328  for (const auto& mu : internalMuons) {
329  if (mu->hwPt() > 0) {
331  (mu->hwPt() - 1) * 0.5, mu->hwEta() * 0.010875, mu->hwGlobalPhi() * 0.010908, 0.0};
332  int iso = mu->hwAbsIso() + (mu->hwRelIso() << 1);
333  int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(mu->hwQual(), mu->trackFinderType(), mu->hwHF());
334  Muon outMu{vec,
335  mu->hwPt(),
336  mu->hwEta(),
337  mu->hwGlobalPhi(),
338  outMuQual,
339  mu->hwSign(),
340  mu->hwSignValid(),
341  iso,
342  mu->tfMuonIndex(),
343  0,
344  true,
345  mu->hwIsoSum(),
346  mu->hwDPhi(),
347  mu->hwDEta(),
348  mu->hwRank()};
349 
350  // Set coordinates at the vertex
351  outMu.setHwEtaAtVtx(MicroGMTConfiguration::calcMuonHwEtaExtra(outMu));
352  outMu.setHwPhiAtVtx(MicroGMTConfiguration::calcMuonHwPhiExtra(outMu));
353  outMu.setEtaAtVtx(MicroGMTConfiguration::calcMuonEtaExtra(outMu));
354  outMu.setPhiAtVtx(MicroGMTConfiguration::calcMuonPhiExtra(outMu));
355 
356  // Set displacement information
357  int hwPtUnconstrained{mu->hwPtUnconstrained()};
358  outMu.setPtUnconstrained(
359  hwPtUnconstrained == 0
360  ? 0
361  : (hwPtUnconstrained - 1)); // Don't want negative pT, unconstr. pT has LSB of 1 GeV.
362  outMu.setHwPtUnconstrained(hwPtUnconstrained);
363  outMu.setHwDXY(mu->hwDXY());
364 
365  if (mu->hwSignValid()) {
366  outMu.setCharge(1 - 2 * mu->hwSign());
367  } else {
368  outMu.setCharge(0);
369  }
370  m_debugOut << mu->hwCaloPhi() << " " << mu->hwCaloEta() << std::endl;
371  outMuons->push_back(bx, outMu);
372  }
373  }
374  }
375 
376  iEvent.put(std::move(outMuons));
377  iEvent.put(std::move(imdMuonsBMTF), "imdMuonsBMTF");
378  iEvent.put(std::move(imdMuonsEMTFPos), "imdMuonsEMTFPos");
379  iEvent.put(std::move(imdMuonsEMTFNeg), "imdMuonsEMTFNeg");
380  iEvent.put(std::move(imdMuonsOMTFPos), "imdMuonsOMTFPos");
381  iEvent.put(std::move(imdMuonsOMTFNeg), "imdMuonsOMTFNeg");
382 }
void extrapolateMuons(MicroGMTConfiguration::InterMuonList &) const
void setCancelOutBitsOverlapEndcap(GMTInternalWedges &, GMTInternalWedges &, cancelmode)
Cancel-out between overlap and endcap track finders.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
std::ofstream m_debugOut
void setCancelOutBitsOverlapBarrel(GMTInternalWedges &, GMTInternalWedges &, cancelmode)
Cancel-out between overlap and barrel track finders.
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_endcapTfInputToken
void convertMuons(edm::Handle< MicroGMTConfiguration::InputCollection > const &in, MicroGMTConfiguration::InterMuonList &out, GMTInternalWedges &wedges, int bx) const
std::bitset< 12 > m_bmtfInputsToDisable
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void setTowerSums(const MicroGMTConfiguration::CaloInputCollection &inputs, int bx)
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_overlapTfInputToken
edm::EDGetTokenT< MicroGMTConfiguration::CaloInputCollection > m_caloTowerInputToken
MicroGMTIsolationUnit m_isolationUnit
l1t::cancelmode m_emtfCancelMode
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
std::bitset< 12 > m_emtfInputsToDisable
void calculateRank(MicroGMTConfiguration::InterMuonList &muons) const
def move
Definition: eostools.py:511
void sortMuons(MicroGMTConfiguration::InterMuonList &, unsigned) const
const int mu
Definition: Constants.h:22
T min(T a, T b)
Definition: MathUtil.h:58
GMTInternalMuonList InterMuonList
std::bitset< 12 > m_maskedBmtfInputs
Definition: Muon.h:21
BXVector< Muon > MuonBxCollection
Definition: Muon.h:11
void setCancelOutBits(GMTInternalWedges &, tftype, cancelmode)
Cancel out between sectors/wedges in one track finder.
void addMuonsToCollections(MicroGMTConfiguration::InterMuonList &coll, MicroGMTConfiguration::InterMuonList &interout, std::unique_ptr< MuonBxCollection > &out, int bx) const
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_barrelTfInputToken
std::bitset< 12 > m_maskedEmtfInputs
l1t::cancelmode m_bmtfCancelMode
void splitAndConvertMuons(edm::Handle< MicroGMTConfiguration::InputCollection > const &in, MicroGMTConfiguration::InterMuonList &out_pos, MicroGMTConfiguration::InterMuonList &out_neg, GMTInternalWedges &wedges_pos, GMTInternalWedges &wedges_neg, int bx) const
std::map< int, std::vector< std::shared_ptr< GMTInternalMuon > > > GMTInternalWedges
std::bitset< 12 > m_maskedOmtfInputs
std::bitset< 28 > m_caloInputsToDisable
std::bitset< 12 > m_omtfInputsToDisable
MicroGMTCancelOutUnit m_cancelOutUnit
void isolatePreSummed(MicroGMTConfiguration::InterMuonList &muons) const
std::bitset< 28 > m_maskedCaloInputs
void L1TMuonProducer::sortMuons ( MicroGMTConfiguration::InterMuonList muons,
unsigned  nSurvivors 
) const
private

Definition at line 389 of file L1TMuonProducer.cc.

References compareMuons(), and HLT_FULL_cff::muon.

Referenced by produce().

389  {
390  MicroGMTConfiguration::InterMuonList::iterator mu1;
391  // reset from previous sort stage
392  for (mu1 = muons.begin(); mu1 != muons.end(); ++mu1) {
393  (*mu1)->setHwWins(0);
394  }
395 
396  int nCancelled = 0;
397  for (mu1 = muons.begin(); mu1 != muons.end(); ++mu1) {
398  int mu1CancelBit = (*mu1)->hwCancelBit();
399  nCancelled += mu1CancelBit;
400  auto mu2 = mu1;
401  mu2++;
402  for (; mu2 != muons.end(); ++mu2) {
403  if (mu1CancelBit != 1 && (*mu2)->hwCancelBit() != 1) {
404  if ((*mu1)->hwRank() >= (*mu2)->hwRank()) {
405  (*mu1)->increaseWins();
406  } else {
407  (*mu2)->increaseWins();
408  }
409  } else if (mu1CancelBit != 1) {
410  (*mu1)->increaseWins();
411  } else if ((*mu2)->hwCancelBit() != 1) {
412  (*mu2)->increaseWins();
413  }
414  }
415  }
416 
417  size_t nMuonsBefore = muons.size();
418  int minWins = nMuonsBefore - nSurvivors;
419 
420  // remove all muons that were cancelled or that do not have sufficient rank
421  // (reduces the container size to nSurvivors)
422  muons.remove_if([&minWins](auto muon) { return ((muon->hwWins() < minWins) || (muon->hwCancelBit() == 1)); });
424 }
tuple muons
Definition: patZpeak.py:39
static bool compareMuons(const std::shared_ptr< MicroGMTConfiguration::InterMuon > &mu1, const std::shared_ptr< MicroGMTConfiguration::InterMuon > &mu2)
void L1TMuonProducer::splitAndConvertMuons ( edm::Handle< MicroGMTConfiguration::InputCollection > const &  in,
MicroGMTConfiguration::InterMuonList out_pos,
MicroGMTConfiguration::InterMuonList out_neg,
GMTInternalWedges wedges_pos,
GMTInternalWedges wedges_neg,
int  bx 
) const
private

Definition at line 475 of file L1TMuonProducer.cc.

References mps_fire::i, MainPageGenerator::link, m_inputsToDisable, m_maskedInputs, submitPVResolutionJobs::out, and findQualityFiles::size.

Referenced by produce().

480  {
481  // initialize the wedge collections:
482  for (int i = 0; i < 6; ++i) {
483  wedges_pos[i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
484  wedges_pos[i].reserve(3);
485  wedges_neg[i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
486  wedges_neg[i].reserve(3);
487  }
488  if (bx < in->getFirstBX() || bx > in->getLastBX())
489  return;
490  int muIdx = 0;
491  int currentLink = 0;
492  for (size_t i = 0; i < in->size(bx); ++i, ++muIdx) {
493  if (in->at(bx, i).hwPt() > 0) {
494  int link = in->at(bx, i).link();
495  if (m_inputsToDisable.test(link) || m_maskedInputs.test(link)) {
496  continue; // only process if input link is enabled and not masked
497  }
498  if (currentLink != link) {
499  muIdx = 0;
500  currentLink = link;
501  }
502  int gPhi = MicroGMTConfiguration::calcGlobalPhi(
503  in->at(bx, i).hwPhi(), in->at(bx, i).trackFinderType(), in->at(bx, i).processor());
504  int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
505  std::shared_ptr<GMTInternalMuon> out = std::make_shared<GMTInternalMuon>(in->at(bx, i), gPhi, tfMuonIdx);
506  if (in->at(bx, i).hwEta() > 0) {
507  out_pos.push_back(out);
508  wedges_pos[in->at(bx, i).processor()].push_back(out);
509  } else {
510  out_neg.emplace_back(out);
511  wedges_neg[in->at(bx, i).processor()].push_back(out);
512  }
513  }
514  }
515  for (int i = 0; i < 6; ++i) {
516  if (wedges_pos[i].size() > 3)
517  edm::LogWarning("Input Mismatch") << " too many inputs per processor for emtf+ / omtf+. Wedge " << i << ": Size "
518  << wedges_pos[i].size() << std::endl;
519  if (wedges_neg[i].size() > 3)
520  edm::LogWarning("Input Mismatch") << " too many inputs per processor for emtf- / omtf-. Wedge " << i << ": Size "
521  << wedges_neg[i].size() << std::endl;
522  }
523 }
std::bitset< 72 > m_maskedInputs
std::bitset< 72 > m_inputsToDisable
Log< level::Warning, false > LogWarning
tuple size
Write out results.

Member Data Documentation

bool L1TMuonProducer::m_autoBxRange
private

Definition at line 99 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

bool L1TMuonProducer::m_autoCancelMode
private

Definition at line 102 of file L1TMuonProducer.cc.

Referenced by beginRun(), and L1TMuonProducer().

edm::InputTag L1TMuonProducer::m_barrelTfInputTag
private

Definition at line 114 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer().

edm::EDGetTokenT<MicroGMTConfiguration::InputCollection> L1TMuonProducer::m_barrelTfInputToken
private

Definition at line 125 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

l1t::cancelmode L1TMuonProducer::m_bmtfCancelMode
private

Definition at line 122 of file L1TMuonProducer.cc.

Referenced by beginRun(), L1TMuonProducer(), and produce().

std::bitset<12> L1TMuonProducer::m_bmtfInputsToDisable
private

Definition at line 105 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

int L1TMuonProducer::m_bxMax
private

Definition at line 101 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

int L1TMuonProducer::m_bxMin
private

Definition at line 100 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

std::bitset<28> L1TMuonProducer::m_caloInputsToDisable
private

Definition at line 104 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

edm::EDGetTokenT<MicroGMTConfiguration::CaloInputCollection> L1TMuonProducer::m_caloTowerInputToken
private

Definition at line 128 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

MicroGMTCancelOutUnit L1TMuonProducer::m_cancelOutUnit
private

Definition at line 120 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

std::ofstream L1TMuonProducer::m_debugOut
private

Definition at line 121 of file L1TMuonProducer.cc.

Referenced by produce(), and ~L1TMuonProducer().

l1t::cancelmode L1TMuonProducer::m_emtfCancelMode
private

Definition at line 123 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

std::bitset<12> L1TMuonProducer::m_emtfInputsToDisable
private

Definition at line 107 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

edm::InputTag L1TMuonProducer::m_endcapTfInputTag
private

Definition at line 116 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer().

edm::EDGetTokenT<MicroGMTConfiguration::InputCollection> L1TMuonProducer::m_endcapTfInputToken
private

Definition at line 127 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

std::bitset<72> L1TMuonProducer::m_inputsToDisable
private

Definition at line 103 of file L1TMuonProducer.cc.

Referenced by beginRun(), convertMuons(), and splitAndConvertMuons().

MicroGMTIsolationUnit L1TMuonProducer::m_isolationUnit
private

Definition at line 119 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

std::bitset<12> L1TMuonProducer::m_maskedBmtfInputs
private

Definition at line 110 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

std::bitset<28> L1TMuonProducer::m_maskedCaloInputs
private

Definition at line 109 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

std::bitset<12> L1TMuonProducer::m_maskedEmtfInputs
private

Definition at line 112 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

std::bitset<72> L1TMuonProducer::m_maskedInputs
private

Definition at line 108 of file L1TMuonProducer.cc.

Referenced by beginRun(), convertMuons(), and splitAndConvertMuons().

std::bitset<12> L1TMuonProducer::m_maskedOmtfInputs
private

Definition at line 111 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

edm::ESGetToken<L1TMuonGlobalParams, L1TMuonGlobalParamsRcd> L1TMuonProducer::m_microGMTParamsToken
private

Definition at line 129 of file L1TMuonProducer.cc.

Referenced by beginRun(), and L1TMuonProducer().

edm::ESGetToken<L1TMuonGlobalParams, L1TMuonGlobalParamsO2ORcd> L1TMuonProducer::m_o2oProtoToken
private

Definition at line 130 of file L1TMuonProducer.cc.

Referenced by beginRun(), and L1TMuonProducer().

std::bitset<12> L1TMuonProducer::m_omtfInputsToDisable
private

Definition at line 106 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

edm::InputTag L1TMuonProducer::m_overlapTfInputTag
private

Definition at line 115 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer().

edm::EDGetTokenT<MicroGMTConfiguration::InputCollection> L1TMuonProducer::m_overlapTfInputToken
private

Definition at line 126 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

std::shared_ptr<MicroGMTRankPtQualLUT> L1TMuonProducer::m_rankPtQualityLUT
private

Definition at line 118 of file L1TMuonProducer.cc.

Referenced by beginRun(), and calculateRank().

edm::InputTag L1TMuonProducer::m_trigTowerTag
private

Definition at line 117 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer().

std::unique_ptr<L1TMuonGlobalParamsHelper> L1TMuonProducer::microGMTParamsHelper
private

Definition at line 113 of file L1TMuonProducer.cc.

Referenced by beginRun().