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 // system include files
20 #include <memory>
21 #include <string>
22 
23 // user include files
24 
30 
36 
37 //
38 // class decleration
39 //
40 
42 public:
44  ~HcalTPGCoderULUT() override;
45 
46  typedef std::shared_ptr<HcalTPGCoder> ReturnType;
47 
48  ReturnType produce(const HcalTPGRecord&);
49 
50 private:
52 
54 
55  // ----------member data ---------------------------
62  int maskBit_;
63  std::vector<uint32_t> FG_HF_thresholds_;
65 };
66 
67 //
68 // constants, enums and typedefs
69 //
70 
71 //
72 // static data member definitions
73 //
74 
75 //
76 // constructors and destructor
77 //
79  read_Ascii_ = iConfig.getParameter<bool>("read_Ascii_LUTs");
80  read_XML_ = iConfig.getParameter<bool>("read_XML_LUTs");
81  read_FGLut_ = iConfig.getParameter<bool>("read_FG_LUTs");
82  fgfile_ = iConfig.getParameter<edm::FileInPath>("FGLUTs");
83 
84  //the following line is needed to tell the framework what
85  // data is being produced
86  auto cc = setWhatProduced(this);
87  cc.setConsumes(topoToken_).setConsumes(delayToken_, edm::ESInputTag{"", "HBHE"});
88 
89  if (!(read_Ascii_ || read_XML_)) {
90  LUTGenerationMode_ = iConfig.getParameter<bool>("LUTGenerationMode");
91  linearLUTs_ = iConfig.getParameter<bool>("linearLUTs");
92  auto scales = iConfig.getParameter<edm::ParameterSet>("tpScales").getParameter<edm::ParameterSet>("HBHE");
93  linearLSB_QIE8_ = scales.getParameter<double>("LSBQIE8");
94  linearLSB_QIE11_ = scales.getParameter<double>("LSBQIE11");
95  linearLSB_QIE11Overlap_ = scales.getParameter<double>("LSBQIE11Overlap");
96  maskBit_ = iConfig.getParameter<int>("MaskBit");
97  FG_HF_thresholds_ = iConfig.getParameter<std::vector<uint32_t> >("FG_HF_thresholds");
98  cc.setConsumes(serviceToken_);
99  } else {
100  ifilename_ = iConfig.getParameter<edm::FileInPath>("inputLUTs");
101  }
102 }
103 
104 void HcalTPGCoderULUT::buildCoder(const HcalTopology* topo, const HcalTimeSlew* delay, HcaluLUTTPGCoder* theCoder) {
105  using namespace edm::es;
106  theCoder->init(topo, delay);
107  if (read_Ascii_ || read_XML_) {
108  edm::LogInfo("HCAL") << "Using ASCII/XML LUTs" << ifilename_.fullPath() << " for HcalTPGCoderULUT initialization";
109  if (read_Ascii_) {
110  theCoder->update(ifilename_.fullPath().c_str());
111  } else if (read_XML_) {
112  theCoder->updateXML(ifilename_.fullPath().c_str());
113  }
114  // Read FG LUT and append to most significant bit 11
115  if (read_FGLut_) {
116  theCoder->update(fgfile_.fullPath().c_str(), true);
117  }
118  } else {
121  theCoder->setMaskBit(maskBit_);
123  }
124 }
125 
127  // do anything here that needs to be done at desctruction time
128  // (e.g. close files, deallocate resources etc.)
129 }
130 
131 //
132 // member functions
133 //
134 
135 // ------------ method called to produce the data ------------
137  auto host = holder_.makeOrGet([]() { return new HostType; });
138 
139  const auto& topo = iRecord.get(topoToken_);
140  const auto& delay = iRecord.getRecord<HcalDbRecord>().get(delayToken_);
141  if (read_Ascii_ || read_XML_) {
142  buildCoder(&topo, &delay, host.get());
143  } else {
144  host->ifRecordChanges<HcalDbRecord>(iRecord, [this, &topo, &delay, h = host.get()](auto const& rec) {
145  buildCoder(&topo, &delay, h);
146  h->update(rec.get(serviceToken_));
147  // Temporary update for FG Lut
148  // Will be moved to DB
149  if (read_FGLut_)
150  h->update(fgfile_.fullPath().c_str(), true);
151  });
152  }
153  return host;
154 }
155 
156 //define this as a plug-in
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
host
Definition: query.py:115
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
edm::ESGetToken< HcalTimeSlew, HcalTimeSlewRecord > delayToken_
edm::FileInPath ifilename_
std::shared_ptr< HcalTPGCoder > ReturnType
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
~HcalTPGCoderULUT() override
edm::ReusableObjectHolder< HostType > holder_
std::shared_ptr< T > makeOrGet(F iFunc)
If there isn&#39;t an object already available, creates a new one using iFunc.
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)
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > topoToken_
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)
void buildCoder(const HcalTopology *, const HcalTimeSlew *, HcaluLUTTPGCoder *)
edm::ESGetToken< HcalDbService, HcalDbRecord > serviceToken_
double linearLSB_QIE11Overlap_