CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GMTSetup.cc
Go to the documentation of this file.
3 
7 
13 
14 #include "GMTSetup.h"
15 
16 #include <array>
17 #include <string>
18 
19 namespace l1t {
20  namespace stage2 {
21  std::unique_ptr<PackerTokens> GMTSetup::registerConsumes(const edm::ParameterSet& cfg, edm::ConsumesCollector& cc) {
22  return std::unique_ptr<PackerTokens>(new GMTTokens(cfg, cc));
23  }
24 
26  desc.addOptional<edm::InputTag>("BMTFInputLabel")->setComment("for stage2");
27  desc.addOptional<edm::InputTag>("OMTFInputLabel")->setComment("for stage2");
28  desc.addOptional<edm::InputTag>("EMTFInputLabel")->setComment("for stage2");
29  desc.addOptional<edm::InputTag>("ImdInputLabelBMTF")
30  ->setComment("uGMT intermediate muon from BMTF after first sorting stage");
31  desc.addOptional<edm::InputTag>("ImdInputLabelEMTFNeg")
32  ->setComment("uGMT intermediate muon from neg. EMTF side after first sorting stage");
33  desc.addOptional<edm::InputTag>("ImdInputLabelEMTFPos")
34  ->setComment("uGMT intermediate muon from pos. EMTF side after first sorting stage");
35  desc.addOptional<edm::InputTag>("ImdInputLabelOMTFNeg")
36  ->setComment("uGMT intermediate muon from neg. OMTF side after first sorting stage");
37  desc.addOptional<edm::InputTag>("ImdInputLabelOMTFPos")
38  ->setComment("uGMT intermediate muon from pos. OMTF side after first sorting stage");
39  }
40 
41  PackerMap GMTSetup::getPackers(int fed, unsigned int fw) {
42  PackerMap res;
43  if (fed == 1402) {
44  auto gmt_in_packer = static_pointer_cast<l1t::stage2::RegionalMuonGMTPacker>(
45  PackerFactory::get()->make("stage2::RegionalMuonGMTPacker"));
46  if (fw >= 0x6010000) {
47  gmt_in_packer->setUseEmtfDisplacementInfo();
48  }
49  if (fw >= 0x6000000) {
50  gmt_in_packer->setIsKbmtf();
51  }
52  auto gmt_out_packer =
53  static_pointer_cast<l1t::stage2::GMTMuonPacker>(PackerFactory::get()->make("stage2::GMTMuonPacker"));
54  gmt_out_packer->setFed(fed);
55  gmt_out_packer->setFwVersion(fw);
56  // Use amc_no and board id 1 for packing
57  res[{1, 1}] = {
58  gmt_in_packer,
59  gmt_out_packer,
60  PackerFactory::get()->make("stage2::IntermediateMuonPacker"),
61  };
62  }
63  return res;
64  }
65 
70  prod.produces<MuonBxCollection>("Muon");
71  for (int i = 1; i < 6; ++i) {
72  prod.produces<MuonBxCollection>("MuonCopy" + std::to_string(i));
73  }
74  prod.produces<MuonBxCollection>("imdMuonsBMTF");
75  prod.produces<MuonBxCollection>("imdMuonsEMTFNeg");
76  prod.produces<MuonBxCollection>("imdMuonsEMTFPos");
77  prod.produces<MuonBxCollection>("imdMuonsOMTFNeg");
78  prod.produces<MuonBxCollection>("imdMuonsOMTFPos");
79  }
80 
81  std::unique_ptr<UnpackerCollections> GMTSetup::getCollections(edm::Event& e) {
82  return std::unique_ptr<UnpackerCollections>(new GMTCollections(e));
83  }
84 
85  UnpackerMap GMTSetup::getUnpackers(int fed, int board, int amc, unsigned int fw) {
86  UnpackerMap res;
87 
88  // MP7 input link numbers are represented by even numbers starting from 0 (iLink=link*2)
89  // input muons on links 36-71
90  auto gmt_in_unp = static_pointer_cast<l1t::stage2::RegionalMuonGMTUnpacker>(
91  UnpackerFactory::get()->make("stage2::RegionalMuonGMTUnpacker"));
92  if (fw >= 0x6010000) {
93  gmt_in_unp->setUseEmtfDisplacementInfo();
94  }
95  if (fw >= 0x6000000) {
96  gmt_in_unp->setIsKbmtf();
97  }
98 
99  for (int iLink = 72; iLink < 144; iLink += 2) {
100  res[iLink] = gmt_in_unp;
101  }
102 
103  // MP7 output link numbers are represented by odd numbers (oLink=link*2+1)
104  // internal muons on links 24-31
105  auto gmt_imd_unp = static_pointer_cast<l1t::stage2::IntermediateMuonUnpacker>(
106  UnpackerFactory::get()->make("stage2::IntermediateMuonUnpacker"));
107  gmt_imd_unp->setAlgoVersion(fw);
108  for (int oLink = 49; oLink < 65; oLink += 2)
109  res[oLink] = gmt_imd_unp;
110 
111  // output muons on links 0-23 (6 copies on 4 links each)
112  std::array<std::shared_ptr<l1t::stage2::MuonUnpacker>, 6> gmt_out_unps;
113  int i = 0;
114  for (auto gmt_out_unp : gmt_out_unps) {
115  gmt_out_unp =
116  static_pointer_cast<l1t::stage2::MuonUnpacker>(UnpackerFactory::get()->make("stage2::MuonUnpacker"));
117  gmt_out_unp->setAlgoVersion(fw);
118  gmt_out_unp->setFedNumber(fed);
119  gmt_out_unp->setMuonCopy(i);
120 
121  int oLinkMin = i * 8 + 1;
122  for (int oLink = oLinkMin; oLink < oLinkMin + 8; oLink += 2)
123  res[oLink] = gmt_out_unp;
124 
125  ++i;
126  }
127 
128  return res;
129  }
130  } // namespace stage2
131 } // namespace l1t
132 
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
tuple cfg
Definition: looper.py:296
std::unique_ptr< UnpackerCollections > getCollections(edm::Event &e) override
Definition: GMTSetup.cc:81
void setFed(unsigned fedId)
Definition: MuonPacker.h:18
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
std::shared_ptr< Packer > make(const std::string &) const
static const PackerFactory * get()
Definition: PackerFactory.h:14
std::map< int, std::shared_ptr< Unpacker > > UnpackerMap
Definition: PackingSetup.h:25
double amc
Definition: hdecay.h:20
void fillDescription(edm::ParameterSetDescription &desc) override
Definition: GMTSetup.cc:25
PackerMap getPackers(int fed, unsigned int fw) override
Definition: GMTSetup.cc:41
void registerProducts(edm::ProducesCollector) override
Definition: GMTSetup.cc:66
std::shared_ptr< Unpacker > make(const std::string &) const
UnpackerMap getUnpackers(int fed, int board, int amc, unsigned int fw) override
Definition: GMTSetup.cc:85
#define DEFINE_L1T_PACKING_SETUP(type)
std::unique_ptr< PackerTokens > registerConsumes(const edm::ParameterSet &cfg, edm::ConsumesCollector &cc) override
Definition: GMTSetup.cc:21
static const UnpackerFactory * get()
void setAlgoVersion(const unsigned int version)
Definition: Unpacker.h:19
std::map< std::pair< int, int >, Packers > PackerMap
Definition: PackingSetup.h:23