CMS 3D CMS Logo

L1TMuonQualityAdjuster.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // L1TMuonQualityAdjuster
4 //
5 // Fictitious module which filters/remaps TF qualities for studies
6 //
7 //
8 
9 // system include files
10 #include <memory>
11 #include <fstream>
12 
13 // user include files
16 
19 
23 
26 
27 using namespace l1t;
28 
29 #include <iostream>
30 //
31 // class declaration
32 //
33 
35 public:
37 
38  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
39 
40 private:
41  void produce(edm::Event&, const edm::EventSetup&) override;
42  // ----------member data ---------------------------
46  // edm::InputTag m_barrelTfInputTag;
50  int m_bmtfBxOffset; // Hack while sorting our source of -3 BX offset when re-Emulating...
51 };
52 
53 //
54 // constants, enums and typedefs
55 //
56 
57 //
58 // static data member definitions
59 //
60 
61 //
62 // constructors and destructor
63 //
65  m_barrelTfInputTag = iConfig.getParameter<edm::InputTag>("bmtfInput");
66  m_overlapTfInputTag = iConfig.getParameter<edm::InputTag>("omtfInput");
67  m_endCapTfInputTag = iConfig.getParameter<edm::InputTag>("emtfInput");
68  m_bmtfBxOffset = iConfig.getParameter<int>("bmtfBxOffset");
69  m_barrelTfInputToken = consumes<l1t::RegionalMuonCandBxCollection>(m_barrelTfInputTag);
70  m_overlapTfInputToken = consumes<l1t::RegionalMuonCandBxCollection>(m_overlapTfInputTag);
71  m_endCapTfInputToken = consumes<l1t::RegionalMuonCandBxCollection>(m_endCapTfInputTag);
72  //register your products
73  produces<RegionalMuonCandBxCollection>("BMTF");
74  produces<RegionalMuonCandBxCollection>("OMTF");
75  produces<RegionalMuonCandBxCollection>("EMTF");
76 }
77 
78 //
79 // member functions
80 //
81 
82 // ------------ method called to produce the data ------------
84  using namespace edm;
85 
86  std::unique_ptr<l1t::RegionalMuonCandBxCollection> filteredBMTFMuons(new l1t::RegionalMuonCandBxCollection());
87  std::unique_ptr<l1t::RegionalMuonCandBxCollection> filteredOMTFMuons(new l1t::RegionalMuonCandBxCollection());
88  std::unique_ptr<l1t::RegionalMuonCandBxCollection> filteredEMTFMuons(new l1t::RegionalMuonCandBxCollection());
89 
93 
94  iEvent.getByToken(m_barrelTfInputToken, bmtfMuons);
95  iEvent.getByToken(m_overlapTfInputToken, omtfMuons);
96  iEvent.getByToken(m_endCapTfInputToken, emtfMuons);
97 
98  if (bmtfMuons.isValid()) {
99  filteredBMTFMuons->setBXRange(bmtfMuons->getFirstBX(), bmtfMuons->getLastBX());
100  for (int bx = bmtfMuons->getFirstBX(); bx <= bmtfMuons->getLastBX(); ++bx) {
101  for (auto mu = bmtfMuons->begin(bx); mu != bmtfMuons->end(bx); ++mu) {
102  int newqual = 12;
103  l1t::RegionalMuonCand newMu((*mu));
104  newMu.setHwQual(newqual);
105  filteredBMTFMuons->push_back(bx + m_bmtfBxOffset, newMu);
106  }
107  }
108  } else {
109  //cout << "ERROR: did not find BMTF muons in event with label: " << m_barrelTfInputTag << "\n";
110  }
111 
112  if (emtfMuons.isValid()) {
113  filteredEMTFMuons->setBXRange(emtfMuons->getFirstBX(), emtfMuons->getLastBX());
114  for (int bx = emtfMuons->getFirstBX(); bx <= emtfMuons->getLastBX(); ++bx) {
115  for (auto mu = emtfMuons->begin(bx); mu != emtfMuons->end(bx); ++mu) {
116  int newqual = 0;
117  if (mu->hwQual() == 11 || mu->hwQual() > 12)
118  newqual = 12;
119  l1t::RegionalMuonCand newMu((*mu));
120  newMu.setHwQual(newqual);
121  filteredEMTFMuons->push_back(bx, newMu);
122  }
123  }
124  } else {
125  //cout << "ERROR: did not find EMTF muons in event with label: " << m_endCapTfInputTag << "\n";
126  }
127 
128  if (omtfMuons.isValid()) {
129  filteredOMTFMuons->setBXRange(omtfMuons->getFirstBX(), omtfMuons->getLastBX());
130  for (int bx = omtfMuons->getFirstBX(); bx <= omtfMuons->getLastBX(); ++bx) {
131  for (auto mu = omtfMuons->begin(bx); mu != omtfMuons->end(bx); ++mu) {
132  int newqual = 0;
133  if (mu->hwQual() > 0)
134  newqual = 12;
135  l1t::RegionalMuonCand newMu((*mu));
136  newMu.setHwQual(newqual);
137  filteredOMTFMuons->push_back(bx, newMu);
138  }
139  }
140  } else {
141  //cout << "ERROR: did not find OMTF muons in event with label: " << m_overlapTfInputTag << "\n";
142  }
143 
144  //cout << "Size BMTF(-3): " << filteredBMTFMuons->size(-3) << "\n";
145  //cout << "Size BMTF: " << filteredBMTFMuons->size(0) << "\n";
146  //cout << "Size OMTF: " << filteredOMTFMuons->size(0) << "\n";
147  //cout << "Size EMTF: " << filteredEMTFMuons->size(0) << "\n";
148 
149  iEvent.put(std::move(filteredBMTFMuons), "BMTF");
150  iEvent.put(std::move(filteredOMTFMuons), "OMTF");
151  iEvent.put(std::move(filteredEMTFMuons), "EMTF");
152 }
153 
154 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
156  //The following says we do not know what parameters are allowed so do no validation
157  // Please change this to state exactly what you do use, even if it is no parameters
159  desc.setUnknown();
160  descriptions.addDefault(desc);
161 }
162 
163 //define this as a plug-in
int getLastBX() const
int getFirstBX() const
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > m_endCapTfInputToken
delete x;
Definition: CaloConfig.h:22
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const_iterator begin(int bx) const
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
L1TMuonQualityAdjuster(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > m_barrelTfInputToken
void produce(edm::Event &, const edm::EventSetup &) override
void setHwQual(int bits)
Set compressed quality code as transmitted by hardware (4 bits)
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > m_overlapTfInputToken
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool isValid() const
Definition: HandleBase.h:70
const_iterator end(int bx) const
HLT enums.
def move(src, dest)
Definition: eostools.py:511