CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 L1TMuonProducer (const edm::ParameterSet &)
 
 ~L1TMuonProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
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::auto_ptr< MuonBxCollection > &out, int bx) const
 
virtual void beginJob ()
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &)
 
void calculateRank (MicroGMTConfiguration::InterMuonList &muons) const
 
void convertMuons (edm::Handle< MicroGMTConfiguration::InputCollection > const &in, MicroGMTConfiguration::InterMuonList &out, GMTInternalWedges &wedges, int bx) const
 
virtual void endJob ()
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void endRun (edm::Run const &, edm::EventSetup const &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
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::InputCollection
m_barrelTfInputToken
 
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
 
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
 
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::EDProducer
typedef EDProducer 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 58 of file L1TMuonProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 142 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.

142  : m_debugOut("test/debug/iso_debug.dat")
143 {
144  // edm::InputTag barrelTfInputTag = iConfig.getParameter<edm::InputTag>("barrelTFInput");
145  // edm::InputTag overlapTfInputTag = iConfig.getParameter<edm::InputTag>("overlapTFInput");
146  // edm::InputTag forwardTfInputTag = iConfig.getParameter<edm::InputTag>("forwardTFInput");
147 
148  m_barrelTfInputTag = iConfig.getParameter<edm::InputTag>("barrelTFInput");
149  m_overlapTfInputTag = iConfig.getParameter<edm::InputTag>("overlapTFInput");
150  m_endcapTfInputTag = iConfig.getParameter<edm::InputTag>("forwardTFInput");
151  m_trigTowerTag = iConfig.getParameter<edm::InputTag>("triggerTowerInput");
152 
153  m_autoBxRange = iConfig.getParameter<bool>("autoBxRange");
154  m_bxMin = iConfig.getParameter<int>("bxMin");
155  m_bxMax = iConfig.getParameter<int>("bxMax");
156 
157  m_barrelTfInputToken = consumes<MicroGMTConfiguration::InputCollection>(m_barrelTfInputTag);
158  m_overlapTfInputToken = consumes<MicroGMTConfiguration::InputCollection>(m_overlapTfInputTag);
159  m_endcapTfInputToken = consumes<MicroGMTConfiguration::InputCollection>(m_endcapTfInputTag);
160  m_caloTowerInputToken = consumes<MicroGMTConfiguration::CaloInputCollection>(m_trigTowerTag);
161 
162  //register your products
163  produces<MuonBxCollection>();
164  produces<MuonBxCollection>("imdMuonsBMTF");
165  produces<MuonBxCollection>("imdMuonsEMTFPos");
166  produces<MuonBxCollection>("imdMuonsEMTFNeg");
167  produces<MuonBxCollection>("imdMuonsOMTFPos");
168  produces<MuonBxCollection>("imdMuonsOMTFNeg");
169 }
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 ( )

Definition at line 171 of file L1TMuonProducer.cc.

References m_debugOut.

172 {
173  m_debugOut.close();
174 }
std::ofstream m_debugOut

Member Function Documentation

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

Definition at line 411 of file L1TMuonProducer.cc.

References RPCpg::mu.

Referenced by produce().

414 {
415  for (auto& mu : coll) {
416  interout.push_back(mu);
417  math::PtEtaPhiMLorentzVector vec{(mu->hwPt()-1)*0.5, mu->hwEta()*0.010875, mu->hwGlobalPhi()*0.010908, 0.0};
418  // FIXME: once we debugged the change global -> local: Change hwLocalPhi -> hwGlobalPhi to test offsets
419  int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(mu->hwQual(), mu->trackFinderType(), mu->hwHF());
420  Muon outMu{vec, mu->hwPt(), mu->hwEta(), mu->hwGlobalPhi(), outMuQual, mu->hwSign(), mu->hwSignValid(), -1, mu->tfMuonIndex(), 0, true, -1, mu->hwDPhi(), mu->hwDEta(), mu->hwRank()};
421  if (mu->hwSignValid()) {
422  outMu.setCharge(1 - 2 * mu->hwSign());
423  } else {
424  outMu.setCharge(0);
425  }
426 
427  out->push_back(bx, outMu);
428  }
429 }
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
const int mu
Definition: Constants.h:22
Definition: Muon.h:16
JetCorrectorParametersCollection coll
Definition: classes.h:10
void L1TMuonProducer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 506 of file L1TMuonProducer.cc.

507 {
508 }
void L1TMuonProducer::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 554 of file L1TMuonProducer.cc.

555 {
556 }
void L1TMuonProducer::beginRun ( edm::Run const &  run,
edm::EventSetup const &  iSetup 
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 517 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.

518 {
519  const L1TMuonGlobalParamsRcd& microGMTParamsRcd = iSetup.get<L1TMuonGlobalParamsRcd>();
520  edm::ESHandle<L1TMuonGlobalParams> microGMTParamsHandle;
521  microGMTParamsRcd.get(microGMTParamsHandle);
522 
523  microGMTParamsHelper = std::unique_ptr<L1TMuonGlobalParamsHelper>(new L1TMuonGlobalParamsHelper(*microGMTParamsHandle.product()));
524  if (!microGMTParamsHelper) {
525  edm::LogError("L1TMuonProducer") << "Could not retrieve parameters from Event Setup" << std::endl;
526  }
527 
528  //microGMTParamsHelper->print(std::cout);
529  m_inputsToDisable = microGMTParamsHelper->inputsToDisable();
530  edm::LogVerbatim("L1TMuonProducer") << "uGMT inputsToDisable: " << m_inputsToDisable << "\n EMTF-|OMTF-| BMTF |OMTF+|EMTF+| CALO | res 0";
531  m_caloInputsToDisable = microGMTParamsHelper->caloInputsToDisable();
532  m_bmtfInputsToDisable = microGMTParamsHelper->bmtfInputsToDisable();
533  m_omtfInputsToDisable = microGMTParamsHelper->omtfInputsToDisable();
534  m_emtfInputsToDisable = microGMTParamsHelper->emtfInputsToDisable();
535  m_maskedInputs = microGMTParamsHelper->maskedInputs();
536  edm::LogVerbatim("L1TMuonProducer") << "uGMT maskedInputs: " << m_maskedInputs << "\n EMTF-|OMTF-| BMTF |OMTF+|EMTF+| CALO | res 0";
537  m_maskedCaloInputs = microGMTParamsHelper->maskedCaloInputs();
538  m_maskedBmtfInputs = microGMTParamsHelper->maskedBmtfInputs();
539  m_maskedOmtfInputs = microGMTParamsHelper->maskedOmtfInputs();
540  m_maskedEmtfInputs = microGMTParamsHelper->maskedEmtfInputs();
544 }
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 401 of file L1TMuonProducer.cc.

References m_rankPtQualityLUT.

Referenced by produce().

402 {
403  for (auto& mu1 : muons) {
404  int rank = m_rankPtQualityLUT->lookup(mu1->hwPt(), mu1->hwQual());
405  mu1->setHwRank(rank);
406  }
407 }
std::shared_ptr< MicroGMTRankPtQualLUT > m_rankPtQualityLUT
tuple muons
Definition: patZpeak.py:38
bool L1TMuonProducer::compareMuons ( const std::shared_ptr< MicroGMTConfiguration::InterMuon > &  mu1,
const std::shared_ptr< MicroGMTConfiguration::InterMuon > &  mu2 
)
staticprivate

Definition at line 349 of file L1TMuonProducer.cc.

Referenced by sortMuons().

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

Definition at line 474 of file L1TMuonProducer.cc.

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

Referenced by produce().

477 {
478  // initialize the wedge collection:
479  for (int i = 0; i < 12; ++i) {
480  wedges[i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
481  wedges[i].reserve(3);
482  }
483  if (bx < in->getFirstBX() || bx > in->getLastBX()) return;
484  int muIdx = 0;
485  int currentLink = 0;
486  for (size_t i = 0; i < in->size(bx); ++i, ++muIdx) {
487  int link = in->at(bx, i).link();
488  if (m_inputsToDisable.test(link) || m_maskedInputs.test(link)) continue; // only process if input link is enabled and not masked
489  if (currentLink != link) {
490  muIdx = 0;
491  currentLink = link;
492  }
493  int gPhi = MicroGMTConfiguration::calcGlobalPhi(in->at(bx, i).hwPhi(), in->at(bx, i).trackFinderType(), in->at(bx, i).processor());
494  int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
495  std::shared_ptr<GMTInternalMuon> outMu = std::make_shared<GMTInternalMuon>(in->at(bx, i), gPhi, tfMuonIdx);
496  out.emplace_back(outMu);
497  wedges[in->at(bx, i).processor()].push_back(outMu);
498  }
499  for (int i = 0; i < 12; ++i) {
500  if(wedges[i].size() > 3) edm::LogWarning("Input Mismatch") << " too many inputs per processor for barrel. Wedge " << i << ": Size " << wedges[i].size() << std::endl;
501  }
502 }
int i
Definition: DBlmapReader.cc:9
std::bitset< 72 > m_maskedInputs
std::bitset< 72 > m_inputsToDisable
tuple size
Write out results.
void L1TMuonProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 512 of file L1TMuonProducer.cc.

512  {
513 }
void L1TMuonProducer::endLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 560 of file L1TMuonProducer.cc.

561 {
562 }
void L1TMuonProducer::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 548 of file L1TMuonProducer.cc.

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

Definition at line 566 of file L1TMuonProducer.cc.

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

566  {
567  //The following says we do not know what parameters are allowed so do no validation
568  // Please change this to state exactly what you do use, even if it is no parameters
570  desc.setUnknown();
571  descriptions.addDefault(desc);
572 }
void addDefault(ParameterSetDescription const &psetDescription)
void L1TMuonProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 185 of file L1TMuonProducer.cc.

References addMuonsToCollections(), l1t::bmtf, HLT_Fake1_cff::bxMax, HLT_Fake1_cff::bxMin, calculateRank(), convertMuons(), l1t::coordinate, l1t::emtf_neg, l1t::emtf_pos, l1t::MicroGMTIsolationUnit::extrapolateMuons(), edm::Event::getByToken(), 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, bookConverter::max, min(), 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 testEve_cfg::tracks.

186 {
187  using namespace edm;
188  std::auto_ptr<MuonBxCollection> outMuons (new MuonBxCollection());
189  std::auto_ptr<MuonBxCollection> imdMuonsBMTF (new MuonBxCollection());
190  std::auto_ptr<MuonBxCollection> imdMuonsEMTFPos (new MuonBxCollection());
191  std::auto_ptr<MuonBxCollection> imdMuonsEMTFNeg (new MuonBxCollection());
192  std::auto_ptr<MuonBxCollection> imdMuonsOMTFPos (new MuonBxCollection());
193  std::auto_ptr<MuonBxCollection> imdMuonsOMTFNeg (new MuonBxCollection());
194 
195 
200 
201  iEvent.getByToken(m_barrelTfInputToken, bmtfMuons);
202  iEvent.getByToken(m_endcapTfInputToken, emtfMuons);
203  iEvent.getByToken(m_overlapTfInputToken, omtfMuons);
204  iEvent.getByToken(m_caloTowerInputToken, trigTowers);
205 
206  // find out the BX range from the inputs
207  // the smallest BX window defines the output BX window
208  if (m_autoBxRange) {
209  int bxMin = -1000;
210  int bxMax = 1000;
211  if (!(m_caloInputsToDisable.all() || m_maskedCaloInputs.all())) {
212  bxMin = std::max(bxMin, trigTowers->getFirstBX());
213  bxMax = std::min(bxMax, trigTowers->getLastBX());
214  }
215  if (!(m_bmtfInputsToDisable.all() || m_maskedBmtfInputs.all())) {
216  bxMin = std::max(bxMin, bmtfMuons->getFirstBX());
217  bxMax = std::min(bxMax, bmtfMuons->getLastBX());
218  }
219  if (!(m_omtfInputsToDisable.all() || m_maskedOmtfInputs.all())) {
220  bxMin = std::max(bxMin, omtfMuons->getFirstBX());
221  bxMax = std::min(bxMax, omtfMuons->getLastBX());
222  }
223  if (!(m_emtfInputsToDisable.all() || m_maskedEmtfInputs.all())) {
224  bxMin = std::max(bxMin, emtfMuons->getFirstBX());
225  bxMax = std::min(bxMax, emtfMuons->getLastBX());
226  }
227  if (bxMin > 0) {
228  bxMin = 0;
229  }
230  if (bxMax < 0){
231  bxMax = 0;
232  }
233  if (bxMin > -1000) {
234  m_bxMin = bxMin;
235  } else {
236  m_bxMin = 0;
237  }
238  if (bxMax < 1000) {
239  m_bxMax = bxMax;
240  } else {
241  m_bxMax = 0;
242  }
243  }
244 
245  // set BX range for outputs
246  outMuons->setBXRange(m_bxMin, m_bxMax);
247  imdMuonsBMTF->setBXRange(m_bxMin, m_bxMax);
248  imdMuonsEMTFPos->setBXRange(m_bxMin, m_bxMax);
249  imdMuonsEMTFNeg->setBXRange(m_bxMin, m_bxMax);
250  imdMuonsOMTFPos->setBXRange(m_bxMin, m_bxMax);
251  imdMuonsOMTFNeg->setBXRange(m_bxMin, m_bxMax);
252 
253  for (int bx = m_bxMin; bx <= m_bxMax; ++bx) {
254  m_isolationUnit.setTowerSums(*trigTowers, bx);
255  MicroGMTConfiguration::InterMuonList internMuonsBmtf;
256  MicroGMTConfiguration::InterMuonList internMuonsEmtfPos;
257  MicroGMTConfiguration::InterMuonList internMuonsEmtfNeg;
258  MicroGMTConfiguration::InterMuonList internMuonsOmtfPos;
259  MicroGMTConfiguration::InterMuonList internMuonsOmtfNeg;
260 
261  // These wedges contain shared pointers to the ones in the InterMuonList
262  GMTInternalWedges omtfNegWedges;
263  GMTInternalWedges bmtfWedges;
264  GMTInternalWedges emtfPosWedges;
265  GMTInternalWedges emtfNegWedges;
266  GMTInternalWedges omtfPosWedges;
267 
268  // this converts the InputMuon type to the InternalMuon type and splits them into
269  // positive / negative eta collections necessary as LUTs may differ for pos / neg.
270  convertMuons(bmtfMuons, internMuonsBmtf, bmtfWedges, bx);
271  splitAndConvertMuons(emtfMuons, internMuonsEmtfPos, internMuonsEmtfNeg, emtfPosWedges, emtfNegWedges, bx);
272  splitAndConvertMuons(omtfMuons, internMuonsOmtfPos, internMuonsOmtfNeg, omtfPosWedges, omtfNegWedges, bx);
273 
274  // cancel out within the track finders:
278  // cancel-out for endcap will be done in the sorter
281 
282  // cancel out between track finder acceptance overlaps:
287 
288  m_isolationUnit.extrapolateMuons(internMuonsBmtf);
289  m_isolationUnit.extrapolateMuons(internMuonsEmtfNeg);
290  m_isolationUnit.extrapolateMuons(internMuonsEmtfPos);
291  m_isolationUnit.extrapolateMuons(internMuonsOmtfNeg);
292  m_isolationUnit.extrapolateMuons(internMuonsOmtfPos);
293 
294  // the rank calculated here is used in the sort below
295  calculateRank(internMuonsBmtf);
296  calculateRank(internMuonsEmtfNeg);
297  calculateRank(internMuonsEmtfPos);
298  calculateRank(internMuonsOmtfNeg);
299  calculateRank(internMuonsOmtfPos);
300 
301  // The sort function both sorts and removes all but best "nSurvivors"
302  sortMuons(internMuonsBmtf, 8);
303  sortMuons(internMuonsOmtfPos, 4);
304  sortMuons(internMuonsOmtfNeg, 4);
305  sortMuons(internMuonsEmtfPos, 4);
306  sortMuons(internMuonsEmtfNeg, 4);
307 
308  // This combines the 5 streams into one InternalMuon collection for
309  // the final global sort.
311  addMuonsToCollections(internMuonsEmtfPos, internalMuons, imdMuonsEMTFPos, bx);
312  addMuonsToCollections(internMuonsOmtfPos, internalMuons, imdMuonsOMTFPos, bx);
313  addMuonsToCollections(internMuonsBmtf, internalMuons, imdMuonsBMTF, bx);
314  addMuonsToCollections(internMuonsOmtfNeg, internalMuons, imdMuonsOMTFNeg, bx);
315  addMuonsToCollections(internMuonsEmtfNeg, internalMuons, imdMuonsEMTFNeg, bx);
316 
317  // sort internal muons and delete all but best 8
318  sortMuons(internalMuons, 8);
319 
320  m_isolationUnit.isolatePreSummed(internalMuons);
321  // copy muons to output collection...
322  for (const auto& mu : internalMuons) {
323  if (mu->hwPt() > 0) {
324  math::PtEtaPhiMLorentzVector vec{(mu->hwPt()-1)*0.5, mu->hwEta()*0.010875, mu->hwGlobalPhi()*0.010908, 0.0};
325  int iso = mu->hwAbsIso() + (mu->hwRelIso() << 1);
326  int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(mu->hwQual(), mu->trackFinderType(), mu->hwHF());
327  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()};
328  if (mu->hwSignValid()) {
329  outMu.setCharge(1 - 2 * mu->hwSign());
330  } else {
331  outMu.setCharge(0);
332  }
333  m_debugOut << mu->hwCaloPhi() << " " << mu->hwCaloEta() << std::endl;
334  outMuons->push_back(bx, outMu);
335  }
336  }
337  }
338 
339  iEvent.put(outMuons);
340  iEvent.put(imdMuonsBMTF, "imdMuonsBMTF");
341  iEvent.put(imdMuonsEMTFPos, "imdMuonsEMTFPos");
342  iEvent.put(imdMuonsEMTFNeg, "imdMuonsEMTFNeg");
343  iEvent.put(imdMuonsOMTFPos, "imdMuonsOMTFPos");
344  iEvent.put(imdMuonsOMTFNeg, "imdMuonsOMTFNeg");
345 }
void extrapolateMuons(MicroGMTConfiguration::InterMuonList &) const
void setCancelOutBitsOverlapEndcap(GMTInternalWedges &, GMTInternalWedges &, cancelmode)
Cancel-out between overlap and endcap track finders.
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:462
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
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
Definition: Muon.h:16
void addMuonsToCollections(MicroGMTConfiguration::InterMuonList &coll, MicroGMTConfiguration::InterMuonList &interout, std::auto_ptr< MuonBxCollection > &out, int bx) const
BXVector< Muon > MuonBxCollection
Definition: Muon.h:10
void setCancelOutBits(GMTInternalWedges &, tftype, cancelmode)
Cancel out between sectors/wedges in one track finder.
tuple tracks
Definition: testEve_cfg.py:39
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_barrelTfInputToken
std::bitset< 12 > m_maskedEmtfInputs
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 355 of file L1TMuonProducer.cc.

References compareMuons().

Referenced by produce().

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

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

Referenced by produce().

438 {
439  // initialize the wedge collections:
440  for (int i = 0; i < 6; ++i) {
441  wedges_pos[i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
442  wedges_pos[i].reserve(3);
443  wedges_neg[i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
444  wedges_neg[i].reserve(3);
445  }
446  if (bx < in->getFirstBX() || bx > in->getLastBX()) return;
447  int muIdx = 0;
448  int currentLink = 0;
449  for (size_t i = 0; i < in->size(bx); ++i, ++muIdx) {
450  int link = in->at(bx, i).link();
451  if (m_inputsToDisable.test(link) || m_maskedInputs.test(link)) continue; // only process if input link is enabled and not masked
452  if (currentLink != link) {
453  muIdx = 0;
454  currentLink = link;
455  }
456  int gPhi = MicroGMTConfiguration::calcGlobalPhi(in->at(bx, i).hwPhi(), in->at(bx, i).trackFinderType(), in->at(bx, i).processor());
457  int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
458  std::shared_ptr<GMTInternalMuon> out = std::make_shared<GMTInternalMuon>(in->at(bx, i), gPhi, tfMuonIdx);
459  if(in->at(bx, i).hwEta() > 0) {
460  out_pos.push_back(out);
461  wedges_pos[in->at(bx, i).processor()].push_back(out);
462  } else {
463  out_neg.emplace_back(out);
464  wedges_neg[in->at(bx, i).processor()].push_back(out);
465  }
466  }
467  for (int i = 0; i < 6; ++i) {
468  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;
469  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;
470  }
471 }
int i
Definition: DBlmapReader.cc:9
std::bitset< 72 > m_maskedInputs
std::bitset< 72 > m_inputsToDisable
tuple size
Write out results.

Member Data Documentation

bool L1TMuonProducer::m_autoBxRange
private

Definition at line 100 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

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 123 of file L1TMuonProducer.cc.

Referenced by 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 102 of file L1TMuonProducer.cc.

Referenced by L1TMuonProducer(), and produce().

int L1TMuonProducer::m_bxMin
private

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

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 125 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().

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 124 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().