CMS 3D CMS Logo

HcalTPGCoderULUT.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HcalTPGCoderULUT
4 // Class: HcalTPGCoderULUT
5 //
13 //
14 // Original Author: Jeremiah Mans
15 // Created: Fri Sep 15 11:49:44 CDT 2006
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 #include <string>
23 
24 // user include files
25 
31 
37 
38 //
39 // class decleration
40 //
41 
43 public:
45  ~HcalTPGCoderULUT() override;
46 
47  typedef std::shared_ptr<HcalTPGCoder> ReturnType;
48 
49  ReturnType produce(const HcalTPGRecord&);
50 
51 private:
52 
55 
56  void setupDBRecord(const HcalDbRecord&, HcaluLUTTPGCoder*);
57  void buildCoder(const HcalTopology*, const edm::ESHandle<HcalTimeSlew>&, HcaluLUTTPGCoder*);
58 
59  // ----------member data ---------------------------
63  int maskBit_;
64  std::vector<uint32_t> FG_HF_thresholds_;
66 };
67 
68 //
69 // constants, enums and typedefs
70 //
71 
72 //
73 // static data member definitions
74 //
75 
76 //
77 // constructors and destructor
78 //
80 {
81  read_Ascii_ = iConfig.getParameter<bool>("read_Ascii_LUTs");
82  read_XML_ = iConfig.getParameter<bool>("read_XML_LUTs");
83  read_FGLut_ = iConfig.getParameter<bool>("read_FG_LUTs");
84  fgfile_ = iConfig.getParameter<edm::FileInPath>("FGLUTs");
85  //the following line is needed to tell the framework what
86  // data is being produced
87  if (!(read_Ascii_ || read_XML_)) {
88  LUTGenerationMode_ = iConfig.getParameter<bool>("LUTGenerationMode");
89  linearLUTs_ = iConfig.getParameter<bool>("linearLUTs");
90  auto scales = iConfig.getParameter<edm::ParameterSet>("tpScales").getParameter<edm::ParameterSet>("HBHE");
91  linearLSB_QIE8_ = scales.getParameter<double>("LSBQIE8");
92  linearLSB_QIE11_ = scales.getParameter<double>("LSBQIE11");
93  linearLSB_QIE11Overlap_ = scales.getParameter<double>("LSBQIE11Overlap");
94  maskBit_ = iConfig.getParameter<int>("MaskBit");
95  FG_HF_thresholds_ = iConfig.getParameter<std::vector<uint32_t> >("FG_HF_thresholds");
96  } else {
97  ifilename_=iConfig.getParameter<edm::FileInPath>("inputLUTs");
98  }
99  setWhatProduced(this);
100 }
101 
103  using namespace edm::es;
104  theCoder->init(topo, delay.product());
105  if (read_Ascii_ || read_XML_){
106  edm::LogInfo("HCAL") << "Using ASCII/XML LUTs" << ifilename_.fullPath() << " for HcalTPGCoderULUT initialization";
107  if (read_Ascii_) {
108  theCoder->update(ifilename_.fullPath().c_str());
109  } else if (read_XML_) {
110  theCoder->updateXML(ifilename_.fullPath().c_str());
111  }
112  // Read FG LUT and append to most significant bit 11
113  if (read_FGLut_) {
114  theCoder->update(fgfile_.fullPath().c_str(), true);
115  }
116  } else {
119  theCoder->setMaskBit(maskBit_);
121  }
122 }
123 
125 
126  // do anything here that needs to be done at desctruction time
127  // (e.g. close files, deallocate resources etc.)
128 }
129 
130 
131 //
132 // member functions
133 //
134 
135 // ------------ method called to produce the data ------------
138 {
139  auto host = holder_.makeOrGet([]() {
140  return new HostType;
141  });
142 
143  if (read_Ascii_ || read_XML_) {
145  iRecord.getRecord<HcalRecNumberingRecord>().get(htopo);
146  const HcalTopology* topo=&(*htopo);
147 
149  iRecord.getRecord<HcalDbRecord>().getRecord<HcalTimeSlewRecord>().get("HBHE", delay);
150 
151  buildCoder(topo, delay, host.get());
152  } else {
153  host->ifRecordChanges<HcalDbRecord>(iRecord,
154  [this,h=host.get()](auto const& rec) {
155  setupDBRecord(rec, h);
156  });
157  }
158  return host;
159 }
160 
162  HcaluLUTTPGCoder* theCoder) {
163  edm::ESHandle<HcalDbService> conditions;
164  theRec.get(conditions);
166  theRec.getRecord<HcalRecNumberingRecord>().get(htopo);
167  const HcalTopology* topo=&(*htopo);
168 
170  theRec.getRecord<HcalTimeSlewRecord>().get("HBHE", delay);
171 
172  buildCoder(topo, delay, theCoder);
173 
174  theCoder->update(*conditions);
175 
176  // Temporary update for FG Lut
177  // Will be moved to DB
178  if (read_FGLut_) theCoder->update(fgfile_.fullPath().c_str(),true);
179 }
180 
181 //define this as a plug-in
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
host
Definition: query.py:115
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void buildCoder(const HcalTopology *, const edm::ESHandle< HcalTimeSlew > &, HcaluLUTTPGCoder *)
edm::FileInPath ifilename_
std::shared_ptr< HcalTPGCoder > ReturnType
std::shared_ptr< T > makeOrGet(F iFunc)
If there isn&#39;t an object already available, creates a new one using iFunc.
HcalTPGCoderULUT(const edm::ParameterSet &)
void init(const HcalTopology *top, const HcalTimeSlew *delay)
void update(const HcalDbService &conditions)
void updateXML(const char *filename)
void setLUTGenerationMode(bool gen)
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
void setupDBRecord(const HcalDbRecord &, HcaluLUTTPGCoder *)
~HcalTPGCoderULUT() override
edm::ReusableObjectHolder< HostType > holder_
edm::ESProductHost< HcaluLUTTPGCoder, HcalDbRecord > HostType
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
std::vector< uint32_t > FG_HF_thresholds_
void setMaskBit(int bit)
void setAllLinear(bool linear, double lsb8, double lsb11, double lsb11overlap)
edm::FileInPath fgfile_
std::string fullPath() const
Definition: FileInPath.cc:163
ReturnType produce(const HcalTPGRecord &)
void setFGHFthresholds(const std::vector< uint32_t > &fgthresholds)
T const * product() const
Definition: ESHandle.h:86
double linearLSB_QIE11Overlap_