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 //
64 // static data member definitions
65 //
66 
67 //
68 // constructors and destructor
69 //
71 {
72  m_barrelTfInputTag = iConfig.getParameter<edm::InputTag>("bmtfInput");
73  m_overlapTfInputTag = iConfig.getParameter<edm::InputTag>("omtfInput");
74  m_endCapTfInputTag = iConfig.getParameter<edm::InputTag>("emtfInput");
75  m_bmtfBxOffset = iConfig.getParameter<int>("bmtfBxOffset");
76  m_barrelTfInputToken = consumes<l1t::RegionalMuonCandBxCollection>(m_barrelTfInputTag);
77  m_overlapTfInputToken = consumes<l1t::RegionalMuonCandBxCollection>(m_overlapTfInputTag);
78  m_endCapTfInputToken = consumes<l1t::RegionalMuonCandBxCollection>(m_endCapTfInputTag);
79  //register your products
80  produces<RegionalMuonCandBxCollection>("BMTF");
81  produces<RegionalMuonCandBxCollection>("OMTF");
82  produces<RegionalMuonCandBxCollection>("EMTF");
83 }
84 
85 
87 {
88  // do anything here that needs to be done at desctruction time
89  // (e.g. close files, deallocate resources etc.)
90 }
91 
92 
93 //
94 // member functions
95 //
96 
97 
98 // ------------ method called to produce the data ------------
99 void
101 {
102  using namespace edm;
103 
104  std::unique_ptr<l1t::RegionalMuonCandBxCollection> filteredBMTFMuons (new l1t::RegionalMuonCandBxCollection());
105  std::unique_ptr<l1t::RegionalMuonCandBxCollection> filteredOMTFMuons (new l1t::RegionalMuonCandBxCollection());
106  std::unique_ptr<l1t::RegionalMuonCandBxCollection> filteredEMTFMuons (new l1t::RegionalMuonCandBxCollection());
107 
111 
112  iEvent.getByToken(m_barrelTfInputToken, bmtfMuons);
113  iEvent.getByToken(m_overlapTfInputToken, omtfMuons);
114  iEvent.getByToken(m_endCapTfInputToken, emtfMuons);
115 
116 
117  if (bmtfMuons.isValid()){
118  filteredBMTFMuons->setBXRange(bmtfMuons->getFirstBX(), bmtfMuons->getLastBX());
119  for (int bx = bmtfMuons->getFirstBX(); bx <= bmtfMuons->getLastBX(); ++bx) {
120  for (auto mu = bmtfMuons->begin(bx); mu != bmtfMuons->end(bx); ++mu) {
121  int newqual = 12;
122  l1t::RegionalMuonCand newMu((*mu));
123  newMu.setHwQual(newqual);
124  filteredBMTFMuons->push_back(bx+m_bmtfBxOffset, newMu);
125  }
126  }
127  } else {
128  //cout << "ERROR: did not find BMTF muons in event with label: " << m_barrelTfInputTag << "\n";
129  }
130 
131  if (emtfMuons.isValid()){
132  filteredEMTFMuons->setBXRange(emtfMuons->getFirstBX(), emtfMuons->getLastBX());
133  for (int bx = emtfMuons->getFirstBX(); bx <= emtfMuons->getLastBX(); ++bx) {
134  for (auto mu = emtfMuons->begin(bx); mu != emtfMuons->end(bx); ++mu) {
135  int newqual = 0;
136  if (mu->hwQual() == 11 || mu->hwQual() > 12) newqual=12;
137  l1t::RegionalMuonCand newMu((*mu));
138  newMu.setHwQual(newqual);
139  filteredEMTFMuons->push_back(bx, newMu);
140  }
141  }
142  } else {
143  //cout << "ERROR: did not find EMTF muons in event with label: " << m_endCapTfInputTag << "\n";
144  }
145 
146  if (omtfMuons.isValid()){
147  filteredOMTFMuons->setBXRange(omtfMuons->getFirstBX(), omtfMuons->getLastBX());
148  for (int bx = omtfMuons->getFirstBX(); bx <= omtfMuons->getLastBX(); ++bx) {
149  for (auto mu = omtfMuons->begin(bx); mu != omtfMuons->end(bx); ++mu) {
150  int newqual = 0;
151  if (mu->hwQual() > 0) newqual = 12;
152  l1t::RegionalMuonCand newMu((*mu));
153  newMu.setHwQual(newqual);
154  filteredOMTFMuons->push_back(bx, newMu);
155  }
156  }
157  } else {
158  //cout << "ERROR: did not find OMTF muons in event with label: " << m_overlapTfInputTag << "\n";
159  }
160 
161  //cout << "Size BMTF(-3): " << filteredBMTFMuons->size(-3) << "\n";
162  //cout << "Size BMTF: " << filteredBMTFMuons->size(0) << "\n";
163  //cout << "Size OMTF: " << filteredOMTFMuons->size(0) << "\n";
164  //cout << "Size EMTF: " << filteredEMTFMuons->size(0) << "\n";
165 
166  iEvent.put(std::move(filteredBMTFMuons), "BMTF");
167  iEvent.put(std::move(filteredOMTFMuons), "OMTF");
168  iEvent.put(std::move(filteredEMTFMuons), "EMTF");
169 }
170 
171 // ------------ method called when starting to processes a run ------------
172 void
174 {
175 }
176 
177 // ------------ method called when ending the processing of a run ------------
178 void
180 {
181 }
182 
183 // ------------ method called when starting to processes a luminosity block ------------
184 void
186 {
187 }
188 
189 // ------------ method called when ending the processing of a luminosity block ------------
190 void
192 {
193 }
194 
195 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
196 void
198  //The following says we do not know what parameters are allowed so do no validation
199  // Please change this to state exactly what you do use, even if it is no parameters
201  desc.setUnknown();
202  descriptions.addDefault(desc);
203 }
204 
205 
206 
207 //define this as a plug-in
const_iterator end(int bx) const
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > m_endCapTfInputToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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)
void beginRun(const edm::Run &, edm::EventSetup const &) override
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
L1TMuonQualityAdjuster(const edm::ParameterSet &)
const int mu
Definition: Constants.h:22
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > m_barrelTfInputToken
bool isValid() const
Definition: HandleBase.h:74
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
int getFirstBX() const
HLT enums.
void beginLuminosityBlock(const edm::LuminosityBlock &, edm::EventSetup const &) override
int getLastBX() const
const_iterator begin(int bx) const
def move(src, dest)
Definition: eostools.py:510
Definition: Run.h:43