CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
L1GctPrintLuts Class Reference

#include <L1Trigger/L1GlobalCaloTrigger/plugins/L1GctPrintLuts.cc>

Inheritance diagram for L1GctPrintLuts:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Types

typedef L1GlobalCaloTrigger::lutPtr lutPtr
 typedefs More...
 
typedef L1GlobalCaloTrigger::lutPtrVector lutPtrVector
 
- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 L1GctPrintLuts (const edm::ParameterSet &)
 
 ~L1GctPrintLuts () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
int configureGct (const edm::EventSetup &c)
 
void endJob () override
 

Private Attributes

edm::ESGetToken< L1CaloEtScale, L1JetEtScaleRcdm_etScaleToken
 
L1GlobalCaloTriggerm_gct
 
edm::ESGetToken< L1CaloEtScale, L1HfRingEtScaleRcdm_hfRingEtScaleToken
 
std::string m_hfSumLutOutFileName
 
std::string m_htMissLutOutFileName
 
edm::ESGetToken< L1CaloEtScale, L1HtMissScaleRcdm_htMissScaleToken
 
lutPtrVector m_jetEtCalibLuts
 
std::string m_jetRanksOutFileName
 
edm::ESGetToken< L1GctJetFinderParams, L1GctJetFinderParamsRcdm_jfParsToken
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: print Gct lookup table contents to a file

Definition at line 45 of file L1GctPrintLuts.h.

Member Typedef Documentation

◆ lutPtr

typedefs

Definition at line 48 of file L1GctPrintLuts.h.

◆ lutPtrVector

Definition at line 49 of file L1GctPrintLuts.h.

Constructor & Destructor Documentation

◆ L1GctPrintLuts()

L1GctPrintLuts::L1GctPrintLuts ( const edm::ParameterSet iConfig)
explicit

Definition at line 23 of file L1GctPrintLuts.cc.

References L1GctJetFinderBase::COL_OFFSET, hcalRecHitTable_cff::ieta, m_etScaleToken, m_hfRingEtScaleToken, m_htMissScaleToken, m_jetEtCalibLuts, and m_jfParsToken.

24  : m_jetRanksOutFileName(iConfig.getUntrackedParameter<std::string>("jetRanksFilename", "gctJetRanksContents.txt")),
25  m_hfSumLutOutFileName(iConfig.getUntrackedParameter<std::string>("hfSumLutFilename", "gctHfSumLutContents.txt")),
27  iConfig.getUntrackedParameter<std::string>("htMissLutFilename", "gctHtMissLutContents.txt")),
30  // Fill the jetEtCalibLuts vector
31  lutPtr nextLut(new L1GctJetEtCalibrationLut());
32 
33  for (unsigned ieta = 0; ieta < L1GctJetFinderBase::COL_OFFSET; ieta++) {
34  nextLut->setEtaBin(ieta);
35  m_jetEtCalibLuts.push_back(nextLut);
36  nextLut.reset(new L1GctJetEtCalibrationLut());
37  }
38  m_jfParsToken = esConsumes<L1GctJetFinderParams, L1GctJetFinderParamsRcd>();
39  m_etScaleToken = esConsumes<L1CaloEtScale, L1JetEtScaleRcd>();
40  m_htMissScaleToken = esConsumes<L1CaloEtScale, L1HtMissScaleRcd>();
41  m_hfRingEtScaleToken = esConsumes<L1CaloEtScale, L1HfRingEtScaleRcd>();
42 }
Jet Et calibration LUT.
lutPtrVector m_jetEtCalibLuts
Bit-level emulation of the Global Calorimeter Trigger.
T getUntrackedParameter(std::string const &, T const &) const
edm::ESGetToken< L1CaloEtScale, L1HtMissScaleRcd > m_htMissScaleToken
L1GlobalCaloTrigger::lutPtr lutPtr
typedefs
std::string m_hfSumLutOutFileName
edm::ESGetToken< L1CaloEtScale, L1JetEtScaleRcd > m_etScaleToken
static const unsigned int COL_OFFSET
The index offset between columns.
std::string m_jetRanksOutFileName
L1GlobalCaloTrigger * m_gct
std::string m_htMissLutOutFileName
edm::ESGetToken< L1GctJetFinderParams, L1GctJetFinderParamsRcd > m_jfParsToken
edm::ESGetToken< L1CaloEtScale, L1HfRingEtScaleRcd > m_hfRingEtScaleToken

◆ ~L1GctPrintLuts()

L1GctPrintLuts::~L1GctPrintLuts ( )
override

Definition at line 44 of file L1GctPrintLuts.cc.

44  {
45  // do anything here that needs to be done at desctruction time
46  // (e.g. close files, deallocate resources etc.)
47 }

Member Function Documentation

◆ analyze()

void L1GctPrintLuts::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 54 of file L1GctPrintLuts.cc.

References L1GctHfEtSumsLut::bitCountNegEtaRing1, L1GctHfEtSumsLut::bitCountNegEtaRing2, L1GctHfEtSumsLut::bitCountPosEtaRing1, L1GctHfEtSumsLut::bitCountPosEtaRing2, edmScanValgrind::buffer, configureGct(), L1GctHfEtSumsLut::etSumNegEtaRing1, L1GctHfEtSumsLut::etSumNegEtaRing2, L1GctHfEtSumsLut::etSumPosEtaRing1, L1GctHfEtSumsLut::etSumPosEtaRing2, geometryDiff::file, L1GctGlobalHfSumAlgos::getBCLut(), L1GlobalCaloTrigger::getEnergyFinalStage(), L1GctGlobalHfSumAlgos::getESLut(), L1GctGlobalEnergyAlgos::getHfSumProcessor(), L1GctGlobalEnergyAlgos::getHtMissLut(), hcalRecHitTable_cff::ieta, m_gct, m_hfSumLutOutFileName, m_htMissLutOutFileName, m_jetEtCalibLuts, m_jetRanksOutFileName, and edm_modernize_messagelogger::stat.

54  {
55  // get config data from EventSetup
56  // check this has been done successfully before proceeding
57  if (configureGct(iSetup) == 0) {
58  // Write to a new file
59  struct stat buffer;
60  if (!stat(m_jetRanksOutFileName.c_str(), &buffer)) {
61  edm::LogWarning("LutFileExists") << "File " << m_jetRanksOutFileName
62  << " already exists. It will not be overwritten." << std::endl;
63  } else {
64  std::ofstream file;
65  file.open(m_jetRanksOutFileName.c_str());
66 
67  if (file.good()) {
68  // Print the calibration lut contents
69  file << " Gct lookup table printout \n"
70  << "===========================\n\n"
71  << "Jet Et Calibration lut contents\n"
72  << std::endl;
73  for (unsigned ieta = 0; ieta < m_jetEtCalibLuts.size(); ieta++) {
74  file << *m_jetEtCalibLuts.at(ieta) << std::endl;
75  }
76  } else {
77  edm::LogWarning("LutFileError") << "Error opening file " << m_jetRanksOutFileName
78  << ". No lookup tables written." << std::endl;
79  }
80  file.close();
81  }
82 
83  if (!stat(m_hfSumLutOutFileName.c_str(), &buffer)) {
84  edm::LogWarning("LutFileExists") << "File " << m_hfSumLutOutFileName
85  << " already exists. It will not be overwritten." << std::endl;
86  } else {
87  std::ofstream file;
88  file.open(m_hfSumLutOutFileName.c_str());
89 
90  if (file.good()) {
91  // Print the Hf luts
92  file << "\n\n Hf ring jet bit count luts:" << std::endl;
93  file << "\n Positive eta, ring1" << std::endl;
95  << std::endl;
96  file << "\n Positive eta, ring2" << std::endl;
98  << std::endl;
99  file << "\n Negative eta, ring1" << std::endl;
101  << std::endl;
102  file << "\n Negative eta, ring2" << std::endl;
104  << std::endl;
105  file << "\n\n Hf Et sum luts:" << std::endl;
106  file << "\n Positive eta, ring1" << std::endl;
108  << std::endl;
109  file << "\n Positive eta, ring2" << std::endl;
111  << std::endl;
112  file << "\n Negative eta, ring1" << std::endl;
114  << std::endl;
115  file << "\n Negative eta, ring2" << std::endl;
117  << std::endl;
118  } else {
119  edm::LogWarning("LutFileError") << "Error opening file " << m_hfSumLutOutFileName
120  << ". No lookup tables written." << std::endl;
121  }
122  file.close();
123  }
124 
125  if (!stat(m_htMissLutOutFileName.c_str(), &buffer)) {
126  edm::LogWarning("LutFileExists") << "File " << m_htMissLutOutFileName
127  << " already exists. It will not be overwritten." << std::endl;
128  } else {
129  std::ofstream file;
130  file.open(m_htMissLutOutFileName.c_str());
131 
132  if (file.good()) {
133  // Print the HtMiss luts
134  file << "\n\n missing Ht lut:" << std::endl;
135  file << *m_gct->getEnergyFinalStage()->getHtMissLut() << std::endl;
136  } else {
137  edm::LogWarning("LutFileError") << "Error opening file " << m_hfSumLutOutFileName
138  << ". No lookup tables written." << std::endl;
139  }
140  file.close();
141  }
142  }
143 }
L1GctGlobalHfSumAlgos * getHfSumProcessor() const
provide access to hf sum processor
L1GctGlobalEnergyAlgos * getEnergyFinalStage() const
get the energy final stage
lutPtrVector m_jetEtCalibLuts
const L1GctHfBitCountsLut * getBCLut(const L1GctHfEtSumsLut::hfLutType type) const
Get lut pointers.
std::string m_hfSumLutOutFileName
int configureGct(const edm::EventSetup &c)
const L1GctHfEtSumsLut * getESLut(const L1GctHfEtSumsLut::hfLutType type) const
std::string m_jetRanksOutFileName
L1GlobalCaloTrigger * m_gct
std::string m_htMissLutOutFileName
const L1GctHtMissLut * getHtMissLut() const
Log< level::Warning, false > LogWarning

◆ beginJob()

void L1GctPrintLuts::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 147 of file L1GctPrintLuts.cc.

147 {}

◆ configureGct()

int L1GctPrintLuts::configureGct ( const edm::EventSetup c)
private

Definition at line 150 of file L1GctPrintLuts.cc.

References HltBtagPostValidation_cff::c, photonValidator_cfi::etScale, hcalRecHitTable_cff::ieta, m_etScaleToken, m_gct, m_hfRingEtScaleToken, m_htMissScaleToken, m_jetEtCalibLuts, m_jfParsToken, edm::ESHandle< T >::product(), L1GlobalCaloTrigger::setHtMissScale(), L1GlobalCaloTrigger::setJetEtCalibrationLuts(), L1GlobalCaloTrigger::setJetFinderParams(), L1GlobalCaloTrigger::setupHfSumLuts(), and summarizeEdmComparisonLogfiles::success.

Referenced by analyze().

150  {
151  int success = 0;
152 
153  if (success == 0) {
154  // get data from EventSetup
156  edm::ESHandle<L1CaloEtScale> hfRingEtScale = c.getHandle(m_hfRingEtScaleToken);
157  edm::ESHandle<L1CaloEtScale> htMissScale = c.getHandle(m_htMissScaleToken);
159 
160  if (jfPars.product() == nullptr) {
161  success = -1;
162  edm::LogWarning("L1GctConfigFailure")
163  << "Failed to find a L1GctJetFinderParamsRcd:L1GctJetFinderParams in EventSetup!" << std::endl;
164  }
165 
166  if (hfRingEtScale.product() == nullptr) {
167  success = -1;
168  edm::LogWarning("L1GctConfigFailure")
169  << "Failed to find a L1HfRingEtScaleRcd:L1CaloEtScale in EventSetup!" << std::endl;
170  }
171 
172  if (htMissScale.product() == nullptr) {
173  success = -1;
174  edm::LogWarning("L1GctConfigFailure")
175  << "Failed to find a L1HtMissScaleRcd:L1CaloEtScale in EventSetup!" << std::endl;
176  }
177 
178  // if (chanMask.product() == 0) {
179  // success = -1;
180  // edm::LogWarning("L1GctConfigFailure")
181  // << "Failed to find a L1GctChannelMaskRcd:L1GctChannelMask in EventSetup!" << std::endl;
182  // }
183 
184  if (success == 0) {
185  // tell the jet Et Luts about the scales
186  for (unsigned ieta = 0; ieta < m_jetEtCalibLuts.size(); ieta++) {
187  m_jetEtCalibLuts.at(ieta)->setFunction(jfPars.product());
188  m_jetEtCalibLuts.at(ieta)->setOutputEtScale(etScale.product());
189  }
190 
191  // pass all the setup info to the gct
193  m_gct->setJetFinderParams(jfPars.product());
194  m_gct->setHtMissScale(htMissScale.product());
195  m_gct->setupHfSumLuts(hfRingEtScale.product());
196  // m_gct->setChannelMask(chanMask.product());
197  }
198  }
199 
200  if (success != 0) {
201  edm::LogError("L1GctConfigError") << "Configuration failed - GCT emulator will not be run" << std::endl;
202  }
203  return success;
204 }
lutPtrVector m_jetEtCalibLuts
void setJetFinderParams(const L1GctJetFinderParams *const jfpars)
Log< level::Error, false > LogError
edm::ESGetToken< L1CaloEtScale, L1HtMissScaleRcd > m_htMissScaleToken
T const * product() const
Definition: ESHandle.h:86
void setHtMissScale(const L1CaloEtScale *const scale)
setup scale for missing Ht
edm::ESGetToken< L1CaloEtScale, L1JetEtScaleRcd > m_etScaleToken
void setupHfSumLuts(const L1CaloEtScale *const scale)
setup Hf sum LUTs
void setJetEtCalibrationLuts(const lutPtrVector &jfluts)
setup the Jet Calibration Luts
L1GlobalCaloTrigger * m_gct
edm::ESGetToken< L1GctJetFinderParams, L1GctJetFinderParamsRcd > m_jfParsToken
Log< level::Warning, false > LogWarning
edm::ESGetToken< L1CaloEtScale, L1HfRingEtScaleRcd > m_hfRingEtScaleToken

◆ endJob()

void L1GctPrintLuts::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 207 of file L1GctPrintLuts.cc.

207 {}

Member Data Documentation

◆ m_etScaleToken

edm::ESGetToken<L1CaloEtScale, L1JetEtScaleRcd> L1GctPrintLuts::m_etScaleToken
private

Definition at line 76 of file L1GctPrintLuts.h.

Referenced by configureGct(), and L1GctPrintLuts().

◆ m_gct

L1GlobalCaloTrigger* L1GctPrintLuts::m_gct
private

Definition at line 69 of file L1GctPrintLuts.h.

Referenced by analyze(), and configureGct().

◆ m_hfRingEtScaleToken

edm::ESGetToken<L1CaloEtScale, L1HfRingEtScaleRcd> L1GctPrintLuts::m_hfRingEtScaleToken
private

Definition at line 78 of file L1GctPrintLuts.h.

Referenced by configureGct(), and L1GctPrintLuts().

◆ m_hfSumLutOutFileName

std::string L1GctPrintLuts::m_hfSumLutOutFileName
private

Definition at line 65 of file L1GctPrintLuts.h.

Referenced by analyze().

◆ m_htMissLutOutFileName

std::string L1GctPrintLuts::m_htMissLutOutFileName
private

Definition at line 66 of file L1GctPrintLuts.h.

Referenced by analyze().

◆ m_htMissScaleToken

edm::ESGetToken<L1CaloEtScale, L1HtMissScaleRcd> L1GctPrintLuts::m_htMissScaleToken
private

Definition at line 77 of file L1GctPrintLuts.h.

Referenced by configureGct(), and L1GctPrintLuts().

◆ m_jetEtCalibLuts

lutPtrVector L1GctPrintLuts::m_jetEtCalibLuts
private

Definition at line 72 of file L1GctPrintLuts.h.

Referenced by analyze(), configureGct(), and L1GctPrintLuts().

◆ m_jetRanksOutFileName

std::string L1GctPrintLuts::m_jetRanksOutFileName
private

Definition at line 64 of file L1GctPrintLuts.h.

Referenced by analyze().

◆ m_jfParsToken

edm::ESGetToken<L1GctJetFinderParams, L1GctJetFinderParamsRcd> L1GctPrintLuts::m_jfParsToken
private

Definition at line 75 of file L1GctPrintLuts.h.

Referenced by configureGct(), and L1GctPrintLuts().