19 : isLoaded_(
false), nominal_gain_(0.), rctlsb_factor_(0.),
20 compressionFile_(compressionFile),
21 decompressionFile_(decompressionFile)
42 analyticalLUT[
i] = (
unsigned int)(
sqrt(14.94*
log(1.+
i/14.94)*
i) + 0.5);
43 identityLUT[
i] =
min(
i,0xffu);
46 for (
int ieta=-32; ieta <= 32; ieta++){
47 for (
int iphi = 1; iphi <= 72; iphi++){
48 if (!
HTvalid(ieta,iphi))
continue;
52 std::cout <<
"Error: LUT with (ieta,iphi) = (" << ieta <<
"," << iphi <<
") has been previously allocated!" << std::endl;
73 std::ifstream userfile;
74 std::vector< std::vector<LUT> > outputluts;
76 std::cout <<
"Initializing compression LUT's from " << (
char *)filename.data() << std::endl;
78 int maxid = 0, minid = 0x7FFFFFFF, rawid = 0;
79 for (
int ieta=-32; ieta <= 32; ieta++) {
80 for (
int iphi = 1; iphi <= 72; iphi++) {
83 if (
outputLUT_[rawid] != 0)
std::cout <<
"Error: LUT with (ieta,iphi) = (" << ieta <<
"," << iphi <<
") has been previously allocated!" << std::endl;
85 if (rawid < minid) minid = rawid;
86 if (rawid > maxid) maxid = rawid;
91 userfile.open((
char *)filename.data());
96 std::vector<int> loieta,hiieta;
97 std::vector<int> loiphi,hiiphi;
102 unsigned int index = 0;
103 while (index < s.length()) {
104 while (isspace(s[index])) index++;
105 if (index < s.length()) nluts++;
106 while (!isspace(s[index])) index++;
108 for (
unsigned int i=0;
i<=s.length();
i++) userfile.unget();
109 outputluts.resize(nluts);
113 for (
int i=0;
i<nluts;
i++) {
115 loieta.push_back(tool);
118 for (
int i=0;
i<nluts;
i++) {
120 hiieta.push_back(tool);
123 for (
int i=0;
i<nluts;
i++) {
125 loiphi.push_back(tool);
129 for (
int i=0;
i<nluts;
i++) {
131 hiiphi.push_back(tool);
136 for(
int i=0;
i <nluts;
i++) {
139 std::cout <<
"Error: LUT can't have negative numbers; 0 used instead: " <<
i <<
", " <<
j <<
" : = " << tool << std::endl;
141 }
else if (tool > 0xff) {
142 std::cout <<
"Error: LUT can't have >8-bit numbers; 0xff used instead: " <<
i <<
", " <<
j <<
" : = " << tool << std::endl;
145 outputluts[
i][
j] = tool;
146 if (userfile.eof())
std::cout <<
"Error: LUT file is truncated or has a wrong format: " <<
i <<
"," <<
j << std::endl;
153 for (
int i=0;
i < nluts;
i++) {
155 for (
int iphi = loiphi[
i]; iphi <= hiiphi[
i]; iphi++) {
156 for (
int ieta=loieta[
i]; ieta <= hiieta[
i]; ieta++) {
159 if (
outputLUT_[
id] == 0)
throw cms::Exception(
"PROBLEM: outputLUT_ has not been initialized for ieta, iphi, id = ") << ieta <<
", " << iphi <<
", " <<
id << std::endl;
182 for (
int ieta = -32; ieta <= 32; ++ieta){
184 double eta_low = 0., eta_high = 0.;
186 double cosh_ieta = fabs(cosh((eta_low + eta_high)/2.));
188 for (
int iphi = 1; iphi <= 72; iphi++) {
189 if (!
HTvalid(ieta, iphi))
continue;
209 unsigned int mid = (low +
i)/2;
210 hcaluncomp_[lutId][tpg] = (tpg == 0 ? low : factor * mid);
221 std::ifstream userfile;
222 userfile.open(filename.c_str());
227 static const int etabound = 32;
231 for(
int j = 1;
j <=etabound;
j++) {
233 for (
int iphi = 1; iphi <= 72; iphi++) {
250 int ieta =
id.ieta();
251 int iphi =
id.iphi();
255 if (itower < 0)
cms::Exception(
"Invalid Data") <<
"No trigger tower found for ieta, iphi = " << ieta <<
", " << iphi;
258 throw cms::Exception(
"Out of Range") <<
"LUT has 1024 entries for " << itower <<
" but " << sample <<
" was requested.";
272 if (itower < 0)
std::cout <<
"hcaletValue error: no decompression LUT found for ieta, iphi = " << ieta <<
", " << iphi << std::endl;
273 else if (compET < 0 || compET > 0xff)
std::cout <<
"hcaletValue error: compressed value out of range: eta, phi, cET = " << ieta <<
", " << iphi <<
", " << compET << std::endl;
288 if (compET < 0 || compET > 0xff)
std::cout <<
"hcaletValue error: compressed value out of range: eta, cET = " << ieta <<
", " << compET << std::endl;
291 for (
int iphi=1; iphi <= 72; iphi++) {
298 if (nphi > 0) etvalue /= nphi;
299 else std::cout <<
"hcaletValue error: no decompression LUTs found for any iphi for ieta = " << ieta << std::endl;
307 int ieta = hid.
ieta();
308 int iphi = hid.
iphi();
316 throw cms::Exception(
"Not Implemented") <<
"CaloTPGTranscoderULUT::ecalCompress";
321 unsigned int& et,
bool& egVecto,
bool& activity)
const {
322 throw cms::Exception(
"Not Implemented") <<
"CaloTPGTranscoderULUT::rctEGammaUncompress";
326 unsigned int& et)
const {
327 throw cms::Exception(
"Not Implemented") <<
"CaloTPGTranscoderULUT::rctJetUncompress";
332 if (iphi <= 0 || iphi > 72 || ieta == 0 ||
abs(ieta) > 32)
return false;
333 if (
abs(ieta) > 28) {
335 if ((iphi/4)*4 + 1 != iphi)
return false;
338 if (iphi > 18)
return false;
349 if (ietaabs < 29)
return 72*(ietaabs - 1) + (iphi - 1) +
offset;
352 return 18*(ietaabs - 29) + iphi + 2015 + offset;
358 std::vector<unsigned char>
lut;
375 if (rctlsb != 0.25 && rctlsb != 0.5)
376 throw cms::Exception(
"RCTLSB") <<
" value=" << rctlsb <<
" (should be 0.25 or 0.5)" << std::endl;
384 std::cout <<
"From Text File:" << std::endl;
391 std::cout <<
"RCT Decompression table" << std::endl;
392 for (
int i=0;
i < 256;
i++) {
std::vector< RCTdecompression > hcaluncomp_
edm::ESHandle< HcalLutMetadata > lutMetadata_
virtual void setup(const edm::EventSetup &es, Mode) const
Obtain any needed objects from the EventSetup. Note that any member variables which are changed must ...
std::string decompressionFile_
CaloTPGTranscoderULUT(const std::string &compressionFile="", const std::string &decompressionFile="")
virtual std::vector< unsigned char > getCompressionLUT(HcalTrigTowerDetId id) const
edm::ESHandle< HcalTrigTowerGeometry > theTrigTowerGeometry
int ieta() const
get the tower ieta
virtual ~CaloTPGTranscoderULUT()
virtual void rctJetUncompress(const HcalTrigTowerDetId &hid, const HcalTriggerPrimitiveSample &hc, const EcalTrigTowerDetId &eid, const EcalTriggerPrimitiveSample &ec, unsigned int &et) const
Uncompression for the JET path in the RCT.
Abs< T >::type abs(const T &t)
static const unsigned int OUTPUT_LUT_SIZE
virtual void rctEGammaUncompress(const HcalTrigTowerDetId &hid, const HcalTriggerPrimitiveSample &hc, const EcalTrigTowerDetId &eid, const EcalTriggerPrimitiveSample &ec, unsigned int &et, bool &egVecto, bool &activity) const
Uncompression for the Electron/Photon path in the RCT.
unsigned int offset(bool)
virtual bool HTvalid(const int ieta, const int iphi) const
void printDecompression() const
LUT * outputLUT_[NOUTLUTS]
std::vector< double > RCTdecompression
std::string compressionFile_
virtual double hcaletValue(const int &ieta, const int &compressedValue) const
static const int NOUTLUTS
virtual int getOutputLUTId(const int ieta, const int iphi) const
void loadHCALCompress(void) const
int compressedEt() const
get the encoded/compressed Et
virtual EcalTriggerPrimitiveSample ecalCompress(const EcalTrigTowerDetId &id, unsigned int sample, bool fineGrain) const
Compression from linear samples+fine grain in the ECAL.
static const bool newHFphi
volatile std::atomic< bool > shutdown_flag false
void loadHCALUncompress(void) const
virtual HcalTriggerPrimitiveSample hcalCompress(const HcalTrigTowerDetId &id, unsigned int sample, bool fineGrain) const
Compression from linear samples+fine grain in the HTR.
int iphi() const
get the tower iphi