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
Ecal2004TBTDCRanges_v1_cff.endRun
endRun
Definition: Ecal2004TBTDCRanges_v1_cff.py:4
L1TMuonQualityAdjuster::beginRun
void beginRun(const edm::Run &, edm::EventSetup const &) override
Definition: L1TMuonQualityAdjuster.cc:165
L1TMuonQualityAdjuster
Definition: L1TMuonQualityAdjuster.cc:34
MessageLogger.h
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
edm::Run
Definition: Run.h:45
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
L1TMuonQualityAdjuster::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: L1TMuonQualityAdjuster.cc:93
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
L1TMuonQualityAdjuster::m_barrelTfInputToken
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > m_barrelTfInputToken
Definition: L1TMuonQualityAdjuster.cc:48
EDProducer.h
edm::Handle
Definition: AssociativeIterator.h:50
L1TMuonQualityAdjuster::m_overlapTfInputToken
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > m_overlapTfInputToken
Definition: L1TMuonQualityAdjuster.cc:49
BXVector< RegionalMuonCand >
BXVector::getFirstBX
int getFirstBX() const
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
L1TMuonQualityAdjuster::beginLuminosityBlock
void beginLuminosityBlock(const edm::LuminosityBlock &, edm::EventSetup const &) override
Definition: L1TMuonQualityAdjuster.cc:171
L1TMuonQualityAdjuster::m_barrelTfInputTag
edm::InputTag m_barrelTfInputTag
Definition: L1TMuonQualityAdjuster.cc:52
BXVector::begin
const_iterator begin(int bx) const
L1TMuonQualityAdjuster::m_endCapTfInputToken
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > m_endCapTfInputToken
Definition: L1TMuonQualityAdjuster.cc:50
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
BXVector::end
const_iterator end(int bx) const
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
l1t
delete x;
Definition: CaloConfig.h:22
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
l1t::RegionalMuonCand::setHwQual
void setHwQual(int bits)
Set compressed quality code as transmitted by hardware (4 bits)
Definition: RegionalMuonCand.h:140
L1TMuonQualityAdjuster::m_endCapTfInputTag
edm::InputTag m_endCapTfInputTag
Definition: L1TMuonQualityAdjuster.cc:54
L1TMuonQualityAdjuster::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: L1TMuonQualityAdjuster.cc:177
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
Frameworkfwd.h
L1TMuonQualityAdjuster::L1TMuonQualityAdjuster
L1TMuonQualityAdjuster(const edm::ParameterSet &)
Definition: L1TMuonQualityAdjuster.cc:69
RegionalMuonCand.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
L1TMuonQualityAdjuster::m_overlapTfInputTag
edm::InputTag m_overlapTfInputTag
Definition: L1TMuonQualityAdjuster.cc:53
L1TMuonQualityAdjuster::endLuminosityBlock
void endLuminosityBlock(const edm::LuminosityBlock &, edm::EventSetup const &) override
Definition: L1TMuonQualityAdjuster.cc:174
L1TMuonQualityAdjuster::m_bmtfBxOffset
int m_bmtfBxOffset
Definition: L1TMuonQualityAdjuster.cc:55
RegionalMuonCandFwd.h
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
BXVector::getLastBX
int getLastBX() const
L1TMuonQualityAdjuster::~L1TMuonQualityAdjuster
~L1TMuonQualityAdjuster() override
Definition: L1TMuonQualityAdjuster.cc:83
edm::InputTag
Definition: InputTag.h:15
l1t::RegionalMuonCand
Definition: RegionalMuonCand.h:8
L1TMuonQualityAdjuster::endRun
void endRun(const edm::Run &, edm::EventSetup const &) override
Definition: L1TMuonQualityAdjuster.cc:168