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 
21 // system include files
22 #include <memory>
23 #include <fstream>
24 
25 // user include files
30 
33 
37 
45 
49 
50 #include <iostream>
51 //
52 // class declaration
53 //
54 using namespace l1t;
55 
56 class L1TMicroGMTLUTDumper : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
57  public:
58  explicit L1TMicroGMTLUTDumper(const edm::ParameterSet&);
59  ~L1TMicroGMTLUTDumper() override;
60  void analyze(const edm::Event&, const edm::EventSetup&) override;
61 
62  private:
63  void beginRun(edm::Run const&, edm::EventSetup const&) override;
64  void endRun(edm::Run const&, edm::EventSetup const&) override;
65 
66  void dumpLut(MicroGMTLUT*, const std::string&);
67 
68  // ----------member data ---------------------------
69  std::unique_ptr<L1TMuonGlobalParamsHelper> microGMTParamsHelper;
71 
72  std::shared_ptr<MicroGMTRankPtQualLUT> m_rankLUT;
73 
74  std::shared_ptr<MicroGMTAbsoluteIsolationCheckLUT> m_absIsoCheckMemLUT;
75  std::shared_ptr<MicroGMTRelativeIsolationCheckLUT> m_relIsoCheckMemLUT;
76 
77  std::shared_ptr<MicroGMTCaloIndexSelectionLUT> m_idxSelMemPhiLUT;
78  std::shared_ptr<MicroGMTCaloIndexSelectionLUT> m_idxSelMemEtaLUT;
79 
80  std::shared_ptr<MicroGMTExtrapolationLUT> m_bPhiExtrapolationLUT;
81  std::shared_ptr<MicroGMTExtrapolationLUT> m_oPhiExtrapolationLUT;
82  std::shared_ptr<MicroGMTExtrapolationLUT> m_fPhiExtrapolationLUT;
83  std::shared_ptr<MicroGMTExtrapolationLUT> m_bEtaExtrapolationLUT;
84  std::shared_ptr<MicroGMTExtrapolationLUT> m_oEtaExtrapolationLUT;
85  std::shared_ptr<MicroGMTExtrapolationLUT> m_fEtaExtrapolationLUT;
86 
87  std::shared_ptr<MicroGMTMatchQualLUT> m_boPosMatchQualLUT;
88  std::shared_ptr<MicroGMTMatchQualLUT> m_boNegMatchQualLUT;
89  std::shared_ptr<MicroGMTMatchQualLUT> m_foPosMatchQualLUT;
90  std::shared_ptr<MicroGMTMatchQualLUT> m_foNegMatchQualLUT;
91  //std::shared_ptr<MicroGMTMatchQualLUT> m_brlSingleMatchQualLUT;
92  std::shared_ptr<MicroGMTMatchQualLUT> m_ovlPosSingleMatchQualLUT;
93  std::shared_ptr<MicroGMTMatchQualLUT> m_ovlNegSingleMatchQualLUT;
94  std::shared_ptr<MicroGMTMatchQualLUT> m_fwdPosSingleMatchQualLUT;
95  std::shared_ptr<MicroGMTMatchQualLUT> m_fwdNegSingleMatchQualLUT;
96 };
97 
98 //
99 // constants, enums and typedefs
100 //
101 
102 
103 //
104 // static data member definitions
105 //
106 
107 //
108 // constructors and destructor
109 //
111 {
112  //now do what ever other initialization is needed
113  m_foldername = iConfig.getParameter<std::string> ("out_directory");
114 
115  microGMTParamsHelper = std::make_unique<L1TMuonGlobalParamsHelper>();
116 }
117 
118 
120 {
121  // do anything here that needs to be done at desctruction time
122  // (e.g. close files, deallocate resources etc.)
123 }
124 
125 
126 //
127 // member functions
128 //
129 void
131  std::ofstream fStream(m_foldername+oName);
132  lut->save(fStream);
133  fStream.close();
134 }
135 
136 
137 
138 // ------------ method called to produce the data ------------
139 void
141 {
142  using namespace edm;
143  dumpLut(m_rankLUT.get(), std::string("/SortRank.txt"));
144  dumpLut(m_absIsoCheckMemLUT.get(), std::string("/AbsIsoCheckMem.txt"));
145  dumpLut(m_relIsoCheckMemLUT.get(), std::string("/RelIsoCheckMem.txt"));
146  dumpLut(m_idxSelMemPhiLUT.get(), std::string("/IdxSelMemPhi.txt"));
147  dumpLut(m_idxSelMemEtaLUT.get(), std::string("/IdxSelMemEta.txt"));
148  dumpLut(m_bPhiExtrapolationLUT.get(), std::string("/BPhiExtrapolation.txt"));
149  dumpLut(m_oPhiExtrapolationLUT.get(), std::string("/OPhiExtrapolation.txt"));
150  dumpLut(m_fPhiExtrapolationLUT.get(), std::string("/EPhiExtrapolation.txt"));
151  dumpLut(m_bEtaExtrapolationLUT.get(), std::string("/BEtaExtrapolation.txt"));
152  dumpLut(m_oEtaExtrapolationLUT.get(), std::string("/OEtaExtrapolation.txt"));
153  dumpLut(m_fEtaExtrapolationLUT.get(), std::string("/EEtaExtrapolation.txt"));
154  dumpLut(m_boPosMatchQualLUT.get(), std::string("/BOPosMatchQual.txt"));
155  dumpLut(m_boNegMatchQualLUT.get(), std::string("/BONegMatchQual.txt"));
156  dumpLut(m_foPosMatchQualLUT.get(), std::string("/EOPosMatchQual.txt"));
157  dumpLut(m_foNegMatchQualLUT.get(), std::string("/EONegMatchQual.txt"));
158  //dumpLut(m_brlSingleMatchQualLUT.get(), std::string("/BmtfSingleMatchQual.txt"));
159  dumpLut(m_ovlPosSingleMatchQualLUT.get(), std::string("/OmtfPosSingleMatchQual.txt"));
160  dumpLut(m_ovlNegSingleMatchQualLUT.get(), std::string("/OmtfNegSingleMatchQual.txt"));
161  dumpLut(m_fwdPosSingleMatchQualLUT.get(), std::string("/EmtfPosSingleMatchQual.txt"));
162  dumpLut(m_fwdNegSingleMatchQualLUT.get(), std::string("/EmtfNegSingleMatchQual.txt"));
163 
164 }
165 
166 // ------------ method called when starting to processes a run ------------
167 void
169 {
170  const L1TMuonGlobalParamsRcd& microGMTParamsRcd = iSetup.get<L1TMuonGlobalParamsRcd>();
171  edm::ESHandle<L1TMuonGlobalParams> microGMTParamsHandle;
172  microGMTParamsRcd.get(microGMTParamsHandle);
173 
174  microGMTParamsHelper = std::make_unique<L1TMuonGlobalParamsHelper>(*microGMTParamsHandle.product());
175  if (!microGMTParamsHelper) {
176  edm::LogError("L1TMicroGMTLUTDumper") << "Could not retrieve parameters from Event Setup" << std::endl;
177  }
178 
179  int fwVersion = microGMTParamsHelper->fwVersion();
180  m_rankLUT = MicroGMTRankPtQualLUTFactory::create(microGMTParamsHelper->sortRankLUT(), fwVersion);
181 
182  m_absIsoCheckMemLUT = MicroGMTAbsoluteIsolationCheckLUTFactory::create(microGMTParamsHelper->absIsoCheckMemLUT(), fwVersion);
183  m_relIsoCheckMemLUT = MicroGMTRelativeIsolationCheckLUTFactory::create(microGMTParamsHelper->relIsoCheckMemLUT(), fwVersion);
184  m_idxSelMemPhiLUT = MicroGMTCaloIndexSelectionLUTFactory::create(microGMTParamsHelper->idxSelMemPhiLUT(), l1t::MicroGMTConfiguration::PHI, fwVersion);
185  m_idxSelMemEtaLUT = MicroGMTCaloIndexSelectionLUTFactory::create(microGMTParamsHelper->idxSelMemEtaLUT(), l1t::MicroGMTConfiguration::ETA, fwVersion);
186 
187  m_bPhiExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(microGMTParamsHelper->bPhiExtrapolationLUT(), l1t::MicroGMTConfiguration::PHI_OUT, fwVersion);
188  m_oPhiExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(microGMTParamsHelper->oPhiExtrapolationLUT(), l1t::MicroGMTConfiguration::PHI_OUT, fwVersion);
189  m_fPhiExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(microGMTParamsHelper->fPhiExtrapolationLUT(), l1t::MicroGMTConfiguration::PHI_OUT, fwVersion);
190  m_bEtaExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(microGMTParamsHelper->bEtaExtrapolationLUT(), l1t::MicroGMTConfiguration::ETA_OUT, fwVersion);
191  m_oEtaExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(microGMTParamsHelper->oEtaExtrapolationLUT(), l1t::MicroGMTConfiguration::ETA_OUT, fwVersion);
192  m_fEtaExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(microGMTParamsHelper->fEtaExtrapolationLUT(), l1t::MicroGMTConfiguration::ETA_OUT, fwVersion);
193 
194  m_boPosMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(microGMTParamsHelper->bOPosMatchQualLUT(), cancel_t::omtf_bmtf_pos, fwVersion);
195  m_boNegMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(microGMTParamsHelper->bONegMatchQualLUT(), cancel_t::omtf_bmtf_neg, fwVersion);
196  m_foPosMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(microGMTParamsHelper->fOPosMatchQualLUT(), cancel_t::omtf_emtf_pos, fwVersion);
197  m_foNegMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(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(microGMTParamsHelper->ovlPosSingleMatchQualLUT(), cancel_t::omtf_omtf_pos, fwVersion);
200  m_ovlNegSingleMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(microGMTParamsHelper->ovlNegSingleMatchQualLUT(), cancel_t::omtf_omtf_neg, fwVersion);
201  m_fwdPosSingleMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(microGMTParamsHelper->fwdPosSingleMatchQualLUT(), cancel_t::emtf_emtf_pos, fwVersion);
202  m_fwdNegSingleMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(microGMTParamsHelper->fwdNegSingleMatchQualLUT(), cancel_t::emtf_emtf_neg, fwVersion);
203 }
204 
205 // ------------ method called when ending to processes a run ------------
206 void
208 {
209 }
210 
211  //define this as a plug-in
T getParameter(std::string const &) const
void endRun(edm::Run const &, edm::EventSetup const &) override
void analyze(const edm::Event &, const edm::EventSetup &) override
def analyze(function, filename, filter=None)
Definition: Profiling.py:11
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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)
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:230
static ReturnType create(const std::string &filename, const int fwVersion)
std::shared_ptr< MicroGMTExtrapolationLUT > m_bPhiExtrapolationLUT
std::shared_ptr< MicroGMTCaloIndexSelectionLUT > m_idxSelMemPhiLUT
std::shared_ptr< MicroGMTRankPtQualLUT > m_rankLUT
void get(HolderT &iHolder) const
void dumpLut(MicroGMTLUT *, const std::string &)
L1TMicroGMTLUTDumper(const edm::ParameterSet &)
std::unique_ptr< L1TMuonGlobalParamsHelper > microGMTParamsHelper
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
const T & get() const
Definition: EventSetup.h:55
std::shared_ptr< MicroGMTMatchQualLUT > m_boPosMatchQualLUT
HLT enums.
void save(std::ofstream &output)
Definition: MicroGMTLUT.cc:15
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:43
static ReturnType create(const std::string &filename, const int type, const int fwVersion)