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 
29 
35 
36 //
37 // class decleration
38 //
39 
41 public:
43  ~HcalTPGCoderULUT() override;
44 
45  typedef std::shared_ptr<HcalTPGCoder> ReturnType;
46 
48 
49 private:
51 
53 
54  // ----------member data ---------------------------
65  int maskBit_;
66  std::vector<uint32_t> FG_HF_thresholds_;
68 };
69 
70 //
71 // constants, enums and typedefs
72 //
73 
74 //
75 // static data member definitions
76 //
77 
78 //
79 // constructors and destructor
80 //
82  read_Ascii_ = iConfig.getParameter<bool>("read_Ascii_LUTs");
83  read_XML_ = iConfig.getParameter<bool>("read_XML_LUTs");
84  read_FGLut_ = iConfig.getParameter<bool>("read_FG_LUTs");
85  fgfile_ = iConfig.getParameter<edm::FileInPath>("FGLUTs");
86  contain1TSHB_ = iConfig.getParameter<bool>("contain1TSHB");
87  contain1TSHE_ = iConfig.getParameter<bool>("contain1TSHE");
88  containPhaseNSHB_ = iConfig.getParameter<double>("containPhaseNSHB");
89  containPhaseNSHE_ = iConfig.getParameter<double>("containPhaseNSHE");
90  overrideDBweightsAndFilterHB_ = iConfig.getParameter<bool>("overrideDBweightsAndFilterHB");
91  overrideDBweightsAndFilterHE_ = iConfig.getParameter<bool>("overrideDBweightsAndFilterHE");
92  applyFixPCC_ = iConfig.getParameter<bool>("applyFixPCC");
93 
94  //the following line is needed to tell the framework what
95  // data is being produced
96  auto cc = setWhatProduced(this);
97  topoToken_ = cc.consumes();
98  delayToken_ = cc.consumes(edm::ESInputTag{"", "HBHE"});
99 
100  if (!(read_Ascii_ || read_XML_)) {
101  LUTGenerationMode_ = iConfig.getParameter<bool>("LUTGenerationMode");
102  linearLUTs_ = iConfig.getParameter<bool>("linearLUTs");
103  auto scales = iConfig.getParameter<edm::ParameterSet>("tpScales").getParameter<edm::ParameterSet>("HBHE");
104  linearLSB_QIE8_ = scales.getParameter<double>("LSBQIE8");
105  linearLSB_QIE11_ = scales.getParameter<double>("LSBQIE11");
106  linearLSB_QIE11Overlap_ = scales.getParameter<double>("LSBQIE11Overlap");
107  maskBit_ = iConfig.getParameter<int>("MaskBit");
108  FG_HF_thresholds_ = iConfig.getParameter<std::vector<uint32_t> >("FG_HF_thresholds");
109  serviceToken_ = cc.consumes();
110  } else {
111  ifilename_ = iConfig.getParameter<edm::FileInPath>("inputLUTs");
112  }
113 }
114 
116  using namespace edm::es;
117  theCoder->init(topo, delay);
118 
121 
122  theCoder->set1TSContainHB(contain1TSHB_);
123  theCoder->set1TSContainHE(contain1TSHE_);
124 
127 
128  theCoder->setApplyFixPCC(applyFixPCC_);
129 
130  if (read_Ascii_ || read_XML_) {
131  edm::LogInfo("HCAL") << "Using ASCII/XML LUTs" << ifilename_.fullPath() << " for HcalTPGCoderULUT initialization";
132  if (read_Ascii_) {
133  theCoder->update(ifilename_.fullPath().c_str());
134  } else if (read_XML_) {
135  theCoder->updateXML(ifilename_.fullPath().c_str());
136  }
137  // Read FG LUT and append to most significant bit 11
138  if (read_FGLut_) {
139  theCoder->update(fgfile_.fullPath().c_str(), true);
140  }
141  } else {
144  theCoder->setMaskBit(maskBit_);
146  }
147 }
148 
150  // do anything here that needs to be done at desctruction time
151  // (e.g. close files, deallocate resources etc.)
152 }
153 
154 //
155 // member functions
156 //
157 
158 // ------------ method called to produce the data ------------
160  auto host = holder_.makeOrGet([]() { return new HostType; });
161 
162  const auto& topo = iRecord.get(topoToken_);
163  const auto& delay = iRecord.getRecord<HcalDbRecord>().get(delayToken_);
164  if (read_Ascii_ || read_XML_) {
165  buildCoder(&topo, &delay, host.get());
166  } else {
167  host->ifRecordChanges<HcalDbRecord>(iRecord, [this, &topo, &delay, h = host.get()](auto const& rec) {
168  buildCoder(&topo, &delay, h);
169  h->update(rec.get(serviceToken_));
170  // Temporary update for FG Lut
171  // Will be moved to DB
172  if (read_FGLut_)
173  h->update(fgfile_.fullPath().c_str(), true);
174  });
175  }
176  return host;
177 }
178 
179 //define this as a plug-in
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
string host
Definition: query.py:115
std::string fullPath() const
Definition: FileInPath.cc:161
edm::ESGetToken< HcalTimeSlew, HcalTimeSlewRecord > delayToken_
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::FileInPath ifilename_
std::shared_ptr< HcalTPGCoder > ReturnType
HcalTPGCoderULUT(const edm::ParameterSet &)
void setOverrideDBweightsAndFilterHE(bool overrideDBweightsAndFilterHE)
void init(const HcalTopology *top, const HcalTimeSlew *delay)
void update(const HcalDbService &conditions)
bool overrideDBweightsAndFilterHE_
void updateXML(const char *filename)
void setLUTGenerationMode(bool gen)
void setApplyFixPCC(double applyFixPCC)
~HcalTPGCoderULUT() override
edm::ReusableObjectHolder< HostType > holder_
void setContainPhaseHE(double containPhaseNSHE)
bool overrideDBweightsAndFilterHB_
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:61
std::shared_ptr< T > makeOrGet(FM &&iMakeFunc)
Takes an object from the queue if one is available, or creates one using iMakeFunc.
edm::ESProductHost< HcaluLUTTPGCoder, HcalDbRecord > HostType
Log< level::Info, false > LogInfo
std::vector< uint32_t > FG_HF_thresholds_
void setMaskBit(int bit)
void setContainPhaseHB(double containPhaseNSHB)
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > topoToken_
void setAllLinear(bool linear, double lsb8, double lsb11, double lsb11overlap)
edm::FileInPath fgfile_
ReturnType produce(const HcalTPGRecord &)
void set1TSContainHB(bool contain1TSHB)
void setFGHFthresholds(const std::vector< uint32_t > &fgthresholds)
void set1TSContainHE(bool contain1TSHE)
void buildCoder(const HcalTopology *, const HcalTimeSlew *, HcaluLUTTPGCoder *)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
void setOverrideDBweightsAndFilterHB(bool overrideDBweightsAndFilterHB)
edm::ESGetToken< HcalDbService, HcalDbRecord > serviceToken_
double linearLSB_QIE11Overlap_