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 // system include files
20 #include <memory>
21 #include <string>
22 
23 // user include files
24 
29 
35 
36 //
37 // class decleration
38 //
39 
41 public:
43  ~HcalTPGCoderULUT() override;
44 
45  typedef std::shared_ptr<HcalTPGCoder> ReturnType;
46 
48 
49 private:
51 
53 
54  // ----------member data ---------------------------
64  int maskBit_;
65  std::vector<uint32_t> FG_HF_thresholds_;
67 };
68 
69 //
70 // constants, enums and typedefs
71 //
72 
73 //
74 // static data member definitions
75 //
76 
77 //
78 // constructors and destructor
79 //
81  read_Ascii_ = iConfig.getParameter<bool>("read_Ascii_LUTs");
82  read_XML_ = iConfig.getParameter<bool>("read_XML_LUTs");
83  read_FGLut_ = iConfig.getParameter<bool>("read_FG_LUTs");
84  fgfile_ = iConfig.getParameter<edm::FileInPath>("FGLUTs");
85  contain1TSHB_ = iConfig.getParameter<bool>("contain1TSHB");
86  contain1TSHE_ = iConfig.getParameter<bool>("contain1TSHE");
87  containPhaseNSHB_ = iConfig.getParameter<double>("containPhaseNSHB");
88  containPhaseNSHE_ = iConfig.getParameter<double>("containPhaseNSHE");
89  overrideDBweightsAndFilterHB_ = iConfig.getParameter<bool>("overrideDBweightsAndFilterHB");
90  overrideDBweightsAndFilterHE_ = iConfig.getParameter<bool>("overrideDBweightsAndFilterHE");
91 
92  //the following line is needed to tell the framework what
93  // data is being produced
94  auto cc = setWhatProduced(this);
95  topoToken_ = cc.consumes();
96  delayToken_ = cc.consumes(edm::ESInputTag{"", "HBHE"});
97 
98  if (!(read_Ascii_ || read_XML_)) {
99  LUTGenerationMode_ = iConfig.getParameter<bool>("LUTGenerationMode");
100  linearLUTs_ = iConfig.getParameter<bool>("linearLUTs");
101  auto scales = iConfig.getParameter<edm::ParameterSet>("tpScales").getParameter<edm::ParameterSet>("HBHE");
102  linearLSB_QIE8_ = scales.getParameter<double>("LSBQIE8");
103  linearLSB_QIE11_ = scales.getParameter<double>("LSBQIE11");
104  linearLSB_QIE11Overlap_ = scales.getParameter<double>("LSBQIE11Overlap");
105  maskBit_ = iConfig.getParameter<int>("MaskBit");
106  FG_HF_thresholds_ = iConfig.getParameter<std::vector<uint32_t> >("FG_HF_thresholds");
107  serviceToken_ = cc.consumes();
108  } else {
109  ifilename_ = iConfig.getParameter<edm::FileInPath>("inputLUTs");
110  }
111 }
112 
114  using namespace edm::es;
115  theCoder->init(topo, delay);
116 
119 
120  theCoder->set1TSContainHB(contain1TSHB_);
121  theCoder->set1TSContainHE(contain1TSHE_);
122 
125 
126  if (read_Ascii_ || read_XML_) {
127  edm::LogInfo("HCAL") << "Using ASCII/XML LUTs" << ifilename_.fullPath() << " for HcalTPGCoderULUT initialization";
128  if (read_Ascii_) {
129  theCoder->update(ifilename_.fullPath().c_str());
130  } else if (read_XML_) {
131  theCoder->updateXML(ifilename_.fullPath().c_str());
132  }
133  // Read FG LUT and append to most significant bit 11
134  if (read_FGLut_) {
135  theCoder->update(fgfile_.fullPath().c_str(), true);
136  }
137  } else {
140  theCoder->setMaskBit(maskBit_);
142  }
143 }
144 
146  // do anything here that needs to be done at desctruction time
147  // (e.g. close files, deallocate resources etc.)
148 }
149 
150 //
151 // member functions
152 //
153 
154 // ------------ method called to produce the data ------------
156  auto host = holder_.makeOrGet([]() { return new HostType; });
157 
158  const auto& topo = iRecord.get(topoToken_);
159  const auto& delay = iRecord.getRecord<HcalDbRecord>().get(delayToken_);
160  if (read_Ascii_ || read_XML_) {
161  buildCoder(&topo, &delay, host.get());
162  } else {
163  host->ifRecordChanges<HcalDbRecord>(iRecord, [this, &topo, &delay, h = host.get()](auto const& rec) {
164  buildCoder(&topo, &delay, h);
165  h->update(rec.get(serviceToken_));
166  // Temporary update for FG Lut
167  // Will be moved to DB
168  if (read_FGLut_)
169  h->update(fgfile_.fullPath().c_str(), true);
170  });
171  }
172  return host;
173 }
174 
175 //define this as a plug-in
edm::eventsetup::DependentRecordImplementation::getRecord
const DepRecordT getRecord() const
Definition: DependentRecordImplementation.h:50
HcaluLUTTPGCoder::update
void update(const HcalDbService &conditions)
Definition: HcaluLUTTPGCoder.cc:331
HcalTPGCoderULUT::FG_HF_thresholds_
std::vector< uint32_t > FG_HF_thresholds_
Definition: HcalTPGCoderULUT.cc:65
edm::ESInputTag
Definition: ESInputTag.h:87
HcalTPGCoderULUT::fgfile_
edm::FileInPath fgfile_
Definition: HcalTPGCoderULUT.cc:66
MessageLogger.h
HcaluLUTTPGCoder::set1TSContainHE
void set1TSContainHE(bool contain1TSHE)
Definition: HcaluLUTTPGCoder.h:69
HcalTPGCoderULUT::read_Ascii_
bool read_Ascii_
Definition: HcalTPGCoderULUT.cc:59
HcalTPGRecord
Definition: HcalTPGRecord.h:25
HcalTPGCoderULUT::LUTGenerationMode_
bool LUTGenerationMode_
Definition: HcalTPGCoderULUT.cc:59
HcalTPGCoderULUT::produce
ReturnType produce(const HcalTPGRecord &)
Definition: HcalTPGCoderULUT.cc:155
HcaluLUTTPGCoder::updateXML
void updateXML(const char *filename)
Definition: HcaluLUTTPGCoder.cc:259
HcalTopology
Definition: HcalTopology.h:26
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
ESProducer.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
HcalTPGCoderULUT::buildCoder
void buildCoder(const HcalTopology *, const HcalTimeSlew *, HcaluLUTTPGCoder *)
Definition: HcalTPGCoderULUT.cc:113
HcalTPGRecord.h
query.host
string host
Definition: query.py:115
HcalTimeSlew
Definition: HcalTimeSlew.h:19
HcaluLUTTPGCoder::setOverrideDBweightsAndFilterHB
void setOverrideDBweightsAndFilterHB(bool overrideDBweightsAndFilterHB)
Definition: HcaluLUTTPGCoder.h:72
HcalTPGCoderULUT::linearLSB_QIE11Overlap_
double linearLSB_QIE11Overlap_
Definition: HcalTPGCoderULUT.cc:63
edm::ReusableObjectHolder< HostType >
edm::ReusableObjectHolder::makeOrGet
std::shared_ptr< T > makeOrGet(F iFunc)
If there isn't an object already available, creates a new one using iFunc.
Definition: ReusableObjectHolder.h:126
HcaluLUTTPGCoder::setContainPhaseHE
void setContainPhaseHE(double containPhaseNSHE)
Definition: HcaluLUTTPGCoder.h:71
edm::FileInPath
Definition: FileInPath.h:61
HcalTPGCoderULUT::topoToken_
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > topoToken_
Definition: HcalTPGCoderULUT.cc:56
HcaluLUTTPGCoder.h
ReusableObjectHolder.h
h
HcaluLUTTPGCoder::setLUTGenerationMode
void setLUTGenerationMode(bool gen)
Definition: HcaluLUTTPGCoder.h:59
HcaluLUTTPGCoder::setOverrideDBweightsAndFilterHE
void setOverrideDBweightsAndFilterHE(bool overrideDBweightsAndFilterHE)
Definition: HcaluLUTTPGCoder.h:75
HcaluLUTTPGCoder::setMaskBit
void setMaskBit(int bit)
Definition: HcaluLUTTPGCoder.h:61
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:109
HcalTPGCoderULUT::contain1TSHE_
bool contain1TSHE_
Definition: HcalTPGCoderULUT.cc:60
HcalTPGCoderULUT::delayToken_
edm::ESGetToken< HcalTimeSlew, HcalTimeSlewRecord > delayToken_
Definition: HcalTPGCoderULUT.cc:57
HcalTPGCoderULUT::ifilename_
edm::FileInPath ifilename_
Definition: HcalTPGCoderULUT.cc:66
HcalTPGCoderULUT::linearLSB_QIE11_
double linearLSB_QIE11_
Definition: HcalTPGCoderULUT.cc:63
edm::ParameterSet
Definition: ParameterSet.h:47
HcalTPGCoderULUT
Definition: HcalTPGCoderULUT.cc:40
HcalTPGCoderULUT::contain1TSHB_
bool contain1TSHB_
Definition: HcalTPGCoderULUT.cc:60
HcalTPGCoderULUT::ReturnType
std::shared_ptr< HcalTPGCoder > ReturnType
Definition: HcalTPGCoderULUT.cc:45
HcaluLUTTPGCoder
Definition: HcaluLUTTPGCoder.h:32
HcalTPGCoderULUT::overrideDBweightsAndFilterHE_
bool overrideDBweightsAndFilterHE_
Definition: HcalTPGCoderULUT.cc:62
HcaluLUTTPGCoder::init
void init(const HcalTopology *top, const HcalTimeSlew *delay)
Definition: HcaluLUTTPGCoder.cc:72
HcalTPGCoderULUT::HcalTPGCoderULUT
HcalTPGCoderULUT(const edm::ParameterSet &)
Definition: HcalTPGCoderULUT.cc:80
HcaluLUTTPGCoder::set1TSContainHB
void set1TSContainHB(bool contain1TSHB)
Definition: HcaluLUTTPGCoder.h:68
HcalTPGCoderULUT::maskBit_
int maskBit_
Definition: HcalTPGCoderULUT.cc:64
get
#define get
cc
HcalTPGCoderULUT::linearLUTs_
bool linearLUTs_
Definition: HcalTPGCoderULUT.cc:59
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord >
HcalTPGCoderULUT::serviceToken_
edm::ESGetToken< HcalDbService, HcalDbRecord > serviceToken_
Definition: HcalTPGCoderULUT.cc:58
HcalTopology.h
ModuleFactory.h
edm::ESProductHost
Definition: ESProductHost.h:93
HcalTPGCoderULUT::~HcalTPGCoderULUT
~HcalTPGCoderULUT() override
Definition: HcalTPGCoderULUT.cc:145
HcaluLUTTPGCoder::setAllLinear
void setAllLinear(bool linear, double lsb8, double lsb11, double lsb11overlap)
Definition: HcaluLUTTPGCoder.h:62
HcalTPGCoderULUT::containPhaseNSHB_
double containPhaseNSHB_
Definition: HcalTPGCoderULUT.cc:61
HcalTPGCoderULUT::containPhaseNSHE_
double containPhaseNSHE_
Definition: HcalTPGCoderULUT.cc:61
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
HcaluLUTTPGCoder::setContainPhaseHB
void setContainPhaseHB(double containPhaseNSHB)
Definition: HcaluLUTTPGCoder.h:70
HcalTPGCoderULUT::read_XML_
bool read_XML_
Definition: HcalTPGCoderULUT.cc:59
edm::es
Definition: es_Label.h:33
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HcalDbService.h
edm::ESProducer
Definition: ESProducer.h:104
ESProductHost.h
HcalTPGCoderULUT::overrideDBweightsAndFilterHB_
bool overrideDBweightsAndFilterHB_
Definition: HcalTPGCoderULUT.cc:62
phase2TrackerDigitizer_cfi.delay
delay
Definition: phase2TrackerDigitizer_cfi.py:49
HcalDbRecord
Definition: HcalDbRecord.h:30
HcalTPGCoderULUT::holder_
edm::ReusableObjectHolder< HostType > holder_
Definition: HcalTPGCoderULUT.cc:55
HcalTPGCoderULUT::read_FGLut_
bool read_FGLut_
Definition: HcalTPGCoderULUT.cc:59
HcalTPGCoderULUT::HostType
edm::ESProductHost< HcaluLUTTPGCoder, HcalDbRecord > HostType
Definition: HcalTPGCoderULUT.cc:50
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161
HcaluLUTTPGCoder::setFGHFthresholds
void setFGHFthresholds(const std::vector< uint32_t > &fgthresholds)
Definition: HcaluLUTTPGCoder.h:60
HcalTPGCoderULUT::linearLSB_QIE8_
double linearLSB_QIE8_
Definition: HcalTPGCoderULUT.cc:63