CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
L1GtVhdlWriterCore Class Reference

#include <L1GtVhdlWriterCore.h>

Inheritance diagram for L1GtVhdlWriterCore:
L1GtVhdlDefinitions

Public Member Functions

void addJetCountsToCond2IntMap (const int chip, const std::vector< ConditionMap > &conditionMap, std::map< std::string, int > &conditionToIntegerMap)
 
void buildCommonHeader (std::map< std::string, std::string > &headerParameters, const std::vector< std::string > &connectedChannels)
 builds the common header for all files More...
 
std::string buildDefValString (const int &conditionIndex, const std::vector< int > &values)
 
bool buildDefValuesBuffer (L1GtVhdlTemplateFile &buffer, const std::map< L1GtConditionType, std::string > &typeList, const std::vector< std::string > &defValuesList, const L1GtObject &object)
 
std::string chip2OutputSubDir (const int &chip)
 
void countCondsAndAdd2NumberVec (const L1GtConditionType &type, const L1GtConditionCategory &category, const L1GtObject &object, const ConditionMap &map, ConditionMap &outputMap, const int &condChip)
 
bool findObjectType (const L1GtObject &object, ConditionMap &map)
 
bool getCaloSetupContentFromTriggerMenu (const unsigned short int &condChip, std::map< std::string, std::string > &caloParameters, const L1GtObject &caloObject)
 
L1GtConditionCategory getCategoryFromObject (const L1GtObject &object)
 gets condition category from object More...
 
std::map< std::string, int > getCond2IntMap ()
 
bool getCondChipVhdContentFromTriggerMenu (const unsigned short int &condChip, std::map< std::string, L1GtVhdlTemplateFile > &templates, std::map< std::string, std::string > &commonParams)
 
std::string getDefValsFromTriggerMenu (const L1GtConditionType &type, const L1GtObject &object, const VmeRegister &reg)
 
bool getEsumsSetupContentFromTriggerMenu (const unsigned short int &condChip, const L1GtObject &object, std::string &energySumParameter)
 contains only one subsitution parameter which is stored in reference energySumParameter More...
 
bool getIntVal (const std::map< std::string, int > &map, const std::string &searchValue, int &intVal)
 checks weather value searchValue exists in a <string,int> map, saves it in &intVal if it exists and returns false if not More...
 
std::vector< std::string > getMsgBuf ()
 returns intern message buffer More...
 
void getMuonSetupContentFromTriggerMenu (const unsigned short int &condChip, std::map< std::string, std::string > &muonParameters)
 
bool getSubstParamCommonFromTriggerMenu (const unsigned short int &condChip, L1GtVhdlTemplateFile &particle, const L1GtObject &object, const L1GtConditionCategory &category, std::string &parameterStr)
 builds the parameters particle_common for the cond_chip.vhd's More...
 
std::string gtTemplatesPath ()
 returns the templates path More...
 
std::string index4CondChipVhd (int intval)
 
void initializeDeltaConditions ()
 
 L1GtVhdlWriterCore (const std::string &templatesDirectory, const std::string &outputDirectory, const bool &debug)
 constructor More...
 
bool makeFirmware (const std::vector< ConditionMap > &conditionMap, const AlgorithmMap &algorithmMap)
 produces the firmware code More...
 
void msg (const std::string &message)
 adds a string to intern message buffer More...
 
L1GtVhdlTemplateFile openVhdlFileWithCommonHeader (const std::string &filename, const std::string &outputFilename)
 opens a new template file and inserts the common header More...
 
void printCommonHeader ()
 prints the common header More...
 
void printConditionsOfCategory (const L1GtConditionCategory &category, const ConditionMap &map)
 for debuggin More...
 
bool processAlgorithmMap (std::vector< std::map< int, std::string > > &algoStrings)
 
std::string retNumberOfConditionsString (const std::string &typeStr, const int &number)
 
L1GtVhdlTemplateFile retrunCommonHeader ()
 returns the common header More...
 
bool returnConditionsOfOneClass (const L1GtConditionType &type, const L1GtConditionCategory &category, const L1GtObject &object, const ConditionMap &map, ConditionMap &outputMap)
 
std::string sp (const std::string &name)
 converts string name to substiution parameter synthax; name –> More...
 
void writeAlgoSetup (std::vector< std::map< int, std::string > > &algoStrings)
 builds the prealgo_and_or setup More...
 
void writeCond2intMap2File ()
 produces a control output file for condition to integer conversion More...
 
void writeCondChipPkg (const int &chip)
 
void writeConditionChipSetup (const std::map< std::string, L1GtVhdlTemplateFile > &templates, const std::map< std::string, std::string > &common, const unsigned short int &chip)
 builds cond_chip.vhds More...
 
void writeDefValPkg (const std::vector< ConditionMap > &conditionMap, const int &chip)
 writes def_val_pkg.vhd More...
 
void writeEtmSetup (std::string &etmString, const int &condChip)
 builds etm setup files More...
 
void writeMuonSetupVhdl (std::map< std::string, std::string > &muonParameters, const std::string &particle, unsigned short int &condChip)
 builds muon setup files More...
 
void writeQsfSetupFiles (const std::string &version)
 builds the two quartus setup files. This routine is called in buildCommonHeader! More...
 
 ~L1GtVhdlWriterCore () override
 destructor More...
 
- Public Member Functions inherited from L1GtVhdlDefinitions
const std::map< L1GtObject, std::string > getCalo2IntMap ()
 
const std::map< L1GtConditionType, std::string > getCond2StrMap ()
 
const std::map< L1GtObject, std::string > getObj2StrMap ()
 
 L1GtVhdlDefinitions ()
 constructor More...
 
std::string obj2str (const L1GtObject &type)
 converts object type to firmware string More...
 
std::string type2str (const L1GtConditionType &type)
 converts a condition type to firmware string More...
 
virtual ~L1GtVhdlDefinitions ()
 destructor More...
 

Static Public Member Functions

static std::string int2str (const int &integerValue)
 converts a integer into a string More...
 

Private Attributes

const AlgorithmMapalgorithmMap_
 algorithm map More...
 
L1GtVhdlWriterBitManager bm_
 bit manager for bit operations More...
 
std::vector< L1GtObjectcaloObjects_
 list of all possible calo objects More...
 
std::map< L1GtObject, std::string > caloType2Int_
 converts L1GtObject to calo_nr More...
 
L1GtVhdlTemplateFile commonHeader_
 common header for all files More...
 
const std::vector< ConditionMap > * conditionMap_
 condition map More...
 
std::map< std::string, int > conditionToIntegerMap_
 stores to condition name to integer conversion table More...
 
std::map< L1GtConditionType, std::string > condType2Str_
 converts L1GtConditionType to firmware string More...
 
bool debugMode_
 class will produce some additional debugging output if set More...
 
std::vector< L1GtObjectesumObjects_
 list of all possible esums objects More...
 
std::vector< std::string > internMessageBuf_
 
std::vector< std::vector< std::string > > numberOfConditions_
 vector containing the initialization of all conditions More...
 
std::map< L1GtObject, std::string > objType2Str_
 converts L1GtObject to string More...
 
std::string outputDir_
 output directory More...
 
std::string version_
 
std::string vhdlDir_
 templates directory More...
 

Additional Inherited Members

- Public Types inherited from L1GtVhdlDefinitions
enum  VmeRegister {
  RegPtHighThreshold, RegPtLowThreshold, RegQualityRange, RegChargeCorrelation,
  RegEtThreshold
}
 
- Static Protected Attributes inherited from L1GtVhdlDefinitions
static const std::string outputSubDir1_
 
static const std::string outputSubDir2_
 
static const std::string quartusSetupFileChip1_
 
static const std::string quartusSetupFileChip2_
 
static const std::string stringConstantAlgo_
 
static const std::string stringConstantCalo_
 
static const std::string stringConstantCharge1s_
 
static const std::string stringConstantCharge2s_
 
static const std::string stringConstantCharge2wsc_
 
static const std::string stringConstantCharge3s_
 
static const std::string stringConstantCharge4s_
 
static const std::string stringConstantCommon_
 
static const std::string stringConstantConstantNr_
 
static const std::string stringConstantDefValId_
 
static const std::string stringConstantEsumsHigh_
 
static const std::string stringConstantEsumsLHighDefVal_
 
static const std::string stringConstantEsumsLow_
 
static const std::string stringConstantEsumsLowDefVal_
 
static const std::string stringConstantJetCountsDefVal_
 
static const std::string stringConstantPth_
 
static const std::string stringConstantPtHighDefVal_
 
static const std::string stringConstantPtl_
 
static const std::string stringConstantPtLowDefVal_
 
static const std::string stringConstantQuality_
 
static const std::string stringConstantQualityDefVal_
 
static const std::string stringConstantQuargeDefVal_
 
static const std::string substParamAlgos_
 
static const std::string substParamCaloDefVals_
 
static const std::string substParamCaloOrMuon_
 
static const std::string substParamCharge_
 
static const std::string substParamContent_
 
static const std::string substParamDefValId_
 
static const std::string substParamDefValType_
 
static const std::string substParamEsumsDefVals_
 
static const std::string substParamJetCntsCommon_
 
static const std::string substParamJetsDefVals_
 
static const std::string substParamMaxNr_
 
static const std::string substParamMuonDefVals_
 
static const std::string substParamOthers_
 
static const std::string substParamParticle_
 
static const std::string substParamType_
 
static const std::string vhdlTemplateAlgoAndOr_
 
static const std::string vhdlTemplateCaloSetup_
 
static const std::string vhdlTemplateCondChip_
 
static const std::string vhdlTemplateCondChipPkg1_
 
static const std::string vhdlTemplateCondChipPkg2_
 
static const std::string vhdlTemplateDefValPkg_
 
static const std::string vhdlTemplateEtmSetup_
 
static const std::string vhdlTemplateMuonSetup_
 

Detailed Description

writes the actual VHDL code and stores global information like the common header. This class is using parameter maps containing the substitution parameters and their content.

Implementation: <TODO: enter implementation details>

Author
Philipp Wagner

Description: a class to deal with VHDL template files

Implementation: <TODO: enter implementation details>

Author
: Philipp Wagner

Definition at line 42 of file L1GtVhdlWriterCore.h.

Constructor & Destructor Documentation

◆ L1GtVhdlWriterCore()

L1GtVhdlWriterCore::L1GtVhdlWriterCore ( const std::string &  templatesDirectory,
const std::string &  outputDirectory,
const bool &  debug 
)

constructor

Definition at line 49 of file L1GtVhdlWriterCore.cc.

References caloObjects_, caloType2Int_, CenJet, condType2Str_, debug, debugMode_, esumObjects_, ETM, ETT, ForJet, L1GtVhdlDefinitions::getCalo2IntMap(), L1GtVhdlDefinitions::getCond2StrMap(), L1GtVhdlDefinitions::getObj2StrMap(), HTT, IsoEG, NoIsoEG, numberOfConditions_, objType2Str_, outputDir_, TauJet, groupFilesInBlocks::temp, and vhdlDir_.

51  {
52  // set templates directory
53  vhdlDir_ = templatesDirectory;
54 
55  // set output directory
56  outputDir_ = outputDirectory;
57 
58  // Get maps
60 
61  objType2Str_ = maps.getObj2StrMap();
64 
65  // fill calo object vector
66  caloObjects_.push_back(IsoEG);
67  caloObjects_.push_back(NoIsoEG);
68  caloObjects_.push_back(CenJet);
69  caloObjects_.push_back(ForJet);
70  caloObjects_.push_back(TauJet);
71 
72  esumObjects_.push_back(HTT);
73  esumObjects_.push_back(ETT);
74  esumObjects_.push_back(ETM);
75 
76  // prepare number of condition vector with two empty string vectors for the two condition chips
77  std::vector<std::string> temp;
78  numberOfConditions_.push_back(temp);
79  numberOfConditions_.push_back(temp);
80 
81  // set debug mode
82  debugMode_ = debug;
83 }
std::map< L1GtObject, std::string > caloType2Int_
converts L1GtObject to calo_nr
std::string vhdlDir_
templates directory
const std::map< L1GtConditionType, std::string > getCond2StrMap()
std::vector< L1GtObject > esumObjects_
list of all possible esums objects
Definition: L1GtObject.h:35
std::vector< L1GtObject > caloObjects_
list of all possible calo objects
std::vector< std::vector< std::string > > numberOfConditions_
vector containing the initialization of all conditions
Definition: L1GtObject.h:37
std::map< L1GtConditionType, std::string > condType2Str_
converts L1GtConditionType to firmware string
std::map< L1GtObject, std::string > objType2Str_
converts L1GtObject to string
#define debug
Definition: HDRShower.cc:19
std::string outputDir_
output directory
Definition: L1GtObject.h:36
const std::map< L1GtObject, std::string > getObj2StrMap()
bool debugMode_
class will produce some additional debugging output if set
const std::map< L1GtObject, std::string > getCalo2IntMap()

◆ ~L1GtVhdlWriterCore()

L1GtVhdlWriterCore::~L1GtVhdlWriterCore ( )
override

destructor

Definition at line 86 of file L1GtVhdlWriterCore.cc.

86  {
87  // empty
88 }

Member Function Documentation

◆ addJetCountsToCond2IntMap()

void L1GtVhdlWriterCore::addJetCountsToCond2IntMap ( const int  chip,
const std::vector< ConditionMap > &  conditionMap,
std::map< std::string, int > &  conditionToIntegerMap 
)

calculates the integer value for jet counts conditions and furthermore counts how many jet counts of one type are in trigger menu

Definition at line 1139 of file L1GtVhdlWriterCore.cc.

References conditionToIntegerMap_, CondJetCounts, counter, mps_fire::i, int2str(), JetCounts, numberOfConditions_, L1GtJetCountsTemplate::objectParameter(), retNumberOfConditionsString(), returnConditionsOfOneClass(), and TypeJetCounts.

Referenced by makeFirmware().

1141  {
1142  ConditionMap jetConditions;
1143 
1144  returnConditionsOfOneClass(TypeJetCounts, CondJetCounts, JetCounts, conditionMap.at(chip - 1), jetConditions);
1145  /*
1146  int counter = 0;
1147 
1148  for (ConditionMap::const_iterator iterCond = jetConditions.begin(); iterCond != jetConditions.end(); iterCond++)
1149  {
1150  conditionToIntegerMap_[iterCond->first]=counter;
1151  counter++;
1152  msg(iterCond->first);
1153  }
1154 
1155  */
1156 
1157  unsigned int maxJetsCountsIndex = 11;
1158 
1159  for (unsigned int i = 0; i <= maxJetsCountsIndex; i++) {
1160  int counter = 0;
1161 
1162  for (ConditionMap::const_iterator iterCond = jetConditions.begin(); iterCond != jetConditions.end(); iterCond++) {
1163  L1GtJetCountsTemplate *jetsTemplate = static_cast<L1GtJetCountsTemplate *>(iterCond->second);
1164  const std::vector<L1GtJetCountsTemplate::ObjectParameter> *op = jetsTemplate->objectParameter();
1165 
1166  conditionToIntegerMap_[iterCond->first] = counter;
1167  if ((*op)[0].countIndex == i)
1168  counter++;
1169 
1170  //msg(int2str((*op)[0].countIndex));
1171  }
1172 
1173  numberOfConditions_.at(chip - 1).push_back(
1174  retNumberOfConditionsString("jet_cnts_" + int2str(i) + "_cond", counter));
1175  }
1176 }
std::map< std::string, L1GtCondition * > ConditionMap
map containing the conditions
std::vector< std::vector< std::string > > numberOfConditions_
vector containing the initialization of all conditions
static std::string int2str(const int &integerValue)
converts a integer into a string
bool returnConditionsOfOneClass(const L1GtConditionType &type, const L1GtConditionCategory &category, const L1GtObject &object, const ConditionMap &map, ConditionMap &outputMap)
const std::vector< ObjectParameter > * objectParameter() const
std::string retNumberOfConditionsString(const std::string &typeStr, const int &number)
static std::atomic< unsigned int > counter
std::map< std::string, int > conditionToIntegerMap_
stores to condition name to integer conversion table

◆ buildCommonHeader()

void L1GtVhdlWriterCore::buildCommonHeader ( std::map< std::string, std::string > &  headerParameters,
const std::vector< std::string > &  connectedChannels 
)

builds the common header for all files

Definition at line 864 of file L1GtVhdlWriterCore.cc.

References commonHeader_, L1GtVhdlTemplateFile::insert(), msg(), L1GtVhdlTemplateFile::open(), L1GtVhdlTemplateFile::substitute(), version_, and vhdlDir_.

Referenced by L1GtVhdlWriter::analyze().

865  {
866  commonHeader_.open(vhdlDir_ + "InternalTemplates/header");
867 
868  std::map<std::string, std::string>::iterator iter = headerParameters.begin();
869 
870  // loop over the header parameter map and replace all subsitution
871  // parameters with their values
872  while (iter != headerParameters.end()) {
873  commonHeader_.substitute((*iter).first, (*iter).second);
874  iter++;
875  }
876 
877  commonHeader_.insert("$(connected_channels_1)", connectedChannels);
878  commonHeader_.insert("$(connected_channels_2)", connectedChannels);
879 
880  //---------------------build the Quartus configuration files----------------------------------------
881 
882  //writeQsfSetupFiles(headerParameters["version"]);
883 
884  version_ = headerParameters["version"];
885 
886  msg("Build Common header and Quartus setup files sucessuflly!");
887 }
std::string vhdlDir_
templates directory
bool substitute(const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString
L1GtVhdlTemplateFile commonHeader_
common header for all files
bool insert(const std::string &atLine, const std::vector< std::string > &content)
replaces the whole line containing atLine and inserts content instead of it
void msg(const std::string &message)
adds a string to intern message buffer
bool open(const std::string &fileName, bool internal=false)
opens a template file. If the header information shall be parsed intern has to be set to true ...

◆ buildDefValString()

std::string L1GtVhdlWriterCore::buildDefValString ( const int &  conditionIndex,
const std::vector< int > &  values 
)

builds the string representing a condition in def_val_pkg.vhd. Parameters are condition index and a vector containig default values.

Definition at line 1216 of file L1GtVhdlWriterCore.cc.

1216  {
1217  // has to produce something like 1 => ("00000000", "00000000")
1218 
1219  return "1 => (\"00000000\", \"00000000\")";
1220 }

◆ buildDefValuesBuffer()

bool L1GtVhdlWriterCore::buildDefValuesBuffer ( L1GtVhdlTemplateFile buffer,
const std::map< L1GtConditionType, std::string > &  typeList,
const std::vector< std::string > &  defValuesList,
const L1GtObject object 
)

helper, used by writeDefValPkg. Builds default values buffer for each object type. this buffer finally is inserte in the def_val_pkg.vhd template file

Definition at line 1380 of file L1GtVhdlWriterCore.cc.

References edmScanValgrind::buffer, condType2Str_, Skims_PA_cff::content, ETM, ETT, L1GtVhdlTemplateFile::findAndReplaceString(), getDefValsFromTriggerMenu(), L1GtVhdlTemplateFile::getInternalParameter(), HTT, mps_fire::i, JetCounts, Mu, objType2Str_, L1GtVhdlTemplateFile::open(), L1GtVhdlDefinitions::RegEtThreshold, sp(), AlCaHLTBitMon_QueryRunRegistry::string, L1GtVhdlDefinitions::stringConstantCalo_, L1GtVhdlDefinitions::stringConstantDefValId_, L1GtVhdlTemplateFile::substitute(), L1GtVhdlDefinitions::substParamCaloOrMuon_, L1GtVhdlDefinitions::substParamContent_, L1GtVhdlDefinitions::substParamDefValId_, L1GtVhdlDefinitions::substParamDefValType_, L1GtVhdlDefinitions::substParamMaxNr_, L1GtVhdlDefinitions::substParamOthers_, L1GtVhdlDefinitions::substParamParticle_, L1GtVhdlDefinitions::substParamType_, and vhdlDir_.

Referenced by writeDefValPkg().

1383  {
1384  // type iterator
1385  std::map<L1GtConditionType, std::string>::const_iterator typeIter;
1386 
1387  for (typeIter = typeList.begin(); typeIter != typeList.end(); typeIter++) {
1388  for (unsigned int i = 0; i < defValuesList.size(); i++) {
1389  // open a new internale template
1390  L1GtVhdlTemplateFile internalTemplate;
1391  internalTemplate.open(vhdlDir_ + "InternalTemplates/defvalpkg", true);
1392 
1393  std::string idString = internalTemplate.getInternalParameter(stringConstantDefValId_);
1394 
1395  // The following three steps convert "$(particle)_$(type)_$(defvaltype)_def_val"
1396  // to e.g. "muon_1s_et_def_val"
1397 
1398  // replace the substiution parameter particle with muon - thereby parameterString is a
1399  // reference and therefore changed.
1401 
1402  // replace the substiution parameter particle with muon
1403  L1GtVhdlTemplateFile::findAndReplaceString(idString, sp(substParamType_), typeIter->second);
1404 
1405  // replace the substiution parameter defvaltype with muon
1407 
1408  // usage of the subsitute routine:
1409  // first the substitution parameter, then the content
1410  internalTemplate.substitute(substParamDefValId_, idString);
1411 
1412  // !here the body of the internale template is build - almost done!
1413 
1414  // The body looks as follows $(def_val), $(max_nr), $(content) and
1415  // $(others) have to be subsituted
1416 
1417  /*
1418  * CONSTANT $(def_val) : $(calo_or_muon)_maxnr$(max_nr)vector8_arr :=
1419  * (
1420  * $(content)
1421  * $(others)
1422  * );
1423  */
1424 
1425  // substitute the particle
1426  internalTemplate.substitute(substParamParticle_, objType2Str_[object]);
1427 
1428  // go on with max number - get the correct expression for max number from the internal template
1429  internalTemplate.substitute(
1431  internalTemplate.getInternalParameter(substParamMaxNr_ + "_" + condType2Str_[typeIter->first]));
1432 
1433  // now we have to choose the correct OTHERS string for the
1434  // internal template. The identifier for the OTHERS string
1435  // is the condition type (as firmware string) therefore:
1436 
1437  // we get it as follows
1438  std::string othersString;
1439 
1440  // jet_cnts are a special case
1441  if (object == JetCounts || object == HTT || object == ETM || object == ETT)
1442  othersString = internalTemplate.getInternalParameter(objType2Str_[JetCounts]);
1443  else
1444  othersString = internalTemplate.getInternalParameter(typeIter->second);
1445 
1446  internalTemplate.substitute(substParamOthers_, othersString);
1447 
1448  // the actual content, taken from the trigger menu
1449 
1450  std::string content = getDefValsFromTriggerMenu(typeIter->first, object, RegEtThreshold);
1451 
1452  internalTemplate.substitute(substParamContent_, content);
1453 
1454  // Finally the parameter $(calo_or_muon) is left open
1455  std::string caloOrMuonStr = stringConstantCalo_;
1456 
1457  if (object == Mu)
1458  caloOrMuonStr = objType2Str_[Mu];
1459 
1460  internalTemplate.substitute(substParamCaloOrMuon_, caloOrMuonStr);
1461 
1462  // The internal template has been processed and now can be added to the buffer..
1463  buffer.append(internalTemplate);
1464  }
1465  }
1466 
1467  return true;
1468 }
std::string vhdlDir_
templates directory
std::string sp(const std::string &name)
converts string name to substiution parameter synthax; name –>
static const bool findAndReplaceString(std::string &paramString, const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString at it&#39;s first occurance in string
bool substitute(const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString
static const std::string stringConstantDefValId_
Definition: L1GtObject.h:35
std::string getDefValsFromTriggerMenu(const L1GtConditionType &type, const L1GtObject &object, const VmeRegister &reg)
static const std::string substParamDefValType_
Definition: L1GtObject.h:37
static const std::string substParamType_
static const std::string substParamDefValId_
std::map< L1GtConditionType, std::string > condType2Str_
converts L1GtConditionType to firmware string
std::string getInternalParameter(const std::string &indentifier)
returns a parameter of a internal template file
std::map< L1GtObject, std::string > objType2Str_
converts L1GtObject to string
Definition: L1GtObject.h:29
static const std::string stringConstantCalo_
static const std::string substParamContent_
static const std::string substParamParticle_
Definition: L1GtObject.h:36
static const std::string substParamOthers_
static const std::string substParamCaloOrMuon_
static const std::string substParamMaxNr_
bool open(const std::string &fileName, bool internal=false)
opens a template file. If the header information shall be parsed intern has to be set to true ...

◆ chip2OutputSubDir()

std::string L1GtVhdlWriterCore::chip2OutputSubDir ( const int &  chip)

Definition at line 743 of file L1GtVhdlWriterCore.cc.

References outputDir_, L1GtVhdlDefinitions::outputSubDir1_, and L1GtVhdlDefinitions::outputSubDir2_.

Referenced by writeAlgoSetup(), writeCond2intMap2File(), writeCondChipPkg(), writeConditionChipSetup(), writeDefValPkg(), writeEtmSetup(), writeMuonSetupVhdl(), and writeQsfSetupFiles().

743  {
744  if (chip == 1)
745  return outputDir_ + "/" + outputSubDir1_ + "/";
746  if (chip == 2)
747  return outputDir_ + "/" + outputSubDir2_ + "/";
748 
749  return "";
750 }
static const std::string outputSubDir1_
static const std::string outputSubDir2_
std::string outputDir_
output directory

◆ countCondsAndAdd2NumberVec()

void L1GtVhdlWriterCore::countCondsAndAdd2NumberVec ( const L1GtConditionType type,
const L1GtConditionCategory category,
const L1GtObject object,
const ConditionMap map,
ConditionMap outputMap,
const int &  condChip 
)

returns conditions of a class in output map and counts the occurance of all conditions of a certain type at the same time with the result being stored in numberOfConditions_ in the following format: CONSTANT nr_muon_3 : integer := 0; Tis is the format for the cond_chip_pkg files.

Definition at line 1470 of file L1GtVhdlWriterCore.cc.

References taus_updatedMVAIds_cff::category, condType2Str_, genParticles_cff::map, contentValuesFiles::number, numberOfConditions_, objType2Str_, retNumberOfConditionsString(), returnConditionsOfOneClass(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getCaloSetupContentFromTriggerMenu(), getEsumsSetupContentFromTriggerMenu(), and getMuonSetupContentFromTriggerMenu().

1475  {
1476  // Get the absoloute amount of conditions
1477 
1478  int number;
1479 
1480  if (returnConditionsOfOneClass(type, category, object, map, outputMap))
1481  number = outputMap.size();
1482  else
1483  number = 0;
1484 
1486 
1487  numberOfConditions_.at(condChip - 1).push_back(initstr);
1488 }
std::vector< std::vector< std::string > > numberOfConditions_
vector containing the initialization of all conditions
bool returnConditionsOfOneClass(const L1GtConditionType &type, const L1GtConditionCategory &category, const L1GtObject &object, const ConditionMap &map, ConditionMap &outputMap)
std::map< L1GtConditionType, std::string > condType2Str_
converts L1GtConditionType to firmware string
std::string retNumberOfConditionsString(const std::string &typeStr, const int &number)
std::map< L1GtObject, std::string > objType2Str_
converts L1GtObject to string

◆ findObjectType()

bool L1GtVhdlWriterCore::findObjectType ( const L1GtObject object,
ConditionMap map 
)

Definition at line 110 of file L1GtVhdlWriterCore.cc.

References mps_fire::i, genParticles_cff::map, resolutioncreator_cfi::object, findQualityFiles::size, and mps_update::status.

110  {
111  bool status = false;
112 
113  ConditionMap::iterator condIter = map.begin();
114  while (condIter != map.end()) {
115  for (unsigned int i = 0; i < (condIter->second->objectType()).size(); i++) {
116  if (condIter->second->objectType()[i] == object) {
117  status = true;
118  break;
119  }
120  }
121 
122  if (status)
123  break;
124  condIter++;
125  }
126 
127  return status;
128 }
size
Write out results.

◆ getCaloSetupContentFromTriggerMenu()

bool L1GtVhdlWriterCore::getCaloSetupContentFromTriggerMenu ( const unsigned short int &  condChip,
std::map< std::string, std::string > &  caloParameters,
const L1GtObject caloObject 
)

Definition at line 266 of file L1GtVhdlWriterCore.cc.

References bm_, L1GtVhdlWriterBitManager::buildDeltaEtaCalo(), L1GtVhdlWriterBitManager::buildDeltaPhiCalo(), L1GtVhdlWriterBitManager::buildEtaCalo(), L1GtVhdlWriterBitManager::buildPhiCalo(), CondCalo, conditionToIntegerMap_, L1GtCaloTemplate::correlationParameter(), countCondsAndAdd2NumberVec(), counter, debugMode_, mps_fire::i, L1GtCaloTemplate::objectParameter(), Type1s, Type2s, Type2wsc, and Type4s.

Referenced by makeFirmware().

268  {
269  // vector containing all relevant types for calo conditions
270  std::vector<L1GtConditionType> caloConditionTypes;
271 
272  caloConditionTypes.push_back(Type1s);
273  caloConditionTypes.push_back(Type2s);
274  caloConditionTypes.push_back(Type2wsc);
275  caloConditionTypes.push_back(Type4s);
276 
277  for (unsigned int i = 0; i < caloConditionTypes.size(); i++) {
278  unsigned int counter = 0;
279 
280  ConditionMap caloConditions;
281 
282  // stores all conditions of type given in the first three parameters
284  caloConditionTypes.at(i), CondCalo, caloObject, (*conditionMap_).at(condChip - 1), caloConditions, condChip);
285 
286  for (ConditionMap::const_iterator iterCond = caloConditions.begin(); iterCond != caloConditions.end(); iterCond++) {
287  // add this condition to name -> integer conversion map
288  conditionToIntegerMap_[iterCond->first] = counter;
289 
290  L1GtCaloTemplate *m_gtCaloTemplate = static_cast<L1GtCaloTemplate *>(iterCond->second);
291  const std::vector<L1GtCaloTemplate::ObjectParameter> *op = m_gtCaloTemplate->objectParameter();
292 
293  if (caloConditionTypes.at(i) == Type1s) {
294  //= static_cast<std::vector<L1GtCaloTemplate::ObjectPaenergySumParameter+=rameter*> >(op);
295 
296  // build eta
297  caloParameters["eta_1_s"] += (bm_.buildEtaCalo(op, 1, counter));
298 
299  caloParameters["phi_1_s"] += bm_.buildPhiCalo(op, 1, counter);
300 
301  if (debugMode_) {
302  caloParameters["eta_1_s"] += ("--" + iterCond->first + "\n");
303  caloParameters["phi_1_s"] += ("--" + iterCond->first + "\n");
304  }
305 
306  } else if (caloConditionTypes.at(i) == Type2s) {
307  // build eta
308  caloParameters["eta_2_s"] += (bm_.buildEtaCalo(op, 2, counter));
309 
310  // add the parameters to parameter map
311  caloParameters["phi_2_s"] += bm_.buildPhiCalo(op, 2, counter);
312 
313  if (debugMode_) {
314  caloParameters["eta_2_s"] += ("--" + iterCond->first + "\n");
315  caloParameters["phi_2_s"] += ("--" + iterCond->first + "\n");
316  }
317 
318  } else if (caloConditionTypes.at(i) == Type4s) {
319  // build eta
320  caloParameters["eta_4"] += (bm_.buildEtaCalo(op, 4, counter));
321 
322  // add the parameters to parameter map
323  caloParameters["phi_4"] += bm_.buildPhiCalo(op, 4, counter);
324 
325  if (debugMode_) {
326  caloParameters["eta_4"] += ("--" + iterCond->first + "\n");
327  caloParameters["phi_4"] += ("--" + iterCond->first + "\n");
328  }
329 
330  } else if (caloConditionTypes.at(i) == Type2wsc) {
332 
333  // build eta
334  caloParameters["eta_2_wsc"] += (bm_.buildEtaCalo(op, 2, counter));
335 
336  // build phi
337  caloParameters["phi_2_wsc"] += bm_.buildPhiCalo(op, 2, counter);
338 
339  // build delta_eta
340  caloParameters["delta_eta"] += bm_.buildDeltaEtaCalo(cp, counter);
341 
342  // build delta_phi
343  caloParameters["delta_phi"] += bm_.buildDeltaPhiCalo(cp, counter);
344 
345  if (debugMode_) {
346  caloParameters["eta_2_wsc"] += ("--" + iterCond->first + "\n");
347  caloParameters["phi_2_wsc"] += ("--" + iterCond->first + "\n");
348  caloParameters["delta_eta"] += ("--" + iterCond->first + "\n");
349  caloParameters["delta_phi"] += ("--" + iterCond->first + "\n");
350  }
351  }
352 
353  counter++;
354  }
355  }
356 
357  return true;
358 }
std::string buildEtaCalo(const std::vector< L1GtCaloTemplate::ObjectParameter > *op, const unsigned int &num, const unsigned int &counter)
const std::vector< ObjectParameter > * objectParameter() const
std::map< std::string, L1GtCondition * > ConditionMap
map containing the conditions
L1GtVhdlWriterBitManager bm_
bit manager for bit operations
std::string buildDeltaEtaCalo(const L1GtCaloTemplate::CorrelationParameter *&cp, const unsigned int &counter)
const CorrelationParameter * correlationParameter() const
std::string buildDeltaPhiCalo(const L1GtCaloTemplate::CorrelationParameter *&cp, const unsigned int &counter)
std::string buildPhiCalo(const std::vector< L1GtCaloTemplate::ObjectParameter > *op, const unsigned int &num, const unsigned int &counter)
typedef for correlation parameters
void countCondsAndAdd2NumberVec(const L1GtConditionType &type, const L1GtConditionCategory &category, const L1GtObject &object, const ConditionMap &map, ConditionMap &outputMap, const int &condChip)
static std::atomic< unsigned int > counter
std::map< std::string, int > conditionToIntegerMap_
stores to condition name to integer conversion table
bool debugMode_
class will produce some additional debugging output if set

◆ getCategoryFromObject()

L1GtConditionCategory L1GtVhdlWriterCore::getCategoryFromObject ( const L1GtObject object)

gets condition category from object

Definition at line 1524 of file L1GtVhdlWriterCore.cc.

References taus_updatedMVAIds_cff::category, CenJet, CondCalo, CondEnergySum, CondJetCounts, CondMuon, CondNull, ETM, ETT, ForJet, HTT, IsoEG, JetCounts, Mu, NoIsoEG, and TauJet.

Referenced by getDefValsFromTriggerMenu().

1524  {
1526 
1527  if (object == Mu)
1528  category = CondMuon;
1529  else if (object == ETM || object == HTT || object == ETT)
1531  else if (object == IsoEG || object == NoIsoEG || object == CenJet || object == ForJet || object == TauJet)
1532  category = CondCalo;
1533  else if (object == IsoEG || object == NoIsoEG || object == CenJet || object == ForJet || object == TauJet)
1534  category = CondCalo;
1535  else if (object == JetCounts)
1537  else
1538  category = CondNull;
1539 
1540  return category;
1541 }
Definition: L1GtObject.h:35
Definition: L1GtObject.h:37
Definition: L1GtObject.h:29
Definition: L1GtObject.h:36
L1GtConditionCategory
condition categories

◆ getCond2IntMap()

std::map< std::string, int > L1GtVhdlWriterCore::getCond2IntMap ( )

Definition at line 1583 of file L1GtVhdlWriterCore.cc.

References conditionToIntegerMap_.

Referenced by L1GtVhdlWriter::analyze().

1583 { return conditionToIntegerMap_; }
std::map< std::string, int > conditionToIntegerMap_
stores to condition name to integer conversion table

◆ getCondChipVhdContentFromTriggerMenu()

bool L1GtVhdlWriterCore::getCondChipVhdContentFromTriggerMenu ( const unsigned short int &  condChip,
std::map< std::string, L1GtVhdlTemplateFile > &  templates,
std::map< std::string, std::string > &  commonParams 
)

builds the substitution parameters for the cond_chip.vhd the condition chip that will be processed

Parameters
conditionToIntegerMapthis has to be a already FILLED conversion map. therefore this routine has to be called after all those which are adding information to the conditionToIntegerMap map (getMuonSetupContentFromTriggerMenu, buildCaloParameterMap...)
templatesin this map the final content for the subsitution parameters is stored in VHDL template file format

Definition at line 434 of file L1GtVhdlWriterCore.cc.

References L1GtVhdlTemplateFile::append(), L1TowerCalibrationProducer_cfi::calo, caloObjects_, caloType2Int_, CondCalo, CondCorrelation, CondEnergySum, conditionToIntegerMap_, CondJetCounts, CondMuon, CondNull, condType2Str_, esumObjects_, ETM, spr::find(), L1GtVhdlTemplateFile::findAndReplaceString(), getIntVal(), getSubstParamCommonFromTriggerMenu(), mps_fire::i, index4CondChipVhd(), int2str(), metsig::jet, JetCounts, msg(), Mu, HLT_2022v12_cff::muon, L1GtCondition::nrObjects(), L1GtJetCountsTemplate::objectParameter(), objType2Str_, L1GtVhdlTemplateFile::open(), AlCaHLTBitMon_ParallelJobs::p, L1GtVhdlTemplateFile::removeEmptyLines(), L1GtVhdlTemplateFile::returnParameterMap(), sp(), AlCaHLTBitMon_QueryRunRegistry::string, L1GtVhdlDefinitions::stringConstantCharge1s_, L1GtVhdlDefinitions::stringConstantCharge2s_, L1GtVhdlDefinitions::stringConstantCharge2wsc_, L1GtVhdlDefinitions::stringConstantCharge3s_, L1GtVhdlDefinitions::stringConstantCharge4s_, L1GtVhdlDefinitions::stringConstantCommon_, L1GtVhdlTemplateFile::substitute(), L1GtVhdlDefinitions::substParamCharge_, L1GtVhdlDefinitions::substParamJetCntsCommon_, L1GtVhdlDefinitions::substParamParticle_, L1GtVhdlDefinitions::substParamType_, PixelCPETemplateReco_cfi::templates, Type1s, Type2s, Type2wsc, Type3s, Type4s, and vhdlDir_.

Referenced by makeFirmware().

436  {
437  // open the necessary internal templates
439 
440  muon.open(vhdlDir_ + "InternalTemplates/muon", true);
441  muon.substitute("particle", "muon");
442 
443  calo.open(vhdlDir_ + "InternalTemplates/calo", true);
444  esums.open(vhdlDir_ + "InternalTemplates/esums", true);
445  jet.open(vhdlDir_ + "InternalTemplates/jet_cnts", true);
446 
447  /*
448  charge1s.open(vhdlDir_+"InternalTemplates/charge_1s",false);
449  charge2s.open(vhdlDir_+"InternalTemplates/charge_2s",false);
450  charge2wsc.open(vhdlDir_+"InternalTemplates/charge_2_wsc",false);
451  charge3s.open(vhdlDir_+"InternalTemplates/charge_3",false);
452  charge4s.open(vhdlDir_+"InternalTemplates/charge_4",false);
453  */
454 
455  // only for jet_cnts common parameter relevant since common parameter is build in this routine
456  std::vector<unsigned int> processedTypes;
457 
458  //-------------------------------------build the common parameters-------------------------------------------
459 
460  // build $(muon_common)
461  getSubstParamCommonFromTriggerMenu(condChip, muon, Mu, CondMuon, commonParams["muon_common"]);
462 
463  // build $(calo_common) - loop over all calo objects
464  std::vector<L1GtObject>::iterator caloObjIter = caloObjects_.begin();
465 
466  while (caloObjIter != caloObjects_.end()) {
467  getSubstParamCommonFromTriggerMenu(condChip, muon, (*caloObjIter), CondCalo, commonParams["calo_common"]);
468  caloObjIter++;
469  }
470 
471  // build $(esums_common) - loop over all esums objects
472  std::vector<L1GtObject>::iterator esumObjIter = esumObjects_.begin();
473 
474  while (esumObjIter != esumObjects_.end()) {
475  getSubstParamCommonFromTriggerMenu(condChip, esums, (*esumObjIter), CondEnergySum, commonParams["esums_common"]);
476  esumObjIter++;
477  }
478 
479  //--------------------------------------build the parameter maps----------------------------------------------
480 
481  // loop over condition map
482  for (ConditionMap::const_iterator iterCond = (*conditionMap_).at(condChip - 1).begin();
483  iterCond != (*conditionMap_).at(condChip - 1).end();
484  iterCond++) {
485  switch ((iterCond->second)->condCategory()) {
486  case CondMuon: {
487  int cond2int;
488  if (!getIntVal(conditionToIntegerMap_, (iterCond->first), cond2int)) {
489  msg("Panik! Condition " + (iterCond->first) + " does not have a integer equivalent!");
490  break;
491  }
492 
493  std::string intVal = index4CondChipVhd(cond2int);
494 
495  L1GtVhdlTemplateFile muoncopy = muon;
496 
497  muoncopy.substitute("type", condType2Str_[(iterCond->second)->condType()]);
498 
499  muoncopy.substitute("ser_no", intVal);
500 
501  muoncopy.substitute("name", iterCond->first);
502 
503  if ((iterCond->second)->condType() == Type1s) {
504  muoncopy.substitute(substParamCharge_, muon.getInternalParameter(stringConstantCharge1s_));
505  } else if ((iterCond->second)->condType() == Type2s) {
506  muoncopy.substitute(substParamCharge_, muon.getInternalParameter(stringConstantCharge2s_));
507  } else if ((iterCond->second)->condType() == Type2wsc) {
508  muoncopy.substitute(substParamCharge_, muon.getInternalParameter(stringConstantCharge2wsc_));
509  } else if ((iterCond->second)->condType() == Type3s) {
510  muoncopy.substitute(substParamCharge_, muon.getInternalParameter(stringConstantCharge3s_));
511  } else if ((iterCond->second)->condType() == Type4s) {
512  muoncopy.substitute(substParamCharge_, muon.getInternalParameter(stringConstantCharge4s_));
513  }
514 
515  std::string tempStr = muoncopy.returnParameterMap()["PREALGO"];
516 
517  muoncopy.findAndReplaceString(tempStr, "$(particle)", "muon");
518  muoncopy.findAndReplaceString(tempStr, "$(ser_no)", intVal);
519  muoncopy.findAndReplaceString(tempStr, "$(type)", condType2Str_[(iterCond->second)->condType()]);
520 
521  muoncopy.append(tempStr);
522 
523  muoncopy.removeEmptyLines();
524 
525  // add the processed internal template to parameter map
526  templates["muon"].append(muoncopy);
527 
528  } break;
529 
530  case CondCalo: {
531  int cond2int;
532 
533  if (!getIntVal(conditionToIntegerMap_, (iterCond->first), cond2int)) {
534  msg("Panik! Condition " + (iterCond->first) + " does not have a integer equivalent!");
535  break;
536  }
537 
538  std::string intVal = index4CondChipVhd(cond2int);
539 
540  L1GtVhdlTemplateFile calocopy = calo;
541 
542  calocopy.substitute("type", condType2Str_[(iterCond->second)->condType()]);
543  calocopy.substitute("particle", objType2Str_[((iterCond->second)->objectType()).at(0)]);
544  calocopy.substitute("name", iterCond->first);
545  calocopy.substitute("ser_no", intVal);
546  calocopy.substitute("calo_nr", caloType2Int_[((iterCond->second)->objectType()).at(0)]);
547 
548  // builds something like tau_1_s(20));
549  calocopy.append(objType2Str_[((iterCond->second)->objectType()).at(0)] + "_" +
550  condType2Str_[(iterCond->second)->condType()] + "(" + intVal + "));");
551 
552  templates["calo"].append(calocopy);
553 
554  } break;
555 
556  case CondEnergySum: {
557  int cond2int;
558 
559  if (!getIntVal(conditionToIntegerMap_, (iterCond->first), cond2int)) {
560  msg("Panik! Condition " + (iterCond->first) + " does not have a integer equivalent!");
561  break;
562  }
563 
564  std::string intVal = index4CondChipVhd(cond2int);
565 
566  L1GtVhdlTemplateFile esumscopy = esums;
567 
568  esumscopy.substitute("type", condType2Str_[(iterCond->second)->condType()]);
569  esumscopy.substitute("particle", objType2Str_[((iterCond->second)->objectType()).at(0)]);
570  esumscopy.substitute("name", iterCond->first);
571  esumscopy.substitute("ser_no", intVal);
572 
573  if (((iterCond->second)->objectType()).at(0) == ETM)
574  esumscopy.substitute("if_etm_then_1_else_0", "1");
575  else
576  esumscopy.substitute("if_etm_then_1_else_0", "0");
577 
578  // builds something like htt_cond(4));
579  esumscopy.append(objType2Str_[((iterCond->second)->objectType()).at(0)] + "_" +
580  condType2Str_[(iterCond->second)->condType()] + "(" + intVal + "));");
581 
582  templates["esums"].append(esumscopy);
583  }
584 
585  break;
586 
587  case CondJetCounts: {
588  // build the common parameter for the jet counts
589 
590  L1GtJetCountsTemplate *jetsTemplate = static_cast<L1GtJetCountsTemplate *>(iterCond->second);
591 
592  int nObjects = iterCond->second->nrObjects();
593 
594  const std::vector<L1GtJetCountsTemplate::ObjectParameter> *op = jetsTemplate->objectParameter();
595 
596  for (int i = 0; i < nObjects; i++) {
597  std::vector<unsigned int>::iterator p =
598  find(processedTypes.begin(), processedTypes.end(), (*op)[i].countIndex);
599 
600  // check, weather this count index was already processed
601  // and process it if not
602  if (p == processedTypes.end()) {
603  std::ostringstream indStr;
604  indStr << (*op)[i].countIndex;
605 
606  std::string tempStr2 = jet.returnParameterMap()[stringConstantCommon_];
607  while (jet.findAndReplaceString(tempStr2, sp(substParamParticle_), objType2Str_[JetCounts]))
608  ;
609  while (jet.findAndReplaceString(tempStr2, sp(substParamType_), indStr.str()))
610  ;
611  commonParams[substParamJetCntsCommon_] += tempStr2 + "\n"; // +"<= '0';\n");
612  processedTypes.push_back((*op)[i].countIndex);
613  }
614  }
615 
616  int cond2int;
617 
618  if (!getIntVal(conditionToIntegerMap_, (iterCond->first), cond2int)) {
619  msg("Panik! Condition " + (iterCond->first) + " does not have a integer equivalent!");
620  break;
621  }
622 
623  std::string intVal = index4CondChipVhd(cond2int);
624 
625  L1GtVhdlTemplateFile jetcopy = jet;
626 
627  jetcopy.substitute("particle", condType2Str_[(iterCond->second)->condType()]);
628  jetcopy.substitute("type", int2str((*op)[0].countIndex));
629  jetcopy.substitute("name", iterCond->first);
630 
631  jetcopy.substitute("ser_no", intVal);
632 
633  // builds the final string
634  std::string tempStr = jetcopy.returnParameterMap()["PREALGO"];
635 
636  jetcopy.findAndReplaceString(tempStr, "$(particle)", "jet_cnt");
637  jetcopy.findAndReplaceString(tempStr, "$(ser_no)", intVal);
638  jetcopy.findAndReplaceString(tempStr, "$(type)", int2str((*op)[0].countIndex));
639 
640  jetcopy.append(tempStr);
641  jetcopy.removeEmptyLines();
642 
643  templates["jet_cnts"].append(jetcopy);
644  }
645 
646  break;
647 
648  case CondCorrelation: {
649  //empty
650  } break;
651 
652  case CondNull: {
653  //empty
654  } break;
655 
656  default: {
657  //empty
658  } break;
659  }
660  }
661 
662  // delete superfluous newlines at the end of common parameters
663  std::map<std::string, std::string>::iterator pIt = commonParams.begin();
664 
665  while (pIt != commonParams.end()) {
666  if ((pIt->second)[((pIt->second).length() - 1)] == '\n')
667  (pIt->second) = (pIt->second).substr(0, (pIt->second).length() - 1);
668  pIt++;
669  }
670 
671  return true;
672 }
std::map< L1GtObject, std::string > caloType2Int_
converts L1GtObject to calo_nr
std::string vhdlDir_
templates directory
std::string sp(const std::string &name)
converts string name to substiution parameter synthax; name –>
static const bool findAndReplaceString(std::string &paramString, const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString at it&#39;s first occurance in string
bool substitute(const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString
static const std::string stringConstantCharge2wsc_
std::vector< L1GtObject > esumObjects_
list of all possible esums objects
Definition: L1GtObject.h:35
std::vector< L1GtObject > caloObjects_
list of all possible calo objects
static const std::string substParamJetCntsCommon_
std::string index4CondChipVhd(int intval)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
static const std::string stringConstantCommon_
bool getIntVal(const std::map< std::string, int > &map, const std::string &searchValue, int &intVal)
checks weather value searchValue exists in a <string,int> map, saves it in &intVal if it exists and r...
static std::string int2str(const int &integerValue)
converts a integer into a string
static const std::string stringConstantCharge4s_
static const std::string substParamType_
bool getSubstParamCommonFromTriggerMenu(const unsigned short int &condChip, L1GtVhdlTemplateFile &particle, const L1GtObject &object, const L1GtConditionCategory &category, std::string &parameterStr)
builds the parameters particle_common for the cond_chip.vhd&#39;s
void append(const std::string &str)
adds a line at the end of the the file with the content of str
const std::vector< ObjectParameter > * objectParameter() const
std::map< L1GtConditionType, std::string > condType2Str_
converts L1GtConditionType to firmware string
static const std::string stringConstantCharge3s_
std::map< L1GtObject, std::string > objType2Str_
converts L1GtObject to string
void msg(const std::string &message)
adds a string to intern message buffer
Definition: L1GtObject.h:29
std::map< std::string, std::string > returnParameterMap() const
returns parameter map
static const std::string substParamParticle_
static const std::string stringConstantCharge1s_
const int nrObjects() const
get number of trigger objects
std::map< std::string, int > conditionToIntegerMap_
stores to condition name to integer conversion table
static const std::string substParamCharge_
bool removeEmptyLines()
deletes all empty lines in a template file
bool open(const std::string &fileName, bool internal=false)
opens a template file. If the header information shall be parsed intern has to be set to true ...
Definition: Common.h:9
static const std::string stringConstantCharge2s_

◆ getDefValsFromTriggerMenu()

std::string L1GtVhdlWriterCore::getDefValsFromTriggerMenu ( const L1GtConditionType type,
const L1GtObject object,
const VmeRegister reg 
)

this routine extracts default values for def_val_pkg.vhd from trigger menu. it is used from buildDefValuesBuffer.

Definition at line 1222 of file L1GtVhdlWriterCore.cc.

References taus_updatedMVAIds_cff::category, CondCalo, submitPVValidationJobs::conditions, getCategoryFromObject(), mps_fire::i, int2str(), L1GtCaloTemplate::objectParameter(), mps_fire::result, returnConditionsOfOneClass(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by buildDefValuesBuffer().

1224  {
1226 
1227  // get condition category from object
1228 
1229  category = getCategoryFromObject(object);
1230 
1232  returnConditionsOfOneClass(type, category, object, (*conditionMap_).at(0), conditions);
1233 
1235 
1236  if (category == CondCalo) {
1237  for (ConditionMap::const_iterator iterCond = conditions.begin(); iterCond != conditions.end(); iterCond++) {
1238  L1GtCaloTemplate *caloTemplate = static_cast<L1GtCaloTemplate *>(iterCond->second);
1239  const std::vector<L1GtCaloTemplate::ObjectParameter> *op = caloTemplate->objectParameter();
1240 
1241  unsigned int nObjects = iterCond->second->nrObjects();
1242 
1243  for (unsigned int i = 0; i < nObjects; i++) {
1244  if (i == 0)
1245  result += "(";
1246  result += "\"";
1247  result += int2str((*op).at(i).etThreshold);
1248  result += "\"";
1249  if (i != nObjects - 1)
1250  result += ",";
1251  else
1252  result += ")\n";
1253  }
1254  }
1255  }
1256 
1257  return "-- 0 => (\"00000000\", \"00000000\" ... )";
1258  return result;
1259 }
const std::vector< ObjectParameter > * objectParameter() const
std::map< std::string, L1GtCondition * > ConditionMap
map containing the conditions
static std::string int2str(const int &integerValue)
converts a integer into a string
bool returnConditionsOfOneClass(const L1GtConditionType &type, const L1GtConditionCategory &category, const L1GtObject &object, const ConditionMap &map, ConditionMap &outputMap)
L1GtConditionCategory getCategoryFromObject(const L1GtObject &object)
gets condition category from object
L1GtConditionCategory
condition categories

◆ getEsumsSetupContentFromTriggerMenu()

bool L1GtVhdlWriterCore::getEsumsSetupContentFromTriggerMenu ( const unsigned short int &  condChip,
const L1GtObject object,
std::string &  energySumParameter 
)

contains only one subsitution parameter which is stored in reference energySumParameter

Definition at line 360 of file L1GtVhdlWriterCore.cc.

References bm_, L1GtVhdlWriterBitManager::buildPhiEnergySum(), CondEnergySum, conditionToIntegerMap_, countCondsAndAdd2NumberVec(), debugMode_, ETM, ETT, HTT, L1GtEnergySumTemplate::objectParameter(), TypeETM, TypeETT, and TypeHTT.

Referenced by makeFirmware().

362  {
364 
365  unsigned int counter = 0;
366 
367  if (object == HTT)
368  type = TypeHTT;
369  else if (object == ETM)
370  type = TypeETM;
371  else if (object == ETT)
372  type = TypeETT;
373 
374  ConditionMap esumsConditions;
375  // stores all conditions of type given in the first three parameters
376  countCondsAndAdd2NumberVec(type, CondEnergySum, object, (*conditionMap_).at(condChip - 1), esumsConditions, condChip);
377 
378  for (ConditionMap::const_iterator iterCond = esumsConditions.begin(); iterCond != esumsConditions.end(); iterCond++) {
379  L1GtEnergySumTemplate *energySumTempl = static_cast<L1GtEnergySumTemplate *>(iterCond->second);
380  const std::vector<L1GtEnergySumTemplate::ObjectParameter> *op = energySumTempl->objectParameter();
381 
382  if (!bm_.buildPhiEnergySum(op, 1, counter).empty())
383  energySumParameter += bm_.buildPhiEnergySum(op, 1, counter);
384 
385  if (debugMode_) {
386  energySumParameter += ("--" + iterCond->first + "\n");
387  }
388 
389  conditionToIntegerMap_[(iterCond->first)] = counter;
390 
391  counter++;
392  }
393 
394  return true;
395 }
std::map< std::string, L1GtCondition * > ConditionMap
map containing the conditions
Definition: L1GtObject.h:35
L1GtConditionType
L1GtVhdlWriterBitManager bm_
bit manager for bit operations
Definition: L1GtObject.h:37
void countCondsAndAdd2NumberVec(const L1GtConditionType &type, const L1GtConditionCategory &category, const L1GtObject &object, const ConditionMap &map, ConditionMap &outputMap, const int &condChip)
Definition: L1GtObject.h:36
std::string buildPhiEnergySum(const std::vector< L1GtEnergySumTemplate::ObjectParameter > *op, const unsigned int &num, const unsigned int &counter)
std::map< std::string, int > conditionToIntegerMap_
stores to condition name to integer conversion table
const std::vector< ObjectParameter > * objectParameter() const
bool debugMode_
class will produce some additional debugging output if set

◆ getIntVal()

bool L1GtVhdlWriterCore::getIntVal ( const std::map< std::string, int > &  map,
const std::string &  searchValue,
int &  intVal 
)

checks weather value searchValue exists in a <string,int> map, saves it in &intVal if it exists and returns false if not

Definition at line 1126 of file L1GtVhdlWriterCore.cc.

References genParticles_cff::map.

Referenced by getCondChipVhdContentFromTriggerMenu().

1126  {
1127  std::map<std::string, int>::const_iterator iter = map.find(searchValue);
1128  if (iter == map.end())
1129  return false;
1130  intVal = (*iter).second;
1131  return true;
1132 }

◆ getMsgBuf()

std::vector< std::string > L1GtVhdlWriterCore::getMsgBuf ( )

returns intern message buffer

Definition at line 1124 of file L1GtVhdlWriterCore.cc.

References internMessageBuf_.

1124 { return internMessageBuf_; }
std::vector< std::string > internMessageBuf_

◆ getMuonSetupContentFromTriggerMenu()

void L1GtVhdlWriterCore::getMuonSetupContentFromTriggerMenu ( const unsigned short int &  condChip,
std::map< std::string, std::string > &  muonParameters 
)

builds a parameter map that can be used by the L1GtVhdlWriterCore class the output is written into the parameter

Parameters
conditionToIntegerMapis the condition is added to this conversion map
muonParametershere the routine stores the content of the subsitution parameters
conditionMapcontaining the input

Definition at line 130 of file L1GtVhdlWriterCore.cc.

References bm_, L1GtVhdlWriterBitManager::buildDeltaEtaMuon(), L1GtVhdlWriterBitManager::buildDeltaPhiMuon(), L1GtVhdlWriterBitManager::buildEtaMuon(), L1GtVhdlWriterBitManager::buildPhiMuon(), conditionToIntegerMap_, CondMuon, L1GtMuonTemplate::correlationParameter(), countCondsAndAdd2NumberVec(), counter, debugMode_, HLT_2022v12_cff::dEta, mps_fire::i, Mu, L1GtMuonTemplate::objectParameter(), Type1s, Type2s, Type2wsc, Type3s, and Type4s.

Referenced by makeFirmware().

131  {
132  // vector containing all relevant types for muon conditions
133  std::vector<L1GtConditionType> muonConditionTypes;
134 
135  muonConditionTypes.push_back(Type1s);
136  muonConditionTypes.push_back(Type2s);
137  muonConditionTypes.push_back(Type2wsc);
138  muonConditionTypes.push_back(Type3s);
139  muonConditionTypes.push_back(Type4s);
140 
141  for (unsigned int i = 0; i < muonConditionTypes.size(); i++) {
142  //std::cout<<i<<std::endl;
143 
144  ConditionMap MuonConditions1s;
145 
147  muonConditionTypes.at(i), CondMuon, Mu, (*conditionMap_).at(condChip - 1), MuonConditions1s, condChip);
148 
149  /*
150  // Get the absoloute amount of conditions
151  std::string initstr="CONSTANT nr_"+objType2Str_[Mu]+"_"+condType2Str_[muonConditionTypes.at(i)]+" : integer := ";
152 
153  if (returnConditionsOfOneClass(muonConditionTypes.at(i),CondMuon,Mu,conditionMap_.at(condChip-1), MuonConditions1s))
154  initstr+=(int2str(MuonConditions1s.size())+";");
155  else
156  initstr+=("0;");
157 
158  numberOfConditions_.at(condChip-1).push_back(initstr);
159 
160  */
161 
162  //std::cout<< std::hex << (*myObjectParameter).at(0).etThreshold << std::endl;
163  unsigned int counter = 0;
164 
165  for (ConditionMap::const_iterator iterCond = MuonConditions1s.begin(); iterCond != MuonConditions1s.end();
166  iterCond++) {
167  // add this condition to name -> integer conversion map
168  conditionToIntegerMap_[iterCond->first] = counter;
169 
170  L1GtMuonTemplate *m_gtMuonTemplate = static_cast<L1GtMuonTemplate *>(iterCond->second);
171  const std::vector<L1GtMuonTemplate::ObjectParameter> *op = m_gtMuonTemplate->objectParameter();
172 
173  if (muonConditionTypes.at(i) == Type1s) {
174  // build eta
175  muonParameters["eta_1_s"] += (bm_.buildEtaMuon(op, 1, counter));
176 
177  // add the parameters to parameter map
178  muonParameters["phi_h_1_s"] += bm_.buildPhiMuon(op, 1, counter, true);
179  muonParameters["phi_l_1_s"] += bm_.buildPhiMuon(op, 1, counter, false);
180 
181  if (debugMode_) {
182  muonParameters["phi_l_1_s"] += ("--" + iterCond->first + "\n");
183  muonParameters["phi_h_1_s"] += ("--" + iterCond->first + "\n");
184  muonParameters["eta_1_s"] += ("--" + iterCond->first + "\n");
185  }
186 
187  } else
188 
189  if (muonConditionTypes.at(i) == Type2s) {
190  // build eta
191  muonParameters["eta_2_s"] += (bm_.buildEtaMuon(op, 2, counter));
192 
193  // add the parameters to parameter map
194  muonParameters["phi_h_2_s"] += bm_.buildPhiMuon(op, 2, counter, true);
195  muonParameters["phi_l_2_s"] += bm_.buildPhiMuon(op, 2, counter, false);
196 
197  if (debugMode_) {
198  muonParameters["phi_l_2_s"] += ("--" + iterCond->first + "\n");
199  muonParameters["phi_h_2_s"] += ("--" + iterCond->first + "\n");
200  muonParameters["eta_2_s"] += ("--" + iterCond->first + "\n");
201  }
202 
203  } else
204  //m_gtMuonTemplate->print(std::cout);
205 
206  if (muonConditionTypes.at(i) == Type3s) {
207  // build eta
208  muonParameters["eta_3"] += (bm_.buildEtaMuon(op, 3, counter));
209 
210  // add the parameters to parameter map
211  muonParameters["phi_h_3"] += bm_.buildPhiMuon(op, 3, counter, true);
212  muonParameters["phi_l_3"] += bm_.buildPhiMuon(op, 3, counter, false);
213 
214  if (debugMode_) {
215  muonParameters["phi_l_3"] += ("--" + iterCond->first + "\n");
216  muonParameters["phi_h_3"] += ("--" + iterCond->first + "\n");
217  muonParameters["eta_3"] += ("--" + iterCond->first + "\n");
218  }
219  }
220 
221  if (muonConditionTypes.at(i) == Type4s) {
222  // build eta
223  muonParameters["eta_4"] += (bm_.buildEtaMuon(op, 4, counter));
224 
225  // add the parameters to parameter map
226  muonParameters["phi_h_4"] += bm_.buildPhiMuon(op, 4, counter, true);
227  muonParameters["phi_l_4"] += bm_.buildPhiMuon(op, 4, counter, false);
228 
229  if (debugMode_) {
230  muonParameters["phi_l_4"] += ("--" + iterCond->first + "\n");
231  muonParameters["phi_h_4"] += ("--" + iterCond->first + "\n");
232  muonParameters["eta_4"] += ("--" + iterCond->first + "\n");
233  }
234  }
235 
236  if (muonConditionTypes.at(i) == Type2wsc) {
238 
239  // build eta
240  muonParameters["eta_2_wsc"] += (bm_.buildEtaMuon(op, 2, counter));
241 
242  // build phi
243  muonParameters["phi_h_2_wsc"] += bm_.buildPhiMuon(op, 2, counter, true);
244  muonParameters["phi_l_2_wsc"] += bm_.buildPhiMuon(op, 2, counter, false);
245 
246  // build delta_eta
247  std::ostringstream dEta;
248  muonParameters["delta_eta"] += bm_.buildDeltaEtaMuon(cp, counter);
249 
250  // build delta_phi
251  muonParameters["delta_phi"] += bm_.buildDeltaPhiMuon(cp, counter);
252 
253  if (debugMode_) {
254  muonParameters["eta_2_wsc"] += ("--" + iterCond->first + "\n");
255  muonParameters["phi_h_2_wsc"] += ("--" + iterCond->first + "\n");
256  muonParameters["phi_l_2_wsc"] += ("--" + iterCond->first + "\n");
257  muonParameters["delta_eta"] += ("--" + iterCond->first + "\n");
258  muonParameters["delta_phi"] += ("--" + iterCond->first + "\n");
259  }
260  }
261  counter++;
262  }
263  }
264 }
std::map< std::string, L1GtCondition * > ConditionMap
map containing the conditions
L1GtVhdlWriterBitManager bm_
bit manager for bit operations
std::string buildDeltaPhiMuon(const L1GtMuonTemplate::CorrelationParameter *&cp, const unsigned int &counter)
const CorrelationParameter * correlationParameter() const
void countCondsAndAdd2NumberVec(const L1GtConditionType &type, const L1GtConditionCategory &category, const L1GtObject &object, const ConditionMap &map, ConditionMap &outputMap, const int &condChip)
std::string buildDeltaEtaMuon(const L1GtMuonTemplate::CorrelationParameter *&cp, const unsigned int &counter)
const std::vector< ObjectParameter > * objectParameter() const
Definition: L1GtObject.h:29
static std::atomic< unsigned int > counter
std::string buildEtaMuon(const std::vector< L1GtMuonTemplate::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::map< std::string, int > conditionToIntegerMap_
stores to condition name to integer conversion table
bool debugMode_
class will produce some additional debugging output if set

◆ getSubstParamCommonFromTriggerMenu()

bool L1GtVhdlWriterCore::getSubstParamCommonFromTriggerMenu ( const unsigned short int &  condChip,
L1GtVhdlTemplateFile particle,
const L1GtObject object,
const L1GtConditionCategory category,
std::string &  parameterStr 
)

builds the parameters particle_common for the cond_chip.vhd's

Definition at line 397 of file L1GtVhdlWriterCore.cc.

References taus_updatedMVAIds_cff::category, condType2Str_, L1GtVhdlTemplateFile::findAndReplaceString(), JetCounts, objType2Str_, returnConditionsOfOneClass(), L1GtVhdlTemplateFile::returnParameterMap(), sp(), AlCaHLTBitMon_QueryRunRegistry::string, L1GtVhdlDefinitions::stringConstantCommon_, L1GtVhdlDefinitions::substParamParticle_, and L1GtVhdlDefinitions::substParamType_.

Referenced by getCondChipVhdContentFromTriggerMenu().

401  {
402  std::map<L1GtConditionType, std::string> condType2Strcopy = condType2Str_;
403 
404  // make a copy since types will deleted later after they are processed
405  std::map<L1GtConditionType, std::string>::iterator typeIterator = condType2Strcopy.begin();
406 
407  while (typeIterator != condType2Strcopy.end()) {
408  ConditionMap outputMap;
409 
411  (*typeIterator).first, category, object, (*conditionMap_).at(condChip - 1), outputMap)) {
412  // special treatment for jet counts in buildCodChipParameters
413  if (object != JetCounts) {
415  while (particle.findAndReplaceString(tempStr2, sp(substParamParticle_), objType2Str_[object]))
416  ;
417  while (particle.findAndReplaceString(tempStr2, sp(substParamType_), condType2Str_[(*typeIterator).first]))
418  ;
419  parameterStr += (tempStr2 + "\n\n");
420 
421  //parameterStr+=(tempStr2+"<= '0';\n");
422 
423  // remove this type since it was already processed
424  condType2Strcopy.erase(typeIterator);
425  }
426  }
427 
428  typeIterator++;
429  }
430 
431  return true;
432 }
std::string sp(const std::string &name)
converts string name to substiution parameter synthax; name –>
static const bool findAndReplaceString(std::string &paramString, const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString at it&#39;s first occurance in string
std::map< std::string, L1GtCondition * > ConditionMap
map containing the conditions
static const std::string stringConstantCommon_
bool returnConditionsOfOneClass(const L1GtConditionType &type, const L1GtConditionCategory &category, const L1GtObject &object, const ConditionMap &map, ConditionMap &outputMap)
static const std::string substParamType_
std::map< L1GtConditionType, std::string > condType2Str_
converts L1GtConditionType to firmware string
std::map< L1GtObject, std::string > objType2Str_
converts L1GtObject to string
std::map< std::string, std::string > returnParameterMap() const
returns parameter map
static const std::string substParamParticle_

◆ gtTemplatesPath()

std::string L1GtVhdlWriterCore::gtTemplatesPath ( )

returns the templates path

Definition at line 856 of file L1GtVhdlWriterCore.cc.

References vhdlDir_.

856 { return vhdlDir_; }
std::string vhdlDir_
templates directory

◆ index4CondChipVhd()

std::string L1GtVhdlWriterCore::index4CondChipVhd ( int  intval)

builds the index for the cond_chip vhds. (They have to start at 1 so one has to be added to the value in conversion map)

Definition at line 1134 of file L1GtVhdlWriterCore.cc.

References int2str().

Referenced by getCondChipVhdContentFromTriggerMenu().

1134  {
1135  intval++;
1136  return int2str(intval);
1137 }
static std::string int2str(const int &integerValue)
converts a integer into a string

◆ initializeDeltaConditions()

void L1GtVhdlWriterCore::initializeDeltaConditions ( )

Definition at line 1490 of file L1GtVhdlWriterCore.cc.

References caloObjects_, ETM, mps_fire::i, dqmdumpme::k, Mu, numberOfConditions_, objType2Str_, and retNumberOfConditionsString().

Referenced by makeFirmware().

1490  {
1491  for (unsigned int k = 0; k <= 1; k++) {
1492  // combine muon with calo particles
1493  for (unsigned int i = 0; i < caloObjects_.size(); i++) {
1494  numberOfConditions_.at(k).push_back(
1496  }
1497 
1498  // combine etm with muon
1500 
1501  // combine etm with calo particles
1502  for (unsigned int i = 0; i < caloObjects_.size(); i++) {
1503  numberOfConditions_.at(k).push_back(
1505  }
1506 
1507  std::vector<L1GtObject> caloObjectsCp = caloObjects_;
1508 
1509  while (!caloObjectsCp.empty()) {
1510  std::vector<L1GtObject>::iterator iter = caloObjectsCp.begin();
1511  L1GtObject firstPartner = (*iter);
1512  caloObjectsCp.erase(iter);
1513 
1514  iter = caloObjectsCp.begin();
1515  while (iter != caloObjectsCp.end()) {
1516  numberOfConditions_.at(k).push_back(
1517  retNumberOfConditionsString(objType2Str_[firstPartner] + "_" + objType2Str_[(*iter)], 0));
1518  iter++;
1519  }
1520  }
1521  }
1522 }
Definition: L1GtObject.h:35
std::vector< L1GtObject > caloObjects_
list of all possible calo objects
std::vector< std::vector< std::string > > numberOfConditions_
vector containing the initialization of all conditions
std::string retNumberOfConditionsString(const std::string &typeStr, const int &number)
std::map< L1GtObject, std::string > objType2Str_
converts L1GtObject to string
Definition: L1GtObject.h:29

◆ int2str()

std::string L1GtVhdlWriterCore::int2str ( const int &  integerValue)
static

converts a integer into a string

Definition at line 858 of file L1GtVhdlWriterCore.cc.

Referenced by addJetCountsToCond2IntMap(), getCondChipVhdContentFromTriggerMenu(), getDefValsFromTriggerMenu(), index4CondChipVhd(), printConditionsOfCategory(), retNumberOfConditionsString(), writeAlgoSetup(), writeConditionChipSetup(), writeDefValPkg(), writeEtmSetup(), and L1GtVmeWriterCore::writeVME().

858  {
859  std::ostringstream oss;
860  oss << integerValue;
861  return oss.str();
862 }

◆ makeFirmware()

bool L1GtVhdlWriterCore::makeFirmware ( const std::vector< ConditionMap > &  conditionMap,
const AlgorithmMap algorithmMap 
)

produces the firmware code

Definition at line 752 of file L1GtVhdlWriterCore.cc.

References addJetCountsToCond2IntMap(), algorithmMap_, caloObjects_, eostools::chmod(), trackingPlots::common, conditionMap_, conditionToIntegerMap_, debugMode_, esumObjects_, getCaloSetupContentFromTriggerMenu(), getCondChipVhdContentFromTriggerMenu(), getEsumsSetupContentFromTriggerMenu(), getMuonSetupContentFromTriggerMenu(), mps_fire::i, initializeDeltaConditions(), eostools::mkdir(), objType2Str_, outputDir_, L1GtVhdlDefinitions::outputSubDir1_, L1GtVhdlDefinitions::outputSubDir2_, processAlgorithmMap(), AlCaHLTBitMon_QueryRunRegistry::string, PixelCPETemplateReco_cfi::templates, version_, funct::void, writeAlgoSetup(), writeCond2intMap2File(), writeCondChipPkg(), writeConditionChipSetup(), writeDefValPkg(), writeEtmSetup(), writeMuonSetupVhdl(), and writeQsfSetupFiles().

Referenced by L1GtVhdlWriter::analyze().

752  {
753  conditionMap_ = &conditionMap;
754 
755  algorithmMap_ = &algorithmMap;
756 
759 
760  (void)mkdir(subDir1.c_str(), 666);
761  (void)mkdir(subDir2.c_str(), 666);
762 
763  chmod(subDir1.c_str(), 0777);
764  chmod(subDir2.c_str(), 0777);
765 
766  /*
767  subDirs_.push_back(subDir1);
768  subDirs_.push_back(subDir2);
769  */
770 
772 
773  //--------------------------------------build setups-------------------------------------------------------
774 
775  // loop over the two condition chips
776  for (unsigned short int i = 1; i <= 2; i++) {
777  // ----------------------- muon setup -------------------------------------------------------
778 
779  std::map<std::string, std::string> muonParameters;
780  getMuonSetupContentFromTriggerMenu(i, muonParameters);
781  writeMuonSetupVhdl(muonParameters, "muon", i);
782 
783  // ----------------------- calo setup -------------------------------------------------------
784 
785  // map containing all calo object types correlated with the strings
786  // under which they appear in the firmware
787  std::vector<L1GtObject>::iterator caloObjIter = caloObjects_.begin();
788 
789  // loop over all calo objectsbuildMuonSetupVhdl
790  while (caloObjIter != caloObjects_.end()) {
791  std::map<std::string, std::string> caloParameters;
792  getCaloSetupContentFromTriggerMenu(i, caloParameters, (*caloObjIter));
793  writeMuonSetupVhdl(caloParameters, objType2Str_[(*caloObjIter)], i);
794 
795  caloObjIter++;
796  }
797 
798  // ----------------------- etm setup ---------------------------------------------------------
799 
800  // map containing all calo object types correlated with the strings
801  // under which they appear in the firmware
802  std::vector<L1GtObject>::iterator esumObjIter = esumObjects_.begin();
803 
804  while (esumObjIter != esumObjects_.end()) {
805  std::string etmParameter;
806 
807  getEsumsSetupContentFromTriggerMenu(i, (*esumObjIter), etmParameter);
808  writeEtmSetup(etmParameter, i);
809 
810  esumObjIter++;
811  }
812 
813  // add jet counts to condition 2 integer map
815 
816  // --------------------cond chip setup---------------------------------------------------------
817  // Important: all other setups have to be build BEFORE this one because it needs a
818  // complete condition2integer map !!!
819 
820  std::map<std::string, L1GtVhdlTemplateFile> templates;
821  std::map<std::string, std::string> common;
824 
825  // despite yet not existing they have to appear in cond_chip_pkg vhds
827 
828  // --------------------cond chip pkg------------------------------------------------------------
829 
831 
832  // -----------------------def val pkg -------------------------------------------------
833 
835 
836  // debug
837  if (debugMode_) {
838  //printConditionsOfCategory(CondEnergySum, (*conditionMap_).at(i-1));
839  }
840  }
841 
842  if (debugMode_)
844 
845  //-------------------------------process algorithms----------------------------------------------------------
846 
847  std::vector<std::map<int, std::string> > algoStrings;
848 
849  processAlgorithmMap(algoStrings);
850 
851  writeAlgoSetup(algoStrings);
852 
853  return true;
854 }
void writeQsfSetupFiles(const std::string &version)
builds the two quartus setup files. This routine is called in buildCommonHeader!
std::vector< L1GtObject > esumObjects_
list of all possible esums objects
void writeDefValPkg(const std::vector< ConditionMap > &conditionMap, const int &chip)
writes def_val_pkg.vhd
bool getCaloSetupContentFromTriggerMenu(const unsigned short int &condChip, std::map< std::string, std::string > &caloParameters, const L1GtObject &caloObject)
std::vector< L1GtObject > caloObjects_
list of all possible calo objects
bool getEsumsSetupContentFromTriggerMenu(const unsigned short int &condChip, const L1GtObject &object, std::string &energySumParameter)
contains only one subsitution parameter which is stored in reference energySumParameter ...
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
const AlgorithmMap * algorithmMap_
algorithm map
void writeEtmSetup(std::string &etmString, const int &condChip)
builds etm setup files
def chmod(path, mode)
Definition: eostools.py:294
void writeCond2intMap2File()
produces a control output file for condition to integer conversion
void writeCondChipPkg(const int &chip)
const std::vector< ConditionMap > * conditionMap_
condition map
std::map< L1GtObject, std::string > objType2Str_
converts L1GtObject to string
Definition: common.py:1
static const std::string outputSubDir1_
void getMuonSetupContentFromTriggerMenu(const unsigned short int &condChip, std::map< std::string, std::string > &muonParameters)
static const std::string outputSubDir2_
std::string outputDir_
output directory
bool getCondChipVhdContentFromTriggerMenu(const unsigned short int &condChip, std::map< std::string, L1GtVhdlTemplateFile > &templates, std::map< std::string, std::string > &commonParams)
void writeConditionChipSetup(const std::map< std::string, L1GtVhdlTemplateFile > &templates, const std::map< std::string, std::string > &common, const unsigned short int &chip)
builds cond_chip.vhds
def mkdir(path)
Definition: eostools.py:251
void addJetCountsToCond2IntMap(const int chip, const std::vector< ConditionMap > &conditionMap, std::map< std::string, int > &conditionToIntegerMap)
void writeMuonSetupVhdl(std::map< std::string, std::string > &muonParameters, const std::string &particle, unsigned short int &condChip)
builds muon setup files
std::map< std::string, int > conditionToIntegerMap_
stores to condition name to integer conversion table
void writeAlgoSetup(std::vector< std::map< int, std::string > > &algoStrings)
builds the prealgo_and_or setup
bool processAlgorithmMap(std::vector< std::map< int, std::string > > &algoStrings)
bool debugMode_
class will produce some additional debugging output if set

◆ msg()

void L1GtVhdlWriterCore::msg ( const std::string &  message)

adds a string to intern message buffer

Definition at line 1122 of file L1GtVhdlWriterCore.cc.

References internMessageBuf_.

Referenced by buildCommonHeader(), getCondChipVhdContentFromTriggerMenu(), printConditionsOfCategory(), and processAlgorithmMap().

1122 { internMessageBuf_.push_back(message); }
std::vector< std::string > internMessageBuf_

◆ openVhdlFileWithCommonHeader()

L1GtVhdlTemplateFile L1GtVhdlWriterCore::openVhdlFileWithCommonHeader ( const std::string &  filename,
const std::string &  outputFilename 
)

opens a new template file and inserts the common header

Definition at line 889 of file L1GtVhdlWriterCore.cc.

References commonHeader_, corrVsCorr::filename, L1GtVhdlTemplateFile::insert(), GTTFileWriter_cff::outputFilename, L1GtVhdlTemplateFile::substitute(), and vhdlDir_.

Referenced by writeAlgoSetup(), writeCondChipPkg(), writeConditionChipSetup(), writeDefValPkg(), writeEtmSetup(), and writeMuonSetupVhdl().

890  {
891  L1GtVhdlTemplateFile commonHeaderCp;
892  commonHeaderCp = commonHeader_;
893 
894  commonHeaderCp.substitute("vhdl_file_name", outputFilename);
895 
896  L1GtVhdlTemplateFile myTemplate(vhdlDir_ + "Templates/" + filename);
897  myTemplate.insert("$(header)", commonHeaderCp);
898 
899  return myTemplate;
900 }
std::string vhdlDir_
templates directory
bool substitute(const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString
L1GtVhdlTemplateFile commonHeader_
common header for all files

◆ printCommonHeader()

void L1GtVhdlWriterCore::printCommonHeader ( )

prints the common header

Definition at line 1095 of file L1GtVhdlWriterCore.cc.

References commonHeader_, and L1GtVhdlTemplateFile::print().

1095 { commonHeader_.print(); }
void print() const
prints the content of the VHDL File (only lines_)
L1GtVhdlTemplateFile commonHeader_
common header for all files

◆ printConditionsOfCategory()

void L1GtVhdlWriterCore::printConditionsOfCategory ( const L1GtConditionCategory category,
const ConditionMap map 
)

for debuggin

Definition at line 1543 of file L1GtVhdlWriterCore.cc.

References int2str(), genParticles_cff::map, and msg().

1543  {
1544  int counter = 0;
1545  for (ConditionMap::const_iterator iterCond = map.begin(); iterCond != map.end(); iterCond++) {
1546  msg(iterCond->first);
1547  counter++;
1548  }
1549 
1550  msg("Total Occurances: " + int2str(counter));
1551 }
static std::string int2str(const int &integerValue)
converts a integer into a string
void msg(const std::string &message)
adds a string to intern message buffer

◆ processAlgorithmMap()

bool L1GtVhdlWriterCore::processAlgorithmMap ( std::vector< std::map< int, std::string > > &  algoStrings)

processes algorithm map delivered by parser, replaces condition names by types and serial numbers, splits the map in a vector two seperate ones for the two condition chips

Definition at line 674 of file L1GtVhdlWriterCore.cc.

References conditionMap_, submitPVValidationJobs::conditions, conditionToIntegerMap_, condType2Str_, debugMode_, mps_fire::i, msg(), objType2Str_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by makeFirmware().

674  {
675  std::map<int, std::string> algorithmsChip1;
676  std::map<int, std::string> algorithmsChip2;
677 
678  AlgorithmMap::const_iterator algoIter = (*algorithmMap_).begin();
679 
680  // loop over algorithm map
681  while (algoIter != (*algorithmMap_).end()) {
682  // msg(algoIter->first);
683 
685 
686  // get the logical expression
687  std::string logicalExpr = (algoIter->second).algoLogicalExpression();
688  std::vector<std::string> conditions;
689 
690  dummy.getConditionsFromAlgo(logicalExpr, conditions);
691 
692  std::string logicalExprCopy = logicalExpr;
693 
694  // loop over all condition names appearing in algorithm and replace them by type and integer value
695  for (unsigned int i = 0; i < conditions.size(); i++) {
696  std::ostringstream newExpr;
697 
698  // look for the condition on correct chip
699  ConditionMap const &chip = conditionMap_->at(algoIter->second.algoChipNumber());
700  L1GtCondition const *cond = (chip.find(conditions.at(i)) == chip.end()) ? nullptr : chip.at(conditions.at(i));
701 
702  // check weather condition exists
703  if (cond != nullptr) {
704  newExpr << objType2Str_[(cond->objectType()).at(0)];
705  newExpr << "_" << condType2Str_[cond->condType()] << "(";
706  newExpr << conditionToIntegerMap_[conditions.at(i)] << ")";
707  dummy.findAndReplaceString(logicalExpr, conditions.at(i), newExpr.str());
708  } else
709  msg("Panik! Didn't find Condition " + conditions.at(i));
710  }
711 
712  // has to be checked!
713  std::vector<int> orderConditionChip;
714  orderConditionChip.push_back(2);
715  orderConditionChip.push_back(1);
716 
717  int pin = (algoIter->second).algoOutputPin(2, 96, orderConditionChip);
718 
719  //msg(int2str(pin));
720 
721  if (pin < 0)
722  pin *= -1;
723 
724  if ((algoIter->second).algoChipNumber() == 0) {
725  algorithmsChip1[pin] = logicalExpr;
726  if (debugMode_)
727  algorithmsChip1[pin] += ("-- " + logicalExprCopy);
728  } else if ((algoIter->second).algoChipNumber() == 1) {
729  algorithmsChip2[pin] = logicalExpr;
730  if (debugMode_)
731  algorithmsChip2[pin] += ("-- " + logicalExprCopy);
732  }
733 
734  algoIter++;
735  }
736 
737  algoStrings.push_back(algorithmsChip1);
738  algoStrings.push_back(algorithmsChip2);
739 
740  return true;
741 }
std::map< std::string, L1GtCondition * > ConditionMap
map containing the conditions
std::map< L1GtConditionType, std::string > condType2Str_
converts L1GtConditionType to firmware string
const std::vector< ConditionMap > * conditionMap_
condition map
std::map< L1GtObject, std::string > objType2Str_
converts L1GtObject to string
void msg(const std::string &message)
adds a string to intern message buffer
Definition: plugin.cc:23
std::map< std::string, int > conditionToIntegerMap_
stores to condition name to integer conversion table
bool debugMode_
class will produce some additional debugging output if set

◆ retNumberOfConditionsString()

std::string L1GtVhdlWriterCore::retNumberOfConditionsString ( const std::string &  typeStr,
const int &  number 
)

Definition at line 1577 of file L1GtVhdlWriterCore.cc.

References int2str(), contentValuesFiles::number, AlCaHLTBitMon_QueryRunRegistry::string, and L1GtVhdlDefinitions::stringConstantConstantNr_.

Referenced by addJetCountsToCond2IntMap(), countCondsAndAdd2NumberVec(), and initializeDeltaConditions().

1577  {
1578  std::string initstr = stringConstantConstantNr_ + typeStr + " : integer := " + int2str(number) + ";";
1579 
1580  return initstr;
1581 }
static std::string int2str(const int &integerValue)
converts a integer into a string
static const std::string stringConstantConstantNr_

◆ retrunCommonHeader()

L1GtVhdlTemplateFile L1GtVhdlWriterCore::retrunCommonHeader ( )

returns the common header

Definition at line 1097 of file L1GtVhdlWriterCore.cc.

References commonHeader_.

Referenced by L1GtVhdlWriter::analyze().

1097 { return commonHeader_; }
L1GtVhdlTemplateFile commonHeader_
common header for all files

◆ returnConditionsOfOneClass()

bool L1GtVhdlWriterCore::returnConditionsOfOneClass ( const L1GtConditionType type,
const L1GtConditionCategory category,
const L1GtObject object,
const ConditionMap map,
ConditionMap outputMap 
)

returns all condition of the same class. Conditions belong to one class if they are matching in type (Type1s, Type2s..) category (CondMuon, CondCalo,)and are defined for the same object (Mu, fwdJet..)

Parameters
mapis the ConditionMap that shall be filtered
conditionToIntegerMapis the condition is added to this conversion map
outputMaphere the conditions matching the requirements are stored

Definition at line 90 of file L1GtVhdlWriterCore.cc.

References taus_updatedMVAIds_cff::category, genParticles_cff::map, and mps_update::status.

Referenced by addJetCountsToCond2IntMap(), countCondsAndAdd2NumberVec(), getDefValsFromTriggerMenu(), and getSubstParamCommonFromTriggerMenu().

94  {
95  bool status = false;
96 
97  ConditionMap::const_iterator condIter = map.begin();
98  while (condIter != map.end()) {
99  if (condIter->second->condCategory() == category && condIter->second->condType() == type &&
100  (condIter->second->objectType())[0] == object) {
101  outputMap[condIter->first] = condIter->second;
102  status = true;
103  }
104  condIter++;
105  }
106 
107  return status;
108 }

◆ sp()

std::string L1GtVhdlWriterCore::sp ( const std::string &  name)

converts string name to substiution parameter synthax; name –>

Definition at line 1585 of file L1GtVhdlWriterCore.cc.

References Skims_PA_cff::name.

Referenced by buildDefValuesBuffer(), getCondChipVhdContentFromTriggerMenu(), getSubstParamCommonFromTriggerMenu(), and writeDefValPkg().

1585 { return "$(" + name + ")"; }

◆ writeAlgoSetup()

void L1GtVhdlWriterCore::writeAlgoSetup ( std::vector< std::map< int, std::string > > &  algoStrings)

builds the prealgo_and_or setup

Definition at line 1039 of file L1GtVhdlWriterCore.cc.

References edmScanValgrind::buffer, chip2OutputSubDir(), eostools::chmod(), corrVsCorr::filename, L1GtVhdlTemplateFile::findAndReplaceString(), mps_fire::i, int2str(), dqmdumpme::k, openVhdlFileWithCommonHeader(), reco_skim_cfg_mod::outputFileName, L1GtVhdlTemplateFile::save(), AlCaHLTBitMon_QueryRunRegistry::string, L1GtVhdlDefinitions::stringConstantAlgo_, L1GtVhdlTemplateFile::substitute(), L1GtVhdlDefinitions::substParamAlgos_, and L1GtVhdlDefinitions::vhdlTemplateAlgoAndOr_.

Referenced by makeFirmware().

1039  {
1040  // loop over the two condition chips
1041  for (unsigned int i = 1; i <= 2; i++) {
1043 
1044  // output file name
1047 
1049 
1050  std::ostringstream buffer;
1051 
1052  unsigned int algoPinsPerChip = 96;
1053 
1054  for (unsigned int k = 1; k <= algoPinsPerChip; k++) {
1055  buffer << stringConstantAlgo_ << "(" << k << ")";
1056  if (!algoStrings.at(i - 1)[k].empty())
1057  buffer << " <= " << algoStrings.at(i - 1)[k] << ";" << std::endl;
1058  else
1059  buffer << " <= '0';" << std::endl;
1060  }
1061 
1062  templateFile.substitute(substParamAlgos_, buffer.str());
1063  templateFile.save(chip2OutputSubDir(i) + filename);
1064  chmod((chip2OutputSubDir(i) + filename).c_str(), 0666);
1065  }
1066 }
static const std::string vhdlTemplateAlgoAndOr_
static const bool findAndReplaceString(std::string &paramString, const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString at it&#39;s first occurance in string
bool substitute(const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString
bool save(const std::string &fileName)
saves the content of the template file to a local file (the content of parameterMap_ will not be save...
static std::string int2str(const int &integerValue)
converts a integer into a string
static const std::string substParamAlgos_
static const std::string stringConstantAlgo_
def chmod(path, mode)
Definition: eostools.py:294
std::string chip2OutputSubDir(const int &chip)
L1GtVhdlTemplateFile openVhdlFileWithCommonHeader(const std::string &filename, const std::string &outputFilename)
opens a new template file and inserts the common header

◆ writeCond2intMap2File()

void L1GtVhdlWriterCore::writeCond2intMap2File ( )

produces a control output file for condition to integer conversion

Definition at line 1178 of file L1GtVhdlWriterCore.cc.

References chip2OutputSubDir(), eostools::chmod(), conditionMap_, conditionToIntegerMap_, corrVsCorr::filename, mps_fire::i, download_sqlite_cfg::outputFile, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by makeFirmware().

1178  {
1179  for (unsigned int i = 0; i <= 1; i++) {
1180  ConditionMap::const_iterator iterCond = conditionMap_->at(i).begin();
1181 
1182  std::string filename = chip2OutputSubDir(i + 1) + "cond_names_integer.txt";
1183 
1184  std::ofstream outputFile(filename.c_str());
1185 
1186  while (iterCond != conditionMap_->at(i).end()) {
1187  conditionToIntegerMap_[(*iterCond).first];
1188 
1189  outputFile << (iterCond->first) << ": " << conditionToIntegerMap_[(*iterCond).first] << std::endl;
1190  iterCond++;
1191  }
1192 
1193  outputFile.close();
1194 
1195  chmod(filename.c_str(), 0666);
1196  }
1197 
1198  /*
1199 
1200 
1201  const std::vector<ConditionMap> * conditionMap_;
1202 
1203  std::string filename=outputDir_+"cond_names_integer.txt";
1204  std::ofstream outputFile(filename.c_str());
1205 
1206  for (std::map<std::string,int>::const_iterator iterCond =
1207  conditionToIntegerMap_.begin(); iterCond
1208  != conditionToIntegerMap_.end(); iterCond++)
1209  {
1210  outputFile<<(iterCond->first)<<": "<<(iterCond->second)<<std::endl;
1211  }
1212 
1213  */
1214 }
def chmod(path, mode)
Definition: eostools.py:294
const std::vector< ConditionMap > * conditionMap_
condition map
std::string chip2OutputSubDir(const int &chip)
std::map< std::string, int > conditionToIntegerMap_
stores to condition name to integer conversion table

◆ writeCondChipPkg()

void L1GtVhdlWriterCore::writeCondChipPkg ( const int &  chip)

Definition at line 1553 of file L1GtVhdlWriterCore.cc.

References chip2OutputSubDir(), eostools::chmod(), corrVsCorr::filename, L1GtVhdlTemplateFile::findAndReplaceString(), L1GtVhdlTemplateFile::insert(), numberOfConditions_, openVhdlFileWithCommonHeader(), L1GtVhdlTemplateFile::save(), AlCaHLTBitMon_QueryRunRegistry::string, L1GtVhdlTemplateFile::substitute(), version_, L1GtVhdlDefinitions::vhdlTemplateCondChipPkg1_, and L1GtVhdlDefinitions::vhdlTemplateCondChipPkg2_.

Referenced by makeFirmware().

1553  {
1554  // build filename
1555 
1557 
1558  if (chip == 1)
1560  else if (chip == 2)
1562 
1563  // write the output
1565 
1566  myTemplate.substitute("version", version_);
1567 
1568  myTemplate.insert("$(conditions_nr)", numberOfConditions_.at(chip - 1));
1569 
1572 
1573  myTemplate.save(chip2OutputSubDir(chip) + filename);
1574  chmod((chip2OutputSubDir(chip) + filename).c_str(), 0666);
1575 }
static const bool findAndReplaceString(std::string &paramString, const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString at it&#39;s first occurance in string
bool substitute(const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString
bool save(const std::string &fileName)
saves the content of the template file to a local file (the content of parameterMap_ will not be save...
std::vector< std::vector< std::string > > numberOfConditions_
vector containing the initialization of all conditions
static const std::string vhdlTemplateCondChipPkg2_
def chmod(path, mode)
Definition: eostools.py:294
bool insert(const std::string &atLine, const std::vector< std::string > &content)
replaces the whole line containing atLine and inserts content instead of it
static const std::string vhdlTemplateCondChipPkg1_
std::string chip2OutputSubDir(const int &chip)
L1GtVhdlTemplateFile openVhdlFileWithCommonHeader(const std::string &filename, const std::string &outputFilename)
opens a new template file and inserts the common header

◆ writeConditionChipSetup()

void L1GtVhdlWriterCore::writeConditionChipSetup ( const std::map< std::string, L1GtVhdlTemplateFile > &  templates,
const std::map< std::string, std::string > &  common,
const unsigned short int &  chip 
)

builds cond_chip.vhds

Definition at line 1005 of file L1GtVhdlWriterCore.cc.

References chip2OutputSubDir(), eostools::chmod(), corrVsCorr::filename, L1GtVhdlTemplateFile::findAndReplaceString(), L1GtVhdlTemplateFile::insert(), int2str(), openVhdlFileWithCommonHeader(), reco_skim_cfg_mod::outputFileName, L1GtVhdlTemplateFile::save(), AlCaHLTBitMon_QueryRunRegistry::string, L1GtVhdlTemplateFile::substitute(), PixelCPETemplateReco_cfi::templates, and L1GtVhdlDefinitions::vhdlTemplateCondChip_.

Referenced by makeFirmware().

1007  {
1008  // get filename
1010 
1011  // build output filename
1014 
1016 
1017  // map containing the subsitution parameters with their content (as L1GtVhdlTemplateFile file object)
1018  std::map<std::string, L1GtVhdlTemplateFile>::const_iterator iter = templates.begin();
1019 
1020  while (iter != templates.end()) {
1021  myTemplate.insert("$(" + (iter->first) + ")", iter->second);
1022 
1023  iter++;
1024  }
1025 
1026  // subsitutes common parameters
1027  std::map<std::string, std::string>::const_iterator iter2 = common.begin();
1028 
1029  while (iter2 != common.end()) {
1030  myTemplate.substitute((iter2->first), iter2->second);
1031 
1032  iter2++;
1033  }
1034 
1035  myTemplate.save(chip2OutputSubDir(chip) + filename);
1036  chmod((chip2OutputSubDir(chip) + filename).c_str(), 0666);
1037 }
static const bool findAndReplaceString(std::string &paramString, const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString at it&#39;s first occurance in string
bool substitute(const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString
bool save(const std::string &fileName)
saves the content of the template file to a local file (the content of parameterMap_ will not be save...
static std::string int2str(const int &integerValue)
converts a integer into a string
def chmod(path, mode)
Definition: eostools.py:294
bool insert(const std::string &atLine, const std::vector< std::string > &content)
replaces the whole line containing atLine and inserts content instead of it
Definition: common.py:1
std::string chip2OutputSubDir(const int &chip)
L1GtVhdlTemplateFile openVhdlFileWithCommonHeader(const std::string &filename, const std::string &outputFilename)
opens a new template file and inserts the common header
static const std::string vhdlTemplateCondChip_

◆ writeDefValPkg()

void L1GtVhdlWriterCore::writeDefValPkg ( const std::vector< ConditionMap > &  conditionMap,
const int &  chip 
)

writes def_val_pkg.vhd

Definition at line 1261 of file L1GtVhdlWriterCore.cc.

References buildDefValuesBuffer(), caloObjects_, chip2OutputSubDir(), eostools::chmod(), condType2Str_, esumObjects_, corrVsCorr::filename, L1GtVhdlTemplateFile::findAndReplaceString(), L1GtVhdlTemplateFile::getInternalParameter(), mps_fire::i, L1GtVhdlTemplateFile::insert(), int2str(), JetCounts, Mu, L1GtVhdlTemplateFile::open(), openVhdlFileWithCommonHeader(), download_sqlite_cfg::outputFile, L1GtVhdlTemplateFile::save(), sp(), AlCaHLTBitMon_QueryRunRegistry::string, L1GtVhdlDefinitions::stringConstantEsumsHigh_, L1GtVhdlDefinitions::stringConstantEsumsLow_, L1GtVhdlDefinitions::stringConstantPth_, L1GtVhdlDefinitions::stringConstantPtl_, L1GtVhdlDefinitions::stringConstantQuality_, L1GtVhdlDefinitions::substParamCaloDefVals_, L1GtVhdlDefinitions::substParamCharge_, L1GtVhdlDefinitions::substParamEsumsDefVals_, L1GtVhdlDefinitions::substParamJetsDefVals_, L1GtVhdlDefinitions::substParamMuonDefVals_, Type2cor, Type3s, TypeETM, TypeETT, TypeHTT, TypeJetCounts, vhdlDir_, and L1GtVhdlDefinitions::vhdlTemplateDefValPkg_.

Referenced by makeFirmware().

1261  {
1262  // open internal template file
1263  L1GtVhdlTemplateFile internalTemplate;
1264  internalTemplate.open(vhdlDir_ + "InternalTemplates/defvalpkg", true);
1265 
1266  // to write the def_value_pkg file it has to be looped over all POSSIBLE types of conditions
1267  // POSSIBLE: calo_3 eg. does not exist and therefore makes no sense..
1268 
1269  // Process muon conditions first
1270 
1271  // temporary buffers for the default value blocks (see internal templates) of the different types.
1272  // in the end those buffers are simply appended to the actual template!
1273  L1GtVhdlTemplateFile muonDefValuesBuffer, caloDefValuesBuffer, jetCountsDefValuesBuffer, esumsDefValBuffer;
1274 
1275  // Get the default value type strings from internal template
1276  std::vector<std::string> muonDefValTypes;
1277  muonDefValTypes.push_back(internalTemplate.getInternalParameter(stringConstantPtl_));
1278  muonDefValTypes.push_back(internalTemplate.getInternalParameter(stringConstantPth_));
1279  muonDefValTypes.push_back(internalTemplate.getInternalParameter(stringConstantQuality_));
1280  muonDefValTypes.push_back(internalTemplate.getInternalParameter(substParamCharge_));
1281 
1282  int jetCountsMaxIndex = 11;
1283 
1284  // fill jet counts vector (from 1 to 11)
1285  std::vector<std::string> jetCountsDefValTypes;
1286  for (int i = 0; i <= jetCountsMaxIndex; i++) {
1287  jetCountsDefValTypes.push_back(int2str(i));
1288  }
1289 
1290  // only one default value for calo objects therefore only a empty string
1291  std::vector<std::string> caloDefValTypes;
1292  caloDefValTypes.push_back("");
1293 
1294  // get types of esums defvalues (as firmware strings) from the internal templates
1295  std::vector<std::string> esumsDefValTypes;
1296  esumsDefValTypes.push_back(internalTemplate.getInternalParameter(stringConstantEsumsLow_));
1297  esumsDefValTypes.push_back(internalTemplate.getInternalParameter(stringConstantEsumsHigh_));
1298 
1299  std::map<L1GtConditionType, std::string>::iterator typeIter;
1300 
1301  // prepare a map with all muon relevant types by removing
1302  // obsolete types from a copy of condType2Str_ map
1303  // should be improved
1304  std::map<L1GtConditionType, std::string> muonTypes = condType2Str_;
1305 
1306  typeIter = muonTypes.find(Type2cor);
1307  muonTypes.erase(typeIter);
1308  typeIter = muonTypes.find(TypeETM);
1309  muonTypes.erase(typeIter);
1310  typeIter = muonTypes.find(TypeETT);
1311  muonTypes.erase(typeIter);
1312  typeIter = muonTypes.find(TypeHTT);
1313  muonTypes.erase(typeIter);
1314  typeIter = muonTypes.find(TypeJetCounts);
1315  muonTypes.erase(typeIter);
1316 
1317  std::map<L1GtConditionType, std::string> caloTypes = muonTypes;
1318  typeIter = caloTypes.find(Type3s);
1319  caloTypes.erase(typeIter);
1320 
1321  // dummy type in order to be able to use the same code as for calo and muon
1322  // this map is also used for esums since there is no difference in treatment
1323  std::map<L1GtConditionType, std::string> jetCountsTypes;
1324  jetCountsTypes[TypeJetCounts] = "";
1325 
1326  // here the DefValuesBuffer are build (=objects of the class L1GtVhdlTemplateFile
1327  // that are containing all default values and finally can be inserted into the
1328  // def_val_pkg.vhd template
1329 
1330  buildDefValuesBuffer(muonDefValuesBuffer, muonTypes, muonDefValTypes, Mu);
1331 
1332  // loop over all possible calo objects here
1333  for (unsigned int i = 0; i < caloObjects_.size(); i++) {
1334  buildDefValuesBuffer(caloDefValuesBuffer, caloTypes, caloDefValTypes, caloObjects_.at(i));
1335  }
1336 
1337  // loop over all possible esums objects here
1338  for (unsigned int i = 0; i < esumObjects_.size(); i++) {
1339  buildDefValuesBuffer(esumsDefValBuffer, jetCountsTypes, esumsDefValTypes, esumObjects_.at(i));
1340  }
1341 
1342  // same procedure for jet counts
1343  buildDefValuesBuffer(esumsDefValBuffer, jetCountsTypes, jetCountsDefValTypes, JetCounts);
1344 
1345  //----------------------In this section the actual output file is written----------------
1346 
1347  // now open the actual template file:
1348 
1350 
1352 
1353  // modify output filename
1356 
1357  // insert the temporary buffers to the template
1358 
1359  // muon default values
1360  defValTemplate.insert(sp(substParamMuonDefVals_), muonDefValuesBuffer);
1361 
1362  // calo default values
1363  defValTemplate.insert(sp(substParamCaloDefVals_), caloDefValuesBuffer);
1364 
1365  // esums default values
1366  defValTemplate.insert(sp(substParamEsumsDefVals_), esumsDefValBuffer);
1367 
1368  // jet counts default values
1369  defValTemplate.insert(sp(substParamJetsDefVals_), jetCountsDefValuesBuffer);
1370 
1371  // close and save the file
1372 
1375 
1376  defValTemplate.save(chip2OutputSubDir(chip) + outputFile);
1377  chmod((chip2OutputSubDir(chip) + outputFile).c_str(), 0666);
1378 }
static const std::string substParamMuonDefVals_
std::string vhdlDir_
templates directory
std::string sp(const std::string &name)
converts string name to substiution parameter synthax; name –>
static const bool findAndReplaceString(std::string &paramString, const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString at it&#39;s first occurance in string
static const std::string substParamCaloDefVals_
std::vector< L1GtObject > esumObjects_
list of all possible esums objects
bool save(const std::string &fileName)
saves the content of the template file to a local file (the content of parameterMap_ will not be save...
static const std::string stringConstantEsumsLow_
static const std::string substParamJetsDefVals_
std::vector< L1GtObject > caloObjects_
list of all possible calo objects
static std::string int2str(const int &integerValue)
converts a integer into a string
def chmod(path, mode)
Definition: eostools.py:294
static const std::string stringConstantEsumsHigh_
std::map< L1GtConditionType, std::string > condType2Str_
converts L1GtConditionType to firmware string
std::string getInternalParameter(const std::string &indentifier)
returns a parameter of a internal template file
bool insert(const std::string &atLine, const std::vector< std::string > &content)
replaces the whole line containing atLine and inserts content instead of it
Definition: L1GtObject.h:29
static const std::string stringConstantPth_
std::string chip2OutputSubDir(const int &chip)
static const std::string stringConstantPtl_
static const std::string vhdlTemplateDefValPkg_
L1GtVhdlTemplateFile openVhdlFileWithCommonHeader(const std::string &filename, const std::string &outputFilename)
opens a new template file and inserts the common header
static const std::string stringConstantQuality_
static const std::string substParamCharge_
bool buildDefValuesBuffer(L1GtVhdlTemplateFile &buffer, const std::map< L1GtConditionType, std::string > &typeList, const std::vector< std::string > &defValuesList, const L1GtObject &object)
bool open(const std::string &fileName, bool internal=false)
opens a template file. If the header information shall be parsed intern has to be set to true ...
static const std::string substParamEsumsDefVals_

◆ writeEtmSetup()

void L1GtVhdlWriterCore::writeEtmSetup ( std::string &  etmString,
const int &  condChip 
)

builds etm setup files

Definition at line 1068 of file L1GtVhdlWriterCore.cc.

References chip2OutputSubDir(), eostools::chmod(), corrVsCorr::filename, L1GtVhdlTemplateFile::findAndReplaceString(), int2str(), openVhdlFileWithCommonHeader(), download_sqlite_cfg::outputFile, L1GtVhdlTemplateFile::save(), AlCaHLTBitMon_QueryRunRegistry::string, L1GtVhdlTemplateFile::substitute(), and L1GtVhdlDefinitions::vhdlTemplateEtmSetup_.

Referenced by makeFirmware().

1068  {
1069  // get filename
1072 
1073  L1GtVhdlTemplateFile myTemplate;
1074 
1075  // modify output filename
1076  myTemplate.findAndReplaceString(outputFile, ".", int2str(condChip) + ".");
1077 
1079 
1080  // replace all occurances of $(particle)
1081  while (myTemplate.substitute("particle", "etm"))
1082  while (myTemplate.substitute("particle", "etm"))
1083  ;
1084 
1085  // delete last char if it is \n
1086  if (etmString[etmString.length() - 1] == '\n')
1087  etmString = etmString.substr(0, etmString.length() - 1);
1088 
1089  myTemplate.substitute("phi", etmString);
1090 
1091  myTemplate.save(chip2OutputSubDir(condChip) + filename);
1092  chmod((chip2OutputSubDir(condChip) + filename).c_str(), 0666);
1093 }
static const bool findAndReplaceString(std::string &paramString, const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString at it&#39;s first occurance in string
bool substitute(const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString
bool save(const std::string &fileName)
saves the content of the template file to a local file (the content of parameterMap_ will not be save...
static std::string int2str(const int &integerValue)
converts a integer into a string
def chmod(path, mode)
Definition: eostools.py:294
static const std::string vhdlTemplateEtmSetup_
std::string chip2OutputSubDir(const int &chip)
L1GtVhdlTemplateFile openVhdlFileWithCommonHeader(const std::string &filename, const std::string &outputFilename)
opens a new template file and inserts the common header

◆ writeMuonSetupVhdl()

void L1GtVhdlWriterCore::writeMuonSetupVhdl ( std::map< std::string, std::string > &  muonParameters,
const std::string &  particle,
unsigned short int &  condChip 
)

builds muon setup files

Definition at line 902 of file L1GtVhdlWriterCore.cc.

References L1GtVhdlTemplateFile::append(), chip2OutputSubDir(), eostools::chmod(), corrVsCorr::filename, L1GtVhdlTemplateFile::findAndReplaceString(), L1GtVhdlTemplateFile::getSubstitutionParametersFromTemplate(), mps_fire::i, L1GtVhdlTemplateFile::insert(), L1GtVhdlTemplateFile::open(), openVhdlFileWithCommonHeader(), download_sqlite_cfg::outputFile, L1GtVhdlTemplateFile::removeLineWithContent(), L1GtVhdlTemplateFile::returnParameterMap(), L1GtVhdlTemplateFile::save(), AlCaHLTBitMon_QueryRunRegistry::string, L1GtVhdlTemplateFile::substitute(), vhdlDir_, L1GtVhdlDefinitions::vhdlTemplateCaloSetup_, and L1GtVhdlDefinitions::vhdlTemplateMuonSetup_.

Referenced by makeFirmware().

904  {
906 
907  L1GtVhdlTemplateFile muonTemplate, internalTemplate, internalTemplateCopy;
908 
909  // choose the correct template file name
910  if (particle == "muon") {
912  internalTemplate.open(vhdlDir_ + "InternalTemplates/muonsetup", true);
913  } else {
915  internalTemplate.open(vhdlDir_ + "InternalTemplates/calosetup", true);
916  }
917 
920 
921  // modify filename
922  if (particle != "muon")
923  muonTemplate.findAndReplaceString(outputFile, "calo", particle);
924 
925  // add condition chip index to output filename
926  //muonTemplate.findAndReplaceString(outputFile, ".", int2str(condChip)+".");
927 
928  // open the template file and insert header
930 
931  std::map<std::string, std::string> parameterMap = internalTemplate.returnParameterMap();
932 
933  std::vector<std::string> substitutionParameters;
934 
935  // fills the map with all substitution parameters of the template file
936  substitutionParameters = muonTemplate.getSubstitutionParametersFromTemplate();
937 
938  // insert a emty line at the end of each block
939  internalTemplate.append("");
940 
941  std::map<std::string, std::string>::iterator iter;
942 
943  // loop over all substitution parameters that have been extracted from the template file
944  for (unsigned int i = 0; i < substitutionParameters.size(); i++) {
945  // make a working copy of the template file
946  internalTemplateCopy = internalTemplate;
947 
948  // choose which of the three constant template strings to take - only for calo!
949  if (particle != "muon") {
950  if (substitutionParameters.at(i).substr(0, 3) == "eta")
951  internalTemplateCopy.substitute("constant", parameterMap["eta"]);
952  else if (substitutionParameters.at(i).substr(0, 3) == "phi")
953  internalTemplateCopy.substitute("constant", parameterMap["phi"]);
954  else if (substitutionParameters.at(i).substr(0, 3) == "del" /*ta*/) {
955  internalTemplateCopy.substitute("constant", parameterMap["delta"]);
956  while (internalTemplateCopy.substitute("delta", substitutionParameters[i]))
957  internalTemplateCopy.substitute("delta", substitutionParameters[i]);
958  }
959  }
960 
961  if (particle == "muon") {
962  // final preparation of the internal template before it is inserted in the actual template file
963  internalTemplateCopy.substitute("type", substitutionParameters[i]);
964  } else
965 
966  {
967  internalTemplateCopy.substitute("type", substitutionParameters[i].substr(4));
968  }
969 
970  // subsitute the second occurance of type without "_l" and "_h"
971 
972  std::string paramCopy = substitutionParameters[i];
973 
974  internalTemplateCopy.findAndReplaceString(paramCopy, "_l", "");
975  internalTemplateCopy.findAndReplaceString(paramCopy, "_h", "");
976 
977  internalTemplateCopy.substitute("type2", paramCopy);
978 
979  internalTemplateCopy.substitute("others", parameterMap[substitutionParameters[i]]);
980 
981  // replace all the occurances of "particle"
982  while (muonTemplate.substitute("particle", particle))
983  muonTemplate.substitute("particle", particle);
984 
985  // remove the the parameter $(content) if its empty
986  iter = muonParameters.find(substitutionParameters[i]);
987 
988  // check weather this parameter exists
989  if (iter != muonParameters.end()) {
990  if ((*iter).second[(*iter).second.length() - 1] == '\n')
991  (*iter).second[(*iter).second.length() - 1] = ' ';
992  internalTemplateCopy.substitute("content", (*iter).second);
993  } else
994  internalTemplateCopy.removeLineWithContent("$(content)");
995 
996  // insert the processed internal template in the muon template file
997  muonTemplate.insert("$(" + substitutionParameters[i] + ")", internalTemplateCopy);
998  }
999 
1000  // save the muon template file
1001  muonTemplate.save(chip2OutputSubDir(condChip) + outputFile);
1002  chmod((chip2OutputSubDir(condChip) + outputFile).c_str(), 0666);
1003 }
std::string vhdlDir_
templates directory
static const bool findAndReplaceString(std::string &paramString, const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString at it&#39;s first occurance in string
bool substitute(const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString
bool save(const std::string &fileName)
saves the content of the template file to a local file (the content of parameterMap_ will not be save...
std::vector< std::string > getSubstitutionParametersFromTemplate() const
returns a vector with all substitution parameters that are found in the template file ...
bool removeLineWithContent(const std::string &str)
removes all lines that contain the str
def chmod(path, mode)
Definition: eostools.py:294
static const std::string vhdlTemplateCaloSetup_
void append(const std::string &str)
adds a line at the end of the the file with the content of str
bool insert(const std::string &atLine, const std::vector< std::string > &content)
replaces the whole line containing atLine and inserts content instead of it
static const std::string vhdlTemplateMuonSetup_
std::map< std::string, std::string > returnParameterMap() const
returns parameter map
std::string chip2OutputSubDir(const int &chip)
L1GtVhdlTemplateFile openVhdlFileWithCommonHeader(const std::string &filename, const std::string &outputFilename)
opens a new template file and inserts the common header
bool open(const std::string &fileName, bool internal=false)
opens a template file. If the header information shall be parsed intern has to be set to true ...

◆ writeQsfSetupFiles()

void L1GtVhdlWriterCore::writeQsfSetupFiles ( const std::string &  version)

builds the two quartus setup files. This routine is called in buildCommonHeader!

Definition at line 1099 of file L1GtVhdlWriterCore.cc.

References chip2OutputSubDir(), eostools::chmod(), L1GtVhdlTemplateFile::findAndReplaceString(), mps_fire::i, L1GtVhdlTemplateFile::open(), L1GtVhdlDefinitions::quartusSetupFileChip1_, L1GtVhdlDefinitions::quartusSetupFileChip2_, L1GtVhdlTemplateFile::save(), AlCaHLTBitMon_QueryRunRegistry::string, L1GtVhdlTemplateFile::substitute(), BeamSplash_cfg::version, and vhdlDir_.

Referenced by makeFirmware().

1099  {
1100  std::vector<std::string> filenames;
1101  filenames.push_back(quartusSetupFileChip1_);
1102  filenames.push_back(quartusSetupFileChip2_);
1103 
1104  for (unsigned int i = 0; i < filenames.size(); i++) {
1105  L1GtVhdlTemplateFile myTemplate;
1106 
1107  myTemplate.open(vhdlDir_ + "Templates/" + filenames.at(i));
1108  myTemplate.substitute("version", version);
1109 
1110  std::string tempStr = filenames.at(i);
1111 
1112  if (i == 0)
1113  L1GtVhdlTemplateFile::findAndReplaceString(tempStr, "cond1", "cond");
1114  if (i == 1)
1115  L1GtVhdlTemplateFile::findAndReplaceString(tempStr, "cond2", "cond");
1116 
1117  myTemplate.save(chip2OutputSubDir(i + 1) + tempStr);
1118  chmod((chip2OutputSubDir(i + 1) + tempStr).c_str(), 0666);
1119  }
1120 }
std::string vhdlDir_
templates directory
static const bool findAndReplaceString(std::string &paramString, const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString at it&#39;s first occurance in string
bool substitute(const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString
static const std::string quartusSetupFileChip2_
bool save(const std::string &fileName)
saves the content of the template file to a local file (the content of parameterMap_ will not be save...
def chmod(path, mode)
Definition: eostools.py:294
static const std::string quartusSetupFileChip1_
std::string chip2OutputSubDir(const int &chip)
bool open(const std::string &fileName, bool internal=false)
opens a template file. If the header information shall be parsed intern has to be set to true ...

Member Data Documentation

◆ algorithmMap_

const AlgorithmMap* L1GtVhdlWriterCore::algorithmMap_
private

algorithm map

Definition at line 222 of file L1GtVhdlWriterCore.h.

Referenced by makeFirmware().

◆ bm_

L1GtVhdlWriterBitManager L1GtVhdlWriterCore::bm_
private

◆ caloObjects_

std::vector<L1GtObject> L1GtVhdlWriterCore::caloObjects_
private

list of all possible calo objects

Definition at line 237 of file L1GtVhdlWriterCore.h.

Referenced by getCondChipVhdContentFromTriggerMenu(), initializeDeltaConditions(), L1GtVhdlWriterCore(), makeFirmware(), and writeDefValPkg().

◆ caloType2Int_

std::map<L1GtObject, std::string> L1GtVhdlWriterCore::caloType2Int_
private

converts L1GtObject to calo_nr

Definition at line 231 of file L1GtVhdlWriterCore.h.

Referenced by getCondChipVhdContentFromTriggerMenu(), and L1GtVhdlWriterCore().

◆ commonHeader_

L1GtVhdlTemplateFile L1GtVhdlWriterCore::commonHeader_
private

common header for all files

Definition at line 254 of file L1GtVhdlWriterCore.h.

Referenced by buildCommonHeader(), openVhdlFileWithCommonHeader(), printCommonHeader(), and retrunCommonHeader().

◆ conditionMap_

const std::vector<ConditionMap>* L1GtVhdlWriterCore::conditionMap_
private

condition map

Definition at line 219 of file L1GtVhdlWriterCore.h.

Referenced by makeFirmware(), processAlgorithmMap(), and writeCond2intMap2File().

◆ conditionToIntegerMap_

std::map<std::string, int> L1GtVhdlWriterCore::conditionToIntegerMap_
private

◆ condType2Str_

std::map<L1GtConditionType, std::string> L1GtVhdlWriterCore::condType2Str_
private

◆ debugMode_

bool L1GtVhdlWriterCore::debugMode_
private

◆ esumObjects_

std::vector<L1GtObject> L1GtVhdlWriterCore::esumObjects_
private

list of all possible esums objects

Definition at line 240 of file L1GtVhdlWriterCore.h.

Referenced by getCondChipVhdContentFromTriggerMenu(), L1GtVhdlWriterCore(), makeFirmware(), and writeDefValPkg().

◆ internMessageBuf_

std::vector<std::string> L1GtVhdlWriterCore::internMessageBuf_
private

Definition at line 256 of file L1GtVhdlWriterCore.h.

Referenced by getMsgBuf(), and msg().

◆ numberOfConditions_

std::vector<std::vector<std::string> > L1GtVhdlWriterCore::numberOfConditions_
private

vector containing the initialization of all conditions

Definition at line 259 of file L1GtVhdlWriterCore.h.

Referenced by addJetCountsToCond2IntMap(), countCondsAndAdd2NumberVec(), initializeDeltaConditions(), L1GtVhdlWriterCore(), and writeCondChipPkg().

◆ objType2Str_

std::map<L1GtObject, std::string> L1GtVhdlWriterCore::objType2Str_
private

◆ outputDir_

std::string L1GtVhdlWriterCore::outputDir_
private

◆ version_

std::string L1GtVhdlWriterCore::version_
private

Definition at line 251 of file L1GtVhdlWriterCore.h.

Referenced by buildCommonHeader(), makeFirmware(), and writeCondChipPkg().

◆ vhdlDir_

std::string L1GtVhdlWriterCore::vhdlDir_
private