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_;
55  int maskBit_;
56  unsigned int FG_HF_threshold_;
58 };
59 
60 //
61 // constants, enums and typedefs
62 //
63 
64 //
65 // static data member definitions
66 //
67 
68 //
69 // constructors and destructor
70 //
72 {
73  read_Ascii_ = iConfig.getParameter<bool>("read_Ascii_LUTs");
74  read_XML_ = iConfig.getParameter<bool>("read_XML_LUTs");
75  read_FGLut_ = iConfig.getParameter<bool>("read_FG_LUTs");
76  fgfile_ = iConfig.getParameter<edm::FileInPath>("FGLUTs");
77  //the following line is needed to tell the framework what
78  // data is being produced
79  if (!(read_Ascii_ || read_XML_)) {
81  LUTGenerationMode_ = iConfig.getParameter<bool>("LUTGenerationMode");
82  maskBit_ = iConfig.getParameter<int>("MaskBit");
83  FG_HF_threshold_ = iConfig.getParameter<uint32_t>("FG_HF_threshold");
84  } else {
85  ifilename_=iConfig.getParameter<edm::FileInPath>("inputLUTs");
86  setWhatProduced(this);
87  }
88 
89  theCoder_=nullptr;
90 }
91 
92 
94  using namespace edm::es;
95  theCoder_ = new HcaluLUTTPGCoder(topo);
96  if (read_Ascii_ || read_XML_){
97  edm::LogInfo("HCAL") << "Using ASCII/XML LUTs" << ifilename_.fullPath() << " for HcalTPGCoderULUT initialization";
98  if (read_Ascii_) {
99  theCoder_->update(ifilename_.fullPath().c_str());
100  } else if (read_XML_) {
102  }
103  // Read FG LUT and append to most significant bit 11
104  if (read_FGLut_) {
105  theCoder_->update(fgfile_.fullPath().c_str(), true);
106  }
107  } else {
111  }
113 }
114 
115 
117 
118  // do anything here that needs to be done at desctruction time
119  // (e.g. close files, deallocate resources etc.)
120 }
121 
122 
123 //
124 // member functions
125 //
126 
127 // ------------ method called to produce the data ------------
130 {
131  if (theCoder_==nullptr) {
133  iRecord.getRecord<HcalRecNumberingRecord>().get(htopo);
134  const HcalTopology* topo=&(*htopo);
135  buildCoder(topo);
136  }
137 
138 
139  return coder_;
140 }
141 
143  edm::ESHandle<HcalDbService> conditions;
144  theRec.get(conditions);
146  theRec.getRecord<HcalRecNumberingRecord>().get(htopo);
147  const HcalTopology* topo=&(*htopo);
148 
149  if (theCoder_==nullptr) {
150  buildCoder(topo);
151  }
152 
153  theCoder_->update(*conditions);
154 
155  // Temporary update for FG Lut
156  // Will be moved to DB
157  if (read_FGLut_) theCoder_->update(fgfile_.fullPath().c_str(),true);
158 }
159 
160 //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
edm::FileInPath fgfile_
std::string fullPath() const
Definition: FileInPath.cc:184
ReturnType produce(const HcalTPGRecord &)
void buildCoder(const HcalTopology *)