CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
28 
35 
36 //
37 // class decleration
38 //
39 
41 public:
43  ~HcalTPGCoderULUT() override;
44 
45  typedef std::shared_ptr<HcalTPGCoder> ReturnType;
46  void dbRecordCallback(const HcalDbRecord&);
47 
48  ReturnType produce(const HcalTPGRecord&);
49 private:
51  // ----------member data ---------------------------
52  ReturnType coder_;
56  int maskBit_;
57  unsigned int FG_HF_threshold_;
59 };
60 
61 //
62 // constants, enums and typedefs
63 //
64 
65 //
66 // static data member definitions
67 //
68 
69 //
70 // constructors and destructor
71 //
73 {
74  read_Ascii_ = iConfig.getParameter<bool>("read_Ascii_LUTs");
75  read_XML_ = iConfig.getParameter<bool>("read_XML_LUTs");
76  read_FGLut_ = iConfig.getParameter<bool>("read_FG_LUTs");
77  fgfile_ = iConfig.getParameter<edm::FileInPath>("FGLUTs");
78  //the following line is needed to tell the framework what
79  // data is being produced
80  if (!(read_Ascii_ || read_XML_)) {
82  LUTGenerationMode_ = iConfig.getParameter<bool>("LUTGenerationMode");
83  linearLUTs_ = iConfig.getParameter<bool>("linearLUTs");
84  auto scales = iConfig.getParameter<edm::ParameterSet>("tpScales").getParameter<edm::ParameterSet>("HBHE");
85  linearLSB_QIE8_ = scales.getParameter<double>("LSBQIE8");
86  linearLSB_QIE11_ = scales.getParameter<double>("LSBQIE11");
87  linearLSB_QIE11Overlap_ = scales.getParameter<double>("LSBQIE11Overlap");
88  maskBit_ = iConfig.getParameter<int>("MaskBit");
89  FG_HF_threshold_ = iConfig.getParameter<uint32_t>("FG_HF_threshold");
90  } else {
91  ifilename_=iConfig.getParameter<edm::FileInPath>("inputLUTs");
92  setWhatProduced(this);
93  }
94 
95  theCoder_=nullptr;
96 }
97 
98 
100  const edm::ESHandle<HcalMCParams>& mcParams, const edm::ESHandle<HcalRecoParams>& recoParams) {
101  using namespace edm::es;
102  theCoder_ = new HcaluLUTTPGCoder(topo, delay, mcParams, recoParams);
103  if (read_Ascii_ || read_XML_){
104  edm::LogInfo("HCAL") << "Using ASCII/XML LUTs" << ifilename_.fullPath() << " for HcalTPGCoderULUT initialization";
105  if (read_Ascii_) {
106  theCoder_->update(ifilename_.fullPath().c_str());
107  } else if (read_XML_) {
109  }
110  // Read FG LUT and append to most significant bit 11
111  if (read_FGLut_) {
112  theCoder_->update(fgfile_.fullPath().c_str(), true);
113  }
114  } else {
119  }
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  if (theCoder_==nullptr || (read_Ascii_ || read_XML_)) {// !(read_Ascii_ || read_XML_) goes via dbRecordCallback
141  iRecord.getRecord<HcalRecNumberingRecord>().get(htopo);
142  const HcalTopology* topo=&(*htopo);
143 
145  iRecord.getRecord<HcalDbRecord>().getRecord<HcalTimeSlewRecord>().get("HBHE", delay);
146 
148  iRecord.getRecord<HcalDbRecord>().getRecord<HcalMCParamsRcd>().get(mcParams);
149 
151  iRecord.getRecord<HcalDbRecord>().getRecord<HcalRecoParamsRcd>().get(recoParams);
152 
153  buildCoder(topo, delay, mcParams, recoParams);
154  }
155 
156 
157  return coder_;
158 }
159 
161  edm::ESHandle<HcalDbService> conditions;
162  theRec.get(conditions);
164  theRec.getRecord<HcalRecNumberingRecord>().get(htopo);
165  const HcalTopology* topo=&(*htopo);
166 
168  theRec.getRecord<HcalTimeSlewRecord>().get("HBHE", delay);
170  theRec.getRecord<HcalMCParamsRcd>().get(mcParams);
172  theRec.getRecord<HcalRecoParamsRcd>().get(recoParams);
173 
174  buildCoder(topo, delay, mcParams, recoParams);
175 
176  theCoder_->update(*conditions);
177 
178  // Temporary update for FG Lut
179  // Will be moved to DB
180  if (read_FGLut_) theCoder_->update(fgfile_.fullPath().c_str(),true);
181 }
182 
183 //define this as a plug-in
T getParameter(std::string const &) const
depends_on::OneHolder< T, TDependsOnRecord > dependsOn(void(T::*iT)(const TDependsOnRecord &))
void dbRecordCallback(const HcalDbRecord &)
unsigned int FG_HF_threshold_
edm::FileInPath ifilename_
HcaluLUTTPGCoder * theCoder_
std::shared_ptr< HcalTPGCoder > ReturnType
HcalTPGCoderULUT(const edm::ParameterSet &)
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
void update(const HcalDbService &conditions)
void updateXML(const char *filename)
void setLUTGenerationMode(bool gen)
~HcalTPGCoderULUT() override
void get(HolderT &iHolder) const
void setFGHFthreshold(unsigned int fgthreshold)
void setMaskBit(int bit)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
void setAllLinear(bool linear, double lsb8, double lsb11, double lsb11overlap)
edm::FileInPath fgfile_
std::string fullPath() const
Definition: FileInPath.cc:197
ReturnType produce(const HcalTPGRecord &)
double linearLSB_QIE11Overlap_
void buildCoder(const HcalTopology *, const edm::ESHandle< HcalTimeSlew > &, const edm::ESHandle< HcalMCParams > &, const edm::ESHandle< HcalRecoParams > &)