CMS 3D CMS Logo

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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 L1TMuonProducer (const edm::ParameterSet &)
 
 ~L1TMuonProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (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
 
edm::InputTag m_barrelTfInputTag
 
edm::EDGetTokenT< MicroGMTConfiguration::InputCollectionm_barrelTfInputToken
 
std::bitset< 12 > m_bmtfInputsToDisable
 
int m_bxMax
 
int m_bxMin
 
std::bitset< 28 > m_caloInputsToDisable
 
edm::EDGetTokenT< MicroGMTConfiguration::CaloInputCollectionm_caloTowerInputToken
 
MicroGMTCancelOutUnit m_cancelOutUnit
 
std::ofstream m_debugOut
 
std::bitset< 12 > m_emtfInputsToDisable
 
edm::InputTag m_endcapTfInputTag
 
edm::EDGetTokenT< MicroGMTConfiguration::InputCollectionm_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
 
std::bitset< 12 > m_omtfInputsToDisable
 
edm::InputTag m_overlapTfInputTag
 
edm::EDGetTokenT< MicroGMTConfiguration::InputCollectionm_overlapTfInputToken
 
std::shared_ptr< MicroGMTRankPtQualLUTm_rankPtQualityLUT
 
edm::InputTag m_trigTowerTag
 
std::unique_ptr< L1TMuonGlobalParamsHelpermicroGMTParamsHelper
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

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

Implementation: [Notes on implementation]

Definition at line 57 of file L1TMuonProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 139 of file L1TMuonProducer.cc.

References edm::ParameterSet::getParameter(), m_autoBxRange, m_barrelTfInputTag, m_barrelTfInputToken, m_bxMax, m_bxMin, m_caloTowerInputToken, m_endcapTfInputTag, m_endcapTfInputToken, m_overlapTfInputTag, m_overlapTfInputToken, and m_trigTowerTag.

139  : m_debugOut("test/debug/iso_debug.dat")
140 {
141  // edm::InputTag barrelTfInputTag = iConfig.getParameter<edm::InputTag>("barrelTFInput");
142  // edm::InputTag overlapTfInputTag = iConfig.getParameter<edm::InputTag>("overlapTFInput");
143  // edm::InputTag forwardTfInputTag = iConfig.getParameter<edm::InputTag>("forwardTFInput");
144 
145  m_barrelTfInputTag = iConfig.getParameter<edm::InputTag>("barrelTFInput");
146  m_overlapTfInputTag = iConfig.getParameter<edm::InputTag>("overlapTFInput");
147  m_endcapTfInputTag = iConfig.getParameter<edm::InputTag>("forwardTFInput");
148  m_trigTowerTag = iConfig.getParameter<edm::InputTag>("triggerTowerInput");
149 
150  m_autoBxRange = iConfig.getParameter<bool>("autoBxRange");
151  m_bxMin = iConfig.getParameter<int>("bxMin");
152  m_bxMax = iConfig.getParameter<int>("bxMax");
153 
154  m_barrelTfInputToken = consumes<MicroGMTConfiguration::InputCollection>(m_barrelTfInputTag);
155  m_overlapTfInputToken = consumes<MicroGMTConfiguration::InputCollection>(m_overlapTfInputTag);
156  m_endcapTfInputToken = consumes<MicroGMTConfiguration::InputCollection>(m_endcapTfInputTag);
157  m_caloTowerInputToken = consumes<MicroGMTConfiguration::CaloInputCollection>(m_trigTowerTag);
158 
159  //register your products
160  produces<MuonBxCollection>();
161  produces<MuonBxCollection>("imdMuonsBMTF");
162  produces<MuonBxCollection>("imdMuonsEMTFPos");
163  produces<MuonBxCollection>("imdMuonsEMTFNeg");
164  produces<MuonBxCollection>("imdMuonsOMTFPos");
165  produces<MuonBxCollection>("imdMuonsOMTFNeg");
166 }
T getParameter(std::string const &) const
std::ofstream m_debugOut
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_endcapTfInputToken
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_overlapTfInputToken
edm::EDGetTokenT< MicroGMTConfiguration::CaloInputCollection > m_caloTowerInputToken
edm::InputTag m_overlapTfInputTag
edm::InputTag m_barrelTfInputTag
edm::InputTag m_endcapTfInputTag
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_barrelTfInputToken
edm::InputTag m_trigTowerTag
L1TMuonProducer::~L1TMuonProducer ( )
override

Definition at line 168 of file L1TMuonProducer.cc.

References m_debugOut.

169 {
170  m_debugOut.close();
171 }
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 407 of file L1TMuonProducer.cc.

References RPCpg::mu.

Referenced by produce().

410 {
411  for (auto& mu : coll) {
412  interout.push_back(mu);
413  math::PtEtaPhiMLorentzVector vec{(mu->hwPt()-1)*0.5, mu->hwEta()*0.010875, mu->hwGlobalPhi()*0.010908, 0.0};
414  int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(mu->hwQual(), mu->trackFinderType(), mu->hwHF());
415  // set tfMuonIndex and iso to 0 like in the FW
416  Muon outMu{vec, mu->hwPt(), mu->hwEta(), mu->hwGlobalPhi(), outMuQual, mu->hwSign(), mu->hwSignValid(), 0, 0, 0, true, 0, mu->hwDPhi(), mu->hwDEta(), mu->hwRank()};
417  if (mu->hwSignValid()) {
418  outMu.setCharge(1 - 2 * mu->hwSign());
419  } else {
420  outMu.setCharge(0);
421  }
422 
423  out->push_back(bx, outMu);
424  }
425 }
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
Definition: Muon.py:1
const int mu
Definition: Constants.h:22
JetCorrectorParametersCollection coll
Definition: classes.h:10
void L1TMuonProducer::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
overrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 539 of file L1TMuonProducer.cc.

540 {
541 }
void L1TMuonProducer::beginRun ( edm::Run const &  run,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 502 of file L1TMuonProducer.cc.

References l1t::MicroGMTRankPtQualLUTFactory::create(), edm::EventSetup::get(), edm::eventsetup::EventSetupRecord::get(), l1t::MicroGMTIsolationUnit::initialise(), l1t::MicroGMTCancelOutUnit::initialise(), m_bmtfInputsToDisable, m_caloInputsToDisable, m_cancelOutUnit, m_emtfInputsToDisable, m_inputsToDisable, m_isolationUnit, m_maskedBmtfInputs, m_maskedCaloInputs, m_maskedEmtfInputs, m_maskedInputs, m_maskedOmtfInputs, m_omtfInputsToDisable, m_rankPtQualityLUT, and microGMTParamsHelper.

503 {
504  const L1TMuonGlobalParamsRcd& microGMTParamsRcd = iSetup.get<L1TMuonGlobalParamsRcd>();
505  edm::ESHandle<L1TMuonGlobalParams> microGMTParamsHandle;
506  microGMTParamsRcd.get(microGMTParamsHandle);
507 
508  microGMTParamsHelper = std::make_unique<L1TMuonGlobalParamsHelper>(*microGMTParamsHandle.product());
509  if (!microGMTParamsHelper) {
510  edm::LogError("L1TMuonProducer") << "Could not retrieve parameters from Event Setup" << std::endl;
511  }
512 
513  //microGMTParamsHelper->print(std::cout);
514  m_inputsToDisable = microGMTParamsHelper->inputsToDisable();
515  edm::LogVerbatim("L1TMuonProducer") << "uGMT inputsToDisable: " << m_inputsToDisable << "\n EMTF-|OMTF-| BMTF |OMTF+|EMTF+| CALO | res 0";
516  m_caloInputsToDisable = microGMTParamsHelper->caloInputsToDisable();
517  m_bmtfInputsToDisable = microGMTParamsHelper->bmtfInputsToDisable();
518  m_omtfInputsToDisable = microGMTParamsHelper->omtfInputsToDisable();
519  m_emtfInputsToDisable = microGMTParamsHelper->emtfInputsToDisable();
520  m_maskedInputs = microGMTParamsHelper->maskedInputs();
521  edm::LogVerbatim("L1TMuonProducer") << "uGMT maskedInputs: " << m_maskedInputs << "\n EMTF-|OMTF-| BMTF |OMTF+|EMTF+| CALO | res 0";
522  m_maskedCaloInputs = microGMTParamsHelper->maskedCaloInputs();
523  m_maskedBmtfInputs = microGMTParamsHelper->maskedBmtfInputs();
524  m_maskedOmtfInputs = microGMTParamsHelper->maskedOmtfInputs();
525  m_maskedEmtfInputs = microGMTParamsHelper->maskedEmtfInputs();
529 }
void initialise(L1TMuonGlobalParamsHelper *)
Initialisation from ES record.
std::unique_ptr< L1TMuonGlobalParamsHelper > microGMTParamsHelper
std::bitset< 12 > m_bmtfInputsToDisable
MicroGMTIsolationUnit m_isolationUnit
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
void get(HolderT &iHolder) const
std::bitset< 12 > m_maskedBmtfInputs
std::bitset< 12 > m_maskedEmtfInputs
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 397 of file L1TMuonProducer.cc.

References m_rankPtQualityLUT.

Referenced by produce().

398 {
399  for (auto& mu1 : muons) {
400  int rank = m_rankPtQualityLUT->lookup(mu1->hwPt(), mu1->hwQual());
401  mu1->setHwRank(rank);
402  }
403 }
std::shared_ptr< MicroGMTRankPtQualLUT > m_rankPtQualityLUT
bool L1TMuonProducer::compareMuons ( const std::shared_ptr< MicroGMTConfiguration::InterMuon > &  mu1,
const std::shared_ptr< MicroGMTConfiguration::InterMuon > &  mu2 
)
staticprivate

Definition at line 351 of file L1TMuonProducer.cc.

Referenced by sortMuons().

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

Definition at line 470 of file L1TMuonProducer.cc.

References BXVector< T >::at(), BXVector< T >::getLastBX(), l1t::RegionalMuonCand::hwPhi(), mps_fire::i, l1t::RegionalMuonCand::link(), m_inputsToDisable, m_maskedInputs, l1t::RegionalMuonCand::processor(), BXVector< T >::size(), findQualityFiles::size, and l1t::RegionalMuonCand::trackFinderType().

Referenced by produce().

473 {
474  // initialize the wedge collection:
475  for (int i = 0; i < 12; ++i) {
476  wedges[i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
477  wedges[i].reserve(3);
478  }
479  if (bx < in->getFirstBX() || bx > in->getLastBX()) return;
480  int muIdx = 0;
481  int currentLink = 0;
482  for (size_t i = 0; i < in->size(bx); ++i, ++muIdx) {
483  int link = in->at(bx, i).link();
484  if (m_inputsToDisable.test(link) || m_maskedInputs.test(link)) continue; // only process if input link is enabled and not masked
485  if (currentLink != link) {
486  muIdx = 0;
487  currentLink = link;
488  }
489  int gPhi = MicroGMTConfiguration::calcGlobalPhi(in->at(bx, i).hwPhi(), in->at(bx, i).trackFinderType(), in->at(bx, i).processor());
490  int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
491  std::shared_ptr<GMTInternalMuon> outMu = std::make_shared<GMTInternalMuon>(in->at(bx, i), gPhi, tfMuonIdx);
492  out.emplace_back(outMu);
493  wedges[in->at(bx, i).processor()].push_back(outMu);
494  }
495  for (int i = 0; i < 12; ++i) {
496  if(wedges[i].size() > 3) edm::LogWarning("Input Mismatch") << " too many inputs per processor for barrel. Wedge " << i << ": Size " << wedges[i].size() << std::endl;
497  }
498 }
size
Write out results.
unsigned size(int bx) const
const int hwPhi() const
Get compressed local phi (returned int * 2*pi/576 = local phi in rad)
const int link() const
Get link on which the MicroGMT receives the candidate.
const tftype trackFinderType() const
Get track-finder which found the muon (bmtf, emtf_pos/emtf_neg or omtf_pos/omtf_neg) ...
const int processor() const
Get processor ID on which the candidate was found (0..5 for OMTF/EMTF; 0..11 for BMTF) ...
int getLastBX() const
std::bitset< 72 > m_maskedInputs
std::bitset< 72 > m_inputsToDisable
const T & at(int bx, unsigned i) const
void L1TMuonProducer::endLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
overrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 545 of file L1TMuonProducer.cc.

546 {
547 }
void L1TMuonProducer::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
overrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 533 of file L1TMuonProducer.cc.

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

Definition at line 551 of file L1TMuonProducer.cc.

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

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

Definition at line 182 of file L1TMuonProducer.cc.

References addMuonsToCollections(), l1t::bmtf, calculateRank(), convertMuons(), l1t::coordinate, l1t::emtf_neg, l1t::emtf_pos, l1t::MicroGMTIsolationUnit::extrapolateMuons(), edm::Event::getByToken(), BXVector< T >::getFirstBX(), BXVector< T >::getLastBX(), l1t::MicroGMTIsolationUnit::isolatePreSummed(), m_autoBxRange, m_barrelTfInputToken, m_bmtfInputsToDisable, m_bxMax, m_bxMin, m_caloInputsToDisable, m_caloTowerInputToken, m_cancelOutUnit, m_debugOut, m_emtfInputsToDisable, m_endcapTfInputToken, m_isolationUnit, m_maskedBmtfInputs, m_maskedCaloInputs, m_maskedEmtfInputs, m_maskedOmtfInputs, m_omtfInputsToDisable, m_overlapTfInputToken, hpstanc_transforms::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(), splitAndConvertMuons(), and l1t::tracks.

183 {
184  using namespace edm;
185  std::unique_ptr<MuonBxCollection> outMuons (new MuonBxCollection());
186  std::unique_ptr<MuonBxCollection> imdMuonsBMTF (new MuonBxCollection());
187  std::unique_ptr<MuonBxCollection> imdMuonsEMTFPos (new MuonBxCollection());
188  std::unique_ptr<MuonBxCollection> imdMuonsEMTFNeg (new MuonBxCollection());
189  std::unique_ptr<MuonBxCollection> imdMuonsOMTFPos (new MuonBxCollection());
190  std::unique_ptr<MuonBxCollection> imdMuonsOMTFNeg (new MuonBxCollection());
191 
192 
197 
198  iEvent.getByToken(m_barrelTfInputToken, bmtfMuons);
199  iEvent.getByToken(m_endcapTfInputToken, emtfMuons);
200  iEvent.getByToken(m_overlapTfInputToken, omtfMuons);
201  iEvent.getByToken(m_caloTowerInputToken, trigTowers);
202 
203  // find out the BX range from the inputs
204  // the smallest BX window defines the output BX window
205  if (m_autoBxRange) {
206  int bxMin = -1000;
207  int bxMax = 1000;
208  if (!(m_caloInputsToDisable.all() || m_maskedCaloInputs.all())) {
209  bxMin = std::max(bxMin, trigTowers->getFirstBX());
210  bxMax = std::min(bxMax, trigTowers->getLastBX());
211  }
212  if (!(m_bmtfInputsToDisable.all() || m_maskedBmtfInputs.all())) {
213  bxMin = std::max(bxMin, bmtfMuons->getFirstBX());
214  bxMax = std::min(bxMax, bmtfMuons->getLastBX());
215  }
216  if (!(m_omtfInputsToDisable.all() || m_maskedOmtfInputs.all())) {
217  bxMin = std::max(bxMin, omtfMuons->getFirstBX());
218  bxMax = std::min(bxMax, omtfMuons->getLastBX());
219  }
220  if (!(m_emtfInputsToDisable.all() || m_maskedEmtfInputs.all())) {
221  bxMin = std::max(bxMin, emtfMuons->getFirstBX());
222  bxMax = std::min(bxMax, emtfMuons->getLastBX());
223  }
224  if (bxMin > 0) {
225  bxMin = 0;
226  }
227  if (bxMax < 0){
228  bxMax = 0;
229  }
230  if (bxMin > -1000) {
231  m_bxMin = bxMin;
232  } else {
233  m_bxMin = 0;
234  }
235  if (bxMax < 1000) {
236  m_bxMax = bxMax;
237  } else {
238  m_bxMax = 0;
239  }
240  }
241 
242  // set BX range for outputs
243  outMuons->setBXRange(m_bxMin, m_bxMax);
244  imdMuonsBMTF->setBXRange(m_bxMin, m_bxMax);
245  imdMuonsEMTFPos->setBXRange(m_bxMin, m_bxMax);
246  imdMuonsEMTFNeg->setBXRange(m_bxMin, m_bxMax);
247  imdMuonsOMTFPos->setBXRange(m_bxMin, m_bxMax);
248  imdMuonsOMTFNeg->setBXRange(m_bxMin, m_bxMax);
249 
250  for (int bx = m_bxMin; bx <= m_bxMax; ++bx) {
251  m_isolationUnit.setTowerSums(*trigTowers, bx);
252  MicroGMTConfiguration::InterMuonList internMuonsBmtf;
253  MicroGMTConfiguration::InterMuonList internMuonsEmtfPos;
254  MicroGMTConfiguration::InterMuonList internMuonsEmtfNeg;
255  MicroGMTConfiguration::InterMuonList internMuonsOmtfPos;
256  MicroGMTConfiguration::InterMuonList internMuonsOmtfNeg;
257 
258  // These wedges contain shared pointers to the ones in the InterMuonList
259  GMTInternalWedges omtfNegWedges;
260  GMTInternalWedges bmtfWedges;
261  GMTInternalWedges emtfPosWedges;
262  GMTInternalWedges emtfNegWedges;
263  GMTInternalWedges omtfPosWedges;
264 
265  // this converts the InputMuon type to the InternalMuon type and splits them into
266  // positive / negative eta collections necessary as LUTs may differ for pos / neg.
267  convertMuons(bmtfMuons, internMuonsBmtf, bmtfWedges, bx);
268  splitAndConvertMuons(emtfMuons, internMuonsEmtfPos, internMuonsEmtfNeg, emtfPosWedges, emtfNegWedges, bx);
269  splitAndConvertMuons(omtfMuons, internMuonsOmtfPos, internMuonsOmtfNeg, omtfPosWedges, omtfNegWedges, bx);
270 
271  // cancel out within the track finders:
275  // cancel-out for endcap will be done in the sorter
278 
279  // cancel out between track finder acceptance overlaps:
284 
285  m_isolationUnit.extrapolateMuons(internMuonsBmtf);
286  m_isolationUnit.extrapolateMuons(internMuonsEmtfNeg);
287  m_isolationUnit.extrapolateMuons(internMuonsEmtfPos);
288  m_isolationUnit.extrapolateMuons(internMuonsOmtfNeg);
289  m_isolationUnit.extrapolateMuons(internMuonsOmtfPos);
290 
291  // the rank calculated here is used in the sort below
292  calculateRank(internMuonsBmtf);
293  calculateRank(internMuonsEmtfNeg);
294  calculateRank(internMuonsEmtfPos);
295  calculateRank(internMuonsOmtfNeg);
296  calculateRank(internMuonsOmtfPos);
297 
298  // The sort function both sorts and removes all but best "nSurvivors"
299  sortMuons(internMuonsBmtf, 8);
300  sortMuons(internMuonsOmtfPos, 4);
301  sortMuons(internMuonsOmtfNeg, 4);
302  sortMuons(internMuonsEmtfPos, 4);
303  sortMuons(internMuonsEmtfNeg, 4);
304 
305  // This combines the 5 streams into one InternalMuon collection for
306  // the final global sort.
308  addMuonsToCollections(internMuonsEmtfPos, internalMuons, imdMuonsEMTFPos, bx);
309  addMuonsToCollections(internMuonsOmtfPos, internalMuons, imdMuonsOMTFPos, bx);
310  addMuonsToCollections(internMuonsBmtf, internalMuons, imdMuonsBMTF, bx);
311  addMuonsToCollections(internMuonsOmtfNeg, internalMuons, imdMuonsOMTFNeg, bx);
312  addMuonsToCollections(internMuonsEmtfNeg, internalMuons, imdMuonsEMTFNeg, bx);
313 
314  // sort internal muons and delete all but best 8
315  sortMuons(internalMuons, 8);
316 
317  m_isolationUnit.isolatePreSummed(internalMuons);
318  // copy muons to output collection...
319  for (const auto& mu : internalMuons) {
320  if (mu->hwPt() > 0) {
321  math::PtEtaPhiMLorentzVector vec{(mu->hwPt()-1)*0.5, mu->hwEta()*0.010875, mu->hwGlobalPhi()*0.010908, 0.0};
322  int iso = mu->hwAbsIso() + (mu->hwRelIso() << 1);
323  int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(mu->hwQual(), mu->trackFinderType(), mu->hwHF());
324  Muon outMu{vec, mu->hwPt(), mu->hwEta(), mu->hwGlobalPhi(), outMuQual, mu->hwSign(), mu->hwSignValid(), iso, mu->tfMuonIndex(), 0, true, mu->hwIsoSum(), mu->hwDPhi(), mu->hwDEta(), mu->hwRank()};
325  if (mu->hwSignValid()) {
326  outMu.setCharge(1 - 2 * mu->hwSign());
327  } else {
328  outMu.setCharge(0);
329  }
330  // set the coordinates at the vertex
331  outMu.setHwEtaAtVtx(MicroGMTConfiguration::calcMuonHwEtaExtra(outMu));
332  outMu.setHwPhiAtVtx(MicroGMTConfiguration::calcMuonHwPhiExtra(outMu));
333  outMu.setEtaAtVtx(MicroGMTConfiguration::calcMuonEtaExtra(outMu));
334  outMu.setPhiAtVtx(MicroGMTConfiguration::calcMuonPhiExtra(outMu));
335  m_debugOut << mu->hwCaloPhi() << " " << mu->hwCaloEta() << std::endl;
336  outMuons->push_back(bx, outMu);
337  }
338  }
339  }
340 
341  iEvent.put(std::move(outMuons));
342  iEvent.put(std::move(imdMuonsBMTF), "imdMuonsBMTF");
343  iEvent.put(std::move(imdMuonsEMTFPos), "imdMuonsEMTFPos");
344  iEvent.put(std::move(imdMuonsEMTFNeg), "imdMuonsEMTFNeg");
345  iEvent.put(std::move(imdMuonsOMTFPos), "imdMuonsOMTFPos");
346  iEvent.put(std::move(imdMuonsOMTFNeg), "imdMuonsOMTFNeg");
347 }
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:122
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:460
void setTowerSums(const MicroGMTConfiguration::CaloInputCollection &inputs, int bx)
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_overlapTfInputToken
edm::EDGetTokenT< MicroGMTConfiguration::CaloInputCollection > m_caloTowerInputToken
MicroGMTIsolationUnit m_isolationUnit
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
std::bitset< 12 > m_emtfInputsToDisable
Definition: Muon.py:1
void calculateRank(MicroGMTConfiguration::InterMuonList &muons) const
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
BXVector< Muon > MuonBxCollection
Definition: Muon.h:10
int getFirstBX() const
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
HLT enums.
std::bitset< 12 > m_maskedEmtfInputs
int getLastBX() 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
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
def move(src, dest)
Definition: eostools.py:510
std::bitset< 28 > m_maskedCaloInputs
void L1TMuonProducer::sortMuons ( MicroGMTConfiguration::InterMuonList muons,
unsigned  nSurvivors 
) const
private

Definition at line 357 of file L1TMuonProducer.cc.

References compareMuons().

Referenced by produce().

357  {
358  MicroGMTConfiguration::InterMuonList::iterator mu1;
359  // reset from previous sort stage
360  for (mu1 = muons.begin(); mu1 != muons.end(); ++mu1) {
361  (*mu1)->setHwWins(0);
362  }
363 
364  int nCancelled = 0;
365  for (mu1 = muons.begin(); mu1 != muons.end(); ++mu1) {
366  int mu1CancelBit = (*mu1)->hwCancelBit();
367  nCancelled += mu1CancelBit;
368  auto mu2 = mu1;
369  mu2++;
370  for ( ; mu2 != muons.end(); ++mu2) {
371  if (mu1CancelBit != 1 && (*mu2)->hwCancelBit() != 1) {
372  if ((*mu1)->hwRank() >= (*mu2)->hwRank()) {
373  (*mu1)->increaseWins();
374  } else {
375  (*mu2)->increaseWins();
376  }
377  } else if (mu1CancelBit != 1) {
378  (*mu1)->increaseWins();
379  } else if ((*mu2)->hwCancelBit() != 1) {
380  (*mu2)->increaseWins();
381  }
382  }
383  }
384 
385  size_t nMuonsBefore = muons.size();
386  int minWins = nMuonsBefore - nSurvivors;
387 
388  // remove all muons that were cancelled or that do not have sufficient rank
389  // (reduces the container size to nSurvivors)
390  muons.remove_if([&minWins](auto muon) { return ((muon->hwWins() < minWins) || (muon->hwCancelBit() == 1)); });
392 }
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 428 of file L1TMuonProducer.cc.

References BXVector< T >::at(), BXVector< T >::getLastBX(), l1t::RegionalMuonCand::hwEta(), l1t::RegionalMuonCand::hwPhi(), mps_fire::i, l1t::RegionalMuonCand::link(), m_inputsToDisable, m_maskedInputs, MillePedeFileConverter_cfg::out, l1t::RegionalMuonCand::processor(), BXVector< T >::size(), findQualityFiles::size, and l1t::RegionalMuonCand::trackFinderType().

Referenced by produce().

434 {
435  // initialize the wedge collections:
436  for (int i = 0; i < 6; ++i) {
437  wedges_pos[i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
438  wedges_pos[i].reserve(3);
439  wedges_neg[i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
440  wedges_neg[i].reserve(3);
441  }
442  if (bx < in->getFirstBX() || bx > in->getLastBX()) return;
443  int muIdx = 0;
444  int currentLink = 0;
445  for (size_t i = 0; i < in->size(bx); ++i, ++muIdx) {
446  int link = in->at(bx, i).link();
447  if (m_inputsToDisable.test(link) || m_maskedInputs.test(link)) continue; // only process if input link is enabled and not masked
448  if (currentLink != link) {
449  muIdx = 0;
450  currentLink = link;
451  }
452  int gPhi = MicroGMTConfiguration::calcGlobalPhi(in->at(bx, i).hwPhi(), in->at(bx, i).trackFinderType(), in->at(bx, i).processor());
453  int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
454  std::shared_ptr<GMTInternalMuon> out = std::make_shared<GMTInternalMuon>(in->at(bx, i), gPhi, tfMuonIdx);
455  if(in->at(bx, i).hwEta() > 0) {
456  out_pos.push_back(out);
457  wedges_pos[in->at(bx, i).processor()].push_back(out);
458  } else {
459  out_neg.emplace_back(out);
460  wedges_neg[in->at(bx, i).processor()].push_back(out);
461  }
462  }
463  for (int i = 0; i < 6; ++i) {
464  if(wedges_pos[i].size() > 3) edm::LogWarning("Input Mismatch") << " too many inputs per processor for emtf+ / omtf+. Wedge " << i << ": Size " << wedges_pos[i].size() << std::endl;
465  if(wedges_neg[i].size() > 3) edm::LogWarning("Input Mismatch") << " too many inputs per processor for emtf- / omtf-. Wedge " << i << ": Size " << wedges_neg[i].size() << std::endl;
466  }
467 }
size
Write out results.
unsigned size(int bx) const
const int hwEta() const
Get compressed eta (returned int * 0.010875 = eta)
const int hwPhi() const
Get compressed local phi (returned int * 2*pi/576 = local phi in rad)
const int link() const
Get link on which the MicroGMT receives the candidate.
const tftype trackFinderType() const
Get track-finder which found the muon (bmtf, emtf_pos/emtf_neg or omtf_pos/omtf_neg) ...
const int processor() const
Get processor ID on which the candidate was found (0..5 for OMTF/EMTF; 0..11 for BMTF) ...
int getLastBX() const
std::bitset< 72 > m_maskedInputs
std::bitset< 72 > m_inputsToDisable
const T & at(int bx, unsigned i) const

Member Data Documentation

bool L1TMuonProducer::m_autoBxRange
private

Definition at line 97 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

edm::InputTag L1TMuonProducer::m_barrelTfInputTag
private

Definition at line 111 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer().

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

Definition at line 120 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

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

Definition at line 102 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

int L1TMuonProducer::m_bxMax
private

Definition at line 99 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

int L1TMuonProducer::m_bxMin
private

Definition at line 98 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

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

Definition at line 101 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

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

Definition at line 123 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

MicroGMTCancelOutUnit L1TMuonProducer::m_cancelOutUnit
private

Definition at line 117 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

std::ofstream L1TMuonProducer::m_debugOut
private

Definition at line 118 of file L1TMuonProducer.cc.

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

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

Definition at line 104 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

edm::InputTag L1TMuonProducer::m_endcapTfInputTag
private

Definition at line 113 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer().

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

Definition at line 122 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

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

Definition at line 100 of file L1TMuonProducer.cc.

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

MicroGMTIsolationUnit L1TMuonProducer::m_isolationUnit
private

Definition at line 116 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

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

Definition at line 107 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

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

Definition at line 106 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

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

Definition at line 109 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

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

Definition at line 105 of file L1TMuonProducer.cc.

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

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

Definition at line 108 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

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

Definition at line 103 of file L1TMuonProducer.cc.

Referenced by beginRun(), and produce().

edm::InputTag L1TMuonProducer::m_overlapTfInputTag
private

Definition at line 112 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer().

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

Definition at line 121 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

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

Definition at line 115 of file L1TMuonProducer.cc.

Referenced by beginRun(), and calculateRank().

edm::InputTag L1TMuonProducer::m_trigTowerTag
private

Definition at line 114 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer().

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

Definition at line 110 of file L1TMuonProducer.cc.

Referenced by beginRun().