CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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:
38 
39  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
40 
41 private:
42  virtual void beginJob() override ;
43  virtual void produce(edm::Event&, const edm::EventSetup&) override ;
44  virtual void endJob() override ;
45  virtual void beginRun(const edm::Run&, edm::EventSetup const&) override ;
46  virtual void endRun(const edm::Run&, edm::EventSetup const&) override ;
47  virtual void beginLuminosityBlock(const edm::LuminosityBlock&, edm::EventSetup const&) override ;
48  virtual void endLuminosityBlock(const edm::LuminosityBlock&, edm::EventSetup const&) override ;
49  // ----------member data ---------------------------
53  // edm::InputTag m_barrelTfInputTag;
57  int m_bmtfBxOffset; // Hack while sorting our source of -3 BX offset when re-Emulating...
58 };
59 
60 //
61 // constants, enums and typedefs
62 //
63 
64 
65 //
66 // static data member definitions
67 //
68 
69 //
70 // constructors and destructor
71 //
73 {
74  m_barrelTfInputTag = iConfig.getParameter<edm::InputTag>("bmtfInput");
75  m_overlapTfInputTag = iConfig.getParameter<edm::InputTag>("omtfInput");
76  m_endCapTfInputTag = iConfig.getParameter<edm::InputTag>("emtfInput");
77  m_bmtfBxOffset = iConfig.getParameter<int>("bmtfBxOffset");
78  m_barrelTfInputToken = consumes<l1t::RegionalMuonCandBxCollection>(m_barrelTfInputTag);
79  m_overlapTfInputToken = consumes<l1t::RegionalMuonCandBxCollection>(m_overlapTfInputTag);
80  m_endCapTfInputToken = consumes<l1t::RegionalMuonCandBxCollection>(m_endCapTfInputTag);
81  //register your products
82  produces<RegionalMuonCandBxCollection>("BMTF");
83  produces<RegionalMuonCandBxCollection>("OMTF");
84  produces<RegionalMuonCandBxCollection>("EMTF");
85 }
86 
87 
89 {
90  // do anything here that needs to be done at desctruction time
91  // (e.g. close files, deallocate resources etc.)
92 }
93 
94 
95 //
96 // member functions
97 //
98 
99 
100 // ------------ method called to produce the data ------------
101 void
103 {
104  using namespace edm;
105 
106  std::auto_ptr<l1t::RegionalMuonCandBxCollection> filteredBMTFMuons (new l1t::RegionalMuonCandBxCollection());
107  std::auto_ptr<l1t::RegionalMuonCandBxCollection> filteredOMTFMuons (new l1t::RegionalMuonCandBxCollection());
108  std::auto_ptr<l1t::RegionalMuonCandBxCollection> filteredEMTFMuons (new l1t::RegionalMuonCandBxCollection());
109 
113 
114  iEvent.getByToken(m_barrelTfInputToken, bmtfMuons);
115  iEvent.getByToken(m_overlapTfInputToken, omtfMuons);
116  iEvent.getByToken(m_endCapTfInputToken, emtfMuons);
117 
118 
119  if (bmtfMuons.isValid()){
120  filteredBMTFMuons->setBXRange(bmtfMuons->getFirstBX(), bmtfMuons->getLastBX());
121  for (int bx = bmtfMuons->getFirstBX(); bx <= bmtfMuons->getLastBX(); ++bx) {
122  for (auto mu = bmtfMuons->begin(bx); mu != bmtfMuons->end(bx); ++mu) {
123  int newqual = 12;
124  l1t::RegionalMuonCand newMu((*mu));
125  newMu.setHwQual(newqual);
126  filteredBMTFMuons->push_back(bx+m_bmtfBxOffset, newMu);
127  }
128  }
129  } else {
130  //cout << "ERROR: did not find BMTF muons in event with label: " << m_barrelTfInputTag << "\n";
131  }
132 
133  if (emtfMuons.isValid()){
134  filteredEMTFMuons->setBXRange(emtfMuons->getFirstBX(), emtfMuons->getLastBX());
135  for (int bx = emtfMuons->getFirstBX(); bx <= emtfMuons->getLastBX(); ++bx) {
136  for (auto mu = emtfMuons->begin(bx); mu != emtfMuons->end(bx); ++mu) {
137  int newqual = 0;
138  if (mu->hwQual() == 11 || mu->hwQual() > 12) newqual=12;
139  l1t::RegionalMuonCand newMu((*mu));
140  newMu.setHwQual(newqual);
141  filteredEMTFMuons->push_back(bx, newMu);
142  }
143  }
144  } else {
145  //cout << "ERROR: did not find EMTF muons in event with label: " << m_endCapTfInputTag << "\n";
146  }
147 
148  if (omtfMuons.isValid()){
149  filteredOMTFMuons->setBXRange(omtfMuons->getFirstBX(), omtfMuons->getLastBX());
150  for (int bx = omtfMuons->getFirstBX(); bx <= omtfMuons->getLastBX(); ++bx) {
151  for (auto mu = omtfMuons->begin(bx); mu != omtfMuons->end(bx); ++mu) {
152  int newqual = 0;
153  if (mu->hwQual() > 0) newqual = 12;
154  l1t::RegionalMuonCand newMu((*mu));
155  newMu.setHwQual(newqual);
156  filteredOMTFMuons->push_back(bx, newMu);
157  }
158  }
159  } else {
160  //cout << "ERROR: did not find OMTF muons in event with label: " << m_overlapTfInputTag << "\n";
161  }
162 
163  //cout << "Size BMTF(-3): " << filteredBMTFMuons->size(-3) << "\n";
164  //cout << "Size BMTF: " << filteredBMTFMuons->size(0) << "\n";
165  //cout << "Size OMTF: " << filteredOMTFMuons->size(0) << "\n";
166  //cout << "Size EMTF: " << filteredEMTFMuons->size(0) << "\n";
167 
168  iEvent.put(filteredBMTFMuons, "BMTF");
169  iEvent.put(filteredOMTFMuons, "OMTF");
170  iEvent.put(filteredEMTFMuons, "EMTF");
171 }
172 
173 // ------------ method called once each job just before starting event loop ------------
174 void
176 {
177 }
178 
179 // ------------ method called once each job just after ending the event loop ------------
180 void
182 }
183 
184 // ------------ method called when starting to processes a run ------------
185 void
187 {
188 }
189 
190 // ------------ method called when ending the processing of a run ------------
191 void
193 {
194 }
195 
196 // ------------ method called when starting to processes a luminosity block ------------
197 void
199 {
200 }
201 
202 // ------------ method called when ending the processing of a luminosity block ------------
203 void
205 {
206 }
207 
208 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
209 void
211  //The following says we do not know what parameters are allowed so do no validation
212  // Please change this to state exactly what you do use, even if it is no parameters
214  desc.setUnknown();
215  descriptions.addDefault(desc);
216 }
217 
218 
219 
220 //define this as a plug-in
T getParameter(std::string const &) const
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > m_endCapTfInputToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void endJob() override
virtual void endLuminosityBlock(const edm::LuminosityBlock &, edm::EventSetup const &) override
void beginJob()
Definition: Breakpoints.cc:15
virtual void endRun(const edm::Run &, edm::EventSetup const &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void beginRun(const edm::Run &, edm::EventSetup const &) override
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
L1TMuonQualityAdjuster(const edm::ParameterSet &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
const int mu
Definition: Constants.h:22
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > m_barrelTfInputToken
virtual 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
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, edm::EventSetup const &) override
virtual void beginJob() override
Definition: Run.h:43