CMS 3D CMS Logo

L1TMicroGMTLUTDumper.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1TMicroGMTLUTDumper
4 // Class: L1TMicroGMTLUTDumper
5 //
13 //
14 // Original Author: Joschka Philip Lingemann,40 3-B01,+41227671598,
15 // Created: Thu Oct 3 10:12:30 CEST 2013
16 // $Id$
17 //
18 //
19 
20 // system include files
21 #include <memory>
22 #include <fstream>
23 
24 // user include files
29 
32 
36 
44 
48 
49 #include <iostream>
50 //
51 // class declaration
52 //
53 using namespace l1t;
54 
55 class L1TMicroGMTLUTDumper : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
56 public:
57  explicit L1TMicroGMTLUTDumper(const edm::ParameterSet&);
58  ~L1TMicroGMTLUTDumper() override;
59  void analyze(const edm::Event&, const edm::EventSetup&) override;
60 
61 private:
62  void beginRun(edm::Run const&, edm::EventSetup const&) override;
63  void endRun(edm::Run const&, edm::EventSetup const&) override;
64 
65  void dumpLut(MicroGMTLUT*, const std::string&);
66 
67  // ----------member data ---------------------------
68  std::unique_ptr<L1TMuonGlobalParamsHelper> microGMTParamsHelper;
70 
71  std::shared_ptr<MicroGMTRankPtQualLUT> m_rankLUT;
72 
73  std::shared_ptr<MicroGMTAbsoluteIsolationCheckLUT> m_absIsoCheckMemLUT;
74  std::shared_ptr<MicroGMTRelativeIsolationCheckLUT> m_relIsoCheckMemLUT;
75 
76  std::shared_ptr<MicroGMTCaloIndexSelectionLUT> m_idxSelMemPhiLUT;
77  std::shared_ptr<MicroGMTCaloIndexSelectionLUT> m_idxSelMemEtaLUT;
78 
79  std::shared_ptr<MicroGMTExtrapolationLUT> m_bPhiExtrapolationLUT;
80  std::shared_ptr<MicroGMTExtrapolationLUT> m_oPhiExtrapolationLUT;
81  std::shared_ptr<MicroGMTExtrapolationLUT> m_fPhiExtrapolationLUT;
82  std::shared_ptr<MicroGMTExtrapolationLUT> m_bEtaExtrapolationLUT;
83  std::shared_ptr<MicroGMTExtrapolationLUT> m_oEtaExtrapolationLUT;
84  std::shared_ptr<MicroGMTExtrapolationLUT> m_fEtaExtrapolationLUT;
85 
86  std::shared_ptr<MicroGMTMatchQualLUT> m_boPosMatchQualLUT;
87  std::shared_ptr<MicroGMTMatchQualLUT> m_boNegMatchQualLUT;
88  std::shared_ptr<MicroGMTMatchQualLUT> m_foPosMatchQualLUT;
89  std::shared_ptr<MicroGMTMatchQualLUT> m_foNegMatchQualLUT;
90  //std::shared_ptr<MicroGMTMatchQualLUT> m_brlSingleMatchQualLUT;
91  std::shared_ptr<MicroGMTMatchQualLUT> m_ovlPosSingleMatchQualLUT;
92  std::shared_ptr<MicroGMTMatchQualLUT> m_ovlNegSingleMatchQualLUT;
93  std::shared_ptr<MicroGMTMatchQualLUT> m_fwdPosSingleMatchQualLUT;
94  std::shared_ptr<MicroGMTMatchQualLUT> m_fwdNegSingleMatchQualLUT;
96 };
97 
98 //
99 // constants, enums and typedefs
100 //
101 
102 //
103 // static data member definitions
104 //
105 
106 //
107 // constructors and destructor
108 //
110  //now do what ever other initialization is needed
111  m_foldername = iConfig.getParameter<std::string>("out_directory");
112  m_microGMTParamsToken = esConsumes<L1TMuonGlobalParams, L1TMuonGlobalParamsRcd, edm::Transition::BeginRun>();
113 
114  microGMTParamsHelper = std::make_unique<L1TMuonGlobalParamsHelper>();
115 }
116 
118  // do anything here that needs to be done at desctruction time
119  // (e.g. close files, deallocate resources etc.)
120 }
121 
122 //
123 // member functions
124 //
126  std::ofstream fStream(m_foldername + oName);
127  lut->save(fStream);
128  fStream.close();
129 }
130 
131 // ------------ method called to produce the data ------------
133  using namespace edm;
134  dumpLut(m_rankLUT.get(), std::string("/SortRank.txt"));
135  dumpLut(m_absIsoCheckMemLUT.get(), std::string("/AbsIsoCheckMem.txt"));
136  dumpLut(m_relIsoCheckMemLUT.get(), std::string("/RelIsoCheckMem.txt"));
137  dumpLut(m_idxSelMemPhiLUT.get(), std::string("/IdxSelMemPhi.txt"));
138  dumpLut(m_idxSelMemEtaLUT.get(), std::string("/IdxSelMemEta.txt"));
139  dumpLut(m_bPhiExtrapolationLUT.get(), std::string("/BPhiExtrapolation.txt"));
140  dumpLut(m_oPhiExtrapolationLUT.get(), std::string("/OPhiExtrapolation.txt"));
141  dumpLut(m_fPhiExtrapolationLUT.get(), std::string("/EPhiExtrapolation.txt"));
142  dumpLut(m_bEtaExtrapolationLUT.get(), std::string("/BEtaExtrapolation.txt"));
143  dumpLut(m_oEtaExtrapolationLUT.get(), std::string("/OEtaExtrapolation.txt"));
144  dumpLut(m_fEtaExtrapolationLUT.get(), std::string("/EEtaExtrapolation.txt"));
145  dumpLut(m_boPosMatchQualLUT.get(), std::string("/BOPosMatchQual.txt"));
146  dumpLut(m_boNegMatchQualLUT.get(), std::string("/BONegMatchQual.txt"));
147  dumpLut(m_foPosMatchQualLUT.get(), std::string("/EOPosMatchQual.txt"));
148  dumpLut(m_foNegMatchQualLUT.get(), std::string("/EONegMatchQual.txt"));
149  //dumpLut(m_brlSingleMatchQualLUT.get(), std::string("/BmtfSingleMatchQual.txt"));
150  dumpLut(m_ovlPosSingleMatchQualLUT.get(), std::string("/OmtfPosSingleMatchQual.txt"));
151  dumpLut(m_ovlNegSingleMatchQualLUT.get(), std::string("/OmtfNegSingleMatchQual.txt"));
152  dumpLut(m_fwdPosSingleMatchQualLUT.get(), std::string("/EmtfPosSingleMatchQual.txt"));
153  dumpLut(m_fwdNegSingleMatchQualLUT.get(), std::string("/EmtfNegSingleMatchQual.txt"));
154 }
155 
156 // ------------ method called when starting to processes a run ------------
158  edm::ESHandle<L1TMuonGlobalParams> microGMTParamsHandle = iSetup.getHandle(m_microGMTParamsToken);
159 
160  microGMTParamsHelper = std::make_unique<L1TMuonGlobalParamsHelper>(*microGMTParamsHandle.product());
161  if (!microGMTParamsHelper) {
162  edm::LogError("L1TMicroGMTLUTDumper") << "Could not retrieve parameters from Event Setup" << std::endl;
163  }
164 
165  int fwVersion = microGMTParamsHelper->fwVersion();
166  m_rankLUT = MicroGMTRankPtQualLUTFactory::create(microGMTParamsHelper->sortRankLUT(), fwVersion);
167 
168  m_absIsoCheckMemLUT =
169  MicroGMTAbsoluteIsolationCheckLUTFactory::create(microGMTParamsHelper->absIsoCheckMemLUT(), fwVersion);
170  m_relIsoCheckMemLUT =
171  MicroGMTRelativeIsolationCheckLUTFactory::create(microGMTParamsHelper->relIsoCheckMemLUT(), fwVersion);
173  microGMTParamsHelper->idxSelMemPhiLUT(), l1t::MicroGMTConfiguration::PHI, fwVersion);
175  microGMTParamsHelper->idxSelMemEtaLUT(), l1t::MicroGMTConfiguration::ETA, fwVersion);
176 
177  m_bPhiExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(
178  microGMTParamsHelper->bPhiExtrapolationLUT(), l1t::MicroGMTConfiguration::PHI_OUT, fwVersion);
179  m_oPhiExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(
180  microGMTParamsHelper->oPhiExtrapolationLUT(), l1t::MicroGMTConfiguration::PHI_OUT, fwVersion);
181  m_fPhiExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(
182  microGMTParamsHelper->fPhiExtrapolationLUT(), l1t::MicroGMTConfiguration::PHI_OUT, fwVersion);
183  m_bEtaExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(
184  microGMTParamsHelper->bEtaExtrapolationLUT(), l1t::MicroGMTConfiguration::ETA_OUT, fwVersion);
185  m_oEtaExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(
186  microGMTParamsHelper->oEtaExtrapolationLUT(), l1t::MicroGMTConfiguration::ETA_OUT, fwVersion);
187  m_fEtaExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(
188  microGMTParamsHelper->fEtaExtrapolationLUT(), l1t::MicroGMTConfiguration::ETA_OUT, fwVersion);
189 
190  m_boPosMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(
191  microGMTParamsHelper->bOPosMatchQualLUT(), cancel_t::omtf_bmtf_pos, fwVersion);
192  m_boNegMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(
193  microGMTParamsHelper->bONegMatchQualLUT(), cancel_t::omtf_bmtf_neg, fwVersion);
194  m_foPosMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(
195  microGMTParamsHelper->fOPosMatchQualLUT(), cancel_t::omtf_emtf_pos, fwVersion);
196  m_foNegMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(
197  microGMTParamsHelper->fONegMatchQualLUT(), cancel_t::omtf_emtf_neg, fwVersion);
198  //m_brlSingleMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(microGMTParamsHelper->brlSingleMatchQualLUT(), cancel_t::bmtf_bmtf, fwVersion);
199  m_ovlPosSingleMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(
200  microGMTParamsHelper->ovlPosSingleMatchQualLUT(), cancel_t::omtf_omtf_pos, fwVersion);
201  m_ovlNegSingleMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(
202  microGMTParamsHelper->ovlNegSingleMatchQualLUT(), cancel_t::omtf_omtf_neg, fwVersion);
203  m_fwdPosSingleMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(
204  microGMTParamsHelper->fwdPosSingleMatchQualLUT(), cancel_t::emtf_emtf_pos, fwVersion);
205  m_fwdNegSingleMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(
206  microGMTParamsHelper->fwdNegSingleMatchQualLUT(), cancel_t::emtf_emtf_neg, fwVersion);
207 }
208 
209 // ------------ method called when ending to processes a run ------------
211 
212 //define this as a plug-in
void endRun(edm::Run const &, edm::EventSetup const &) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void analyze(const edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::shared_ptr< MicroGMTExtrapolationLUT > m_oEtaExtrapolationLUT
void beginRun(edm::Run const &, edm::EventSetup const &) override
std::shared_ptr< MicroGMTMatchQualLUT > m_fwdPosSingleMatchQualLUT
delete x;
Definition: CaloConfig.h:22
static ReturnType create(const std::string &filename, const int fwVersion)
Log< level::Error, false > LogError
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
std::shared_ptr< MicroGMTMatchQualLUT > m_boNegMatchQualLUT
static ReturnType create(const std::string &filename, const int type, const int fwVersion)
std::shared_ptr< MicroGMTMatchQualLUT > m_foPosMatchQualLUT
static ReturnType create(const std::string &filename, const int fwVersion, const unsigned ptFactor, const unsigned qualFactor)
int iEvent
Definition: GenABIO.cc:224
T const * product() const
Definition: ESHandle.h:86
static ReturnType create(const std::string &filename, const int fwVersion)
edm::ESGetToken< L1TMuonGlobalParams, L1TMuonGlobalParamsRcd > m_microGMTParamsToken
std::shared_ptr< MicroGMTExtrapolationLUT > m_bPhiExtrapolationLUT
std::shared_ptr< MicroGMTCaloIndexSelectionLUT > m_idxSelMemPhiLUT
std::shared_ptr< MicroGMTRankPtQualLUT > m_rankLUT
void dumpLut(MicroGMTLUT *, const std::string &)
L1TMicroGMTLUTDumper(const edm::ParameterSet &)
std::unique_ptr< L1TMuonGlobalParamsHelper > microGMTParamsHelper
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
std::shared_ptr< MicroGMTMatchQualLUT > m_foNegMatchQualLUT
std::shared_ptr< MicroGMTMatchQualLUT > m_ovlNegSingleMatchQualLUT
std::shared_ptr< MicroGMTAbsoluteIsolationCheckLUT > m_absIsoCheckMemLUT
std::shared_ptr< MicroGMTRelativeIsolationCheckLUT > m_relIsoCheckMemLUT
std::shared_ptr< MicroGMTExtrapolationLUT > m_bEtaExtrapolationLUT
std::shared_ptr< MicroGMTMatchQualLUT > m_ovlPosSingleMatchQualLUT
std::shared_ptr< MicroGMTMatchQualLUT > m_boPosMatchQualLUT
HLT enums.
void save(std::ofstream &output)
Definition: MicroGMTLUT.cc:13
static ReturnType create(const std::string &filename, const double maxDR, const double fEta, const double fEtaCoarse, const double fPhi, cancel_t cancelType, const int fwVersion)
std::shared_ptr< MicroGMTCaloIndexSelectionLUT > m_idxSelMemEtaLUT
std::shared_ptr< MicroGMTMatchQualLUT > m_fwdNegSingleMatchQualLUT
std::shared_ptr< MicroGMTExtrapolationLUT > m_fPhiExtrapolationLUT
std::shared_ptr< MicroGMTExtrapolationLUT > m_fEtaExtrapolationLUT
std::shared_ptr< MicroGMTExtrapolationLUT > m_oPhiExtrapolationLUT
Definition: Run.h:45
static ReturnType create(const std::string &filename, const int type, const int fwVersion)