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 // $Id: HcalTPGCoderULUT.cc,v 1.12 2012/11/12 20:44:36 dlange Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 #include <string>
24 #include "boost/shared_ptr.hpp"
25 
26 // user include files
27 
30 
37 
38 //
39 // class decleration
40 //
41 
43  public:
46 
47  typedef boost::shared_ptr<HcalTPGCoder> ReturnType;
48  void dbRecordCallback(const HcalDbRecord&);
49 
51  private:
52  void buildCoder(const HcalTopology*);
53  // ----------member data ---------------------------
57  int maskBit_;
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  maskBit_ = iConfig.getParameter<int>("MaskBit");
84  } else {
85  ifilename_=iConfig.getParameter<edm::FileInPath>("inputLUTs");
86  setWhatProduced(this);
87  }
88 
89  theCoder_=0;
90 }
91 
92 
94  using namespace edm::es;
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(),*topo);
100  } else if (read_XML_) theCoder_->updateXML(ifilename_.fullPath().c_str(),*topo);
101 
102  // Read FG LUT and append to most significant bit 11
103  if (read_FGLut_) {
104  theCoder_->update(fgfile_.fullPath().c_str(), *topo,true);
105  }
106  } else {
109  }
111 }
112 
113 
115 {
116 
117  // do anything here that needs to be done at desctruction time
118  // (e.g. close files, deallocate resources etc.)
119 }
120 
121 
122 //
123 // member functions
124 //
125 
126 // ------------ method called to produce the data ------------
129 {
130  if (theCoder_==0) {
132  iRecord.getRecord<IdealGeometryRecord>().get(htopo);
133  const HcalTopology* topo=&(*htopo);
134  buildCoder(topo);
135  }
136 
137 
138  return coder_;
139 }
140 
142  edm::ESHandle<HcalDbService> conditions;
143  theRec.get(conditions);
144  const HcalTopology* topo=conditions->getTopologyUsed();
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(),*topo,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_
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 *)