CMS 3D CMS Logo

L1GctPrintLuts.cc
Go to the documentation of this file.
2 
6 
8 
9 // GCT include files
18 
19 #include <iostream>
20 #include <fstream>
21 #include <sys/stat.h>
22 
24  : m_jetRanksOutFileName(iConfig.getUntrackedParameter<std::string>("jetRanksFilename", "gctJetRanksContents.txt")),
25  m_hfSumLutOutFileName(iConfig.getUntrackedParameter<std::string>("hfSumLutFilename", "gctHfSumLutContents.txt")),
26  m_htMissLutOutFileName(
27  iConfig.getUntrackedParameter<std::string>("htMissLutFilename", "gctHtMissLutContents.txt")),
28  m_gct(new L1GlobalCaloTrigger(L1GctJetLeafCard::hardwareJetFinder)),
29  m_jetEtCalibLuts() {
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 }
43 
45  // do anything here that needs to be done at desctruction time
46  // (e.g. close files, deallocate resources etc.)
47 }
48 
49 //
50 // member functions
51 //
52 
53 // ------------ method called to for each event ------------
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 }
144 
145 // ------------ method called once each job just before starting event loop ------------
146 // This is where we work ...
148 
149 // The configuration method for the Gct - copied from L1GctEmulator
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 }
205 
206 // ------------ method called once each job just after ending the event loop ------------
208 
L1GctGlobalEnergyAlgos::getHtMissLut
const L1GctHtMissLut * getHtMissLut() const
Definition: L1GctGlobalEnergyAlgos.h:139
L1GctJetFinderBase::COL_OFFSET
static const unsigned int COL_OFFSET
The index offset between columns.
Definition: L1GctJetFinderBase.h:112
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
L1GctJetEtCalibrationLut.h
L1GctPrintLuts
Definition: L1GctPrintLuts.h:45
MessageLogger.h
L1GlobalCaloTrigger::getEnergyFinalStage
L1GctGlobalEnergyAlgos * getEnergyFinalStage() const
get the energy final stage
Definition: L1GlobalCaloTrigger.h:199
ESHandle.h
L1GctHfEtSumsLut::bitCountPosEtaRing1
Definition: L1GctHfEtSumsLut.h:25
L1GctPrintLuts::configureGct
int configureGct(const edm::EventSetup &c)
Definition: L1GctPrintLuts.cc:150
L1GctGlobalEnergyAlgos::getHfSumProcessor
L1GctGlobalHfSumAlgos * getHfSumProcessor() const
provide access to hf sum processor
Definition: L1GctGlobalEnergyAlgos.h:96
L1GctGlobalHfSumAlgos.h
L1GctPrintLuts::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: L1GctPrintLuts.cc:54
L1GctHfEtSumsLut::etSumNegEtaRing1
Definition: L1GctHfEtSumsLut.h:31
L1GctHtMissLut.h
L1GctPrintLuts::m_jetRanksOutFileName
std::string m_jetRanksOutFileName
Definition: L1GctPrintLuts.h:64
L1GctHfEtSumsLut::etSumPosEtaRing1
Definition: L1GctHfEtSumsLut.h:29
L1GlobalCaloTrigger::setJetFinderParams
void setJetFinderParams(const L1GctJetFinderParams *const jfpars)
Definition: L1GlobalCaloTrigger.cc:308
L1GlobalCaloTrigger::setHtMissScale
void setHtMissScale(const L1CaloEtScale *const scale)
setup scale for missing Ht
Definition: L1GlobalCaloTrigger.cc:345
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
L1GctPrintLuts::lutPtr
L1GlobalCaloTrigger::lutPtr lutPtr
typedefs
Definition: L1GctPrintLuts.h:48
L1GctGlobalEnergyAlgos.h
L1GctHfEtSumsLut::bitCountNegEtaRing1
Definition: L1GctHfEtSumsLut.h:27
MakerMacros.h
L1GctJetEtCalibrationLut
Jet Et calibration LUT.
Definition: L1GctJetEtCalibrationLut.h:28
L1GctPrintLuts.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
hgcalPlots.stat
stat
Definition: hgcalPlots.py:1119
L1GctPrintLuts::beginJob
void beginJob() override
Definition: L1GctPrintLuts.cc:147
L1GctPrintLuts::m_hfSumLutOutFileName
std::string m_hfSumLutOutFileName
Definition: L1GctPrintLuts.h:65
edm::ESHandle
Definition: DTSurvey.h:22
summarizeEdmComparisonLogfiles.success
success
Definition: summarizeEdmComparisonLogfiles.py:115
L1GctHfEtSumsLut.h
L1GctPrintLuts::m_htMissScaleToken
edm::ESGetToken< L1CaloEtScale, L1HtMissScaleRcd > m_htMissScaleToken
Definition: L1GctPrintLuts.h:77
L1GctPrintLuts::m_htMissLutOutFileName
std::string m_htMissLutOutFileName
Definition: L1GctPrintLuts.h:66
L1GctPrintLuts::L1GctPrintLuts
L1GctPrintLuts(const edm::ParameterSet &)
Definition: L1GctPrintLuts.cc:23
L1GctHfEtSumsLut::bitCountPosEtaRing2
Definition: L1GctHfEtSumsLut.h:26
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1GctWheelJetFpga.h
L1GctPrintLuts::endJob
void endJob() override
Definition: L1GctPrintLuts.cc:207
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
edm::ParameterSet
Definition: ParameterSet.h:47
L1GctPrintLuts::m_jetEtCalibLuts
lutPtrVector m_jetEtCalibLuts
Definition: L1GctPrintLuts.h:72
L1GctHfBitCountsLut.h
ModuleDef.h
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
iEvent
int iEvent
Definition: GenABIO.cc:224
L1GctPrintLuts::m_etScaleToken
edm::ESGetToken< L1CaloEtScale, L1JetEtScaleRcd > m_etScaleToken
Definition: L1GctPrintLuts.h:76
L1GctPrintLuts::m_jfParsToken
edm::ESGetToken< L1GctJetFinderParams, L1GctJetFinderParamsRcd > m_jfParsToken
Definition: L1GctPrintLuts.h:75
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
L1GctGlobalHfSumAlgos::getBCLut
const L1GctHfBitCountsLut * getBCLut(const L1GctHfEtSumsLut::hfLutType type) const
Get lut pointers.
Definition: L1GctGlobalHfSumAlgos.cc:244
L1GlobalCaloTrigger::setupHfSumLuts
void setupHfSumLuts(const L1CaloEtScale *const scale)
setup Hf sum LUTs
Definition: L1GlobalCaloTrigger.cc:352
L1GctPrintLuts::m_gct
L1GlobalCaloTrigger * m_gct
Definition: L1GctPrintLuts.h:69
std
Definition: JetResolutionObject.h:76
L1GlobalCaloTrigger::setJetEtCalibrationLuts
void setJetEtCalibrationLuts(const lutPtrVector &jfluts)
setup the Jet Calibration Luts
Definition: L1GlobalCaloTrigger.cc:324
L1GlobalCaloTrigger
Bit-level emulation of the Global Calorimeter Trigger.
Definition: L1GlobalCaloTrigger.h:44
L1GctHfEtSumsLut::bitCountNegEtaRing2
Definition: L1GctHfEtSumsLut.h:28
L1GctHfEtSumsLut::etSumPosEtaRing2
Definition: L1GctHfEtSumsLut.h:30
L1GctPrintLuts::m_hfRingEtScaleToken
edm::ESGetToken< L1CaloEtScale, L1HfRingEtScaleRcd > m_hfRingEtScaleToken
Definition: L1GctPrintLuts.h:78
edm::Event
Definition: Event.h:73
L1GctJetLeafCard
Definition: L1GctJetLeafCard.h:28
L1GlobalCaloTrigger.h
L1GctPrintLuts::~L1GctPrintLuts
~L1GctPrintLuts() override
Definition: L1GctPrintLuts.cc:44
photonValidator_cfi.etScale
etScale
Definition: photonValidator_cfi.py:47
L1GctHfEtSumsLut::etSumNegEtaRing2
Definition: L1GctHfEtSumsLut.h:32
L1GctGlobalHfSumAlgos::getESLut
const L1GctHfEtSumsLut * getESLut(const L1GctHfEtSumsLut::hfLutType type) const
Definition: L1GctGlobalHfSumAlgos.cc:253