CMS 3D CMS Logo

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

#include <L1RCTLutWriter.h>

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

Public Member Functions

 L1RCTLutWriter (const edm::ParameterSet &)
 
 ~L1RCTLutWriter () 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void endJob () override
 
void writeEicLutFile (unsigned short card)
 
void writeJscLutFile ()
 
void writeRcLutFile (unsigned short card)
 
void writeThresholdsFile (unsigned int eicThreshold, unsigned int jscThresholdBarrel, unsigned int jscThresholdEndcap)
 

Private Attributes

edm::ESGetToken< L1CaloEcalScale, L1CaloEcalScaleRcdecalScaleToken_
 
edm::ESGetToken< L1CaloEtScale, L1EmEtScaleRcdemScaleToken_
 
edm::ESGetToken< L1CaloHcalScale, L1CaloHcalScaleRcdhcalScaleToken_
 
std::string keyName_
 
L1RCTLookupTableslookupTable_
 
std::ofstream lutFile_
 
const L1RCTParametersrctParameters_
 
edm::ESGetToken< L1RCTParameters, L1RCTParametersRcdrctParametersToken_
 
EcalTPGScale::Tokens tokens_
 
edm::ESGetToken< CaloTPGTranscoder, CaloTPGRecordtranscoderToken_
 
bool useDebugTpgScales_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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

L1Trigger/L1RCTLutWriter/src/L1RCTLutWriter.cc

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 59 of file L1RCTLutWriter.h.

Constructor & Destructor Documentation

◆ L1RCTLutWriter()

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

Definition at line 37 of file L1RCTLutWriter.cc.

39  keyName_(iConfig.getParameter<std::string>("key")),
40  rctParametersToken_(esConsumes<L1RCTParameters, L1RCTParametersRcd>()),
41  emScaleToken_(esConsumes<L1CaloEtScale, L1EmEtScaleRcd>()),
42  transcoderToken_(esConsumes<CaloTPGTranscoder, CaloTPGRecord>()),
43  hcalScaleToken_(esConsumes<L1CaloHcalScale, L1CaloHcalScaleRcd>()),
44  ecalScaleToken_(esConsumes<L1CaloEcalScale, L1CaloEcalScaleRcd>()),
45  useDebugTpgScales_(iConfig.getParameter<bool>("useDebugTpgScales")),
47  // now do what ever initialization is needed
48 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< L1RCTParameters, L1RCTParametersRcd > rctParametersToken_
edm::ESGetToken< L1CaloEcalScale, L1CaloEcalScaleRcd > ecalScaleToken_
L1RCTLookupTables * lookupTable_
edm::ESGetToken< L1CaloEtScale, L1EmEtScaleRcd > emScaleToken_
std::string keyName_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::ESGetToken< CaloTPGTranscoder, CaloTPGRecord > transcoderToken_
EcalTPGScale::Tokens tokens_
edm::ESGetToken< L1CaloHcalScale, L1CaloHcalScaleRcd > hcalScaleToken_

◆ ~L1RCTLutWriter()

L1RCTLutWriter::~L1RCTLutWriter ( )
override

Definition at line 50 of file L1RCTLutWriter.cc.

References lookupTable_.

50  {
51  // do anything here that needs to be done at destruction time
52  // (e.g. close files, deallocate resources etc.)
53 
54  if (lookupTable_ != nullptr)
55  delete lookupTable_;
56 }
L1RCTLookupTables * lookupTable_

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 63 of file L1RCTLutWriter.cc.

References gather_cfg::cout, MillePedeFileConverter_cfg::e, EcalBarrel, EcalEndcap, ecalScaleToken_, L1RCTParameters::eicIsolationThreshold(), emScaleToken_, edm::EventSetup::getHandle(), EcalTPGScale::getTPGInGeV(), h, CaloTPGTranscoder::hcaletValue(), hcalScaleToken_, mps_fire::i, LEDCalibrationChannels::ieta, dqmiolumiharvest::j, L1RCTParameters::jscQuietThresholdBarrel(), L1RCTParameters::jscQuietThresholdEndcap(), dqmdumpme::k, lookupTable_, visualization-live-secondInstance_cfg::m, callgraph::m2, L1CaloEcalScale::nBinEta, L1CaloHcalScale::nBinEta, L1CaloEcalScale::nBinRank, L1CaloHcalScale::nBinRank, edm::ESHandle< T >::product(), rctParameters_, rctParametersToken_, alignCSCRings::s, L1CaloEcalScale::setBin(), L1CaloHcalScale::setBin(), L1RCTLookupTables::setChannelMask(), L1RCTLookupTables::setEcalScale(), L1RCTLookupTables::setHcalScale(), L1RCTLookupTables::setL1CaloEtScale(), L1RCTLookupTables::setNoisyChannelMask(), L1RCTLookupTables::setRCTParameters(), tokens_, transcoderToken_, useDebugTpgScales_, writeEicLutFile(), writeJscLutFile(), writeRcLutFile(), and writeThresholdsFile().

63  {
64  // get all the configuration information from the event, set it
65  // in the lookuptable
67  rctParameters_ = rctParameters.product();
69  const L1CaloEtScale *s = emScale.product();
70 
71  // make dummy channel mask -- we don't want to mask
72  // any channels when writing LUTs, that comes afterwards
74  for (int i = 0; i < 18; i++) {
75  for (int j = 0; j < 2; j++) {
76  for (int k = 0; k < 28; k++) {
77  m->ecalMask[i][j][k] = false;
78  m->hcalMask[i][j][k] = false;
79  }
80  for (int k = 0; k < 4; k++) {
81  m->hfMask[i][j][k] = false;
82  }
83  }
84  }
85 
86  // Same for Noisy mask
87  // make dummy channel mask -- we don't want to mask
88  // any channels when writing LUTs, that comes afterwards
90  for (int i = 0; i < 18; i++) {
91  for (int j = 0; j < 2; j++) {
92  for (int k = 0; k < 28; k++) {
93  m2->ecalMask[i][j][k] = false;
94  m2->hcalMask[i][j][k] = false;
95  }
96  for (int k = 0; k < 4; k++) {
97  m2->hfMask[i][j][k] = false;
98  }
99  }
100  }
101  m2->ecalThreshold = 0.0;
102  m2->hcalThreshold = 0.0;
103  m2->hfThreshold = 0.0;
104 
105  // use these dummies to get the delete right when using old-style
106  // scales to create set of L1CaloXcalScales
107  L1CaloEcalScale *dummyE(nullptr);
108  L1CaloHcalScale *dummyH(nullptr);
109 
110  if (useDebugTpgScales_) // generate new-style scales from tpg scales
111  {
112  std::cout << "Using old-style TPG scales!" << std::endl;
113 
114  // old version of hcal energy scale to convert input
116  const CaloTPGTranscoder *h_tpg = transcoder.product();
117 
118  // old version of ecal energy scale to convert input
119  EcalTPGScale e_tpg(tokens_, iSetup);
120 
121  L1CaloEcalScale *ecalScale = new L1CaloEcalScale();
122  L1CaloHcalScale *hcalScale = new L1CaloHcalScale();
123 
124  // generate L1CaloXcalScales from old-style scales (thanks, werner!)
125 
126  // ECAL
127  for (unsigned short ieta = 1; ieta <= L1CaloEcalScale::nBinEta; ++ieta) {
128  for (unsigned short irank = 0; irank < L1CaloEcalScale::nBinRank; ++irank) {
129  EcalSubdetector subdet = (ieta <= 17) ? EcalBarrel : EcalEndcap;
130  double etGeVPos = e_tpg.getTPGInGeV(irank,
131  EcalTrigTowerDetId(1, // +ve eta
132  subdet,
133  ieta,
134  1)); // dummy phi value
135  ecalScale->setBin(irank, ieta, 1, etGeVPos);
136  }
137  }
138 
139  for (unsigned short ieta = 1; ieta <= L1CaloEcalScale::nBinEta; ++ieta) {
140  for (unsigned short irank = 0; irank < L1CaloEcalScale::nBinRank; ++irank) {
141  EcalSubdetector subdet = (ieta <= 17) ? EcalBarrel : EcalEndcap;
142 
143  double etGeVNeg = e_tpg.getTPGInGeV(irank,
144  EcalTrigTowerDetId(-1, // -ve eta
145  subdet,
146  ieta,
147  2)); // dummy phi value
148  ecalScale->setBin(irank, ieta, -1, etGeVNeg);
149  }
150  }
151 
152  // HCAL
153  for (unsigned short ieta = 1; ieta <= L1CaloHcalScale::nBinEta; ++ieta) {
154  for (unsigned short irank = 0; irank < L1CaloHcalScale::nBinRank; ++irank) {
155  double etGeV = h_tpg->hcaletValue(ieta, irank);
156 
157  hcalScale->setBin(irank, ieta, 1, etGeV);
158  hcalScale->setBin(irank, ieta, -1, etGeV);
159  }
160  }
161 
162  // set the input scales
163  lookupTable_->setEcalScale(ecalScale);
164  lookupTable_->setHcalScale(hcalScale);
165 
166  dummyE = ecalScale;
167  dummyH = hcalScale;
168 
169  } else {
170  // get energy scale to convert input from ECAL
172  const L1CaloEcalScale *e = ecalScale.product();
173 
174  // get energy scale to convert input from HCAL
176  const L1CaloHcalScale *h = hcalScale.product();
177 
178  // set scales
181  }
182 
186  // lookupTable_->setHcalScale(h);
187  // lookupTable_->setEcalScale(e);
189 
190  for (unsigned short nCard = 0; nCard <= 6; nCard = nCard + 2) {
191  writeRcLutFile(nCard);
192  writeEicLutFile(nCard);
193  }
194  writeJscLutFile();
195 
196  unsigned int eicThreshold = rctParameters_->eicIsolationThreshold();
197  unsigned int jscThresholdBarrel = rctParameters_->jscQuietThresholdBarrel();
198  unsigned int jscThresholdEndcap = rctParameters_->jscQuietThresholdEndcap();
199  writeThresholdsFile(eicThreshold, jscThresholdBarrel, jscThresholdEndcap);
200 
201  if (dummyE != nullptr)
202  delete dummyE;
203  if (dummyH != nullptr)
204  delete dummyH;
205 }
edm::ESGetToken< L1RCTParameters, L1RCTParametersRcd > rctParametersToken_
const L1RCTParameters * rctParameters_
void writeRcLutFile(unsigned short card)
edm::ESGetToken< L1CaloEcalScale, L1CaloEcalScaleRcd > ecalScaleToken_
void setBin(unsigned short rank, unsigned short eta, short etaSign, double et)
set scale element; use this to create non-linear scales
L1RCTLookupTables * lookupTable_
void setBin(unsigned short rank, unsigned short eta, short etaSign, double et)
set scale element; use this to create non-linear scales
edm::ESGetToken< L1CaloEtScale, L1EmEtScaleRcd > emScaleToken_
T const * product() const
Definition: ESHandle.h:86
void setHcalScale(const L1CaloHcalScale *hcalScale)
edm::ESGetToken< CaloTPGTranscoder, CaloTPGRecord > transcoderToken_
static const unsigned short nBinRank
void writeThresholdsFile(unsigned int eicThreshold, unsigned int jscThresholdBarrel, unsigned int jscThresholdEndcap)
EcalTPGScale::Tokens tokens_
edm::ESGetToken< L1CaloHcalScale, L1CaloHcalScaleRcd > hcalScaleToken_
void setL1CaloEtScale(const L1CaloEtScale *etScale)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
unsigned eicIsolationThreshold() const
unsigned jscQuietThresholdBarrel() const
void setEcalScale(const L1CaloEcalScale *ecalScale)
void setRCTParameters(const L1RCTParameters *rctParameters)
static const unsigned short nBinRank
void setNoisyChannelMask(const L1RCTNoisyChannelMask *channelMask)
static const unsigned short nBinEta
static const unsigned short nBinEta
void writeEicLutFile(unsigned short card)
unsigned jscQuietThresholdEndcap() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
virtual double hcaletValue(const int &ieta, const int &iphi, const int &version, const int &compressedValue) const =0
EcalSubdetector
void setChannelMask(const L1RCTChannelMask *channelMask)

◆ endJob()

void L1RCTLutWriter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 209 of file L1RCTLutWriter.cc.

209 {}

◆ writeEicLutFile()

void L1RCTLutWriter::writeEicLutFile ( unsigned short  card)
private

Definition at line 302 of file L1RCTLutWriter.cc.

References mps_check::command, data, TauDecayModes::dec, L1RCTLookupTables::emRank(), corrVsCorr::filename, keyName_, lookupTable_, lutFile_, and pileupReCalc_HLTpaths::trunc.

Referenced by analyze().

302  {
303  // try timestamp
304  char filename[256];
305  char command[264];
306  if (card != 6) {
307  int card2 = card + 1;
308  sprintf(filename, "EIC%i%i-%s.dat", card, card2, keyName_.c_str());
309  } else {
310  sprintf(filename, "EIC6-%s.dat", keyName_.c_str());
311  }
312  // open file for writing, delete any existing content
314  lutFile_ << "Emulator-parameter generated EIC lut file, card " << card << " key " << keyName_ << " ";
315  // close to append timestamp info
316  lutFile_.close();
317  sprintf(command, "date >> %s", filename);
318  system(command);
319 
320  // reopen file for writing values
321  lutFile_.open(filename, std::ios::app);
322 
323  unsigned long data = 0;
324 
325  // write all memory addresses in increasing order
326  // address = (1<<22) + (etIn7Bits<<1)
327 
328  // 2^7 = 0x7f = 128
329  for (int etIn7Bits = 0; etIn7Bits < 128; etIn7Bits++) {
330  data = lookupTable_->emRank(etIn7Bits);
331  if (data > 0x3f) {
332  data = 0x3f;
333  }
334  lutFile_ << std::hex << data << std::dec << std::endl;
335  }
336  lutFile_.close();
337  return;
338 }
L1RCTLookupTables * lookupTable_
std::string keyName_
std::ofstream lutFile_
list command
Definition: mps_check.py:25
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
unsigned int emRank(unsigned short energy) const

◆ writeJscLutFile()

void L1RCTLutWriter::writeJscLutFile ( )
private

Definition at line 341 of file L1RCTLutWriter.cc.

References mps_check::command, data, TauDecayModes::dec, corrVsCorr::filename, keyName_, L1RCTLookupTables::lookup(), lookupTable_, lutFile_, and pileupReCalc_HLTpaths::trunc.

Referenced by analyze().

341  {
342  char filename[256];
343  char command[264];
344  sprintf(filename, "JSC-%s.dat", keyName_.c_str());
345 
346  // open file; if it already existed, delete existing content
348  lutFile_ << "Emulator parameter-generated lut file, key " << keyName_ << " ";
349  // close to append time-stamp
350  lutFile_.close();
351  sprintf(command, "date >> %s", filename);
352  system(command);
353  // reopen file for writing
354  lutFile_.open(filename, std::ios::app);
355 
356  unsigned long data = 0;
357  unsigned long data0 = 0;
358  unsigned long data1 = 0;
359 
360  // write all memory addresses in increasing order
361  // address = (1<<22) + (lutbits<<17) + (phi1et<<9) + (phi0et<<1);
362 
363  // ecl and U93/U225 lut id bits, identify eta segment of hf
364  for (int lutbits = 0; lutbits < 4; lutbits++) {
365  // 8-bit phi_1 et for each eta partition
366  for (unsigned int phi1et = 0; phi1et < 256; phi1et++) {
367  // 8-bit phi_0 et for each eta
368  for (unsigned int phi0et = 0; phi0et < 256; phi0et++) {
369  // lookup takes "(hf_et, crate, card, tower)"
370  // "card" convention for hf is 999, tower is 0-7
371  // but equivalent to 0-3 == lutbits
372  // crate doesn't matter, take 0
373  // only |ieta| matters
374  data0 = lookupTable_->lookup(phi0et, 0, 999, lutbits);
375  if (data0 > 0xff) {
376  data0 = 0xff; // 8-bit output energy for each phi region
377  }
378  data1 = lookupTable_->lookup(phi1et, 0, 999, lutbits);
379  if (data1 > 0xff) {
380  data1 = 0xff; // 8-bit output energy for each phi region
381  }
382  data = (data1 << 8) + (data0);
383  lutFile_ << std::hex << data << std::dec << std::endl;
384  /*
385  if (phi0et < 10 && phi1et < 10)
386  {
387  std::cout << "Writer: jsc. lutbits=" << lutbits
388  << " phi0et=" << phi0et << " data0=" << data0
389  << " phi1et=" << phi1et << " data1=" << data1
390  << std::endl;
391  }
392  */
393  }
394  }
395  }
396 
397  lutFile_.close();
398  return;
399 }
unsigned int lookup(unsigned short ecalInput, unsigned short hcalInput, unsigned short fgbit, unsigned short crtNo, unsigned short crdNo, unsigned short twrNo) const
L1RCTLookupTables * lookupTable_
std::string keyName_
std::ofstream lutFile_
list command
Definition: mps_check.py:25
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79

◆ writeRcLutFile()

void L1RCTLutWriter::writeRcLutFile ( unsigned short  card)
private

Definition at line 212 of file L1RCTLutWriter.cc.

References L1RCTParameters::calcCrate(), L1RCTParameters::calcTower(), mps_check::command, data, TauDecayModes::dec, corrVsCorr::filename, keyName_, L1RCTLookupTables::lookup(), lookupTable_, lutFile_, convertSQLitetoXML_cfg::output, rctParameters_, l1tHGCalTowerProducer_cfi::tower, and pileupReCalc_HLTpaths::trunc.

Referenced by analyze().

212  {
213  // don't mess yet with name
214  char filename[256];
215  char command[264];
216  if (card != 6) {
217  int card2 = card + 1;
218  sprintf(filename, "RC%i%i-%s.dat", card, card2, keyName_.c_str());
219  // sprintf(filename, "RC%i%i.dat", card, card2);
220  } else {
221  sprintf(filename, "RC6-%s.dat", keyName_.c_str());
222  // sprintf(filename, "RC6.dat");
223  }
224  // open file for writing, delete any existing content
226  lutFile_ << "Emulator-parameter generated lut file, card " << card << " key " << keyName_ << " ";
227 
228  // close to append timestamp info
229  lutFile_.close();
230  sprintf(command, "date >> %s", filename);
231  system(command);
232 
233  // reopen file for writing values
234  lutFile_.open(filename, std::ios::app);
235 
236  unsigned long data = 0;
237 
238  // write all memory addresses in increasing order
239  // address = (1<<22)+(nLUT<<19)+(eG?<18)+(hcalEt<<10)+(ecalfg<<9)+(ecalEt<<1)
240 
241  // loop through the physical LUTs on the card, 0-7
242  for (unsigned short nLUT = 0; nLUT < 8; nLUT++) {
243  // determine ieta, iphi, etc. everything
244  unsigned short iAbsEta = 0;
245  if (card != 6) {
246  iAbsEta = (card / 2) * 8 + nLUT + 1;
247  } else {
248  if (nLUT < 4) {
249  iAbsEta = (card / 2) * 8 + nLUT + 1;
250  } else {
251  iAbsEta = (card / 2) * 8 + (3 - (nLUT % 4)) + 1;
252  }
253  // std::cout << "LUT is " << nLUT << " iAbsEta is " << iAbsEta <<
254  // std::endl;
255  }
256 
257  // All RCT stuff uniform in phi, symmetric wrt eta = 0
258 
259  // below line always gives crate in +eta; makes no difference to us
260  unsigned short crate = rctParameters_->calcCrate(1, iAbsEta);
261  unsigned short tower = rctParameters_->calcTower(1, iAbsEta);
262 
263  // first do region sums half of LUTs, bit 18 of address is 0
264  // loop through 8 bits of hcal energy, 2^8 is 256
265  for (unsigned int hcalEt = 0; hcalEt < 256; hcalEt++) {
266  // loop through 1 bit of ecal fine grain
267  for (unsigned short ecalfg = 0; ecalfg < 2; ecalfg++) {
268  // loop through 8 bits of ecal energy
269  for (unsigned int ecalEt = 0; ecalEt < 256; ecalEt++) {
270  // assign 10-bit (9et,1mip) sums data here!
271  unsigned long output = lookupTable_->lookup(ecalEt, hcalEt, ecalfg, crate, card, tower);
272  unsigned short etIn9Bits = (output >> 8) & 511;
273  unsigned short tauActivityBit = (output >> 17) & 1;
274  data = (tauActivityBit << 9) + etIn9Bits;
275  lutFile_ << std::hex << data << std::dec << std::endl;
276  }
277  }
278  }
279  // second do egamma half of LUTs, bit 18 of address is 1
280  // loop through 8 bits of hcal energy
281  for (unsigned int hcalEt = 0; hcalEt < 256; hcalEt++) {
282  // loop through 1 bit of ecal fine grain
283  for (unsigned short ecalfg = 0; ecalfg < 2; ecalfg++) {
284  // loop through 8 bits of ecal energy
285  for (unsigned int ecalEt = 0; ecalEt < 256; ecalEt++) {
286  // assign 8-bit (7et,1veto) egamma data here!
287  unsigned long output = lookupTable_->lookup(ecalEt, hcalEt, ecalfg, crate, card, tower);
288  unsigned short etIn7Bits = output & 127;
289  unsigned short heFgVetoBit = (output >> 7) & 1;
290  data = (heFgVetoBit << 7) + etIn7Bits;
291  lutFile_ << std::hex << data << std::dec << std::endl;
292  }
293  }
294  }
295  }
296 
297  lutFile_.close();
298  return;
299 }
unsigned int lookup(unsigned short ecalInput, unsigned short hcalInput, unsigned short fgbit, unsigned short crtNo, unsigned short crdNo, unsigned short twrNo) const
const L1RCTParameters * rctParameters_
unsigned short calcTower(unsigned short rct_iphi, unsigned short absIeta) const
unsigned short calcCrate(unsigned short rct_iphi, short ieta) const
L1RCTLookupTables * lookupTable_
std::string keyName_
std::ofstream lutFile_
list command
Definition: mps_check.py:25
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79

◆ writeThresholdsFile()

void L1RCTLutWriter::writeThresholdsFile ( unsigned int  eicThreshold,
unsigned int  jscThresholdBarrel,
unsigned int  jscThresholdEndcap 
)
private

Definition at line 402 of file L1RCTLutWriter.cc.

References corrVsCorr::filename, keyName_, and pileupReCalc_HLTpaths::trunc.

Referenced by analyze().

404  {
405  //
406  std::ofstream thresholdsFile;
407  char filename[256];
408  sprintf(filename, "Thresholds-%s.dat", keyName_.c_str());
409  thresholdsFile.open(filename, std::ios::trunc);
410 
411  thresholdsFile << "key is " << keyName_ << std::endl << std::endl;
412  thresholdsFile << "eicIsolationThreshold " << eicThreshold << std::endl;
413  thresholdsFile << "jscQuietThresholdBarrel " << jscThresholdBarrel << std::endl;
414  thresholdsFile << "jscQuietThresholdEndcap " << jscThresholdEndcap << std::endl;
415 
416  thresholdsFile.close();
417 }
std::string keyName_

Member Data Documentation

◆ ecalScaleToken_

edm::ESGetToken<L1CaloEcalScale, L1CaloEcalScaleRcd> L1RCTLutWriter::ecalScaleToken_
private

Definition at line 83 of file L1RCTLutWriter.h.

Referenced by analyze().

◆ emScaleToken_

edm::ESGetToken<L1CaloEtScale, L1EmEtScaleRcd> L1RCTLutWriter::emScaleToken_
private

Definition at line 80 of file L1RCTLutWriter.h.

Referenced by analyze().

◆ hcalScaleToken_

edm::ESGetToken<L1CaloHcalScale, L1CaloHcalScaleRcd> L1RCTLutWriter::hcalScaleToken_
private

Definition at line 82 of file L1RCTLutWriter.h.

Referenced by analyze().

◆ keyName_

std::string L1RCTLutWriter::keyName_
private

◆ lookupTable_

L1RCTLookupTables* L1RCTLutWriter::lookupTable_
private

◆ lutFile_

std::ofstream L1RCTLutWriter::lutFile_
private

Definition at line 77 of file L1RCTLutWriter.h.

Referenced by writeEicLutFile(), writeJscLutFile(), and writeRcLutFile().

◆ rctParameters_

const L1RCTParameters* L1RCTLutWriter::rctParameters_
private

Definition at line 75 of file L1RCTLutWriter.h.

Referenced by analyze(), and writeRcLutFile().

◆ rctParametersToken_

edm::ESGetToken<L1RCTParameters, L1RCTParametersRcd> L1RCTLutWriter::rctParametersToken_
private

Definition at line 79 of file L1RCTLutWriter.h.

Referenced by analyze().

◆ tokens_

EcalTPGScale::Tokens L1RCTLutWriter::tokens_
private

Definition at line 85 of file L1RCTLutWriter.h.

Referenced by analyze().

◆ transcoderToken_

edm::ESGetToken<CaloTPGTranscoder, CaloTPGRecord> L1RCTLutWriter::transcoderToken_
private

Definition at line 81 of file L1RCTLutWriter.h.

Referenced by analyze().

◆ useDebugTpgScales_

bool L1RCTLutWriter::useDebugTpgScales_
private

Definition at line 84 of file L1RCTLutWriter.h.

Referenced by analyze().