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  ~L1TMuonQualityAdjuster() override;
38 
39  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
40 
41 private:
42  void produce(edm::Event&, const edm::EventSetup&) override;
43  void beginRun(const edm::Run&, edm::EventSetup const&) override;
44  void endRun(const edm::Run&, edm::EventSetup const&) override;
45  void beginLuminosityBlock(const edm::LuminosityBlock&, edm::EventSetup const&) override;
46  void endLuminosityBlock(const edm::LuminosityBlock&, edm::EventSetup const&) override;
47  // ----------member data ---------------------------
51  // edm::InputTag m_barrelTfInputTag;
55  int m_bmtfBxOffset; // Hack while sorting our source of -3 BX offset when re-Emulating...
56 };
57 
58 //
59 // constants, enums and typedefs
60 //
61 
62 //
63 // static data member definitions
64 //
65 
66 //
67 // constructors and destructor
68 //
70  m_barrelTfInputTag = iConfig.getParameter<edm::InputTag>("bmtfInput");
71  m_overlapTfInputTag = iConfig.getParameter<edm::InputTag>("omtfInput");
72  m_endCapTfInputTag = iConfig.getParameter<edm::InputTag>("emtfInput");
73  m_bmtfBxOffset = iConfig.getParameter<int>("bmtfBxOffset");
74  m_barrelTfInputToken = consumes<l1t::RegionalMuonCandBxCollection>(m_barrelTfInputTag);
75  m_overlapTfInputToken = consumes<l1t::RegionalMuonCandBxCollection>(m_overlapTfInputTag);
76  m_endCapTfInputToken = consumes<l1t::RegionalMuonCandBxCollection>(m_endCapTfInputTag);
77  //register your products
78  produces<RegionalMuonCandBxCollection>("BMTF");
79  produces<RegionalMuonCandBxCollection>("OMTF");
80  produces<RegionalMuonCandBxCollection>("EMTF");
81 }
82 
84  // do anything here that needs to be done at desctruction time
85  // (e.g. close files, deallocate resources etc.)
86 }
87 
88 //
89 // member functions
90 //
91 
92 // ------------ method called to produce the data ------------
94  using namespace edm;
95 
96  std::unique_ptr<l1t::RegionalMuonCandBxCollection> filteredBMTFMuons(new l1t::RegionalMuonCandBxCollection());
97  std::unique_ptr<l1t::RegionalMuonCandBxCollection> filteredOMTFMuons(new l1t::RegionalMuonCandBxCollection());
98  std::unique_ptr<l1t::RegionalMuonCandBxCollection> filteredEMTFMuons(new l1t::RegionalMuonCandBxCollection());
99 
103 
104  iEvent.getByToken(m_barrelTfInputToken, bmtfMuons);
105  iEvent.getByToken(m_overlapTfInputToken, omtfMuons);
106  iEvent.getByToken(m_endCapTfInputToken, emtfMuons);
107 
108  if (bmtfMuons.isValid()) {
109  filteredBMTFMuons->setBXRange(bmtfMuons->getFirstBX(), bmtfMuons->getLastBX());
110  for (int bx = bmtfMuons->getFirstBX(); bx <= bmtfMuons->getLastBX(); ++bx) {
111  for (auto mu = bmtfMuons->begin(bx); mu != bmtfMuons->end(bx); ++mu) {
112  int newqual = 12;
113  l1t::RegionalMuonCand newMu((*mu));
114  newMu.setHwQual(newqual);
115  filteredBMTFMuons->push_back(bx + m_bmtfBxOffset, newMu);
116  }
117  }
118  } else {
119  //cout << "ERROR: did not find BMTF muons in event with label: " << m_barrelTfInputTag << "\n";
120  }
121 
122  if (emtfMuons.isValid()) {
123  filteredEMTFMuons->setBXRange(emtfMuons->getFirstBX(), emtfMuons->getLastBX());
124  for (int bx = emtfMuons->getFirstBX(); bx <= emtfMuons->getLastBX(); ++bx) {
125  for (auto mu = emtfMuons->begin(bx); mu != emtfMuons->end(bx); ++mu) {
126  int newqual = 0;
127  if (mu->hwQual() == 11 || mu->hwQual() > 12)
128  newqual = 12;
129  l1t::RegionalMuonCand newMu((*mu));
130  newMu.setHwQual(newqual);
131  filteredEMTFMuons->push_back(bx, newMu);
132  }
133  }
134  } else {
135  //cout << "ERROR: did not find EMTF muons in event with label: " << m_endCapTfInputTag << "\n";
136  }
137 
138  if (omtfMuons.isValid()) {
139  filteredOMTFMuons->setBXRange(omtfMuons->getFirstBX(), omtfMuons->getLastBX());
140  for (int bx = omtfMuons->getFirstBX(); bx <= omtfMuons->getLastBX(); ++bx) {
141  for (auto mu = omtfMuons->begin(bx); mu != omtfMuons->end(bx); ++mu) {
142  int newqual = 0;
143  if (mu->hwQual() > 0)
144  newqual = 12;
145  l1t::RegionalMuonCand newMu((*mu));
146  newMu.setHwQual(newqual);
147  filteredOMTFMuons->push_back(bx, newMu);
148  }
149  }
150  } else {
151  //cout << "ERROR: did not find OMTF muons in event with label: " << m_overlapTfInputTag << "\n";
152  }
153 
154  //cout << "Size BMTF(-3): " << filteredBMTFMuons->size(-3) << "\n";
155  //cout << "Size BMTF: " << filteredBMTFMuons->size(0) << "\n";
156  //cout << "Size OMTF: " << filteredOMTFMuons->size(0) << "\n";
157  //cout << "Size EMTF: " << filteredEMTFMuons->size(0) << "\n";
158 
159  iEvent.put(std::move(filteredBMTFMuons), "BMTF");
160  iEvent.put(std::move(filteredOMTFMuons), "OMTF");
161  iEvent.put(std::move(filteredEMTFMuons), "EMTF");
162 }
163 
164 // ------------ method called when starting to processes a run ------------
166 
167 // ------------ method called when ending the processing of a run ------------
169 
170 // ------------ method called when starting to processes a luminosity block ------------
172 
173 // ------------ method called when ending the processing of a luminosity block ------------
175 
176 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
178  //The following says we do not know what parameters are allowed so do no validation
179  // Please change this to state exactly what you do use, even if it is no parameters
181  desc.setUnknown();
182  descriptions.addDefault(desc);
183 }
184 
185 //define this as a plug-in
int getLastBX() const
int getFirstBX() const
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > m_endCapTfInputToken
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
delete x;
Definition: CaloConfig.h:22
void endLuminosityBlock(const edm::LuminosityBlock &, edm::EventSetup const &) override
void endRun(const edm::Run &, edm::EventSetup const &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const_iterator begin(int bx) const
void beginRun(const edm::Run &, edm::EventSetup const &) override
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
L1TMuonQualityAdjuster(const edm::ParameterSet &)
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.
void beginLuminosityBlock(const edm::LuminosityBlock &, edm::EventSetup const &) override
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45