CMS 3D CMS Logo

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

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

Inheritance diagram for L1CaloInputScalesGenerator:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 L1CaloInputScalesGenerator (const edm::ParameterSet &)
 
 ~L1CaloInputScalesGenerator () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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
 
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::vector< ModuleDescription const * > &modules, 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
 
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
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<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)
 

Detailed Description

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

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

Definition at line 27 of file L1CaloInputScalesGenerator.h.

Constructor & Destructor Documentation

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

Definition at line 38 of file L1CaloInputScalesGenerator.cc.

40 {
41  //now do what ever initialization is needed
42 }
L1CaloInputScalesGenerator::~L1CaloInputScalesGenerator ( )
override

Definition at line 44 of file L1CaloInputScalesGenerator.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

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

Definition at line 54 of file L1CaloInputScalesGenerator.cc.

References EcalBarrel, EcalEndcap, edm::EventSetup::get(), EcalTPGScale::getTPGInGeV(), CaloTPGTranscoder::hcaletValue(), input, convertSQLitetoXML_cfg::output, and EcalTPGScale::setEventSetup().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 179 of file L1CaloInputScalesGenerator.cc.

179 {}
void L1CaloInputScalesGenerator::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 182 of file L1CaloInputScalesGenerator.cc.

182 {}