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 #include "boost/shared_ptr.hpp"
24 
25 // user include files
26 
29 
36 
37 //
38 // class decleration
39 //
40 
42  public:
45 
46  typedef boost::shared_ptr<HcalTPGCoder> ReturnType;
47  void dbRecordCallback(const HcalDbRecord&);
48 
50  private:
51  void buildCoder(const HcalTopology*);
52  // ----------member data ---------------------------
56  int maskBit_;
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  } else {
84  ifilename_=iConfig.getParameter<edm::FileInPath>("inputLUTs");
85  setWhatProduced(this);
86  }
87 
88  theCoder_=0;
89 }
90 
91 
93  using namespace edm::es;
95  if (read_Ascii_ || read_XML_){
96  edm::LogInfo("HCAL") << "Using ASCII/XML LUTs" << ifilename_.fullPath() << " for HcalTPGCoderULUT initialization";
97  if (read_Ascii_) {
98  theCoder_->update(ifilename_.fullPath().c_str(),*topo);
99  } else if (read_XML_) theCoder_->updateXML(ifilename_.fullPath().c_str(),*topo);
100 
101  // Read FG LUT and append to most significant bit 11
102  if (read_FGLut_) {
103  theCoder_->update(fgfile_.fullPath().c_str(), *topo,true);
104  }
105  } else {
108  }
110 }
111 
112 
114 {
115 
116  // do anything here that needs to be done at desctruction time
117  // (e.g. close files, deallocate resources etc.)
118 }
119 
120 
121 //
122 // member functions
123 //
124 
125 // ------------ method called to produce the data ------------
128 {
129  if (theCoder_==0) {
131  iRecord.getRecord<IdealGeometryRecord>().get(htopo);
132  const HcalTopology* topo=&(*htopo);
133  buildCoder(topo);
134  }
135 
136 
137  return coder_;
138 }
139 
141  edm::ESHandle<HcalDbService> conditions;
142  theRec.get(conditions);
143  const HcalTopology* topo=conditions->getTopologyUsed();
144 
145  if (theCoder_==0) {
146  buildCoder(topo);
147  }
148 
149  theCoder_->update(*conditions);
150 
151  // Temporary update for FG Lut
152  // Will be moved to DB
153  if (read_FGLut_) theCoder_->update(fgfile_.fullPath().c_str(),*topo,true);
154 }
155 
156 //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_
HcalTPGCoderULUT(const edm::ParameterSet &)
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
void update(const HcalDbService &conditions)
void setLUTGenerationMode(bool gen)
boost::shared_ptr< HcalTPGCoder > ReturnType
void get(HolderT &iHolder) const
void updateXML(const char *filename, const HcalTopology &)
void setMaskBit(int bit)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
edm::FileInPath fgfile_
ReturnType produce(const HcalTPGRecord &)
std::string fullPath() const
Definition: FileInPath.cc:171
void buildCoder(const HcalTopology *)