CMS 3D CMS Logo

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

\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::L1GtVhdlWriterBitManager ( )

Definition at line 34 of file L1GtVhdlWriterBitManager.cc.

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

References hex2binMap_.

Member Function Documentation

◆ bin2hex()

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

Definition at line 83 of file L1GtVhdlWriterBitManager.cc.

83  {
85  for (unsigned int i = 1; i <= binString.length(); i++) {
86  //std::cout<<i%4<<std::endl;
87  if (i % 4 == 0) {
88  //std::cout<<"I'm here!"<<std::endl;
90  str = binString.substr(i - 4, 4);
91  //std::cout<<str<<std::cout<<std::endl;
93  }
94  }
95 
96  return temp;
97 }

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

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

◆ buildDeltaEtaCalo()

std::string L1GtVhdlWriterBitManager::buildDeltaEtaCalo ( const L1GtCaloTemplate::CorrelationParameter *&  cp,
const unsigned int &  counter 
)

Definition at line 281 of file L1GtVhdlWriterBitManager.cc.

282  {
283  std::ostringstream deltaEtaRange, dEta, res;
284 
285  //std::cout<<"b:"<<.hex2bin("00383800")<<std::endl;
286 
287  deltaEtaRange << std::hex << std::setw(4) << std::setfill('0') << (*cp).deltaEtaRange << std::dec;
288 
289  // mirror deltaEtaRang and shift the mirrored value to the left by one bit;
290  // add the original value to the calculated value
291  dEta << hex2bin(shiftLeft(mirror(0, deltaEtaRange.str()))) << hex2bin(deltaEtaRange.str());
292 
294 
295  res << counter << " => X\"" << result << "\",\n";
296 
297  return res.str();
298 }

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

Referenced by L1GtVhdlWriterCore::getCaloSetupContentFromTriggerMenu().

◆ buildDeltaEtaMuon()

std::string L1GtVhdlWriterBitManager::buildDeltaEtaMuon ( const L1GtMuonTemplate::CorrelationParameter *&  cp,
const unsigned int &  counter 
)

Definition at line 300 of file L1GtVhdlWriterBitManager.cc.

301  {
302  std::ostringstream deltaEtaRange, dEta;
303  deltaEtaRange << std::hex << std::setw(16) << std::setfill('0') << (*cp).deltaEtaRange << std::dec;
304 
305  // mirror deltaEtaRang and shift the mirrored value to the left by one bit;
306  // add the original value to the calculated value
307 
308  std::string result = capitalLetters((shiftLeft(mirror(0, deltaEtaRange.str())) + deltaEtaRange.str()));
309 
310  dEta << counter << " => X\"" << result << "\",\n";
311 
312  return dEta.str();
313 }

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

Referenced by L1GtVhdlWriterCore::getMuonSetupContentFromTriggerMenu().

◆ buildDeltaPhiCalo()

std::string L1GtVhdlWriterBitManager::buildDeltaPhiCalo ( const L1GtCaloTemplate::CorrelationParameter *&  cp,
const unsigned int &  counter 
)

Definition at line 315 of file L1GtVhdlWriterBitManager.cc.

316  {
317  std::ostringstream dPhi, deltaPhiRange, result;
318  //std::cout<<.hex2bin("03E0000000000F81")<<std::endl;
319  //std::cout<<.hex2bin("0080000000000200")<<std::endl;
320 
321  deltaPhiRange << std::hex << std::setw(3) << std::setfill('0') << (*cp).deltaPhiRange << std::dec;
322 
323  std::string binString = hex2bin(deltaPhiRange.str());
324 
325  //std::cout <<"========================" <<std::endl;
326 
327  std::string help2 = binString.substr(2, binString.length() - 2);
328  std::string help1 = help2.substr(1);
329  help1 = mirror(0, bin2hex(help1), false);
330 
331  // here delta phi is built
332  result << help1;
333 
334  // might be wrong - has to be tested with more reference values!
335  result << help2.substr(0, 8);
336  result << "0";
337 
338  result << "00000000000000000000000000000";
339 
340  result << help1;
341 
342  result << binString.substr(2, binString.length() - 2);
343 
344  dPhi << counter << " => X\"" << bin2hex(result.str()) << "\",\n";
345 
346  //std::cout<<result<<std::endl;
347 
348  /*
349  * Code from old GTS:
350  bm_dphi = bm_dphi.Get(2);
351  BitMngr help1, help2 = bm_dphi;
352  help2.SetAt(9, '\0');
353  help1 = help2.Get(1);
354  help1.Mirror();
355  BitMngr nuller;
356  nuller.InitBin("00 00 00 00 00 00 00 00 00 00 00 00 00 00 0");
357  BitMngr result;
358  result = result + help1 + help2 + nuller + help1 + bm_dphi;
359  dphi = result.GetHex();
360  */
361 
362  return capitalLetters(dPhi.str());
363 }

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

Referenced by L1GtVhdlWriterCore::getCaloSetupContentFromTriggerMenu().

◆ buildDeltaPhiMuon()

std::string L1GtVhdlWriterBitManager::buildDeltaPhiMuon ( const L1GtMuonTemplate::CorrelationParameter *&  cp,
const unsigned int &  counter 
)

Definition at line 365 of file L1GtVhdlWriterBitManager.cc.

366  {
367  std::ostringstream dPhi, deltaPhiRange0, deltaPhiRange1, temp, result;
368  std::string tempstr;
369 
370  deltaPhiRange0 << std::hex << std::setw(16) << std::setfill('0') << (*cp).deltaPhiRange0Word << std::dec;
371  //deltaPhiRange1 /*<< std::hex<< std::setw(3)<<std::setfill('0')*/<<(*cp).deltaPhiRange1Word<<std::dec;
372 
373  //mirror deltaPhiRange, shift the mirrored value left and convert it to binary format
374  temp << hex2bin(shiftLeft(mirror(0, deltaPhiRange0.str())));
375  tempstr = temp.str();
376  // set last bit of tempstr to one;
377  tempstr[tempstr.length() - 1] = '1';
378 
379  // build delta eta as stringstreamtau
380  result << tempstr
381  // insert 16 ones
382  << hex2bin("FFFF") << hex2bin(deltaPhiRange0.str());
383 
384  dPhi << counter << " => X\"" << bin2hex(result.str()) << "\",\n";
385 
386  return dPhi.str();
387 }

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

Referenced by L1GtVhdlWriterCore::getMuonSetupContentFromTriggerMenu().

◆ buildEtaCalo()

std::string L1GtVhdlWriterBitManager::buildEtaCalo ( const std::vector< L1GtCaloTemplate::ObjectParameter > *  op,
const unsigned int &  num,
const unsigned int &  counter 
)

Definition at line 193 of file L1GtVhdlWriterBitManager.cc.

195  {
196  std::ostringstream ossEta;
197 
198  ossEta << counter << " => X\"";
199 
200  // loop over all relevant components of object parameters
201 
202  for (unsigned int i = 0; i < num; i++) {
203  std::ostringstream ossEtaRange;
204 
205  ossEtaRange << std::hex << std::setw(4) << std::setfill('0') << (*op).at(i).etaRange << std::dec;
206 
207  /*
208  std::string tempstr=hex2bin(ossEtaRange.str());
209  tempstr[0]='0';
210  tempstr[15]='0';
211  */
212 
213  //ossEta<<std::setw(4)<<std::setfill('0')<<mirror(8,bin2hex(tempstr));
214 
215  ossEta << ossEtaRange.str();
216 
217  if (num > 0 && i != num - 1)
218  ossEta << "_";
219  }
220 
221  ossEta << "\",\n";
222  return ossEta.str();
223 }

References TauDecayModes::dec, mps_fire::i, and EgammaValidation_cff::num.

Referenced by L1GtVhdlWriterCore::getCaloSetupContentFromTriggerMenu().

◆ buildEtaMuon()

std::string L1GtVhdlWriterBitManager::buildEtaMuon ( const std::vector< L1GtMuonTemplate::ObjectParameter > *  op,
const unsigned int &  num,
const unsigned int &  counter 
)

Definition at line 167 of file L1GtVhdlWriterBitManager.cc.

169  {
170  std::ostringstream ossEta;
171 
172  ossEta << counter << " => X\"";
173 
174  for (unsigned int i = 0; i < num; i++) {
175  std::ostringstream ossEtaRange;
176  ossEtaRange << std::hex << std::setw(16) << std::setfill('0') << (*op).at(i).etaRange << std::dec;
177 
178  /*
179  ossEta
180  <<mirror(32,ossEtaRange.str());
181  */
182 
183  ossEta << ossEtaRange.str();
184 
185  if (num > 0 && i != num - 1)
186  ossEta << "_";
187  }
188 
189  ossEta << "\",\n";
190  return ossEta.str();
191 }

References TauDecayModes::dec, mps_fire::i, and EgammaValidation_cff::num.

Referenced by L1GtVhdlWriterCore::getMuonSetupContentFromTriggerMenu().

◆ buildPhiCalo()

std::string L1GtVhdlWriterBitManager::buildPhiCalo ( const std::vector< L1GtCaloTemplate::ObjectParameter > *  op,
const unsigned int &  num,
const unsigned int &  counter 
)

Definition at line 225 of file L1GtVhdlWriterBitManager.cc.

227  {
228  std::ostringstream ossPhi;
229 
230  ossPhi << counter << " => X\"";
231 
232  for (unsigned int i = 0; i < num; i++) {
233  ossPhi << std::hex << std::setw(8) << std::setfill('0') << (*op).at(i).phiRange << std::dec;
234 
235  if (num > 0 && i != num - 1)
236  ossPhi << "_";
237  }
238 
239  ossPhi << "\",\n";
240  return capitalLetters(ossPhi.str());
241 }

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

Referenced by L1GtVhdlWriterCore::getCaloSetupContentFromTriggerMenu().

◆ buildPhiEnergySum()

std::string L1GtVhdlWriterBitManager::buildPhiEnergySum ( const std::vector< L1GtEnergySumTemplate::ObjectParameter > *  op,
const unsigned int &  num,
const unsigned int &  counter 
)

Definition at line 243 of file L1GtVhdlWriterBitManager.cc.

245  {
246  std::ostringstream ossPhi, count;
247 
248  if ((*op).at(0).phiRange0Word != 0) {
249  ossPhi << "000000000000000000" << std::hex << (*op).at(0).phiRange1Word << (*op).at(0).phiRange0Word << std::dec;
250 
251  count << counter;
252 
253  return (count.str() + " => X\"" + capitalLetters(ossPhi.str()) + "\",\n");
254 
255  } else
256  return "";
257 }

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

Referenced by L1GtVhdlWriterCore::getEsumsSetupContentFromTriggerMenu().

◆ buildPhiMuon()

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 259 of file L1GtVhdlWriterBitManager.cc.

262  {
263  std::ostringstream ossPhi;
264 
265  ossPhi << counter << " => X\"";
266 
267  for (unsigned int i = 0; i < num; i++) {
268  if (high)
269  ossPhi << std::hex << std::setw(2) << std::setfill('0') << (*op).at(i).phiHigh << std::dec;
270  else
271  ossPhi << std::hex << std::setw(2) << std::setfill('0') << (*op).at(i).phiLow << std::dec;
272 
273  if (num > 0 && i != num - 1)
274  ossPhi << "_";
275  }
276 
277  ossPhi << "\",\n";
278  return capitalLetters(ossPhi.str());
279 }

References capitalLetters(), TauDecayModes::dec, LaserClient_cfi::high, mps_fire::i, and EgammaValidation_cff::num.

Referenced by L1GtVhdlWriterCore::getMuonSetupContentFromTriggerMenu().

◆ capitalLetters()

std::string L1GtVhdlWriterBitManager::capitalLetters ( std::string  hexString)

Definition at line 137 of file L1GtVhdlWriterBitManager.cc.

137  {
138  unsigned int i = 0;
139  while (i < hexString.length()) {
140  if (hexString[i] == 'a')
141  hexString[i] = 'A';
142  else if (hexString[i] == 'b')
143  hexString[i] = 'B';
144  else if (hexString[i] == 'c')
145  hexString[i] = 'C';
146  else if (hexString[i] == 'd')
147  hexString[i] = 'D';
148  else if (hexString[i] == 'e')
149  hexString[i] = 'E';
150  else if (hexString[i] == 'f')
151  hexString[i] = 'F';
152  i++;
153  }
154 
155  return hexString;
156 }

References mps_fire::i.

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

◆ hex2bin()

std::string L1GtVhdlWriterBitManager::hex2bin ( std::string  hexString)

Definition at line 71 of file L1GtVhdlWriterBitManager.cc.

71  {
73  for (unsigned int i = 0; i < hexString.length(); i++) {
75  str = hexString[i];
76 
77  temp += hex2binMap_[str];
78  }
79 
80  return temp;
81 }

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

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

◆ mirror()

std::string L1GtVhdlWriterBitManager::mirror ( unsigned int  offset,
std::string  hexString,
bool  hexOutput = true 
)

Definition at line 99 of file L1GtVhdlWriterBitManager.cc.

99  {
100  std::string temp, binString;
101 
102  char digit;
103  bool hexInput = false;
104 
105  // check weather input hex or binary
106  for (unsigned int i = 0; i < hexString.length(); i++) {
107  if (hexString[i] != '0' || hexString[i] != '1') {
108  hexInput = true;
109  break;
110  }
111  }
112 
113  if (hexInput)
114  binString = hex2bin(hexString);
115  else
116  binString = hexString;
117 
118  unsigned int i = 0, len = 0;
119  len = binString.length();
120 
121  if (offset > len)
122  return binString;
123 
124  for (i = 0; i < (len - offset) / 2; i++) {
125  digit = binString[i + offset];
126 
127  binString[i + offset] = binString[len - 1 - i];
128  binString[len - 1 - i] = digit;
129  }
130 
131  if (hexOutput)
132  return bin2hex(binString);
133  else
134  return binString;
135 }

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

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

◆ readMapInverse()

std::string L1GtVhdlWriterBitManager::readMapInverse ( const std::map< std::string, std::string > &  map,
std::string  value 
)

Definition at line 61 of file L1GtVhdlWriterBitManager.cc.

61  {
62  std::map<std::string, std::string>::const_iterator iter = map.begin();
63  while (iter != map.end()) {
64  if ((*iter).second == value)
65  return (*iter).first;
66  iter++;
67  }
68  return "";
69 }

References genParticles_cff::map.

Referenced by bin2hex().

◆ shiftLeft()

std::string L1GtVhdlWriterBitManager::shiftLeft ( std::string  hexString)

Definition at line 158 of file L1GtVhdlWriterBitManager.cc.

158  {
159  std::string binString = hex2bin(hexString);
160 
161  binString.erase(0, 1);
162  binString += "0";
163 
164  return bin2hex(binString);
165 }

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

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

Member Data Documentation

◆ hex2binMap_

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

Definition at line 35 of file L1GtVhdlWriterBitManager.h.

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

counter
Definition: counter.py:1
L1GtVhdlWriterBitManager::readMapInverse
std::string readMapInverse(const std::map< std::string, std::string > &map, std::string value)
Definition: L1GtVhdlWriterBitManager.cc:61
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.dPhi
dPhi
Definition: HLT_FULL_cff.py:13702
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
L1GtVhdlWriterBitManager::hex2binMap_
std::map< std::string, std::string > hex2binMap_
Definition: L1GtVhdlWriterBitManager.h:35
str
#define str(s)
Definition: TestProcessor.cc:51
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
value
Definition: value.py:1
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:17
res
Definition: Electron.h:6
L1GtVhdlWriterBitManager::shiftLeft
std::string shiftLeft(std::string hexString)
Definition: L1GtVhdlWriterBitManager.cc:158
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
LaserClient_cfi.high
high
Definition: LaserClient_cfi.py:50
L1GtVhdlWriterBitManager::mirror
std::string mirror(unsigned int offset, std::string hexString, bool hexOutput=true)
Definition: L1GtVhdlWriterBitManager.cc:99
HLT_FULL_cff.dEta
dEta
Definition: HLT_FULL_cff.py:13701
L1GtVhdlWriterBitManager::bin2hex
std::string bin2hex(std::string binString)
Definition: L1GtVhdlWriterBitManager.cc:83
L1GtVhdlWriterBitManager::hex2bin
std::string hex2bin(std::string hexString)
Definition: L1GtVhdlWriterBitManager.cc:71
L1GtVhdlWriterBitManager::capitalLetters
std::string capitalLetters(std::string hexString)
Definition: L1GtVhdlWriterBitManager.cc:137
mps_fire.result
result
Definition: mps_fire.py:311
genParticles_cff.map
map
Definition: genParticles_cff.py:11
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143