test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
L1GtVhdlWriterBitManager Class Reference

#include <L1GtVhdlWriterBitManager.h>

Public Member Functions

std::string bin2hex (std::string binString)
 
std::string buildDeltaEtaCalo (const L1GtCaloTemplate::CorrelationParameter *&cp, const unsigned int &counter)
 
std::string buildDeltaEtaMuon (const L1GtMuonTemplate::CorrelationParameter *&cp, const unsigned int &counter)
 
std::string buildDeltaPhiCalo (const L1GtCaloTemplate::CorrelationParameter *&cp, const unsigned int &counter)
 
std::string buildDeltaPhiMuon (const L1GtMuonTemplate::CorrelationParameter *&cp, const unsigned int &counter)
 
std::string buildEtaCalo (const std::vector< L1GtCaloTemplate::ObjectParameter > *op, const unsigned int &num, const unsigned int &counter)
 
std::string buildEtaMuon (const std::vector< L1GtMuonTemplate::ObjectParameter > *op, const unsigned int &num, const unsigned int &counter)
 
std::string buildPhiCalo (const std::vector< L1GtCaloTemplate::ObjectParameter > *op, const unsigned int &num, const unsigned int &counter)
 
std::string buildPhiEnergySum (const std::vector< L1GtEnergySumTemplate::ObjectParameter > *op, const unsigned int &num, const unsigned int &counter)
 
std::string buildPhiMuon (const std::vector< L1GtMuonTemplate::ObjectParameter > *op, const unsigned int &num, const unsigned int &counter, bool high)
 
std::string capitalLetters (std::string hexString)
 
std::string hex2bin (std::string hexString)
 
 L1GtVhdlWriterBitManager ()
 
std::string mirror (unsigned int offset, std::string hexString, bool hexOutput=true)
 
std::string readMapInverse (const std::map< std::string, std::string > &map, std::string value)
 
std::string shiftLeft (std::string hexString)
 

Private Attributes

std::map< std::string,
std::string > 
hex2binMap_
 

Detailed Description

This class builds the LUTS for the GT firmware. Furthermore it is providing some helpers for basic bit operations in binary and hex format.

Implementation: <TODO: enter implementation details>

Author
Philipp Wagner

Definition at line 33 of file L1GtVhdlWriterBitManager.h.

Constructor & Destructor Documentation

L1GtVhdlWriterBitManager::L1GtVhdlWriterBitManager ( )

Definition at line 34 of file L1GtVhdlWriterBitManager.cc.

References hex2binMap_.

35 {
36  hex2binMap_["0"]="0000";
37  hex2binMap_["1"]="0001";
38  hex2binMap_["2"]="0010";
39  hex2binMap_["3"]="0011";
40  hex2binMap_["4"]="0100";
41  hex2binMap_["5"]="0101";
42  hex2binMap_["6"]="0110";
43  hex2binMap_["7"]="0111";
44  hex2binMap_["8"]="1000";
45  hex2binMap_["9"]="1001";
46 
47  hex2binMap_["A"]="1010";
48  hex2binMap_["B"]="1011";
49  hex2binMap_["C"]="1100";
50  hex2binMap_["D"]="1101";
51  hex2binMap_["E"]="1110";
52  hex2binMap_["F"]="1111";
53 
54  hex2binMap_["a"]="1010";
55  hex2binMap_["b"]="1011";
56  hex2binMap_["c"]="1100";
57  hex2binMap_["d"]="1101";
58  hex2binMap_["e"]="1110";
59  hex2binMap_["f"]="1111";
60 }
std::map< std::string, std::string > hex2binMap_

Member Function Documentation

std::string L1GtVhdlWriterBitManager::bin2hex ( std::string  binString)

Definition at line 92 of file L1GtVhdlWriterBitManager.cc.

References hex2binMap_, i, readMapInverse(), AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

Referenced by buildDeltaEtaCalo(), buildDeltaPhiCalo(), buildDeltaPhiMuon(), mirror(), and shiftLeft().

93 {
94 
96  for (unsigned int i=1; i<=binString.length(); i++)
97  {
98  //std::cout<<i%4<<std::endl;
99  if(i%4==0)
100  {
101  //std::cout<<"I'm here!"<<std::endl;
102  std::string str;
103  str = binString.substr(i-4,4);
104  //std::cout<<str<<std::cout<<std::endl;
105  temp+=readMapInverse(hex2binMap_,str);
106  }
107  }
108 
109  return temp;
110 }
int i
Definition: DBlmapReader.cc:9
std::map< std::string, std::string > hex2binMap_
std::string readMapInverse(const std::map< std::string, std::string > &map, std::string value)
std::string L1GtVhdlWriterBitManager::buildDeltaEtaCalo ( const L1GtCaloTemplate::CorrelationParameter *&  cp,
const unsigned int &  counter 
)

Definition at line 312 of file L1GtVhdlWriterBitManager.cc.

References bin2hex(), capitalLetters(), TauDecayModes::dec, hex2bin(), mirror(), mps_fire::result, shiftLeft(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by L1GtVhdlWriterCore::getCaloSetupContentFromTriggerMenu().

313 {
314  std::ostringstream deltaEtaRange, dEta,res;
315 
316  //std::cout<<"b:"<<.hex2bin("00383800")<<std::endl;
317 
318  deltaEtaRange << std::hex<< std::setw(4)<<std::setfill('0')<<(*cp).deltaEtaRange<<std::dec;
319 
320  // mirror deltaEtaRang and shift the mirrored value to the left by one bit;
321  // add the original value to the calculated value
322  dEta<<hex2bin(shiftLeft(mirror(0,deltaEtaRange.str())))<<hex2bin(deltaEtaRange.str());
323 
324  std::string result = capitalLetters(bin2hex(dEta.str()));
325 
326  res<<counter<<" => X\""<<result<<"\",\n";
327 
328  return res.str();
329 
330 }
std::string capitalLetters(std::string hexString)
tuple result
Definition: mps_fire.py:83
std::string hex2bin(std::string hexString)
std::string mirror(unsigned int offset, std::string hexString, bool hexOutput=true)
std::string shiftLeft(std::string hexString)
static std::atomic< unsigned int > counter
std::string bin2hex(std::string binString)
std::string L1GtVhdlWriterBitManager::buildDeltaEtaMuon ( const L1GtMuonTemplate::CorrelationParameter *&  cp,
const unsigned int &  counter 
)

Definition at line 333 of file L1GtVhdlWriterBitManager.cc.

References capitalLetters(), TauDecayModes::dec, mirror(), mps_fire::result, shiftLeft(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by L1GtVhdlWriterCore::getMuonSetupContentFromTriggerMenu().

334 {
335  std::ostringstream deltaEtaRange, dEta;
336  deltaEtaRange << std::hex<< std::setw(16)<<std::setfill('0')<<(*cp).deltaEtaRange<<std::dec;
337 
338  // mirror deltaEtaRang and shift the mirrored value to the left by one bit;
339  // add the original value to the calculated value
340 
341  std::string result = capitalLetters((shiftLeft(mirror(0,deltaEtaRange.str()))+deltaEtaRange.str()));
342 
343  dEta<<counter<<" => X\""<<result<<"\",\n";
344 
345  return dEta.str();
346 
347 }
std::string capitalLetters(std::string hexString)
tuple result
Definition: mps_fire.py:83
std::string mirror(unsigned int offset, std::string hexString, bool hexOutput=true)
std::string shiftLeft(std::string hexString)
static std::atomic< unsigned int > counter
std::string L1GtVhdlWriterBitManager::buildDeltaPhiCalo ( const L1GtCaloTemplate::CorrelationParameter *&  cp,
const unsigned int &  counter 
)

Definition at line 350 of file L1GtVhdlWriterBitManager.cc.

References bin2hex(), capitalLetters(), TauDecayModes::dec, dPhi(), hex2bin(), mirror(), mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by L1GtVhdlWriterCore::getCaloSetupContentFromTriggerMenu().

351 {
352  std::ostringstream dPhi,deltaPhiRange, result;
353  //std::cout<<.hex2bin("03E0000000000F81")<<std::endl;
354  //std::cout<<.hex2bin("0080000000000200")<<std::endl;
355 
356  deltaPhiRange << std::hex<<std::setw(3)<<std::setfill('0')<<(*cp).deltaPhiRange<<std::dec;
357 
358  std::string binString = hex2bin(deltaPhiRange.str());
359 
360  //std::cout <<"========================" <<std::endl;
361 
362  std::string help2 = binString.substr(2,binString.length()-2);
363  std::string help1 = help2.substr(1);
364  help1 = mirror(0,bin2hex(help1),false);
365 
366  // here delta phi is built
367  result<<help1;
368 
369  // might be wrong - has to be tested with more reference values!
370  result<<help2.substr(0,8);
371  result<<"0";
372 
373  result<<"00000000000000000000000000000";
374 
375  result<<help1;
376 
377  result<<binString.substr(2,binString.length()-2);
378 
379  dPhi<<counter<<" => X\""<<bin2hex(result.str())<<"\",\n";
380 
381  //std::cout<<result<<std::endl;
382 
383  /*
384  * Code from old GTS:
385  bm_dphi = bm_dphi.Get(2);
386  BitMngr help1, help2 = bm_dphi;
387  help2.SetAt(9, '\0');
388  help1 = help2.Get(1);
389  help1.Mirror();
390  BitMngr nuller;
391  nuller.InitBin("00 00 00 00 00 00 00 00 00 00 00 00 00 00 0");
392  BitMngr result;
393  result = result + help1 + help2 + nuller + help1 + bm_dphi;
394  dphi = result.GetHex();
395  */
396 
397  return capitalLetters(dPhi.str());
398 }
std::string capitalLetters(std::string hexString)
tuple result
Definition: mps_fire.py:83
std::string hex2bin(std::string hexString)
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
std::string mirror(unsigned int offset, std::string hexString, bool hexOutput=true)
static std::atomic< unsigned int > counter
std::string bin2hex(std::string binString)
std::string L1GtVhdlWriterBitManager::buildDeltaPhiMuon ( const L1GtMuonTemplate::CorrelationParameter *&  cp,
const unsigned int &  counter 
)

Definition at line 401 of file L1GtVhdlWriterBitManager.cc.

References bin2hex(), TauDecayModes::dec, dPhi(), hex2bin(), mirror(), mps_fire::result, shiftLeft(), AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

Referenced by L1GtVhdlWriterCore::getMuonSetupContentFromTriggerMenu().

402 {
403  std::ostringstream dPhi,deltaPhiRange0,deltaPhiRange1,temp,result ;
404  std::string tempstr;
405 
406  deltaPhiRange0 << std::hex<< std::setw(16)<<std::setfill('0')<<(*cp).deltaPhiRange0Word<<std::dec;
407  //deltaPhiRange1 /*<< std::hex<< std::setw(3)<<std::setfill('0')*/<<(*cp).deltaPhiRange1Word<<std::dec;
408 
409  //mirror deltaPhiRange, shift the mirrored value left and convert it to binary format
410  temp<<hex2bin(shiftLeft(mirror(0,deltaPhiRange0.str())));
411  tempstr=temp.str();
412  // set last bit of tempstr to one;
413  tempstr[tempstr.length()-1]='1';
414 
415  // build delta eta as stringstreamtau
416  result
417  <<tempstr
418  // insert 16 ones
419  <<hex2bin("FFFF")
420  <<hex2bin(deltaPhiRange0.str());
421 
422  dPhi<<counter<<" => X\""<<bin2hex(result.str())<<"\",\n";
423 
424  return dPhi.str();
425 
426 }
tuple result
Definition: mps_fire.py:83
std::string hex2bin(std::string hexString)
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
std::string mirror(unsigned int offset, std::string hexString, bool hexOutput=true)
std::string shiftLeft(std::string hexString)
static std::atomic< unsigned int > counter
std::string bin2hex(std::string binString)
std::string L1GtVhdlWriterBitManager::buildEtaCalo ( const std::vector< L1GtCaloTemplate::ObjectParameter > *  op,
const unsigned int &  num,
const unsigned int &  counter 
)

Definition at line 216 of file L1GtVhdlWriterBitManager.cc.

References TauDecayModes::dec, i, and pileupDistInMC::num.

Referenced by L1GtVhdlWriterCore::getCaloSetupContentFromTriggerMenu().

217 {
218  std::ostringstream ossEta;
219 
220  ossEta
221  <<counter
222  <<" => X\"";
223 
224  // loop over all relevant components of object parameters
225 
226  for (unsigned int i =0; i<num; i++)
227  {
228  std::ostringstream ossEtaRange;
229 
230  ossEtaRange << std::hex <<std::setw(4)<<std::setfill('0')<< (*op).at(i).etaRange<<std::dec;
231 
232  /*
233  std::string tempstr=hex2bin(ossEtaRange.str());
234  tempstr[0]='0';
235  tempstr[15]='0';
236  */
237 
238  //ossEta<<std::setw(4)<<std::setfill('0')<<mirror(8,bin2hex(tempstr));
239 
240  ossEta << ossEtaRange.str();
241 
242  if (num>0 && i!=num-1) ossEta <<"_";
243 
244  }
245 
246  ossEta<<"\",\n";
247  return ossEta.str();
248 }
int i
Definition: DBlmapReader.cc:9
static std::atomic< unsigned int > counter
std::string L1GtVhdlWriterBitManager::buildEtaMuon ( const std::vector< L1GtMuonTemplate::ObjectParameter > *  op,
const unsigned int &  num,
const unsigned int &  counter 
)

Definition at line 186 of file L1GtVhdlWriterBitManager.cc.

References TauDecayModes::dec, i, and pileupDistInMC::num.

Referenced by L1GtVhdlWriterCore::getMuonSetupContentFromTriggerMenu().

187 {
188  std::ostringstream ossEta;
189 
190  ossEta
191  <<counter
192  <<" => X\"";
193 
194  for (unsigned int i =0; i<num; i++)
195  {
196  std::ostringstream ossEtaRange;
197  ossEtaRange << std::hex<< std::setw(16)<<std::setfill('0')<<(*op).at(i).etaRange<<std::dec;
198 
199  /*
200  ossEta
201  <<mirror(32,ossEtaRange.str());
202  */
203 
204  ossEta << ossEtaRange.str();
205 
206  if (num>0 && i!=num-1) ossEta <<"_";
207 
208  }
209 
210  ossEta<<"\",\n";
211  return ossEta.str();
212 
213 }
int i
Definition: DBlmapReader.cc:9
static std::atomic< unsigned int > counter
std::string L1GtVhdlWriterBitManager::buildPhiCalo ( const std::vector< L1GtCaloTemplate::ObjectParameter > *  op,
const unsigned int &  num,
const unsigned int &  counter 
)

Definition at line 251 of file L1GtVhdlWriterBitManager.cc.

References capitalLetters(), TauDecayModes::dec, i, and pileupDistInMC::num.

Referenced by L1GtVhdlWriterCore::getCaloSetupContentFromTriggerMenu().

252 {
253  std::ostringstream ossPhi;
254 
255  ossPhi
256  <<counter
257  <<" => X\"";
258 
259  for (unsigned int i =0; i<num; i++)
260  {
261  ossPhi << std::hex<< std::setw(8)<<std::setfill('0')<<(*op).at(i).phiRange<<std::dec;
262 
263  if (num>0 && i!=num-1) ossPhi <<"_";
264  }
265 
266  ossPhi<<"\",\n";
267  return capitalLetters(ossPhi.str());
268 }
int i
Definition: DBlmapReader.cc:9
std::string capitalLetters(std::string hexString)
static std::atomic< unsigned int > counter
std::string L1GtVhdlWriterBitManager::buildPhiEnergySum ( const std::vector< L1GtEnergySumTemplate::ObjectParameter > *  op,
const unsigned int &  num,
const unsigned int &  counter 
)

Definition at line 271 of file L1GtVhdlWriterBitManager.cc.

References capitalLetters(), KineDebug3::count(), counter, and TauDecayModes::dec.

Referenced by L1GtVhdlWriterCore::getEsumsSetupContentFromTriggerMenu().

272 {
273  std::ostringstream ossPhi,count;
274 
275  if ((*op).at(0).phiRange0Word!=0)
276  {
277  ossPhi << "000000000000000000"<<std::hex<<(*op).at(0).phiRange1Word<<(*op).at(0).phiRange0Word<<std::dec;
278 
279  count<<counter;
280 
281  return (count.str()+" => X\""+capitalLetters(ossPhi.str())+"\",\n");
282 
283  } else
284  return "";
285 }
std::string capitalLetters(std::string hexString)
static std::atomic< unsigned int > counter
std::string L1GtVhdlWriterBitManager::buildPhiMuon ( const std::vector< L1GtMuonTemplate::ObjectParameter > *  op,
const unsigned int &  num,
const unsigned int &  counter,
bool  high 
)
Parameters
highis true in order to build phiHigh and false in order to build phiLow

Definition at line 288 of file L1GtVhdlWriterBitManager.cc.

References capitalLetters(), TauDecayModes::dec, i, and pileupDistInMC::num.

Referenced by L1GtVhdlWriterCore::getMuonSetupContentFromTriggerMenu().

289 {
290  std::ostringstream ossPhi;
291 
292  ossPhi
293  <<counter
294  <<" => X\"";
295 
296  for (unsigned int i =0; i<num; i++)
297  {
298  if (high)
299  ossPhi << std::hex<< std::setw(2)<<std::setfill('0')<<(*op).at(i).phiHigh<<std::dec;
300  else
301  ossPhi << std::hex<< std::setw(2)<<std::setfill('0')<<(*op).at(i).phiLow<<std::dec;
302 
303  if (num>0 && i!=num-1) ossPhi <<"_";
304  }
305 
306  ossPhi<<"\",\n";
307  return capitalLetters(ossPhi.str());
308 
309 }
int i
Definition: DBlmapReader.cc:9
std::string capitalLetters(std::string hexString)
static std::atomic< unsigned int > counter
std::string L1GtVhdlWriterBitManager::capitalLetters ( std::string  hexString)

Definition at line 156 of file L1GtVhdlWriterBitManager.cc.

References i.

Referenced by buildDeltaEtaCalo(), buildDeltaEtaMuon(), buildDeltaPhiCalo(), buildPhiCalo(), buildPhiEnergySum(), and buildPhiMuon().

157 {
158 
159  unsigned int i = 0;
160  while(i<hexString.length())
161  {
162  if(hexString[i] == 'a') hexString[i] = 'A';
163  else if(hexString[i] == 'b') hexString[i] = 'B';
164  else if(hexString[i] == 'c') hexString[i] = 'C';
165  else if(hexString[i] == 'd') hexString[i] = 'D';
166  else if(hexString[i] == 'e') hexString[i] = 'E';
167  else if(hexString[i] == 'f') hexString[i] = 'F';
168  i++;
169  }
170 
171  return hexString;
172 }
int i
Definition: DBlmapReader.cc:9
std::string L1GtVhdlWriterBitManager::hex2bin ( std::string  hexString)

Definition at line 76 of file L1GtVhdlWriterBitManager.cc.

References hex2binMap_, i, AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

Referenced by buildDeltaEtaCalo(), buildDeltaPhiCalo(), buildDeltaPhiMuon(), mirror(), and shiftLeft().

77 {
78 
80  for (unsigned int i=0; i<hexString.length(); i++)
81  {
82  std::string str;
83  str=hexString[i];
84 
85  temp+=hex2binMap_[str];
86  }
87 
88  return temp;
89 }
int i
Definition: DBlmapReader.cc:9
std::map< std::string, std::string > hex2binMap_
std::string L1GtVhdlWriterBitManager::mirror ( unsigned int  offset,
std::string  hexString,
bool  hexOutput = true 
)

Definition at line 113 of file L1GtVhdlWriterBitManager.cc.

References bin2hex(), hex2bin(), i, hltrates_dqm_sourceclient-live_cfg::offset, AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

Referenced by buildDeltaEtaCalo(), buildDeltaEtaMuon(), buildDeltaPhiCalo(), and buildDeltaPhiMuon().

114 {
115  std::string temp,binString;
116 
117  char digit;
118  bool hexInput=false;
119 
120  // check weather input hex or binary
121  for(unsigned int i = 0; i<hexString.length(); i++)
122  {
123  if (hexString[i]!='0' || hexString[i]!='1' )
124  {
125  hexInput=true;
126  break;
127  }
128  }
129 
130  if (hexInput)
131  binString = hex2bin(hexString);
132  else binString=hexString;
133 
134  unsigned int i=0, len=0;
135  len = binString.length();
136 
137  if(offset > len)
138  return binString;
139 
140  for(i = 0; i < (len - offset)/2; i++)
141  {
142  digit = binString[i + offset];
143 
144  binString[i + offset] = binString[len - 1 - i];
145  binString[len - 1 - i] = digit;
146 
147  }
148 
149  if (hexOutput)
150  return bin2hex(binString);
151  else return binString;
152 
153 }
int i
Definition: DBlmapReader.cc:9
std::string hex2bin(std::string hexString)
std::string bin2hex(std::string binString)
std::string L1GtVhdlWriterBitManager::readMapInverse ( const std::map< std::string, std::string > &  map,
std::string  value 
)

Definition at line 63 of file L1GtVhdlWriterBitManager.cc.

Referenced by bin2hex().

64 {
65  std::map<std::string,std::string>::const_iterator iter = map.begin();
66  while (iter!=map.end())
67  {
68  if ((*iter).second == value)
69  return (*iter).first;
70  iter++;
71  }
72  return "";
73 }
std::string L1GtVhdlWriterBitManager::shiftLeft ( std::string  hexString)

Definition at line 175 of file L1GtVhdlWriterBitManager.cc.

References bin2hex(), hex2bin(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by buildDeltaEtaCalo(), buildDeltaEtaMuon(), and buildDeltaPhiMuon().

176 {
177  std::string binString = hex2bin(hexString);
178 
179  binString.erase(0,1);
180  binString+="0";
181 
182  return bin2hex(binString);
183 }
std::string hex2bin(std::string hexString)
std::string bin2hex(std::string binString)

Member Data Documentation

std::map<std::string, std::string> L1GtVhdlWriterBitManager::hex2binMap_
private

Definition at line 36 of file L1GtVhdlWriterBitManager.h.

Referenced by bin2hex(), hex2bin(), and L1GtVhdlWriterBitManager().