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