61 void endJob()
override;
68 const std::vector<unsigned char>& lut,
75 std::ostream* openPerCrate(
int crate);
78 std::ostream* openChecksums();
91 : creationtag_(iConfig.getParameter<
std::
string>(
"creationtag")),
92 targetfirmware_(iConfig.getParameter<
std::
string>(
"targetfirmware")),
93 filePerCrate_(iConfig.getUntrackedParameter<
bool>(
"filePerCrate",
true)),
94 fileformat_(iConfig.getParameter<
std::
string>(
"filePrefix")) {
95 tokdb_ = esConsumes<HcalDbService, HcalDbRecord>();
96 tokhcalCode_ = esConsumes<HcalTPGCoder, HcalTPGRecord>();
97 tokcaloCode_ = esConsumes<CaloTPGTranscoder, CaloTPGRecord>();
109 std::ostream* os =
new std::ofstream(
fname);
110 (*os) <<
"<?xml version=\"1.0\"?>\n<CFGBrick>\n";
117 std::ostream* os =
new std::ofstream(
fname);
118 (*os) <<
"<?xml version=\"1.0\"?>\n<CFGBrickSet>\n";
126 "%s_%d_%d%c_%d_%d_1.xml",
128 eid.readoutVMECrateId(),
130 ((
eid.htrTopBottom()) ? (
't') : (
'b')),
133 std::ostream* os =
new std::ofstream(
fname);
134 (*os) <<
"<?xml version=\"1.0\"?>\n";
142 "%s_%d_%d%c_%d_%d_2.xml",
144 eid.readoutVMECrateId(),
146 ((
eid.htrTopBottom()) ? (
't') : (
'b')),
148 eid.slbChannelIndex());
149 std::ostream* os =
new std::ofstream(
fname);
150 (*os) <<
"<?xml version=\"1.0\"?>\n";
156 const std::vector<unsigned short>& lut,
158 os <<
"<CFGBrick> " << std::endl;
159 os <<
" <Parameter name='IETA' type='int'>" <<
id.ieta() <<
"</Parameter>" << std::endl;
160 os <<
" <Parameter name='IPHI' type='int'>" <<
id.iphi() <<
"</Parameter>" << std::endl;
161 os <<
" <Parameter name='DEPTH' type='int'>" <<
id.depth() <<
"</Parameter>" << std::endl;
162 os <<
" <Parameter name='CRATE' type='int'>" <<
eid.readoutVMECrateId() <<
"</Parameter>" << std::endl;
163 os <<
" <Parameter name='SLOT' type='int'>" <<
eid.htrSlot() <<
"</Parameter>" << std::endl;
164 os <<
" <Parameter name='TOPBOTTOM' type='int'>" <<
eid.htrTopBottom() <<
"</Parameter>" << std::endl;
165 os <<
" <Parameter name='FIBER' type='int'>" <<
eid.fiberIndex() <<
"</Parameter>" << std::endl;
166 os <<
" <Parameter name='FIBERCHAN' type='int'>" <<
eid.fiberChanId() <<
"</Parameter>" << std::endl;
167 os <<
" <Parameter name='LUT_TYPE' type='int'>1</Parameter>" << std::endl;
168 os <<
" <Parameter name='CREATIONTAG' type='string'>" <<
creationtag_ <<
"</Parameter>" << std::endl;
169 os <<
" <Parameter name='CREATIONSTAMP' type='string'>" <<
creationstamp_ <<
"</Parameter>" << std::endl;
170 os <<
" <Parameter name='FORMATREVISION' type='string'>" <<
formatRevision_ <<
"</Parameter>" << std::endl;
171 os <<
" <Parameter name='TARGETFIRMWARE' type='string'>" <<
targetfirmware_ <<
"</Parameter>" << std::endl;
172 int generalizedIndex =
id.ietaAbs() + 1000 *
id.depth() + 10000 *
id.iphi() + ((
id.ieta() < 0) ? (0) : (100)) +
173 ((
id.subdet() ==
HcalForward &&
id.ietaAbs() == 29) ? (4 * 10000) : (0));
175 os <<
" <Parameter name='GENERALIZEDINDEX' type='int'>" << generalizedIndex <<
"</Parameter>" << std::endl;
178 md5_byte_t digest[16];
179 unsigned char tool[2];
181 for (
int i = 0;
i < 128;
i++) {
182 tool[0] = lut[
i] & 0xFF;
183 tool[1] = (lut[
i] >> 8) & 0xFF;
184 md5_append(&md5er, tool, 2);
186 md5_finish(&md5er, digest);
187 os <<
" <Parameter name='CHECKSUM' type='string'>";
188 for (
int i = 0;
i < 16;
i++)
189 os << std::hex << (((
int)(digest[
i])) & 0xFF);
190 os <<
"</Parameter>\n";
192 *
oc_ <<
" <Data crate='" <<
eid.readoutVMECrateId() <<
"' slot='" <<
eid.htrSlot() <<
"' fpga='" 193 <<
eid.htrTopBottom() <<
"' fiber='" <<
eid.fiberIndex() <<
"' fiberchan='" <<
eid.fiberChanId()
194 <<
"' luttype='1' elements='1' encoding='hex'>";
195 for (
int i = 0;
i < 16;
i++)
196 *
oc_ << std::hex << (((
int)(digest[
i])) & 0xFF);
199 os <<
" <Data elements='128' encoding='hex'> " << std::endl;
201 for (
int initr2 = 0; initr2 < 128; initr2++) {
202 os << lut[initr2] <<
" ";
206 os <<
" </Data> " << std::endl;
207 os <<
"</CFGBrick> " << std::endl;
212 const std::vector<unsigned char>& lut,
214 os <<
"<CFGBrick> " << std::endl;
215 os <<
" <Parameter name='IETA' type='int'>" <<
id.ieta() <<
"</Parameter>" << std::endl;
216 os <<
" <Parameter name='IPHI' type='int'>" <<
id.iphi() <<
"</Parameter>" << std::endl;
217 os <<
" <Parameter name='CRATE' type='int'>" <<
eid.readoutVMECrateId() <<
"</Parameter>" << std::endl;
218 os <<
" <Parameter name='SLOT' type='int'>" <<
eid.htrSlot() <<
"</Parameter>" << std::endl;
219 os <<
" <Parameter name='TOPBOTTOM' type='int'>" <<
eid.htrTopBottom() <<
"</Parameter>" << std::endl;
220 os <<
" <Parameter name='SLB' type='int'>" <<
eid.slbSiteNumber() <<
"</Parameter>" << std::endl;
221 os <<
" <Parameter name='SLBCHAN' type='int'>" <<
eid.slbChannelIndex() <<
"</Parameter>" << std::endl;
222 os <<
" <Parameter name='LUT_TYPE' type='int'>2</Parameter>" << std::endl;
223 os <<
" <Parameter name='CREATIONTAG' type='string'>" <<
creationtag_ <<
"</Parameter>" << std::endl;
224 os <<
" <Parameter name='CREATIONSTAMP' type='string'>" <<
creationstamp_ <<
"</Parameter>" << std::endl;
225 os <<
" <Parameter name='FORMATREVISION' type='string'>" <<
formatRevision_ <<
"</Parameter>" << std::endl;
226 os <<
" <Parameter name='TARGETFIRMWARE' type='string'>" <<
targetfirmware_ <<
"</Parameter>" << std::endl;
227 int generalizedIndex =
id.ietaAbs() + 10000 *
id.iphi() + ((
id.ieta() < 0) ? (0) : (100));
229 os <<
" <Parameter name='GENERALIZEDINDEX' type='int'>" << generalizedIndex <<
"</Parameter>" << std::endl;
233 md5_byte_t digest[16];
235 md5_append(&md5er, &(lut[0]), 1024);
236 md5_finish(&md5er, digest);
237 os <<
" <Parameter name='CHECKSUM' type='string'>";
238 for (
int i = 0;
i < 16;
i++)
239 os << std::hex << (((
int)(digest[
i])) & 0xFF);
240 os <<
"</Parameter>\n";
242 *
oc_ <<
" <Data crate='" <<
eid.readoutVMECrateId() <<
"' slot='" <<
eid.htrSlot() <<
"' fpga='" 243 <<
eid.htrTopBottom() <<
"' slb='" <<
eid.slbSiteNumber() <<
"' slbchan='" <<
eid.slbChannelIndex()
244 <<
"' luttype='2' elements='1' encoding='hex'>";
245 for (
int i = 0;
i < 16;
i++)
246 *
oc_ << std::hex << (((
int)(digest[
i])) & 0xFF);
249 os <<
" <Data elements='1024' encoding='hex'> " << std::endl;
251 for (
int initr2 = 0; initr2 < 1024; initr2++) {
252 os << (
int(lut[initr2]) & 0xFF) <<
" ";
256 os <<
" </Data> " << std::endl;
257 os <<
"</CFGBrick> " << std::endl;
261 std::vector<unsigned char> lut;
262 for (
int i = 0;
i < 1024;
i++) {
264 lut.push_back(
s.compressedEt());
274 edm::LogInfo(
"Hcal") <<
"Beginning dump of Hcal TPG LUTS (this may take a minute or two)";
284 std::vector<HcalElectronicsId>::iterator itreid;
286 std::ostream* pfile =
nullptr;
289 for (
int crate = 0; crate < 20; crate++) {
291 for (itreid = allEID.begin(); itreid != allEID.end(); ++itreid) {
292 if (itreid->readoutVMECrateId() != crate)
294 if (itreid->isTriggerChainId()) {
301 else if (pfile ==
nullptr)
319 else if (pfile ==
nullptr)
330 if (pfile !=
nullptr) {
332 *pfile <<
"</CFGBrickSet>\n";
337 *
oc_ <<
"</CFGBrick>\n";
345 struct tm* tm = localtime(&
now);
346 strftime(
buffer, 120,
"%F %T", tm);
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
std::ostream * openPerLut2(HcalElectronicsId eid)
edm::ESGetToken< CaloTPGTranscoder, CaloTPGRecord > tokcaloCode_
edm::ESGetToken< HcalTPGCoder, HcalTPGRecord > tokhcalCode_
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
HcalLuttoDB(const edm::ParameterSet &)
std::ostream * openChecksums()
const HcalElectronicsMap * getHcalMapping() const
void writeoutlut2(HcalTrigTowerDetId id, HcalElectronicsId eid, const std::vector< unsigned char > &lut, std::ostream &os)
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
virtual std::vector< unsigned short > getLinearizationLUT(HcalDetId id) const
Get the full linearization LUT (128 elements). Default implementation just uses adc2Linear to get all...
const std::string targetfirmware_
constexpr bool null() const
is this a null id ?
void analyze(const edm::Event &, const edm::EventSetup &) override
const std::string fileformat_
#define DEFINE_FWK_MODULE(type)
std::vector< HcalElectronicsId > allElectronicsId() const
std::ostream * openPerCrate(int crate)
HcalGenericSubdetector genericSubdet() const
Log< level::Info, false > LogInfo
edm::ESGetToken< HcalDbService, HcalDbRecord > tokdb_
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
std::ostream * openPerLut1(HcalElectronicsId eid)
std::string creationstamp_
void writeoutlut1(HcalDetId id, HcalElectronicsId eid, const std::vector< unsigned short > &lut, std::ostream &os)
const std::string creationtag_
const DetId lookupTrigger(HcalElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
std::vector< unsigned char > extractOutputLut(const CaloTPGTranscoder &coder, HcalTrigTowerDetId chan)
Readout chain identification for Hcal.
static const int formatRevision_