Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:23:10

0001 // -*- C++ -*-
0002 //
0003 // Package:    L1TMicroGMTLUTDumper
0004 // Class:      L1TMicroGMTLUTDumper
0005 //
0006 /**\class L1TMicroGMTLUTDumper L1TMicroGMTLUTDumper.cc L1Trigger/L1TGlobalMuon/plugins/L1TMicroGMTLUTDumper.cc
0007 
0008  Description: Takes txt-file input and produces barrel- / overlap- / forward TF muons
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Joschka Philip Lingemann,40 3-B01,+41227671598,
0015 //         Created:  Thu Oct  3 10:12:30 CEST 2013
0016 // $Id$
0017 //
0018 //
0019 
0020 // system include files
0021 #include <memory>
0022 #include <fstream>
0023 
0024 // user include files
0025 #include "FWCore/Framework/interface/EventSetup.h"
0026 #include "FWCore/Framework/interface/ESHandle.h"
0027 #include "FWCore/Framework/interface/Frameworkfwd.h"
0028 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0029 
0030 #include "FWCore/Framework/interface/Event.h"
0031 #include "FWCore/Framework/interface/MakerMacros.h"
0032 
0033 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0034 #include "FWCore/Utilities/interface/Exception.h"
0035 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0036 
0037 #include "L1Trigger/L1TMuon/interface/MicroGMTRankPtQualLUT.h"
0038 #include "L1Trigger/L1TMuon/interface/MicroGMTAbsoluteIsolationCheckLUT.h"
0039 #include "L1Trigger/L1TMuon/interface/MicroGMTRelativeIsolationCheckLUT.h"
0040 #include "L1Trigger/L1TMuon/interface/MicroGMTCaloIndexSelectionLUT.h"
0041 #include "L1Trigger/L1TMuon/interface/MicroGMTExtrapolationLUT.h"
0042 #include "L1Trigger/L1TMuon/interface/MicroGMTMatchQualLUT.h"
0043 #include "L1Trigger/L1TMuon/interface/MicroGMTLUTFactories.h"
0044 
0045 #include "CondFormats/L1TObjects/interface/L1TMuonGlobalParams.h"
0046 #include "CondFormats/DataRecord/interface/L1TMuonGlobalParamsRcd.h"
0047 #include "L1Trigger/L1TMuon/interface/L1TMuonGlobalParamsHelper.h"
0048 
0049 #include <iostream>
0050 //
0051 // class declaration
0052 //
0053 using namespace l1t;
0054 
0055 class L1TMicroGMTLUTDumper : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
0056 public:
0057   explicit L1TMicroGMTLUTDumper(const edm::ParameterSet&);
0058   ~L1TMicroGMTLUTDumper() override;
0059   void analyze(const edm::Event&, const edm::EventSetup&) override;
0060 
0061 private:
0062   void beginRun(edm::Run const&, edm::EventSetup const&) override;
0063   void endRun(edm::Run const&, edm::EventSetup const&) override;
0064 
0065   void dumpLut(MicroGMTLUT*, const std::string&);
0066 
0067   // ----------member data ---------------------------
0068   std::unique_ptr<L1TMuonGlobalParamsHelper> microGMTParamsHelper;
0069   std::string m_foldername;
0070 
0071   std::shared_ptr<MicroGMTRankPtQualLUT> m_rankLUT;
0072 
0073   std::shared_ptr<MicroGMTAbsoluteIsolationCheckLUT> m_absIsoCheckMemLUT;
0074   std::shared_ptr<MicroGMTRelativeIsolationCheckLUT> m_relIsoCheckMemLUT;
0075 
0076   std::shared_ptr<MicroGMTCaloIndexSelectionLUT> m_idxSelMemPhiLUT;
0077   std::shared_ptr<MicroGMTCaloIndexSelectionLUT> m_idxSelMemEtaLUT;
0078 
0079   std::shared_ptr<MicroGMTExtrapolationLUT> m_bPhiExtrapolationLUT;
0080   std::shared_ptr<MicroGMTExtrapolationLUT> m_oPhiExtrapolationLUT;
0081   std::shared_ptr<MicroGMTExtrapolationLUT> m_fPhiExtrapolationLUT;
0082   std::shared_ptr<MicroGMTExtrapolationLUT> m_bEtaExtrapolationLUT;
0083   std::shared_ptr<MicroGMTExtrapolationLUT> m_oEtaExtrapolationLUT;
0084   std::shared_ptr<MicroGMTExtrapolationLUT> m_fEtaExtrapolationLUT;
0085 
0086   std::shared_ptr<MicroGMTMatchQualLUT> m_boPosMatchQualLUT;
0087   std::shared_ptr<MicroGMTMatchQualLUT> m_boNegMatchQualLUT;
0088   std::shared_ptr<MicroGMTMatchQualLUT> m_foPosMatchQualLUT;
0089   std::shared_ptr<MicroGMTMatchQualLUT> m_foNegMatchQualLUT;
0090   //std::shared_ptr<MicroGMTMatchQualLUT> m_brlSingleMatchQualLUT;
0091   std::shared_ptr<MicroGMTMatchQualLUT> m_ovlPosSingleMatchQualLUT;
0092   std::shared_ptr<MicroGMTMatchQualLUT> m_ovlNegSingleMatchQualLUT;
0093   std::shared_ptr<MicroGMTMatchQualLUT> m_fwdPosSingleMatchQualLUT;
0094   std::shared_ptr<MicroGMTMatchQualLUT> m_fwdNegSingleMatchQualLUT;
0095   edm::ESGetToken<L1TMuonGlobalParams, L1TMuonGlobalParamsRcd> m_microGMTParamsToken;
0096 };
0097 
0098 //
0099 // constants, enums and typedefs
0100 //
0101 
0102 //
0103 // static data member definitions
0104 //
0105 
0106 //
0107 // constructors and destructor
0108 //
0109 L1TMicroGMTLUTDumper::L1TMicroGMTLUTDumper(const edm::ParameterSet& iConfig) {
0110   //now do what ever other initialization is needed
0111   m_foldername = iConfig.getParameter<std::string>("out_directory");
0112   m_microGMTParamsToken = esConsumes<L1TMuonGlobalParams, L1TMuonGlobalParamsRcd, edm::Transition::BeginRun>();
0113 
0114   microGMTParamsHelper = std::make_unique<L1TMuonGlobalParamsHelper>();
0115 }
0116 
0117 L1TMicroGMTLUTDumper::~L1TMicroGMTLUTDumper() {
0118   // do anything here that needs to be done at desctruction time
0119   // (e.g. close files, deallocate resources etc.)
0120 }
0121 
0122 //
0123 // member functions
0124 //
0125 void L1TMicroGMTLUTDumper::dumpLut(MicroGMTLUT* lut, const std::string& oName) {
0126   std::ofstream fStream(m_foldername + oName);
0127   lut->save(fStream);
0128   fStream.close();
0129 }
0130 
0131 // ------------ method called to produce the data  ------------
0132 void L1TMicroGMTLUTDumper::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0133   using namespace edm;
0134   dumpLut(m_rankLUT.get(), std::string("/SortRank.txt"));
0135   dumpLut(m_absIsoCheckMemLUT.get(), std::string("/AbsIsoCheckMem.txt"));
0136   dumpLut(m_relIsoCheckMemLUT.get(), std::string("/RelIsoCheckMem.txt"));
0137   dumpLut(m_idxSelMemPhiLUT.get(), std::string("/IdxSelMemPhi.txt"));
0138   dumpLut(m_idxSelMemEtaLUT.get(), std::string("/IdxSelMemEta.txt"));
0139   dumpLut(m_bPhiExtrapolationLUT.get(), std::string("/BPhiExtrapolation.txt"));
0140   dumpLut(m_oPhiExtrapolationLUT.get(), std::string("/OPhiExtrapolation.txt"));
0141   dumpLut(m_fPhiExtrapolationLUT.get(), std::string("/EPhiExtrapolation.txt"));
0142   dumpLut(m_bEtaExtrapolationLUT.get(), std::string("/BEtaExtrapolation.txt"));
0143   dumpLut(m_oEtaExtrapolationLUT.get(), std::string("/OEtaExtrapolation.txt"));
0144   dumpLut(m_fEtaExtrapolationLUT.get(), std::string("/EEtaExtrapolation.txt"));
0145   dumpLut(m_boPosMatchQualLUT.get(), std::string("/BOPosMatchQual.txt"));
0146   dumpLut(m_boNegMatchQualLUT.get(), std::string("/BONegMatchQual.txt"));
0147   dumpLut(m_foPosMatchQualLUT.get(), std::string("/EOPosMatchQual.txt"));
0148   dumpLut(m_foNegMatchQualLUT.get(), std::string("/EONegMatchQual.txt"));
0149   //dumpLut(m_brlSingleMatchQualLUT.get(), std::string("/BmtfSingleMatchQual.txt"));
0150   dumpLut(m_ovlPosSingleMatchQualLUT.get(), std::string("/OmtfPosSingleMatchQual.txt"));
0151   dumpLut(m_ovlNegSingleMatchQualLUT.get(), std::string("/OmtfNegSingleMatchQual.txt"));
0152   dumpLut(m_fwdPosSingleMatchQualLUT.get(), std::string("/EmtfPosSingleMatchQual.txt"));
0153   dumpLut(m_fwdNegSingleMatchQualLUT.get(), std::string("/EmtfNegSingleMatchQual.txt"));
0154 }
0155 
0156 // ------------ method called when starting to processes a run  ------------
0157 void L1TMicroGMTLUTDumper::beginRun(edm::Run const& run, edm::EventSetup const& iSetup) {
0158   edm::ESHandle<L1TMuonGlobalParams> microGMTParamsHandle = iSetup.getHandle(m_microGMTParamsToken);
0159 
0160   microGMTParamsHelper = std::make_unique<L1TMuonGlobalParamsHelper>(*microGMTParamsHandle.product());
0161   if (!microGMTParamsHelper) {
0162     edm::LogError("L1TMicroGMTLUTDumper") << "Could not retrieve parameters from Event Setup" << std::endl;
0163   }
0164 
0165   int fwVersion = microGMTParamsHelper->fwVersion();
0166   m_rankLUT = MicroGMTRankPtQualLUTFactory::create(microGMTParamsHelper->sortRankLUT(), fwVersion);
0167 
0168   m_absIsoCheckMemLUT =
0169       MicroGMTAbsoluteIsolationCheckLUTFactory::create(microGMTParamsHelper->absIsoCheckMemLUT(), fwVersion);
0170   m_relIsoCheckMemLUT =
0171       MicroGMTRelativeIsolationCheckLUTFactory::create(microGMTParamsHelper->relIsoCheckMemLUT(), fwVersion);
0172   m_idxSelMemPhiLUT = MicroGMTCaloIndexSelectionLUTFactory::create(
0173       microGMTParamsHelper->idxSelMemPhiLUT(), l1t::MicroGMTConfiguration::PHI, fwVersion);
0174   m_idxSelMemEtaLUT = MicroGMTCaloIndexSelectionLUTFactory::create(
0175       microGMTParamsHelper->idxSelMemEtaLUT(), l1t::MicroGMTConfiguration::ETA, fwVersion);
0176 
0177   m_bPhiExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(
0178       microGMTParamsHelper->bPhiExtrapolationLUT(), l1t::MicroGMTConfiguration::PHI_OUT, fwVersion);
0179   m_oPhiExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(
0180       microGMTParamsHelper->oPhiExtrapolationLUT(), l1t::MicroGMTConfiguration::PHI_OUT, fwVersion);
0181   m_fPhiExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(
0182       microGMTParamsHelper->fPhiExtrapolationLUT(), l1t::MicroGMTConfiguration::PHI_OUT, fwVersion);
0183   m_bEtaExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(
0184       microGMTParamsHelper->bEtaExtrapolationLUT(), l1t::MicroGMTConfiguration::ETA_OUT, fwVersion);
0185   m_oEtaExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(
0186       microGMTParamsHelper->oEtaExtrapolationLUT(), l1t::MicroGMTConfiguration::ETA_OUT, fwVersion);
0187   m_fEtaExtrapolationLUT = MicroGMTExtrapolationLUTFactory::create(
0188       microGMTParamsHelper->fEtaExtrapolationLUT(), l1t::MicroGMTConfiguration::ETA_OUT, fwVersion);
0189 
0190   m_boPosMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(
0191       microGMTParamsHelper->bOPosMatchQualLUT(), cancel_t::omtf_bmtf_pos, fwVersion);
0192   m_boNegMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(
0193       microGMTParamsHelper->bONegMatchQualLUT(), cancel_t::omtf_bmtf_neg, fwVersion);
0194   m_foPosMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(
0195       microGMTParamsHelper->fOPosMatchQualLUT(), cancel_t::omtf_emtf_pos, fwVersion);
0196   m_foNegMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(
0197       microGMTParamsHelper->fONegMatchQualLUT(), cancel_t::omtf_emtf_neg, fwVersion);
0198   //m_brlSingleMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(microGMTParamsHelper->brlSingleMatchQualLUT(), cancel_t::bmtf_bmtf, fwVersion);
0199   m_ovlPosSingleMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(
0200       microGMTParamsHelper->ovlPosSingleMatchQualLUT(), cancel_t::omtf_omtf_pos, fwVersion);
0201   m_ovlNegSingleMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(
0202       microGMTParamsHelper->ovlNegSingleMatchQualLUT(), cancel_t::omtf_omtf_neg, fwVersion);
0203   m_fwdPosSingleMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(
0204       microGMTParamsHelper->fwdPosSingleMatchQualLUT(), cancel_t::emtf_emtf_pos, fwVersion);
0205   m_fwdNegSingleMatchQualLUT = l1t::MicroGMTMatchQualLUTFactory::create(
0206       microGMTParamsHelper->fwdNegSingleMatchQualLUT(), cancel_t::emtf_emtf_neg, fwVersion);
0207 }
0208 
0209 // ------------ method called when ending to processes a run  ------------
0210 void L1TMicroGMTLUTDumper::endRun(edm::Run const&, edm::EventSetup const&) {}
0211 
0212 //define this as a plug-in
0213 DEFINE_FWK_MODULE(L1TMicroGMTLUTDumper);