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.8 2009/06/04 12:09:45 tulika 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 
35 
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  // ----------member data ---------------------------
56 };
57 
58 //
59 // constants, enums and typedefs
60 //
61 
62 //
63 // static data member definitions
64 //
65 
66 //
67 // constructors and destructor
68 //
70 {
71  bool read_Ascii = iConfig.getParameter<bool>("read_Ascii_LUTs");
72  bool read_XML = iConfig.getParameter<bool>("read_XML_LUTs");
73  read_FGLut_ = iConfig.getParameter<bool>("read_FG_LUTs");
74  fgfile_ = iConfig.getParameter<edm::FileInPath>("FGLUTs");
75 
76  //the following line is needed to tell the framework what
77  // data is being produced
78  if (!(read_Ascii || read_XML)) setWhatProduced(this,(dependsOn(&HcalTPGCoderULUT::dbRecordCallback)));
79  else setWhatProduced(this);
80 
81  //now do what ever other initialization is needed
82  using namespace edm::es;
84  if (read_Ascii || read_XML){
85  edm::FileInPath ifilename(iConfig.getParameter<edm::FileInPath>("inputLUTs"));
86  edm::LogInfo("HCAL") << "Using ASCII/XML LUTs" << ifilename.fullPath() << " for HcalTPGCoderULUT initialization";
87  if (read_Ascii) theCoder_->update(ifilename.fullPath().c_str());
88  else if (read_XML) theCoder_->updateXML(ifilename.fullPath().c_str());
89 
90  // Read FG LUT and append to most significant bit 11
91  if (read_FGLut_) theCoder_->update(fgfile_.fullPath().c_str(), true);
92  }
93  else {
94  bool LUTGenerationMode = iConfig.getParameter<bool>("LUTGenerationMode");
95  int maskBit = iConfig.getParameter<int>("MaskBit");
96  theCoder_->setLUTGenerationMode(LUTGenerationMode);
97  theCoder_->setMaskBit(maskBit);
98  }
100 }
101 
102 
104 {
105 
106  // do anything here that needs to be done at desctruction time
107  // (e.g. close files, deallocate resources etc.)
108 }
109 
110 
111 //
112 // member functions
113 //
114 
115 // ------------ method called to produce the data ------------
118 {
119  return coder_;
120 }
121 
123  edm::ESHandle<HcalDbService> conditions;
124  theRec.get(conditions);
125  theCoder_->update(*conditions);
126 
127  // Temporary update for FG Lut
128  // Will be moved to DB
129  if (read_FGLut_) theCoder_->update(fgfile_.fullPath().c_str(), true);
130 }
131 
132 //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 &)
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 updateXML(const char *filename)
void setLUTGenerationMode(bool gen)
boost::shared_ptr< HcalTPGCoder > ReturnType
void get(HolderT &iHolder) const
void setMaskBit(int bit)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:48
edm::FileInPath fgfile_
ReturnType produce(const HcalTPGRecord &)
std::string fullPath() const
Definition: FileInPath.cc:170