#include <CalibCalorimetry/CaloTPG/src/CaloTPGTranscoderULUT.h>
Public Member Functions | |
CaloTPGTranscoderULUT (const std::string &hcalFile1, const std::string &hcalFile2) | |
virtual EcalTriggerPrimitiveSample | ecalCompress (const EcalTrigTowerDetId &id, unsigned int sample, bool fineGrain) const |
Compression from linear samples+fine grain in the ECAL. | |
virtual HcalTriggerPrimitiveSample | hcalCompress (const HcalTrigTowerDetId &id, unsigned int sample, bool fineGrain) const |
Compression from linear samples+fine grain in the HTR. | |
virtual double | hcaletValue (const HcalTrigTowerDetId &hid, const HcalTriggerPrimitiveSample &hc) const |
virtual double | hcaletValue (const int &ieta, const int &compressedValue) const |
void | loadhcalUncompress () |
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. | |
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. | |
virtual | ~CaloTPGTranscoderULUT () |
Private Types | |
typedef unsigned char | LUT |
typedef std::vector< unsigned char > | LUTType |
Private Member Functions | |
virtual int | GetOutputLUTId (const int ieta, const int iphi) const |
virtual bool | HTvalid (const int ieta, const int iphi) const |
void | loadHCAL (const std::string &filename) |
void | loadhcalUncompress (const std::string &filename) |
Private Attributes | |
std::vector< LUTType > | hcal_ |
std::vector< const LUTType * > | hcalITower_ |
double | hcaluncomp_ [33][256] |
LUT * | outputLUT [noutluts] |
std::vector< LUTType > | outputluts_ |
Static Private Attributes | |
static const int | N_TOWER = 32 |
static const int | noutluts = 4176 |
static const unsigned int | OUTPUT_LUT_SIZE = 1024 |
Definition at line 13 of file CaloTPGTranscoderULUT.h.
typedef unsigned char CaloTPGTranscoderULUT::LUT [private] |
Definition at line 42 of file CaloTPGTranscoderULUT.h.
typedef std::vector<unsigned char> CaloTPGTranscoderULUT::LUTType [private] |
Definition at line 34 of file CaloTPGTranscoderULUT.h.
CaloTPGTranscoderULUT::CaloTPGTranscoderULUT | ( | const std::string & | hcalFile1, | |
const std::string & | hcalFile2 | |||
) |
Definition at line 11 of file CaloTPGTranscoderULUT.cc.
References loadHCAL(), and loadhcalUncompress().
00012 : 00013 hcalITower_(N_TOWER,(const LUTType*)0) 00014 { 00015 loadHCAL(hcalFile1); 00016 loadhcalUncompress(hcalFile2); 00017 }
CaloTPGTranscoderULUT::~CaloTPGTranscoderULUT | ( | ) | [virtual] |
EcalTriggerPrimitiveSample CaloTPGTranscoderULUT::ecalCompress | ( | const EcalTrigTowerDetId & | id, | |
unsigned int | sample, | |||
bool | fineGrain | |||
) | const [virtual] |
Compression from linear samples+fine grain in the ECAL.
Implements CaloTPGTranscoder.
Definition at line 199 of file CaloTPGTranscoderULUT.cc.
References Exception.
00199 { 00200 throw cms::Exception("Not Implemented") << "CaloTPGTranscoderULUT::ecalCompress"; 00201 }
int CaloTPGTranscoderULUT::GetOutputLUTId | ( | const int | ieta, | |
const int | iphi | |||
) | const [private, virtual] |
Definition at line 222 of file CaloTPGTranscoderULUT.cc.
References funct::abs(), HTvalid(), noutluts, and offset.
Referenced by hcalCompress(), and loadHCAL().
00222 { 00223 if (HTvalid(ieta, iphi)) { 00224 int offset = 0, ietaabs; 00225 ietaabs = abs(ieta); 00226 if (ieta < 0) offset = noutluts/2; 00227 if (ietaabs < 29) return 72*(ietaabs - 1) + (iphi - 1) + offset; 00228 else return 18*(ietaabs - 29) + iphi + 2015 + offset; 00229 } else return -1; 00230 }
HcalTriggerPrimitiveSample CaloTPGTranscoderULUT::hcalCompress | ( | const HcalTrigTowerDetId & | id, | |
unsigned int | sample, | |||
bool | fineGrain | |||
) | const [virtual] |
Compression from linear samples+fine grain in the HTR.
Implements CaloTPGTranscoder.
Definition at line 170 of file CaloTPGTranscoderULUT.cc.
References funct::abs(), Exception, GetOutputLUTId(), OUTPUT_LUT_SIZE, and outputLUT.
00170 { 00171 int ieta = id.ieta(); 00172 int iphi = id.iphi(); 00173 if (abs(ieta) > 28) iphi = iphi/4 + 1; // Changing iphi index from 1, 5, ..., 69 to 1, 2, ..., 18 00174 int itower = GetOutputLUTId(ieta,iphi); 00175 // std::cout << "Compressing ieta, iphi, tower: " << ieta << ", " << iphi << ", " << itower << std::endl; 00176 if (itower < 0) cms::Exception("Invalid Data") << "No trigger tower found for ieta, iphi = " << ieta << ", " << iphi; 00177 if (sample >= OUTPUT_LUT_SIZE) { 00178 // std::cout << "Out of range entry in the LUT: " << sample << std::endl; 00179 throw cms::Exception("Out of Range") << "LUT has 1024 entries for " << itower << " but " << sample << " was requested."; 00180 sample=OUTPUT_LUT_SIZE - 1; 00181 } 00182 // std::cout << id << ":" << sample << "-->" << (*lut)[sample] << std::endl; 00183 return HcalTriggerPrimitiveSample(outputLUT[itower][sample],fineGrain,0,0); 00184 }
double CaloTPGTranscoderULUT::hcaletValue | ( | const HcalTrigTowerDetId & | hid, | |
const HcalTriggerPrimitiveSample & | hc | |||
) | const [virtual] |
Definition at line 192 of file CaloTPGTranscoderULUT.cc.
References HcalTriggerPrimitiveSample::compressedEt(), hcaluncomp_, and HcalTrigTowerDetId::ietaAbs().
00192 { 00193 int ieta = hid.ietaAbs(); 00194 int compET = hc.compressedEt(); 00195 double etvalue = hcaluncomp_[ieta][compET];//*cos(eta_ave); 00196 return(etvalue); 00197 }
double CaloTPGTranscoderULUT::hcaletValue | ( | const int & | ieta, | |
const int & | compressedValue | |||
) | const [virtual] |
Implements CaloTPGTranscoder.
Definition at line 187 of file CaloTPGTranscoderULUT.cc.
References hcaluncomp_.
00187 { 00188 double etvalue = hcaluncomp_[ieta][compET];//*cos(eta_ave); 00189 return(etvalue); 00190 }
Definition at line 214 of file CaloTPGTranscoderULUT.cc.
References funct::abs().
Referenced by GetOutputLUTId(), and loadHCAL().
00214 { 00215 if (iphi <= 0 || ieta == 0) return false; 00216 if (abs(ieta) > 32) return false; 00217 else if (abs(ieta) > 28 && iphi > 18) return false; 00218 else if (iphi > 72) return false; 00219 return true; 00220 }
void CaloTPGTranscoderULUT::loadHCAL | ( | const std::string & | filename | ) | [private] |
Definition at line 26 of file CaloTPGTranscoderULUT.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), Exception, GetOutputLUTId(), HTvalid(), i, id, index, j, noutluts, OUTPUT_LUT_SIZE, outputLUT, outputluts_, muonGeometry::rawid, and s.
Referenced by CaloTPGTranscoderULUT().
00026 { 00027 int tool; 00028 std::ifstream userfile; 00029 00030 // std::cout << "Initializing compression LUT's" << std::endl; 00031 for (int i = 0; i < noutluts; i++) outputLUT[i] = 0; 00032 int maxid = 0, minid = 0x7FFFFFFF, rawid = 0; 00033 for (int ieta=-32; ieta <= 32; ieta++) { 00034 for (int iphi = 1; iphi <= 72; iphi++) { 00035 if (HTvalid(ieta,iphi)) { 00036 rawid = GetOutputLUTId(ieta, iphi); 00037 if (outputLUT[rawid] != 0) std::cout << "Error: LUT with (ieta,iphi) = (" << ieta << "," << iphi << ") has been previously allocated!" << std::endl; 00038 else outputLUT[rawid] = new LUT[OUTPUT_LUT_SIZE]; 00039 if (rawid < minid) minid = rawid; 00040 if (rawid > maxid) maxid = rawid; 00041 } 00042 } 00043 } 00044 00045 userfile.open((char *)filename.data()); 00046 //std::cout << filename << std::endl; 00047 if( userfile ) { 00048 int nluts = 0; 00049 std::string s; 00050 std::vector<int> loieta,hiieta; 00051 std::vector<int> loiphi,hiiphi; 00052 getline(userfile,s); 00053 //std::cout << "Reading Compression LUT's for: " << s << std::endl; 00054 getline(userfile,s); 00055 // 00056 unsigned int index = 0; 00057 while (index < s.length()) { 00058 while (isspace(s[index])) index++; 00059 if (index < s.length()) nluts++; 00060 while (!isspace(s[index])) index++; 00061 } 00062 //std::cout << "Found " << nluts << " LUTs" << std::endl; 00063 for (unsigned int i=0; i<=s.length(); i++) userfile.unget(); //rewind last line 00064 00065 outputluts_.resize(nluts); 00066 for (int i=0; i<nluts; i++) { 00067 outputluts_[i].resize(OUTPUT_LUT_SIZE); 00068 } 00069 00070 //std::cout << "EtaMin = "; 00071 for (int i=0; i<nluts; i++) { 00072 userfile >> tool; 00073 loieta.push_back(tool); 00074 // std::cout << tool << " "; 00075 } 00076 //std::cout << std::endl << "EtaMax = "; 00077 for (int i=0; i<nluts; i++) { 00078 userfile >> tool; 00079 hiieta.push_back(tool); 00080 // std::cout << tool << " "; 00081 } 00082 //std::cout << std::endl << "PhiMin = "; 00083 for (int i=0; i<nluts; i++) { 00084 userfile >> tool; 00085 loiphi.push_back(tool); 00086 // std::cout << tool << " "; 00087 } 00088 //std::cout << std::endl << "PhiMax = "; 00089 for (int i=0; i<nluts; i++) { 00090 userfile >> tool; 00091 hiiphi.push_back(tool); 00092 // std::cout << tool << " "; 00093 } 00094 //std::cout << std::endl; 00095 00096 for (unsigned int j=0; j<OUTPUT_LUT_SIZE; j++) { 00097 for(int i=0; i <nluts; i++) { 00098 userfile >> tool; 00099 if (tool < 0) { 00100 std::cout << "Error: LUT can't have negative numbers; 0 used instead: " << i << ", " << j << " : = " << tool << std::endl; 00101 tool = 0; 00102 } else if (tool > 0xff) { 00103 std::cout << "Error: LUT can't have >8-bit numbers; 0xff used instead: " << i << ", " << j << " : = " << tool << std::endl; 00104 tool = 0xff; 00105 } 00106 outputluts_[i][j] = tool; 00107 if (userfile.eof()) std::cout << "Error: LUT file is truncated or has a wrong format: " << i << "," << j << std::endl; 00108 } 00109 } 00110 userfile.close(); 00111 00112 HcalDetId cell; 00113 int id, ntot = 0; 00114 for (int i=0; i < nluts; i++) { 00115 int nini = 0; 00116 for (int iphi = loiphi[i]; iphi <= hiiphi[i]; iphi++) { 00117 for (int ieta=loieta[i]; ieta <= hiieta[i]; ieta++) { 00118 if (HTvalid(ieta,iphi)) { 00119 id = GetOutputLUTId(ieta,iphi); 00120 if (outputLUT[id] == 0) throw cms::Exception("PROBLEM: outputLUT has not been initialized for ieta, iphi, id = ") << ieta << ", " << iphi << ", " << id << std::endl; 00121 for (int j = 0; j <= 0x3ff; j++) outputLUT[id][j] = outputluts_[i][j]; 00122 nini++; 00123 ntot++; 00124 } 00125 } 00126 } 00127 //std::cout << nini << " LUT's have been initialized for eta = [" << loieta[i] << "," << hiieta[i] << "]; iphi = [" << loiphi[i] << "," << hiiphi[i] << "]" << std::endl; 00128 } 00129 //std::cout << "Total of " << ntot << " comression LUT's have been initialized" << std::endl; 00130 } 00131 00132 /* 00133 // map |ieta| to LUT 00134 for (int j=1; j<=N_TOWER; j++) { 00135 int ilut=-1; 00136 for (ilut=0; ilut<nluts; ilut++) 00137 if (j>=loieta[ilut] && j<=hiieta[ilut]) break; 00138 if (ilut==nluts) { 00139 hcalITower_[j-1]=0; 00140 // TODO: log warning 00141 } 00142 else hcalITower_[j-1]=&(hcal_[ilut]); 00143 // std::cout << j << "->" << ilut << std::endl; 00144 } 00145 } else { 00146 throw cms::Exception("Invalid Data") << "Unable to read " << filename; 00147 } */ 00148 }
void CaloTPGTranscoderULUT::loadhcalUncompress | ( | const std::string & | filename | ) | [private] |
Definition at line 150 of file CaloTPGTranscoderULUT.cc.
References Exception, hcaluncomp_, i, and j.
00150 { 00151 std::ifstream userfile; 00152 userfile.open(filename.c_str()); 00153 static const int etabound = 32; 00154 static const int tpgmax = 256; 00155 if( userfile ) 00156 { 00157 for (int i=0; i<tpgmax; i++) { 00158 for(int j = 1; j <=etabound; j++) { 00159 userfile >> hcaluncomp_[j][i];} 00160 } 00161 // cout<<"test hcal"<<endl; 00162 userfile.close(); 00163 00164 } 00165 else { 00166 throw cms::Exception("Invalid Data") << "Unable to read uncompress file" << filename; 00167 } 00168 }
void CaloTPGTranscoderULUT::loadhcalUncompress | ( | ) |
Referenced by CaloTPGTranscoderULUT().
void CaloTPGTranscoderULUT::rctEGammaUncompress | ( | const HcalTrigTowerDetId & | hid, | |
const HcalTriggerPrimitiveSample & | hc, | |||
const EcalTrigTowerDetId & | eid, | |||
const EcalTriggerPrimitiveSample & | ec, | |||
unsigned int & | et, | |||
bool & | egVeto, | |||
bool & | activity | |||
) | const [virtual] |
Uncompression for the Electron/Photon path in the RCT.
Implements CaloTPGTranscoder.
Definition at line 203 of file CaloTPGTranscoderULUT.cc.
References Exception.
00205 { 00206 throw cms::Exception("Not Implemented") << "CaloTPGTranscoderULUT::rctEGammaUncompress"; 00207 }
void CaloTPGTranscoderULUT::rctJetUncompress | ( | const HcalTrigTowerDetId & | hid, | |
const HcalTriggerPrimitiveSample & | hc, | |||
const EcalTrigTowerDetId & | eid, | |||
const EcalTriggerPrimitiveSample & | ec, | |||
unsigned int & | et | |||
) | const [virtual] |
Uncompression for the JET path in the RCT.
Implements CaloTPGTranscoder.
Definition at line 208 of file CaloTPGTranscoderULUT.cc.
References Exception.
00210 { 00211 throw cms::Exception("Not Implemented") << "CaloTPGTranscoderULUT::rctJetUncompress"; 00212 }
std::vector<LUTType> CaloTPGTranscoderULUT::hcal_ [private] |
Definition at line 35 of file CaloTPGTranscoderULUT.h.
std::vector<const LUTType*> CaloTPGTranscoderULUT::hcalITower_ [private] |
Definition at line 36 of file CaloTPGTranscoderULUT.h.
double CaloTPGTranscoderULUT::hcaluncomp_[33][256] [private] |
Definition at line 44 of file CaloTPGTranscoderULUT.h.
Referenced by hcaletValue(), and loadhcalUncompress().
const int CaloTPGTranscoderULUT::N_TOWER = 32 [static, private] |
Definition at line 32 of file CaloTPGTranscoderULUT.h.
const int CaloTPGTranscoderULUT::noutluts = 4176 [static, private] |
Definition at line 32 of file CaloTPGTranscoderULUT.h.
Referenced by GetOutputLUTId(), loadHCAL(), and ~CaloTPGTranscoderULUT().
const unsigned int CaloTPGTranscoderULUT::OUTPUT_LUT_SIZE = 1024 [static, private] |
Definition at line 33 of file CaloTPGTranscoderULUT.h.
Referenced by hcalCompress(), and loadHCAL().
LUT* CaloTPGTranscoderULUT::outputLUT[noutluts] [private] |
Definition at line 43 of file CaloTPGTranscoderULUT.h.
Referenced by hcalCompress(), loadHCAL(), and ~CaloTPGTranscoderULUT().
std::vector<LUTType> CaloTPGTranscoderULUT::outputluts_ [private] |