CMS 3D CMS Logo

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

#include <L1TriggerConfig/L1ScalesProducers/src/L1CaloInputScalesGenerator.cc>

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

Public Member Functions

 L1CaloInputScalesGenerator (const edm::ParameterSet &)
 
 ~L1CaloInputScalesGenerator () 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 beginJob () override
 
void endJob () override
 

Private Attributes

EcalTPGScale::Tokens tokens_
 
edm::ESGetToken< CaloTPGTranscoder, CaloTPGRecordtranscoderToken_
 

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

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

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

Definition at line 31 of file L1CaloInputScalesGenerator.h.

Constructor & Destructor Documentation

◆ L1CaloInputScalesGenerator()

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

Definition at line 38 of file L1CaloInputScalesGenerator.cc.

39  : transcoderToken_(esConsumes<CaloTPGTranscoder, CaloTPGRecord>()), tokens_(consumesCollector()) {
40  //now do what ever initialization is needed
41 }
edm::ESGetToken< CaloTPGTranscoder, CaloTPGRecord > transcoderToken_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.

◆ ~L1CaloInputScalesGenerator()

L1CaloInputScalesGenerator::~L1CaloInputScalesGenerator ( )
override

Definition at line 43 of file L1CaloInputScalesGenerator.cc.

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

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 53 of file L1CaloInputScalesGenerator.cc.

References EcalBarrel, EcalEndcap, edm::EventSetup::getHandle(), EcalTPGScale::getTPGInGeV(), CaloTPGTranscoder::hcaletValue(), input, convertSQLitetoXML_cfg::output, tokens_, and transcoderToken_.

53  {
54  using namespace edm;
55 
56  ESHandle<CaloTPGTranscoder> caloTPGTranscoder = iSetup.getHandle(transcoderToken_);
57 
58  EcalTPGScale ecalTPGScale(tokens_, iSetup);
59 
60  double output;
61  ofstream scalesFile("L1CaloInputScales_cfi.py");
62 
63  // Write the ecal scales, positive eta
64 
65  scalesFile << "import FWCore.ParameterSet.Config as cms\n" << endl;
66 
67  scalesFile << "L1CaloInputScalesProducer =cms.ESProducer(\"L1CaloInputScalesProducer\"," << endl;
68  scalesFile << "L1EcalEtThresholdsPositiveEta = cms.vdouble(" << endl;
69 
70  //Python does not support arrays over 255 entries so we neeed ton accomodate it by creating new array after 255 entries
71  int nEntries = 0;
72 
73  // loop over ietas, barrel
74  for (unsigned short absIeta = 1; absIeta <= 28; absIeta++) {
75  EcalSubdetector subdet = (absIeta <= 17) ? EcalBarrel : EcalEndcap;
76  // 8 bits of input energy
77  for (unsigned short input = 0; input <= 0xFF; input++) {
78  output = ecalTPGScale.getTPGInGeV((unsigned int)input, EcalTrigTowerDetId(1, subdet, absIeta, 1));
79  scalesFile << setprecision(8) << output;
80  nEntries++;
81 
82  if (absIeta == 28 && input == 0xFF) {
83  scalesFile << "),";
84  } else if (nEntries > 254) {
85  scalesFile << ")+cms.vdouble(";
86  nEntries = 0;
87  } else {
88  scalesFile << ", ";
89  }
90  }
91  scalesFile << endl;
92  }
93 
94  // Write the ecal scales, negative eta
95 
96  scalesFile << endl << "\tL1EcalEtThresholdsNegativeEta = cms.vdouble(" << endl;
97 
98  nEntries = 0;
99  // loop over ietas, barrel first
100  for (unsigned short absIeta = 1; absIeta <= 28; absIeta++) {
101  EcalSubdetector subdet = (absIeta <= 17) ? EcalBarrel : EcalEndcap;
102  // 8 bits of input energy
103  for (unsigned short input = 0; input <= 0xFF; input++) {
104  // negative eta
105  output = ecalTPGScale.getTPGInGeV((unsigned int)input, EcalTrigTowerDetId(-1, subdet, absIeta, 2));
106  scalesFile << setprecision(8) << output;
107  nEntries++;
108 
109  if (absIeta == 28 && input == 0xFF) {
110  scalesFile << "),";
111  } else if (nEntries > 254) {
112  scalesFile << ")+cms.vdouble(";
113  nEntries = 0;
114  } else {
115  scalesFile << ", ";
116  }
117  }
118  scalesFile << endl;
119  }
120 
121  // Write the hcal scales (Positive Eta)
122 
123  scalesFile << endl << "\tL1HcalEtThresholdsPositiveEta = cms.vdouble(" << endl;
124 
125  // loop over ietas
126 
127  nEntries = 0;
128  for (unsigned short absIeta = 1; absIeta <= 32; absIeta++) {
129  for (unsigned short input = 0; input <= 0xFF; input++) {
130  output = caloTPGTranscoder->hcaletValue(absIeta, input);
131  scalesFile << setprecision(8) << output;
132  nEntries++;
133 
134  if (absIeta == 32 && input == 0xFF) {
135  scalesFile << "),";
136  } else if (nEntries > 254) {
137  scalesFile << ")+cms.vdouble(";
138  nEntries = 0;
139  } else {
140  scalesFile << ", ";
141  }
142  }
143  scalesFile << endl;
144  }
145 
146  // Write the hcal scales (Negative Eta)
147 
148  scalesFile << endl << "\tL1HcalEtThresholdsNegativeEta = cms.vdouble(" << endl;
149 
150  nEntries = 0;
151  // loop over ietas
152  for (unsigned short absIeta = 1; absIeta <= 32; absIeta++) {
153  for (unsigned short input = 0; input <= 0xFF; input++) {
154  output = caloTPGTranscoder->hcaletValue(-absIeta, input);
155  scalesFile << setprecision(8) << output;
156  nEntries++;
157 
158  if (absIeta == 32 && input == 0xFF) {
159  scalesFile << ")";
160  } else if (nEntries > 254) {
161  scalesFile << ")+cms.vdouble(";
162  nEntries = 0;
163  } else {
164  scalesFile << ", ";
165  }
166  }
167  scalesFile << endl;
168  }
169 
170  scalesFile << ")" << endl;
171 
172  scalesFile.close();
173 }
edm::ESGetToken< CaloTPGTranscoder, CaloTPGRecord > transcoderToken_
static std::string const input
Definition: EdmProvDump.cc:50
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
HLT enums.
virtual double hcaletValue(const int &ieta, const int &iphi, const int &version, const int &compressedValue) const =0
EcalSubdetector

◆ beginJob()

void L1CaloInputScalesGenerator::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 176 of file L1CaloInputScalesGenerator.cc.

176 {}

◆ endJob()

void L1CaloInputScalesGenerator::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 179 of file L1CaloInputScalesGenerator.cc.

179 {}

Member Data Documentation

◆ tokens_

EcalTPGScale::Tokens L1CaloInputScalesGenerator::tokens_
private

Definition at line 43 of file L1CaloInputScalesGenerator.h.

Referenced by analyze().

◆ transcoderToken_

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

Definition at line 42 of file L1CaloInputScalesGenerator.h.

Referenced by analyze().