63 void endJob()
override ;
72 std::ostream* openPerCrate(
int crate);
75 std::ostream* openChecksums();
106 snprintf(fname,1024,
"%s_checksums.xml",fileformat_.c_str());
107 std::ostream* os=
new std::ofstream(fname);
108 (*os) <<
"<?xml version=\"1.0\"?>\n<CFGBrick>\n";
114 snprintf(fname,1024,
"%s_%d.xml",fileformat_.c_str(),crate);
115 std::ostream* os=
new std::ofstream(fname);
116 (*os) <<
"<?xml version=\"1.0\"?>\n<CFGBrickSet>\n";
122 snprintf(fname,1024,
"%s_%d_%d%c_%d_%d_1.xml",fileformat_.c_str(),eid.
readoutVMECrateId(),
124 std::ostream* os=
new std::ofstream(fname);
125 (*os) <<
"<?xml version=\"1.0\"?>\n";
131 snprintf(fname,1024,
"%s_%d_%d%c_%d_%d_2.xml",fileformat_.c_str(),eid.
readoutVMECrateId(),
133 std::ostream* os=
new std::ofstream(fname);
134 (*os) <<
"<?xml version=\"1.0\"?>\n";
142 os <<
"<CFGBrick> "<<std::endl;
143 os <<
" <Parameter name='IETA' type='int'>"<<
id.ieta()<<
"</Parameter>"<<std::endl;
144 os <<
" <Parameter name='IPHI' type='int'>"<<
id.iphi()<<
"</Parameter>"<<std::endl;
145 os <<
" <Parameter name='DEPTH' type='int'>"<<
id.depth()<<
"</Parameter>"<<std::endl;
146 os <<
" <Parameter name='CRATE' type='int'>"<<eid.
readoutVMECrateId()<<
"</Parameter>"<<std::endl;
147 os <<
" <Parameter name='SLOT' type='int'>"<<eid.
htrSlot()<<
"</Parameter>"<<std::endl;
148 os <<
" <Parameter name='TOPBOTTOM' type='int'>"<<eid.
htrTopBottom()<<
"</Parameter>"<<std::endl;
149 os <<
" <Parameter name='FIBER' type='int'>"<<eid.
fiberIndex()<<
"</Parameter>"<<std::endl;
150 os <<
" <Parameter name='FIBERCHAN' type='int'>"<<eid.
fiberChanId()<<
"</Parameter>"<<std::endl;
151 os <<
" <Parameter name='LUT_TYPE' type='int'>1</Parameter>"<<std::endl;
152 os <<
" <Parameter name='CREATIONTAG' type='string'>"<<
creationtag_<<
"</Parameter>"<<std::endl;
153 os <<
" <Parameter name='CREATIONSTAMP' type='string'>"<<creationstamp_<<
"</Parameter>"<<std::endl;
154 os <<
" <Parameter name='FORMATREVISION' type='string'>"<<
formatRevision_<<
"</Parameter>"<<std::endl;
155 os <<
" <Parameter name='TARGETFIRMWARE' type='string'>"<<
targetfirmware_<<
"</Parameter>"<<std::endl;
156 int generalizedIndex=
id.ietaAbs()+1000*
id.depth()+10000*
id.iphi()+
157 ((
id.ieta()<0)?(0):(100))+((
id.subdet()==
HcalForward &&
id.ietaAbs()==29)?(4*10000):(0));
159 os <<
" <Parameter name='GENERALIZEDINDEX' type='int'>"<<generalizedIndex<<
"</Parameter>"<<std::endl;
162 md5_byte_t digest[16];
163 unsigned char tool[2];
165 for (
int i=0;
i<128;
i++) {
167 tool[1]=(lut[
i]>>8)&0xFF;
168 md5_append(&md5er,tool,2);
170 md5_finish(&md5er,digest);
171 os <<
" <Parameter name='CHECKSUM' type='string'>";
172 for (
int i=0;
i<16;
i++) os << std::hex << (((
int)(digest[
i]))&0xFF);
173 os <<
"</Parameter>\n";
180 <<
"' luttype='1' elements='1' encoding='hex'>";
181 for (
int i=0; i<16; i++) *oc_ << std::hex << (((
int)(digest[i]))&0xFF);
184 os <<
" <Data elements='128' encoding='hex'> "<<std::endl;
186 for(
int initr2 = 0; initr2 < 128; initr2++){
187 os<<lut[initr2]<<
" ";
191 os <<
" </Data> "<<std::endl;
192 os <<
"</CFGBrick> "<<std::endl;
199 os <<
"<CFGBrick> "<<std::endl;
200 os <<
" <Parameter name='IETA' type='int'>"<<
id.ieta()<<
"</Parameter>"<<std::endl;
201 os <<
" <Parameter name='IPHI' type='int'>"<<
id.iphi()<<
"</Parameter>"<<std::endl;
202 os <<
" <Parameter name='CRATE' type='int'>"<<eid.
readoutVMECrateId()<<
"</Parameter>"<<std::endl;
203 os <<
" <Parameter name='SLOT' type='int'>"<<eid.
htrSlot()<<
"</Parameter>"<<std::endl;
204 os <<
" <Parameter name='TOPBOTTOM' type='int'>"<<eid.
htrTopBottom()<<
"</Parameter>"<<std::endl;
205 os <<
" <Parameter name='SLB' type='int'>"<<eid.
slbSiteNumber()<<
"</Parameter>"<<std::endl;
206 os <<
" <Parameter name='SLBCHAN' type='int'>"<<eid.
slbChannelIndex()<<
"</Parameter>"<<std::endl;
207 os <<
" <Parameter name='LUT_TYPE' type='int'>2</Parameter>"<<std::endl;
208 os <<
" <Parameter name='CREATIONTAG' type='string'>"<<
creationtag_<<
"</Parameter>"<<std::endl;
209 os <<
" <Parameter name='CREATIONSTAMP' type='string'>"<<creationstamp_<<
"</Parameter>"<<std::endl;
210 os <<
" <Parameter name='FORMATREVISION' type='string'>"<<
formatRevision_<<
"</Parameter>"<<std::endl;
211 os <<
" <Parameter name='TARGETFIRMWARE' type='string'>"<<
targetfirmware_<<
"</Parameter>"<<std::endl;
212 int generalizedIndex=
id.ietaAbs()+10000*
id.iphi()+
213 ((
id.ieta()<0)?(0):(100));
216 os <<
" <Parameter name='GENERALIZEDINDEX' type='int'>"<<generalizedIndex<<
"</Parameter>"<<std::endl;
221 md5_byte_t digest[16];
223 md5_append(&md5er,&(lut[0]),1024);
224 md5_finish(&md5er,digest);
225 os <<
" <Parameter name='CHECKSUM' type='string'>";
226 for (
int i=0;
i<16;
i++) os << std::hex << (((
int)(digest[
i]))&0xFF);
227 os <<
"</Parameter>\n";
234 <<
"' luttype='2' elements='1' encoding='hex'>";
235 for (
int i=0; i<16; i++) *oc_ << std::hex << (((
int)(digest[i]))&0xFF);
238 os <<
" <Data elements='1024' encoding='hex'> "<<std::endl;
240 for(
int initr2 = 0; initr2 < 1024; initr2++){
241 os<< (
int(lut[initr2])&0xFF)<<
" ";
245 os <<
" </Data> "<<std::endl;
246 os <<
"</CFGBrick> "<<std::endl;
251 std::vector<unsigned char>
lut;
252 for (
int i=0;
i<1024;
i++) {
266 edm::LogInfo(
"Hcal") <<
"Beginning dump of Hcal TPG LUTS (this may take a minute or two)";
279 std::vector<HcalElectronicsId>::iterator itreid;
281 std::ostream* pfile=
nullptr;
284 for (
int crate=0; crate<20; crate++) {
286 for(itreid = allEID.begin(); itreid != allEID.end(); ++itreid)
288 if (itreid->readoutVMECrateId()!=crate)
continue;
289 if (itreid->isTriggerChainId()) {
291 if (tid.
null())
continue;
293 if (filePerCrate_ && pfile==
nullptr) pfile=openPerCrate(crate);
294 else if (pfile==
nullptr) pfile=openPerLut2(*itreid);
296 std::vector<unsigned char>
lut=extractOutputLut(*outTranscoder,tid);
297 writeoutlut2(tid,*itreid,lut,*pfile);
298 if (!filePerCrate_) {
delete pfile; pfile=
nullptr; }
303 if (filePerCrate_ && pfile==
nullptr) pfile=openPerCrate(crate);
304 else if (pfile==
nullptr) pfile=openPerLut1(*itreid);
307 writeoutlut1(
HcalDetId(gid),*itreid,lut,*pfile);
308 if (!filePerCrate_) {
delete pfile; pfile=
nullptr; }
311 if (pfile!=
nullptr) {
312 if (filePerCrate_) *pfile <<
"</CFGBrickSet>\n";
317 *oc_ <<
"</CFGBrick>\n";
330 struct tm* tm=localtime(&now);
331 strftime(buffer,120,
"%F %T",tm);
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int fiberIndex() const
get the fiber index. For VME 1-8 (which of eight fibers carried by a spigot), for uTCA fibers are zer...
virtual example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
std::ostream * openPerLut2(HcalElectronicsId eid)
#define DEFINE_FWK_MODULE(type)
int htrSlot() const
get the htr slot
HcalLuttoDB(const edm::ParameterSet &)
std::ostream * openChecksums()
void writeoutlut2(HcalTrigTowerDetId id, HcalElectronicsId eid, const std::vector< unsigned char > &lut, std::ostream &os)
int readoutVMECrateId() const
get the readout VME crate number
std::string targetfirmware_
void analyze(const edm::Event &, const edm::EventSetup &) override
int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom), valid for VME
int fiberChanId() const
get the fiber channel id (which of channels on a fiber)
virtual std::vector< unsigned short > getLinearizationLUT(HcalDetId id) const
Get the full linearization LUT (128 elements). Default implementation just uses adc2Linear to get all...
std::ostream * openPerCrate(int crate)
int slbChannelIndex() const
get the SLB channel index (valid only for VME trigger-chain ids)
std::vector< HcalElectronicsId > allElectronicsId() const
bool null() const
is this a null id ?
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_
int slbSiteNumber() const
get the SLB site number (valid only for VME trigger-chain ids)
const HcalElectronicsMap * getHcalMapping() const
int compressedEt() const
get the encoded/compressed Et
const DetId lookupTrigger(HcalElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
virtual HcalTriggerPrimitiveSample hcalCompress(const HcalTrigTowerDetId &id, unsigned int sample, int fineGrain) const =0
Compression from linear samples+fine grain in the HTR.
void writeoutlut1(HcalDetId id, HcalElectronicsId eid, const std::vector< unsigned short > &lut, std::ostream &os)
HcalGenericSubdetector genericSubdet() const
std::vector< unsigned char > extractOutputLut(const CaloTPGTranscoder &coder, HcalTrigTowerDetId chan)
Readout chain identification for Hcal.
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
static const int formatRevision_