64 virtual void endJob() ;
73 std::ostream* openPerCrate(
int crate);
76 std::ostream* openChecksums();
93 fileformat_=iConfig.
getParameter<std::string>(
"filePrefix");
107 snprintf(fname,1024,
"%s_checksums.xml",fileformat_.c_str());
108 std::ostream* os=
new std::ofstream(fname);
109 (*os) <<
"<?xml version=\"1.0\"?>\n<CFGBrick>\n";
115 snprintf(fname,1024,
"%s_%d.xml",fileformat_.c_str(),crate);
116 std::ostream* os=
new std::ofstream(fname);
117 (*os) <<
"<?xml version=\"1.0\"?>\n<CFGBrickSet>\n";
123 snprintf(fname,1024,
"%s_%d_%d%c_%d_%d_1.xml",fileformat_.c_str(),eid.
readoutVMECrateId(),
125 std::ostream* os=
new std::ofstream(fname);
126 (*os) <<
"<?xml version=\"1.0\"?>\n";
132 snprintf(fname,1024,
"%s_%d_%d%c_%d_%d_2.xml",fileformat_.c_str(),eid.
readoutVMECrateId(),
134 std::ostream* os=
new std::ofstream(fname);
135 (*os) <<
"<?xml version=\"1.0\"?>\n";
143 os <<
"<CFGBrick> "<<std::endl;
144 os <<
" <Parameter name='IETA' type='int'>"<<
id.ieta()<<
"</Parameter>"<<std::endl;
145 os <<
" <Parameter name='IPHI' type='int'>"<<
id.iphi()<<
"</Parameter>"<<std::endl;
146 os <<
" <Parameter name='DEPTH' type='int'>"<<
id.depth()<<
"</Parameter>"<<std::endl;
147 os <<
" <Parameter name='CRATE' type='int'>"<<eid.
readoutVMECrateId()<<
"</Parameter>"<<std::endl;
148 os <<
" <Parameter name='SLOT' type='int'>"<<eid.
htrSlot()<<
"</Parameter>"<<std::endl;
149 os <<
" <Parameter name='TOPBOTTOM' type='int'>"<<eid.
htrTopBottom()<<
"</Parameter>"<<std::endl;
150 os <<
" <Parameter name='FIBER' type='int'>"<<eid.
fiberIndex()<<
"</Parameter>"<<std::endl;
151 os <<
" <Parameter name='FIBERCHAN' type='int'>"<<eid.
fiberChanId()<<
"</Parameter>"<<std::endl;
152 os <<
" <Parameter name='LUT_TYPE' type='int'>1</Parameter>"<<std::endl;
153 os <<
" <Parameter name='CREATIONTAG' type='string'>"<<
creationtag_<<
"</Parameter>"<<std::endl;
154 os <<
" <Parameter name='CREATIONSTAMP' type='string'>"<<creationstamp_<<
"</Parameter>"<<std::endl;
155 os <<
" <Parameter name='FORMATREVISION' type='string'>"<<
formatRevision_<<
"</Parameter>"<<std::endl;
156 os <<
" <Parameter name='TARGETFIRMWARE' type='string'>"<<
targetfirmware_<<
"</Parameter>"<<std::endl;
157 int generalizedIndex=
id.ietaAbs()+1000*
id.depth()+10000*
id.iphi()+
158 ((
id.ieta()<0)?(0):(100))+((
id.subdet()==
HcalForward &&
id.ietaAbs()==29)?(4*10000):(0));
160 os <<
" <Parameter name='GENERALIZEDINDEX' type='int'>"<<generalizedIndex<<
"</Parameter>"<<std::endl;
164 unsigned char tool[2];
166 for (
int i=0;
i<128;
i++) {
168 tool[1]=(lut[
i]>>8)&0xFF;
172 os <<
" <Parameter name='CHECKSUM' type='string'>";
173 for (
int i=0;
i<16;
i++) os << std::hex << (((
int)(digest[
i]))&0xFF);
174 os <<
"</Parameter>\n";
181 <<
"' luttype='1' elements='1' encoding='hex'>";
182 for (
int i=0; i<16; i++) *oc_ << std::hex << (((
int)(digest[i]))&0xFF);
185 os <<
" <Data elements='128' encoding='hex'> "<<std::endl;
187 for(
int initr2 = 0; initr2 < 128; initr2++){
188 os<<lut[initr2]<<
" ";
192 os <<
" </Data> "<<std::endl;
193 os <<
"</CFGBrick> "<<std::endl;
200 os <<
"<CFGBrick> "<<std::endl;
201 os <<
" <Parameter name='IETA' type='int'>"<<
id.ieta()<<
"</Parameter>"<<std::endl;
202 os <<
" <Parameter name='IPHI' type='int'>"<<
id.iphi()<<
"</Parameter>"<<std::endl;
203 os <<
" <Parameter name='CRATE' type='int'>"<<eid.
readoutVMECrateId()<<
"</Parameter>"<<std::endl;
204 os <<
" <Parameter name='SLOT' type='int'>"<<eid.
htrSlot()<<
"</Parameter>"<<std::endl;
205 os <<
" <Parameter name='TOPBOTTOM' type='int'>"<<eid.
htrTopBottom()<<
"</Parameter>"<<std::endl;
206 os <<
" <Parameter name='SLB' type='int'>"<<eid.
slbSiteNumber()<<
"</Parameter>"<<std::endl;
207 os <<
" <Parameter name='SLBCHAN' type='int'>"<<eid.
slbChannelIndex()<<
"</Parameter>"<<std::endl;
208 os <<
" <Parameter name='LUT_TYPE' type='int'>2</Parameter>"<<std::endl;
209 os <<
" <Parameter name='CREATIONTAG' type='string'>"<<
creationtag_<<
"</Parameter>"<<std::endl;
210 os <<
" <Parameter name='CREATIONSTAMP' type='string'>"<<creationstamp_<<
"</Parameter>"<<std::endl;
211 os <<
" <Parameter name='FORMATREVISION' type='string'>"<<
formatRevision_<<
"</Parameter>"<<std::endl;
212 os <<
" <Parameter name='TARGETFIRMWARE' type='string'>"<<
targetfirmware_<<
"</Parameter>"<<std::endl;
213 int generalizedIndex=
id.ietaAbs()+10000*
id.iphi()+
214 ((
id.ieta()<0)?(0):(100));
217 os <<
" <Parameter name='GENERALIZEDINDEX' type='int'>"<<generalizedIndex<<
"</Parameter>"<<std::endl;
226 os <<
" <Parameter name='CHECKSUM' type='string'>";
227 for (
int i=0;
i<16;
i++) os << std::hex << (((
int)(digest[
i]))&0xFF);
228 os <<
"</Parameter>\n";
235 <<
"' luttype='2' elements='1' encoding='hex'>";
236 for (
int i=0; i<16; i++) *oc_ << std::hex << (((
int)(digest[i]))&0xFF);
239 os <<
" <Data elements='1024' encoding='hex'> "<<std::endl;
241 for(
int initr2 = 0; initr2 < 1024; initr2++){
242 os<< (int(lut[initr2])&0xFF)<<
" ";
246 os <<
" </Data> "<<std::endl;
247 os <<
"</CFGBrick> "<<std::endl;
252 std::vector<unsigned char> lut;
253 for (
int i=0;
i<1024;
i++) {
267 edm::LogInfo(
"Hcal") <<
"Beginning dump of Hcal TPG LUTS (this may take a minute or two)";
272 Map_=pSetup->getHcalMapping();
281 std::vector<HcalElectronicsId>::iterator itreid;
283 std::ostream* pfile=0;
286 for (
int crate=0; crate<20; crate++) {
288 for(itreid = allEID.begin(); itreid != allEID.end(); itreid++)
290 if (itreid->readoutVMECrateId()!=crate)
continue;
291 if (itreid->isTriggerChainId()) {
293 if (tid.
null())
continue;
295 if (filePerCrate_ && pfile==0) pfile=openPerCrate(crate);
296 else if (pfile==0) pfile=openPerLut2(*itreid);
298 std::vector<unsigned char> lut=extractOutputLut(*outTranscoder,tid);
299 writeoutlut2(tid,*itreid,lut,*pfile);
300 if (!filePerCrate_) {
delete pfile; pfile=0; }
305 if (filePerCrate_ && pfile==0) pfile=openPerCrate(crate);
306 else if (pfile==0) pfile=openPerLut1(*itreid);
308 std::vector<unsigned short> lut=inputCoder->getLinearizationLUT(
HcalDetId(gid));
309 writeoutlut1(
HcalDetId(gid),*itreid,lut,*pfile);
310 if (!filePerCrate_) {
delete pfile; pfile=0; }
314 if (filePerCrate_) *pfile <<
"</CFGBrickSet>\n";
319 *oc_ <<
"</CFGBrick>\n";
322 outTranscoder->releaseSetup();
333 struct tm* tm=localtime(&now);
334 strftime(buffer,120,
"%F %T",tm);
335 creationstamp_ = buffer;
void md5_init(md5_state_t *pms)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int fiberIndex() const
get the fiber index [1-8] (which of eight fibers carried by a spigot) (valid only for non-trigger-cha...
std::ostream * openPerLut2(HcalElectronicsId eid)
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)
DEFINE_FWK_MODULE(HiMixingModule)
virtual HcalTriggerPrimitiveSample hcalCompress(const HcalTrigTowerDetId &id, unsigned int sample, bool fineGrain) const =0
Compression from linear samples+fine grain in the HTR.
int readoutVMECrateId() const
get the readout VME crate number
std::string targetfirmware_
void md5_finish(md5_state_t *pms, md5_byte_t digest[16])
int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom)
int fiberChanId() const
get the fiber channel id (which of three channels on a readout fiber) (valid only for non-trigger-cha...
std::ostream * openPerCrate(int crate)
int slbChannelIndex() const
get the SLB channel index (valid only for trigger-chain ids)
std::vector< HcalElectronicsId > allElectronicsId() const
bool null() const
is this a null id ?
std::ostream * openPerLut1(HcalElectronicsId eid)
void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
std::string creationstamp_
int slbSiteNumber() const
get the SLB site number (valid only for trigger-chain ids)
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
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 [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
virtual void analyze(const edm::Event &, const edm::EventSetup &)
static const int formatRevision_