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 
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:
50  void buildCoder(const HcalTopology*);
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  using namespace edm::es;
101  theCoder_ = new HcaluLUTTPGCoder(topo);
102  if (read_Ascii_ || read_XML_){
103  edm::LogInfo("HCAL") << "Using ASCII/XML LUTs" << ifilename_.fullPath() << " for HcalTPGCoderULUT initialization";
104  if (read_Ascii_) {
105  theCoder_->update(ifilename_.fullPath().c_str());
106  } else if (read_XML_) {
108  }
109  // Read FG LUT and append to most significant bit 11
110  if (read_FGLut_) {
111  theCoder_->update(fgfile_.fullPath().c_str(), true);
112  }
113  } else {
118  }
120 }
121 
122 
124 
125  // do anything here that needs to be done at desctruction time
126  // (e.g. close files, deallocate resources etc.)
127 }
128 
129 
130 //
131 // member functions
132 //
133 
134 // ------------ method called to produce the data ------------
137 {
138  if (theCoder_==nullptr || (read_Ascii_ || read_XML_)) {// !(read_Ascii_ || read_XML_) goes via dbRecordCallback
140  iRecord.getRecord<HcalRecNumberingRecord>().get(htopo);
141  const HcalTopology* topo=&(*htopo);
142  buildCoder(topo);
143  }
144 
145 
146  return coder_;
147 }
148 
150  edm::ESHandle<HcalDbService> conditions;
151  theRec.get(conditions);
153  theRec.getRecord<HcalRecNumberingRecord>().get(htopo);
154  const HcalTopology* topo=&(*htopo);
155 
156  buildCoder(topo);
157 
158  theCoder_->update(*conditions);
159 
160  // Temporary update for FG Lut
161  // Will be moved to DB
162  if (read_FGLut_) theCoder_->update(fgfile_.fullPath().c_str(),true);
163 }
164 
165 //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 &)
void buildCoder(const HcalTopology *)
double linearLSB_QIE11Overlap_