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

destructor

Definition at line 88 of file L1GtVhdlWriterCore.cc.

89 {
90  // empty
91 }

Member Function Documentation

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 1377 of file L1GtVhdlWriterCore.cc.

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

Referenced by makeFirmware().

1380 {
1381  ConditionMap jetConditions;
1382 
1384  conditionMap.at(chip-1), jetConditions);
1385  /*
1386  int counter = 0;
1387 
1388  for (ConditionMap::const_iterator iterCond = jetConditions.begin(); iterCond != jetConditions.end(); iterCond++)
1389  {
1390  conditionToIntegerMap_[iterCond->first]=counter;
1391  counter++;
1392  msg(iterCond->first);
1393  }
1394 
1395  */
1396 
1397  unsigned int maxJetsCountsIndex = 11;
1398 
1399  for (unsigned int i= 0; i<=maxJetsCountsIndex; i++)
1400  {
1401  int counter = 0;
1402 
1403  for (ConditionMap::const_iterator iterCond = jetConditions.begin(); iterCond
1404  != jetConditions.end(); iterCond++)
1405  {
1406 
1407  L1GtJetCountsTemplate* jetsTemplate =
1408  static_cast<L1GtJetCountsTemplate*>(iterCond->second);
1409  const std::vector<L1GtJetCountsTemplate::ObjectParameter>* op =
1410  jetsTemplate->objectParameter();
1411 
1412  conditionToIntegerMap_[iterCond->first]=counter;
1413  if ((*op)[0].countIndex==i)
1414  counter++;
1415 
1416  //msg(int2str((*op)[0].countIndex));
1417 
1418  }
1419 
1420  numberOfConditions_.at(chip-1).push_back(retNumberOfConditionsString("jet_cnts_"
1421  +int2str(i)+"_cond", counter));
1422 
1423  }
1424 
1425 }
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
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 1039 of file L1GtVhdlWriterCore.cc.

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

Referenced by L1GtVhdlWriter::analyze().

1042 {
1043  commonHeader_.open(vhdlDir_+"InternalTemplates/header");
1044 
1045  std::map<std::string,std::string>::iterator iter = headerParameters.begin();
1046 
1047  // loop over the header parameter map and replace all subsitution
1048  // parameters with their values
1049  while (iter != headerParameters.end() )
1050  {
1051  commonHeader_.substitute((*iter).first, (*iter).second);
1052  iter++;
1053  }
1054 
1055  commonHeader_.insert("$(connected_channels_1)", connectedChannels);
1056  commonHeader_.insert("$(connected_channels_2)", connectedChannels);
1057 
1058  //---------------------build the Quartus configuration files----------------------------------------
1059 
1060  //writeQsfSetupFiles(headerParameters["version"]);
1061 
1062  version_=headerParameters["version"];
1063 
1064  msg("Build Common header and Quartus setup files sucessuflly!");
1065 
1066 }
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 ...
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 1474 of file L1GtVhdlWriterCore.cc.

1476 {
1477  // has to produce something like 1 => ("00000000", "00000000")
1478 
1479  return "1 => (\"00000000\", \"00000000\")";
1480 }
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 1661 of file L1GtVhdlWriterCore.cc.

References L1GtVhdlTemplateFile::append(), condType2Str_, ws_sso_content_reader::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().

1664 {
1665  // type iterator
1666  std::map<L1GtConditionType,std::string>::const_iterator typeIter;
1667 
1668  for (typeIter=typeList.begin(); typeIter!=typeList.end(); typeIter++)
1669  {
1670 
1671  for (unsigned int i = 0; i<defValuesList.size(); i++)
1672  {
1673 
1674  // open a new internale template
1675  L1GtVhdlTemplateFile internalTemplate;
1676  internalTemplate.open(vhdlDir_+"InternalTemplates/defvalpkg", true);
1677 
1678  std::string
1679  idString =
1681 
1682  // The following three steps convert "$(particle)_$(type)_$(defvaltype)_def_val"
1683  // to e.g. "muon_1s_et_def_val"
1684 
1685  // replace the substiution parameter particle with muon - thereby parameterString is a
1686  // reference and therefore changed.
1688  sp(substParamParticle_), objType2Str_[object]);
1689 
1690  // replace the substiution parameter particle with muon
1692  sp(substParamType_), typeIter->second);
1693 
1694  // replace the substiution parameter defvaltype with muon
1696  sp(substParamDefValType_), defValuesList.at(i));
1697 
1698  // usage of the subsitute routine:
1699  // first the substitution parameter, then the content
1700  internalTemplate.substitute(substParamDefValId_, idString);
1701 
1702  // !here the body of the internale template is build - almost done!
1703 
1704  // The body looks as follows $(def_val), $(max_nr), $(content) and
1705  // $(others) have to be subsituted
1706 
1707  /*
1708  * CONSTANT $(def_val) : $(calo_or_muon)_maxnr$(max_nr)vector8_arr :=
1709  * (
1710  * $(content)
1711  * $(others)
1712  * );
1713  */
1714 
1715  // substitute the particle
1716  internalTemplate.substitute(substParamParticle_,
1717  objType2Str_[object]);
1718 
1719  // go on with max number - get the correct expression for max number from the internal template
1720  internalTemplate.substitute(substParamMaxNr_,
1721  internalTemplate.getInternalParameter(substParamMaxNr_+"_"
1722  +condType2Str_[typeIter->first]));
1723 
1724  // now we have to choose the correct OTHERS string for the
1725  // internal template. The identifier for the OTHERS string
1726  // is the condition type (as firmware string) therefore:
1727 
1728  // we get it as follows
1729  std::string othersString;
1730 
1731  // jet_cnts are a special case
1732  if (object==JetCounts || object==HTT || object==ETM || object==ETT )
1733  othersString
1734  = internalTemplate.getInternalParameter(objType2Str_[JetCounts]);
1735  else
1736  othersString
1737  = internalTemplate.getInternalParameter(typeIter->second);
1738 
1739  internalTemplate.substitute(substParamOthers_, othersString);
1740 
1741  // the actual content, taken from the trigger menu
1742 
1743  std::string content = getDefValsFromTriggerMenu(typeIter->first,
1744  object, RegEtThreshold);
1745 
1746  internalTemplate.substitute(substParamContent_, content);
1747 
1748  // Finally the parameter $(calo_or_muon) is left open
1749  std::string caloOrMuonStr = stringConstantCalo_;
1750 
1751  if (object == Mu)
1752  caloOrMuonStr = objType2Str_[Mu];
1753 
1754  internalTemplate.substitute(substParamCaloOrMuon_, caloOrMuonStr);
1755 
1756  // The internal template has been processed and now can be added to the buffer..
1757  buffer.append(internalTemplate);
1758 
1759  }
1760 
1761  }
1762 
1763  return true;
1764 }
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:36
std::map< L1GtConditionType, std::string > condType2Str_
converts L1GtConditionType to firmware string
std::string getDefValsFromTriggerMenu(const L1GtConditionType &type, const L1GtObject &object, const VmeRegister &reg)
static const std::string substParamDefValType_
Definition: L1GtObject.h:38
static const std::string substParamType_
void append(const std::string &str)
adds a line at the end of the the file with the content of str
static const std::string substParamDefValId_
std::string getInternalParameter(const std::string &indentifier)
returns a parameter of a internal template file
Definition: L1GtObject.h:30
static const std::string stringConstantCalo_
static const std::string substParamContent_
static const std::string substParamParticle_
Definition: L1GtObject.h:37
static const std::string substParamOthers_
static const std::string substParamCaloOrMuon_
static const std::string substParamMaxNr_
std::map< L1GtObject, std::string > objType2Str_
converts L1GtObject to string
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 ...
std::string L1GtVhdlWriterCore::chip2OutputSubDir ( const int &  chip)

Definition at line 900 of file L1GtVhdlWriterCore.cc.

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

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

901 {
902  if (chip==1)
903  return outputDir_+"/"+outputSubDir1_+"/";
904  if (chip==2)
905  return outputDir_+"/"+outputSubDir2_+"/";
906 
907  return "";
908 }
static const std::string outputSubDir1_
static const std::string outputSubDir2_
std::string outputDir_
output directory
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 1766 of file L1GtVhdlWriterCore.cc.

References condType2Str_, numberOfConditions_, objType2Str_, retNumberOfConditionsString(), returnConditionsOfOneClass(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

1770 {
1771 
1772  // Get the absoloute amount of conditions
1773 
1774  int number;
1775 
1776  if (returnConditionsOfOneClass(type, category, object, map, outputMap))
1777  number=outputMap.size();
1778  else
1779  number=0;
1780 
1782  +condType2Str_[type], number);
1783 
1784  numberOfConditions_.at(condChip-1).push_back(initstr);
1785 
1786 }
type
Definition: HCALResponse.h:21
std::map< L1GtConditionType, std::string > condType2Str_
converts L1GtConditionType to firmware string
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::string retNumberOfConditionsString(const std::string &typeStr, const int &number)
std::map< L1GtObject, std::string > objType2Str_
converts L1GtObject to string
bool L1GtVhdlWriterCore::findObjectType ( const L1GtObject object,
ConditionMap map 
)

Definition at line 116 of file L1GtVhdlWriterCore.cc.

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

118 {
119  bool status = false;
120 
121  ConditionMap::iterator condIter = map.begin();
122  while (condIter!=map.end())
123  {
124  for (unsigned int i=0; i<(condIter->second->objectType()).size(); i++)
125  {
126  if (condIter->second->objectType()[i]==object)
127  {
128  status = true;
129  break;
130  }
131  }
132 
133  if (status)
134  break;
135  condIter++;
136  }
137 
138  return status;
139 }
size
Write out results.
bool L1GtVhdlWriterCore::getCaloSetupContentFromTriggerMenu ( const unsigned short int &  condChip,
std::map< std::string, std::string > &  caloParameters,
const L1GtObject caloObject 
)

Definition at line 316 of file L1GtVhdlWriterCore.cc.

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

Referenced by makeFirmware().

320 {
321  // vector containing all relevant types for calo conditions
322  std::vector<L1GtConditionType> caloConditionTypes;
323 
324  caloConditionTypes.push_back(Type1s);
325  caloConditionTypes.push_back(Type2s);
326  caloConditionTypes.push_back(Type2wsc);
327  caloConditionTypes.push_back(Type4s);
328 
329  for (unsigned int i = 0; i<caloConditionTypes.size(); i++)
330  {
331  unsigned int counter=0;
332 
333  ConditionMap caloConditions;
334 
335  // stores all conditions of type given in the first three parameters
336  countCondsAndAdd2NumberVec(caloConditionTypes.at(i), CondCalo,
337  caloObject, (*conditionMap_).at(condChip-1), caloConditions,
338  condChip);
339 
340  for (ConditionMap::const_iterator iterCond = caloConditions.begin(); iterCond
341  != caloConditions.end(); iterCond++)
342  {
343 
344  // add this condition to name -> integer conversion map
345  conditionToIntegerMap_[iterCond->first]=counter;
346 
347  L1GtCaloTemplate* m_gtCaloTemplate =
348  static_cast<L1GtCaloTemplate*>(iterCond->second);
349  const std::vector<L1GtCaloTemplate::ObjectParameter>* op =
350  m_gtCaloTemplate->objectParameter();
351 
352  if (caloConditionTypes.at(i)==Type1s)
353  {
354 
355  //= static_cast<std::vector<L1GtCaloTemplate::ObjectPaenergySumParameter+=rameter*> >(op);
356 
357  // build eta
358  caloParameters["eta_1_s"] += (bm_.buildEtaCalo(op, 1, counter));
359 
360  caloParameters["phi_1_s"]+= bm_.buildPhiCalo(op, 1, counter);
361 
362  if (debugMode_)
363  {
364  caloParameters["eta_1_s"]+=("--"+iterCond->first+"\n");
365  caloParameters["phi_1_s"]+=("--"+iterCond->first+"\n");
366  }
367 
368  } else if (caloConditionTypes.at(i)==Type2s)
369  {
370 
371  // build eta
372  caloParameters["eta_2_s"] += (bm_.buildEtaCalo(op, 2, counter));
373 
374  // add the parameters to parameter map
375  caloParameters["phi_2_s"]+= bm_.buildPhiCalo(op, 2, counter);
376 
377  if (debugMode_)
378  {
379  caloParameters["eta_2_s"]+=("--"+iterCond->first+"\n");
380  caloParameters["phi_2_s"]+=("--"+iterCond->first+"\n");
381  }
382 
383  } else if (caloConditionTypes.at(i)==Type4s)
384  {
385  // build eta
386  caloParameters["eta_4"] += (bm_.buildEtaCalo(op, 4, counter));
387 
388  // add the parameters to parameter map
389  caloParameters["phi_4"]+= bm_.buildPhiCalo(op, 4, counter);
390 
391  if (debugMode_)
392  {
393  caloParameters["eta_4"]+=("--"+iterCond->first+"\n");
394  caloParameters["phi_4"]+=("--"+iterCond->first+"\n");
395  }
396 
397  } else if (caloConditionTypes.at(i)==Type2wsc)
398  {
400  m_gtCaloTemplate->correlationParameter();
401 
402  // build eta
403  caloParameters["eta_2_wsc"]
404  += (bm_.buildEtaCalo(op, 2, counter));
405 
406  // build phi
407  caloParameters["phi_2_wsc"]+= bm_.buildPhiCalo(op, 2, counter);
408 
409  // build delta_eta
410  caloParameters["delta_eta"] += bm_.buildDeltaEtaCalo(cp,
411  counter);
412 
413  // build delta_phi
414  caloParameters["delta_phi"] += bm_.buildDeltaPhiCalo(cp,
415  counter);
416 
417  if (debugMode_)
418  {
419  caloParameters["eta_2_wsc"]+=("--"+iterCond->first+"\n");
420  caloParameters["phi_2_wsc"]+=("--"+iterCond->first+"\n");
421  caloParameters["delta_eta"]+=("--"+iterCond->first+"\n");
422  caloParameters["delta_phi"]+=("--"+iterCond->first+"\n");
423  }
424 
425  }
426 
427  counter++;
428 
429  }
430 
431  }
432 
433  return true;
434 }
std::string buildEtaCalo(const std::vector< L1GtCaloTemplate::ObjectParameter > *op, const unsigned int &num, const unsigned int &counter)
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)
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)
const CorrelationParameter * correlationParameter() const
static std::atomic< 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
L1GtConditionCategory L1GtVhdlWriterCore::getCategoryFromObject ( const L1GtObject object)

gets condition category from object

Definition at line 1833 of file L1GtVhdlWriterCore.cc.

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

Referenced by getDefValsFromTriggerMenu().

1835 {
1836 
1838 
1839  if (object==Mu)
1840  category = CondMuon;
1841  else if (object==ETM || object==HTT || object==ETT)
1842  category = CondEnergySum;
1843  else if (object==IsoEG|| object==NoIsoEG || object==CenJet || object
1844  ==ForJet || object==TauJet)
1845  category = CondCalo;
1846  else if (object==IsoEG|| object==NoIsoEG || object==CenJet || object
1847  ==ForJet || object==TauJet)
1848  category = CondCalo;
1849  else if (object==JetCounts)
1850  category = CondJetCounts;
1851  else
1852  category=CondNull;
1853 
1854  return category;
1855 
1856 }
Definition: L1GtObject.h:36
Definition: L1GtObject.h:38
L1GtConditionCategory
condition categories
Definition: L1GtObject.h:30
Definition: L1GtObject.h:37
std::map< std::string, int > L1GtVhdlWriterCore::getCond2IntMap ( )

Definition at line 1909 of file L1GtVhdlWriterCore.cc.

References conditionToIntegerMap_.

Referenced by L1GtVhdlWriter::analyze().

1910 {
1911  return conditionToIntegerMap_;
1912 }
std::map< std::string, int > conditionToIntegerMap_
stores to condition name to integer conversion table
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 528 of file L1GtVhdlWriterCore.cc.

References L1GtVhdlTemplateFile::append(), caloObjects_, caloType2Int_, CondCalo, CondCorrelation, CondEnergySum, conditionToIntegerMap_, CondJetCounts, CondMuon, CondNull, condType2Str_, esumObjects_, ETM, spr::find(), L1GtVhdlTemplateFile::findAndReplaceString(), L1GtVhdlTemplateFile::getInternalParameter(), getIntVal(), getSubstParamCommonFromTriggerMenu(), mps_fire::i, index4CondChipVhd(), int2str(), metsig::jet, JetCounts, msg(), Mu, metsig::muon, L1GtCondition::nrObjects(), L1GtJetCountsTemplate::objectParameter(), objType2Str_, L1GtVhdlTemplateFile::open(), AlCaHLTBitMon_ParallelJobs::p, L1GtVhdlTemplateFile::removeEmptyLines(), L1GtVhdlTemplateFile::returnParameterMap(), 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_, Type1s, Type2s, Type2wsc, Type3s, Type4s, and vhdlDir_.

Referenced by makeFirmware().

532 {
533 
534  // open the necessary internal templates
535  L1GtVhdlTemplateFile muon, calo, esums, jet;
536 
537  muon.open(vhdlDir_+"InternalTemplates/muon", true);
538  muon.substitute("particle", "muon");
539 
540  calo.open(vhdlDir_+"InternalTemplates/calo", true);
541  esums.open(vhdlDir_+"InternalTemplates/esums", true);
542  jet.open(vhdlDir_+"InternalTemplates/jet_cnts", true);
543 
544  /*
545  charge1s.open(vhdlDir_+"InternalTemplates/charge_1s",false);
546  charge2s.open(vhdlDir_+"InternalTemplates/charge_2s",false);
547  charge2wsc.open(vhdlDir_+"InternalTemplates/charge_2_wsc",false);
548  charge3s.open(vhdlDir_+"InternalTemplates/charge_3",false);
549  charge4s.open(vhdlDir_+"InternalTemplates/charge_4",false);
550  */
551 
552  // only for jet_cnts common parameter relevant since common parameter is build in this routine
553  std::vector<unsigned int> processedTypes;
554 
555  //-------------------------------------build the common parameters-------------------------------------------
556 
557  // build $(muon_common)
558  getSubstParamCommonFromTriggerMenu(condChip,muon, Mu, CondMuon, commonParams["muon_common"]);
559 
560  // build $(calo_common) - loop over all calo objects
561  std::vector<L1GtObject>::iterator caloObjIter = caloObjects_.begin();
562 
563  while (caloObjIter != caloObjects_.end())
564  {
565 
566  getSubstParamCommonFromTriggerMenu(condChip, muon, (*caloObjIter), CondCalo,
567  commonParams["calo_common"]);
568  caloObjIter++;
569 
570  }
571 
572  // build $(esums_common) - loop over all esums objects
573  std::vector<L1GtObject>::iterator esumObjIter = esumObjects_.begin();
574 
575  while (esumObjIter != esumObjects_.end())
576  {
577 
578  getSubstParamCommonFromTriggerMenu(condChip, esums, (*esumObjIter), CondEnergySum,
579  commonParams["esums_common"]);
580  esumObjIter++;
581 
582  }
583 
584  //--------------------------------------build the parameter maps----------------------------------------------
585 
586  // loop over condition map
587  for (ConditionMap::const_iterator iterCond = (*conditionMap_).at(condChip-1).begin(); iterCond != (*conditionMap_).at(condChip-1).end(); iterCond++)
588  {
589 
590  switch ((iterCond->second)->condCategory())
591  {
592 
593  case CondMuon:
594  {
595 
596  int cond2int;
597  if (!getIntVal(conditionToIntegerMap_, (iterCond->first), cond2int))
598  {
599  msg("Panik! Condition "+(iterCond->first)
600  +" does not have a integer equivalent!");
601  break;
602  }
603 
604  std::string intVal = index4CondChipVhd(cond2int);
605 
606  L1GtVhdlTemplateFile muoncopy = muon;
607 
608  muoncopy.substitute("type", condType2Str_[(iterCond->second)->condType()]);
609 
610  muoncopy.substitute("ser_no", intVal);
611 
612  muoncopy.substitute("name", iterCond->first);
613 
614  if ((iterCond->second)->condType() == Type1s)
615  {
616  muoncopy.substitute(substParamCharge_,
618  } else if ((iterCond->second)->condType() == Type2s)
619  {
620  muoncopy.substitute(substParamCharge_,
622  } else if ((iterCond->second)->condType() == Type2wsc)
623  {
624  muoncopy.substitute(substParamCharge_,
626  } else if ((iterCond->second)->condType() == Type3s)
627  {
628  muoncopy.substitute(substParamCharge_,
630  } else if ((iterCond->second)->condType() == Type4s)
631  {
632  muoncopy.substitute(substParamCharge_,
634  }
635 
636  std::string tempStr = muoncopy.returnParameterMap()["PREALGO"];
637 
638  muoncopy.findAndReplaceString(tempStr, "$(particle)", "muon");
639  muoncopy.findAndReplaceString(tempStr, "$(ser_no)", intVal);
640  muoncopy.findAndReplaceString(tempStr, "$(type)", condType2Str_[(iterCond->second)->condType()]);
641 
642  muoncopy.append(tempStr);
643 
644  muoncopy.removeEmptyLines();
645 
646  // add the processed internal template to parameter map
647  templates["muon"].append(muoncopy);
648 
649  }
650  break;
651 
652  case CondCalo:
653  {
654  int cond2int;
655 
656  if (!getIntVal(conditionToIntegerMap_, (iterCond->first), cond2int))
657  {
658  msg("Panik! Condition "+(iterCond->first)
659  +" does not have a integer equivalent!");
660  break;
661  }
662 
663  std::string intVal = index4CondChipVhd(cond2int);
664 
665  L1GtVhdlTemplateFile calocopy = calo;
666 
667  calocopy.substitute("type", condType2Str_[(iterCond->second)->condType()]);
668  calocopy.substitute("particle", objType2Str_[((iterCond->second)->objectType()).at(0)]);
669  calocopy.substitute("name", iterCond->first);
670  calocopy.substitute("ser_no", intVal);
671  calocopy.substitute("calo_nr", caloType2Int_[((iterCond->second)->objectType()).at(0)]);
672 
673  // builds something like tau_1_s(20));
674  calocopy.append(objType2Str_[((iterCond->second)->objectType()).at(0)] +"_"+condType2Str_[(iterCond->second)->condType()]+"("+intVal+"));");
675 
676  templates["calo"].append(calocopy);
677 
678  }
679  break;
680 
681  case CondEnergySum:
682  {
683 
684  int cond2int;
685 
686  if (!getIntVal(conditionToIntegerMap_, (iterCond->first), cond2int))
687  {
688  msg("Panik! Condition "+(iterCond->first)
689  +" does not have a integer equivalent!");
690  break;
691  }
692 
693  std::string intVal = index4CondChipVhd(cond2int);
694 
695  L1GtVhdlTemplateFile esumscopy = esums;
696 
697  esumscopy.substitute("type", condType2Str_[(iterCond->second)->condType()]);
698  esumscopy.substitute("particle", objType2Str_[((iterCond->second)->objectType()).at(0)]);
699  esumscopy.substitute("name", iterCond->first);
700  esumscopy.substitute("ser_no", intVal);
701 
702  if (((iterCond->second)->objectType()).at(0)==ETM)
703  esumscopy.substitute("if_etm_then_1_else_0", "1");
704  else
705  esumscopy.substitute("if_etm_then_1_else_0", "0");
706 
707  // builds something like htt_cond(4));
708  esumscopy.append(objType2Str_[((iterCond->second)->objectType()).at(0)] +"_"+condType2Str_[(iterCond->second)->condType()]+"("+ intVal+"));");
709 
710  templates["esums"].append(esumscopy);
711  }
712 
713  break;
714 
715  case CondJetCounts:
716  {
717 
718  // build the common parameter for the jet counts
719 
720  L1GtJetCountsTemplate* jetsTemplate =
721  static_cast<L1GtJetCountsTemplate*>(iterCond->second);
722 
723  int nObjects = iterCond->second->nrObjects();
724 
725  const std::vector<L1GtJetCountsTemplate::ObjectParameter>* op =
726  jetsTemplate->objectParameter();
727 
728  for (int i = 0; i < nObjects; i++)
729  {
730 
731  std::vector<unsigned int>::iterator p = find(
732  processedTypes.begin(), processedTypes.end(), (*op)[i].countIndex);
733 
734  // check, weather this count index was already processed
735  // and process it if not
736  if (p==processedTypes.end())
737  {
738  std::ostringstream indStr;
739  indStr<<(*op)[i].countIndex;
740 
742  while (jet.findAndReplaceString(tempStr2,
744  ;
745  while (jet.findAndReplaceString(tempStr2,
746  sp(substParamType_), indStr.str()))
747  ;
748  commonParams[substParamJetCntsCommon_]+=tempStr2+"\n"; // +"<= '0';\n");
749  processedTypes.push_back((*op)[i].countIndex);
750  }
751 
752  }
753 
754  int cond2int;
755 
756  if (!getIntVal(conditionToIntegerMap_, (iterCond->first), cond2int))
757  {
758  msg("Panik! Condition "+(iterCond->first)
759  +" does not have a integer equivalent!");
760  break;
761  }
762 
763  std::string intVal = index4CondChipVhd(cond2int);
764 
765  L1GtVhdlTemplateFile jetcopy = jet;
766 
767  jetcopy.substitute("particle", condType2Str_[(iterCond->second)->condType()]);
768  jetcopy.substitute("type", int2str((*op)[0].countIndex));
769  jetcopy.substitute("name", iterCond->first);
770 
771  jetcopy.substitute("ser_no", intVal);
772 
773  // builds the final string
774  std::string tempStr = jetcopy.returnParameterMap()["PREALGO"];
775 
776  jetcopy.findAndReplaceString(tempStr, "$(particle)", "jet_cnt");
777  jetcopy.findAndReplaceString(tempStr, "$(ser_no)", intVal);
778  jetcopy.findAndReplaceString(tempStr, "$(type)", int2str((*op)[0].countIndex));
779 
780  jetcopy.append(tempStr);
781  jetcopy.removeEmptyLines();
782 
783  templates["jet_cnts"].append(jetcopy);
784  }
785 
786  break;
787 
788  case CondCorrelation:
789  {
790  //empty
791  }
792  break;
793 
794  case CondNull:
795  {
796  //empty
797  }
798  break;
799 
800  default:
801  {
802  //empty
803  }
804  break;
805  }
806  }
807 
808  // delete superfluous newlines at the end of common parameters
809  std::map<std::string,std::string>::iterator pIt = commonParams.begin();
810 
811  while (pIt!=commonParams.end())
812  {
813  if ((pIt->second)[((pIt->second).length()-1)] == '\n')
814  (pIt->second) = (pIt->second).substr(0, (pIt->second).length()-1);
815  pIt++;
816  }
817 
818  return true;
819 
820 }
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
const int nrObjects() const
get number of trigger objects
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
std::map< L1GtObject, std::string > caloType2Int_
converts L1GtObject to calo_nr
Definition: L1GtObject.h:36
std::map< L1GtConditionType, std::string > condType2Str_
converts L1GtConditionType to firmware string
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:20
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_
const std::vector< ObjectParameter > * objectParameter() const
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
std::string getInternalParameter(const std::string &indentifier)
returns a parameter of a internal template file
static const std::string stringConstantCharge3s_
void msg(const std::string &message)
adds a string to intern message buffer
Definition: L1GtObject.h:30
static const std::string substParamParticle_
std::map< std::string, int > conditionToIntegerMap_
stores to condition name to integer conversion table
static const std::string stringConstantCharge1s_
Definition: sp.h:21
static const std::string substParamCharge_
bool removeEmptyLines()
deletes all empty lines in a template file
std::map< L1GtObject, std::string > objType2Str_
converts L1GtObject to string
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 stringConstantCharge2s_
std::map< std::string, std::string > returnParameterMap() const
returns parameter map
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 1482 of file L1GtVhdlWriterCore.cc.

References python.rootplot.argparse::category, CondCalo, getCategoryFromObject(), mps_fire::i, int2str(), L1GtCaloTemplate::objectParameter(), mps_fire::result, returnConditionsOfOneClass(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by buildDefValuesBuffer().

1485 {
1487 
1488  // get condition category from object
1489 
1490  category = getCategoryFromObject(object);
1491 
1492  ConditionMap conditions;
1493  returnConditionsOfOneClass(type, category, object, (*conditionMap_).at(0),
1494  conditions);
1495 
1497 
1498  if (category==CondCalo)
1499  {
1500  for (ConditionMap::const_iterator iterCond =conditions.begin(); iterCond
1501  != conditions.end(); iterCond++)
1502  {
1503  L1GtCaloTemplate* caloTemplate =
1504  static_cast<L1GtCaloTemplate*>(iterCond->second);
1505  const std::vector<L1GtCaloTemplate::ObjectParameter>* op =
1506  caloTemplate->objectParameter();
1507 
1508  unsigned int nObjects = iterCond->second->nrObjects();
1509 
1510  for (unsigned int i =0; i<nObjects; i++)
1511  {
1512  if (i==0)
1513  result+="(";
1514  result +="\"";
1515  result += int2str((*op).at(i).etThreshold);
1516  result +="\"";
1517  if (i!=nObjects-1)
1518  result +=",";
1519  else
1520  result+=")\n";
1521 
1522  }
1523  }
1524  }
1525 
1526  return "-- 0 => (\"00000000\", \"00000000\" ... )";
1527  return result;
1528 }
type
Definition: HCALResponse.h:21
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
const std::vector< ObjectParameter > * objectParameter() const
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 436 of file L1GtVhdlWriterCore.cc.

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

Referenced by makeFirmware().

439 {
440 
442 
443  unsigned int counter=0;
444 
445  if (object==HTT)
446  type= TypeHTT;
447  else if (object==ETM)
448  type= TypeETM;
449  else if (object==ETT)
450  type= TypeETT;
451 
452  ConditionMap esumsConditions;
453  // stores all conditions of type given in the first three parameters
455  (*conditionMap_).at(condChip-1), esumsConditions, condChip);
456 
457  for (ConditionMap::const_iterator iterCond = esumsConditions.begin(); iterCond
458  != esumsConditions.end(); iterCond++)
459  {
460  L1GtEnergySumTemplate* energySumTempl =
461  static_cast<L1GtEnergySumTemplate*>(iterCond->second);
462  const std::vector<L1GtEnergySumTemplate::ObjectParameter>* op =
463  energySumTempl->objectParameter();
464 
465  if (bm_.buildPhiEnergySum(op, 1, counter)!="")
466  energySumParameter+=bm_.buildPhiEnergySum(op, 1, counter);
467 
468  if (debugMode_)
469  {
470  energySumParameter+=("--"+iterCond->first+"\n");
471  }
472 
473  conditionToIntegerMap_[(iterCond->first)]=counter;
474 
475  counter++;
476  }
477 
478  return true;
479 
480 }
type
Definition: HCALResponse.h:21
std::map< std::string, L1GtCondition * > ConditionMap
map containing the conditions
Definition: L1GtObject.h:36
L1GtVhdlWriterBitManager bm_
bit manager for bit operations
L1GtConditionType
Definition: L1GtObject.h:38
const std::vector< ObjectParameter > * objectParameter() const
void countCondsAndAdd2NumberVec(const L1GtConditionType &type, const L1GtConditionCategory &category, const L1GtObject &object, const ConditionMap &map, ConditionMap &outputMap, const int &condChip)
Definition: L1GtObject.h:37
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
bool debugMode_
class will produce some additional debugging output if set
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 1361 of file L1GtVhdlWriterCore.cc.

Referenced by getCondChipVhdContentFromTriggerMenu().

1363 {
1364  std::map<std::string,int>::const_iterator iter = map.find(searchValue);
1365  if (iter == map.end() )
1366  return false;
1367  intVal = (*iter).second;
1368  return true;
1369 }
std::vector< std::string > L1GtVhdlWriterCore::getMsgBuf ( )

returns intern message buffer

Definition at line 1356 of file L1GtVhdlWriterCore.cc.

References internMessageBuf_.

1357 {
1358  return internMessageBuf_;
1359 }
std::vector< std::string > internMessageBuf_
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 141 of file L1GtVhdlWriterCore.cc.

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

Referenced by makeFirmware().

144 {
145  // vector containing all relevant types for muon conditions
146  std::vector<L1GtConditionType> muonConditionTypes;
147 
148  muonConditionTypes.push_back(Type1s);
149  muonConditionTypes.push_back(Type2s);
150  muonConditionTypes.push_back(Type2wsc);
151  muonConditionTypes.push_back(Type3s);
152  muonConditionTypes.push_back(Type4s);
153 
154  for (unsigned int i = 0; i<muonConditionTypes.size(); i++)
155  {
156  //std::cout<<i<<std::endl;
157 
158  ConditionMap MuonConditions1s;
159 
160  countCondsAndAdd2NumberVec(muonConditionTypes.at(i), CondMuon, Mu,
161  (*conditionMap_).at(condChip-1), MuonConditions1s, condChip);
162 
163  /*
164  // Get the absoloute amount of conditions
165  std::string initstr="CONSTANT nr_"+objType2Str_[Mu]+"_"+condType2Str_[muonConditionTypes.at(i)]+" : integer := ";
166 
167  if (returnConditionsOfOneClass(muonConditionTypes.at(i),CondMuon,Mu,conditionMap_.at(condChip-1), MuonConditions1s))
168  initstr+=(int2str(MuonConditions1s.size())+";");
169  else
170  initstr+=("0;");
171 
172  numberOfConditions_.at(condChip-1).push_back(initstr);
173 
174  */
175 
176  //std::cout<< std::hex << (*myObjectParameter).at(0).etThreshold << std::endl;
177  unsigned int counter=0;
178 
179  for (ConditionMap::const_iterator iterCond = MuonConditions1s.begin(); iterCond
180  != MuonConditions1s.end(); iterCond++)
181  {
182 
183  // add this condition to name -> integer conversion map
184  conditionToIntegerMap_[iterCond->first]=counter;
185 
186  L1GtMuonTemplate* m_gtMuonTemplate =
187  static_cast<L1GtMuonTemplate*>(iterCond->second);
188  const std::vector<L1GtMuonTemplate::ObjectParameter>* op =
189  m_gtMuonTemplate->objectParameter();
190 
191  if (muonConditionTypes.at(i)==Type1s)
192  {
193 
194  // build eta
195  muonParameters["eta_1_s"] += (bm_.buildEtaMuon(op, 1, counter));
196 
197  // add the parameters to parameter map
198  muonParameters["phi_h_1_s"]+= bm_.buildPhiMuon(op, 1, counter,
199  true);
200  muonParameters["phi_l_1_s"]+=bm_.buildPhiMuon(op, 1, counter,
201  false);
202 
203  if (debugMode_)
204  {
205  muonParameters["phi_l_1_s"]+=("--"+iterCond->first+"\n");
206  muonParameters["phi_h_1_s"]+=("--"+iterCond->first+"\n");
207  muonParameters["eta_1_s"] +=("--"+iterCond->first+"\n");
208  }
209 
210  } else
211 
212  if (muonConditionTypes.at(i)==Type2s)
213  {
214 
215  // build eta
216  muonParameters["eta_2_s"] += (bm_.buildEtaMuon(op, 2, counter));
217 
218  // add the parameters to parameter map
219  muonParameters["phi_h_2_s"]+= bm_.buildPhiMuon(op, 2, counter,
220  true);
221  muonParameters["phi_l_2_s"]+=bm_.buildPhiMuon(op, 2, counter,
222  false);
223 
224  if (debugMode_)
225  {
226  muonParameters["phi_l_2_s"]+=("--"+iterCond->first+"\n");
227  muonParameters["phi_h_2_s"]+=("--"+iterCond->first+"\n");
228  muonParameters["eta_2_s"] +=("--"+iterCond->first+"\n");
229  }
230 
231  } else
232  //m_gtMuonTemplate->print(std::cout);
233 
234  if (muonConditionTypes.at(i)==Type3s)
235  {
236 
237  // build eta
238  muonParameters["eta_3"] += (bm_.buildEtaMuon(op, 3, counter));
239 
240  // add the parameters to parameter map
241  muonParameters["phi_h_3"]+= bm_.buildPhiMuon(op, 3, counter,
242  true);
243  muonParameters["phi_l_3"]+=bm_.buildPhiMuon(op, 3, counter,
244  false);
245 
246  if (debugMode_)
247  {
248  muonParameters["phi_l_3"]+=("--"+iterCond->first+"\n");
249  muonParameters["phi_h_3"]+=("--"+iterCond->first+"\n");
250  muonParameters["eta_3"] +=("--"+iterCond->first+"\n");
251  }
252 
253  }
254 
255  if (muonConditionTypes.at(i)==Type4s)
256  {
257 
258  // build eta
259  muonParameters["eta_4"] += (bm_.buildEtaMuon(op, 4, counter));
260 
261  // add the parameters to parameter map
262  muonParameters["phi_h_4"]+= bm_.buildPhiMuon(op, 4, counter,
263  true);
264  muonParameters["phi_l_4"]+=bm_.buildPhiMuon(op, 4, counter,
265  false);
266 
267  if (debugMode_)
268  {
269  muonParameters["phi_l_4"]+=("--"+iterCond->first+"\n");
270  muonParameters["phi_h_4"]+=("--"+iterCond->first+"\n");
271  muonParameters["eta_4"] +=("--"+iterCond->first+"\n");
272  }
273 
274  }
275 
276  if (muonConditionTypes.at(i)==Type2wsc)
277  {
279  m_gtMuonTemplate->correlationParameter();
280 
281  // build eta
282  muonParameters["eta_2_wsc"]
283  += (bm_.buildEtaMuon(op, 2, counter));
284 
285  // build phi
286  muonParameters["phi_h_2_wsc"]+= bm_.buildPhiMuon(op, 2,
287  counter, true);
288  muonParameters["phi_l_2_wsc"]+=bm_.buildPhiMuon(op, 2, counter,
289  false);
290 
291  // build delta_eta
292  std::ostringstream dEta;
293  muonParameters["delta_eta"] += bm_.buildDeltaEtaMuon(cp,
294  counter);
295 
296  // build delta_phi
297  muonParameters["delta_phi"] += bm_.buildDeltaPhiMuon(cp,
298  counter);
299 
300  if (debugMode_)
301  {
302  muonParameters["eta_2_wsc"]+=("--"+iterCond->first+"\n");
303  muonParameters["phi_h_2_wsc"]+=("--"+iterCond->first+"\n");
304  muonParameters["phi_l_2_wsc"] +=("--"+iterCond->first+"\n");
305  muonParameters["delta_eta"]+=("--"+iterCond->first+"\n");
306  muonParameters["delta_phi"] +=("--"+iterCond->first+"\n");
307  }
308 
309  }
310  counter++;
311  }
312  }
313 
314 }
const CorrelationParameter * correlationParameter() const
std::map< std::string, L1GtCondition * > ConditionMap
map containing the conditions
L1GtVhdlWriterBitManager bm_
bit manager for bit operations
const std::vector< ObjectParameter > * objectParameter() const
std::string buildDeltaPhiMuon(const L1GtMuonTemplate::CorrelationParameter *&cp, const unsigned int &counter)
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)
Definition: L1GtObject.h:30
static std::atomic< unsigned int > counter
std::map< std::string, int > conditionToIntegerMap_
stores to condition name to integer conversion table
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)
bool debugMode_
class will produce some additional debugging output if set
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 482 of file L1GtVhdlWriterCore.cc.

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

Referenced by getCondChipVhdContentFromTriggerMenu().

485 {
486 
487  std::map<L1GtConditionType,std::string> condType2Strcopy = condType2Str_;
488 
489  // make a copy since types will deleted later after they are processed
490  std::map<L1GtConditionType,std::string>::iterator typeIterator =
491  condType2Strcopy.begin();
492 
493  while (typeIterator != condType2Strcopy.end())
494  {
495 
496  ConditionMap outputMap;
497 
498  if (returnConditionsOfOneClass((*typeIterator).first, category, object, (*conditionMap_).at(condChip-1), outputMap))
499  {
500 
501  // special treatment for jet counts in buildCodChipParameters
502  if (object !=JetCounts)
503  {
505  while (particle.findAndReplaceString(tempStr2,
507  ;
508  while (particle.findAndReplaceString(tempStr2,
509  sp(substParamType_), condType2Str_[(*typeIterator).first]))
510  ;
511  parameterStr+=(tempStr2+"\n\n");
512 
513  //parameterStr+=(tempStr2+"<= '0';\n");
514 
515  // remove this type since it was already processed
516  condType2Strcopy.erase(typeIterator);
517  }
518 
519  }
520 
521  typeIterator++;
522 
523  }
524 
525  return true;
526 }
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
std::map< L1GtConditionType, std::string > condType2Str_
converts L1GtConditionType to firmware string
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_
static const std::string substParamParticle_
Definition: sp.h:21
std::map< L1GtObject, std::string > objType2Str_
converts L1GtObject to string
std::map< std::string, std::string > returnParameterMap() const
returns parameter map
std::string L1GtVhdlWriterCore::gtTemplatesPath ( )

returns the templates path

Definition at line 1026 of file L1GtVhdlWriterCore.cc.

References vhdlDir_.

1027 {
1028  return vhdlDir_;
1029 }
std::string vhdlDir_
templates directory
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 1371 of file L1GtVhdlWriterCore.cc.

References int2str().

Referenced by getCondChipVhdContentFromTriggerMenu().

1372 {
1373  intval++;
1374  return int2str(intval);
1375 }
static std::string int2str(const int &integerValue)
converts a integer into a string
void L1GtVhdlWriterCore::initializeDeltaConditions ( )

Definition at line 1788 of file L1GtVhdlWriterCore.cc.

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

Referenced by makeFirmware().

1789 {
1790 
1791  for (unsigned int k=0; k<=1; k++)
1792  {
1793 
1794  // combine muon with calo particles
1795  for (unsigned int i=0; i<caloObjects_.size(); i++)
1796  {
1798  +"_"+objType2Str_[caloObjects_.at(i)], 0));
1799  }
1800 
1801  // combine etm with muon
1803  +objType2Str_[Mu], 0));
1804 
1805  // combine etm with calo particles
1806  for (unsigned int i=0; i<caloObjects_.size(); i++)
1807  {
1809  +"_"+objType2Str_[caloObjects_.at(i)], 0));
1810  }
1811 
1812  std::vector<L1GtObject> caloObjectsCp = caloObjects_;
1813 
1814  while (caloObjectsCp.size()>0)
1815  {
1816  std::vector<L1GtObject>::iterator iter=caloObjectsCp.begin();
1817  L1GtObject firstPartner = (*iter);
1818  caloObjectsCp.erase(iter);
1819 
1820  iter=caloObjectsCp.begin();
1821  while (iter!=caloObjectsCp.end())
1822  {
1824  objType2Str_[firstPartner]+"_"+objType2Str_[(*iter)], 0));
1825  iter++;
1826  }
1827 
1828  }
1829 
1830  }
1831 }
Definition: L1GtObject.h:36
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)
int k[5][pyjets_maxn]
Definition: L1GtObject.h:30
std::map< L1GtObject, std::string > objType2Str_
converts L1GtObject to string
std::string L1GtVhdlWriterCore::int2str ( const int &  integerValue)
static

converts a integer into a string

Definition at line 1031 of file L1GtVhdlWriterCore.cc.

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

1032 {
1033  std::ostringstream oss;
1034  oss<<integerValue;
1035  return oss.str();
1036 
1037 }
bool L1GtVhdlWriterCore::makeFirmware ( const std::vector< ConditionMap > &  conditionMap,
const AlgorithmMap algorithmMap 
)

produces the firmware code

Definition at line 911 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_, writeAlgoSetup(), writeCond2intMap2File(), writeCondChipPkg(), writeConditionChipSetup(), writeDefValPkg(), writeEtmSetup(), writeMuonSetupVhdl(), and writeQsfSetupFiles().

Referenced by L1GtVhdlWriter::analyze().

913 {
914  conditionMap_ = &conditionMap;
915 
916  algorithmMap_ = &algorithmMap;
917 
920 
921  if (!mkdir(subDir1.c_str(), 666));
922  if (!mkdir(subDir2.c_str(), 666));
923 
924  chmod(subDir1.c_str(), 0777);
925  chmod(subDir2.c_str(), 0777);
926 
927  /*
928  subDirs_.push_back(subDir1);
929  subDirs_.push_back(subDir2);
930  */
931 
933 
934 
935  //--------------------------------------build setups-------------------------------------------------------
936 
937  // loop over the two condition chips
938  for (unsigned short int i =1; i<=2; i++)
939  {
940  // ----------------------- muon setup -------------------------------------------------------
941 
942  std::map<std::string,std::string> muonParameters;
943  getMuonSetupContentFromTriggerMenu(i, muonParameters);
944  writeMuonSetupVhdl(muonParameters, "muon", i);
945 
946  // ----------------------- calo setup -------------------------------------------------------
947 
948  // map containing all calo object types correlated with the strings
949  // under which they appear in the firmware
950  std::vector<L1GtObject>::iterator caloObjIter = caloObjects_.begin();
951 
952  // loop over all calo objectsbuildMuonSetupVhdl
953  while (caloObjIter != caloObjects_.end())
954  {
955  std::map<std::string,std::string> caloParameters;
956  getCaloSetupContentFromTriggerMenu(i, caloParameters,
957  (*caloObjIter));
958  writeMuonSetupVhdl(caloParameters, objType2Str_[(*caloObjIter)], i);
959 
960  caloObjIter++;
961  }
962 
963  // ----------------------- etm setup ---------------------------------------------------------
964 
965  // map containing all calo object types correlated with the strings
966  // under which they appear in the firmware
967  std::vector<L1GtObject>::iterator esumObjIter = esumObjects_.begin();
968 
969  while (esumObjIter != esumObjects_.end())
970  {
971  std::string etmParameter;
972 
973  getEsumsSetupContentFromTriggerMenu(i, (*esumObjIter),
974  etmParameter);
975  writeEtmSetup(etmParameter, i);
976 
977  esumObjIter++;
978 
979  }
980 
981  // add jet counts to condition 2 integer map
983 
984  // --------------------cond chip setup---------------------------------------------------------
985  // Important: all other setups have to be build BEFORE this one because it needs a
986  // complete condition2integer map !!!
987 
988  std::map<std::string, L1GtVhdlTemplateFile> templates;
989  std::map<std::string, std::string> common;
990  getCondChipVhdContentFromTriggerMenu(i, templates, common);
991  writeConditionChipSetup(templates, common, i);
992 
993  // despite yet not existing they have to appear in cond_chip_pkg vhds
995 
996  // --------------------cond chip pkg------------------------------------------------------------
997 
999 
1000  // -----------------------def val pkg -------------------------------------------------
1001 
1003 
1004  // debug
1005  if (debugMode_)
1006  {
1007  //printConditionsOfCategory(CondEnergySum, (*conditionMap_).at(i-1));
1008  }
1009 
1010  }
1011 
1012  if (debugMode_)
1014 
1015  //-------------------------------process algorithms----------------------------------------------------------
1016 
1017  std::vector< std::map<int, std::string> > algoStrings;
1018 
1019  processAlgorithmMap(algoStrings);
1020 
1021  writeAlgoSetup(algoStrings);
1022 
1023  return true;
1024 }
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 ...
const AlgorithmMap * algorithmMap_
algorithm map
void writeEtmSetup(std::string &etmString, const int &condChip)
builds etm setup files
def chmod(path, mode)
Definition: eostools.py:293
void writeCond2intMap2File()
produces a control output file for condition to integer conversion
void writeCondChipPkg(const int &chip)
const std::vector< ConditionMap > * conditionMap_
condition map
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:250
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)
std::map< L1GtObject, std::string > objType2Str_
converts L1GtObject to string
bool debugMode_
class will produce some additional debugging output if set
void L1GtVhdlWriterCore::msg ( const std::string &  message)

adds a string to intern message buffer

Definition at line 1351 of file L1GtVhdlWriterCore.cc.

References internMessageBuf_.

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

1352 {
1353  internMessageBuf_.push_back(message);
1354 }
std::vector< std::string > internMessageBuf_
L1GtVhdlTemplateFile L1GtVhdlWriterCore::openVhdlFileWithCommonHeader ( const std::string &  filename,
const std::string &  outputFilename 
)

opens a new template file and inserts the common header

Definition at line 1068 of file L1GtVhdlWriterCore.cc.

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

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

1070 {
1071  L1GtVhdlTemplateFile commonHeaderCp;
1072  commonHeaderCp = commonHeader_;
1073 
1074  commonHeaderCp.substitute("vhdl_file_name", outputFilename);
1075 
1076  L1GtVhdlTemplateFile myTemplate(vhdlDir_+"Templates/"+filename);
1077  myTemplate.insert("$(header)", commonHeaderCp);
1078 
1079  return myTemplate;
1080 }
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
void L1GtVhdlWriterCore::printCommonHeader ( )

prints the common header

Definition at line 1314 of file L1GtVhdlWriterCore.cc.

References commonHeader_, and L1GtVhdlTemplateFile::print().

1315 {
1316  commonHeader_.print();
1317 }
L1GtVhdlTemplateFile commonHeader_
common header for all files
void print() const
prints the content of the VHDL File (only lines_)
void L1GtVhdlWriterCore::printConditionsOfCategory ( const L1GtConditionCategory category,
const ConditionMap map 
)

for debuggin

Definition at line 1858 of file L1GtVhdlWriterCore.cc.

References int2str(), and msg().

1860 {
1861  int counter =0;
1862  for (ConditionMap::const_iterator iterCond = map.begin(); iterCond
1863  != map.end(); iterCond++)
1864  {
1865  msg(iterCond->first);
1866  counter++;
1867  }
1868 
1869  msg("Total Occurances: "+int2str(counter));
1870 
1871 }
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
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 822 of file L1GtVhdlWriterCore.cc.

References conditionMap_, conditionToIntegerMap_, L1GtCondition::condType(), condType2Str_, debugMode_, L1GtVhdlTemplateFile::findAndReplaceString(), L1GtVhdlTemplateFile::getConditionsFromAlgo(), mps_fire::i, msg(), NULL, L1GtCondition::objectType(), objType2Str_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by makeFirmware().

823 {
824  std::map<int, std::string> algorithmsChip1;
825  std::map<int, std::string> algorithmsChip2;
826 
827  AlgorithmMap::const_iterator algoIter=(*algorithmMap_).begin();
828 
829  // loop over algorithm map
830  while (algoIter!=(*algorithmMap_).end())
831  {
832  // msg(algoIter->first);
833 
835 
836  // get the logical expression
837  std::string logicalExpr = (algoIter->second).algoLogicalExpression();
838  std::vector<std::string> conditions;
839 
840  dummy.getConditionsFromAlgo(logicalExpr, conditions);
841 
842  std::string logicalExprCopy= logicalExpr;
843 
844  // loop over all condition names appearing in algorithm and replace them by type and integer value
845  for (unsigned int i=0; i<conditions.size(); i++)
846  {
847  std::ostringstream newExpr;
848 
849  // look for the condition on correct chip
850  ConditionMap const& chip = conditionMap_->at(algoIter->second.algoChipNumber());
851  L1GtCondition const* cond = (chip.find(conditions.at(i)) == chip.end()) ? nullptr : chip.at(conditions.at(i));
852 
853  // check weather condition exists
854  if (cond!=NULL)
855  {
856  newExpr << objType2Str_[(cond->objectType()).at(0)];
857  newExpr << "_" << condType2Str_[cond->condType()] << "(";
858  newExpr << conditionToIntegerMap_[conditions.at(i)] << ")";
859  dummy.findAndReplaceString(logicalExpr, conditions.at(i),
860  newExpr.str());
861  } else
862  msg("Panik! Didn't find Condition "+conditions.at(i));
863  }
864 
865  // has to be checked!
866  std::vector<int> orderConditionChip;
867  orderConditionChip.push_back(2);
868  orderConditionChip.push_back(1);
869 
870  int pin = (algoIter->second).algoOutputPin(2, 96, orderConditionChip);
871 
872  //msg(int2str(pin));
873 
874  if (pin<0)
875  pin*=-1;
876 
877  if ((algoIter->second).algoChipNumber()==0)
878  {
879  algorithmsChip1[pin]=logicalExpr;
880  if (debugMode_)
881  algorithmsChip1[pin]+=("-- "+logicalExprCopy);
882  } else if ((algoIter->second).algoChipNumber()==1)
883  {
884  algorithmsChip2[pin]=logicalExpr;
885  if (debugMode_)
886  algorithmsChip2[pin]+=("-- "+logicalExprCopy);
887  } else
888  ;
889 
890  algoIter++;
891  }
892 
893  algoStrings.push_back(algorithmsChip1);
894  algoStrings.push_back(algorithmsChip2);
895 
896  return true;
897 
898 }
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
std::map< L1GtConditionType, std::string > condType2Str_
converts L1GtConditionType to firmware string
#define NULL
Definition: scimark2.h:8
const std::vector< L1GtObject > & objectType() const
get / set the trigger object type(s) in the condition
Definition: L1GtCondition.h:90
const L1GtConditionType & condType() const
get / set the type of the condition (1s, etc)
Definition: L1GtCondition.h:79
const std::vector< ConditionMap > * conditionMap_
condition map
void msg(const std::string &message)
adds a string to intern message buffer
Definition: plugin.cc:24
std::map< std::string, int > conditionToIntegerMap_
stores to condition name to integer conversion table
std::map< L1GtObject, std::string > objType2Str_
converts L1GtObject to string
bool debugMode_
class will produce some additional debugging output if set
void getConditionsFromAlgo(std::string condString, std::vector< std::string > &result) const
extracts all conditions from a algorithm
std::string L1GtVhdlWriterCore::retNumberOfConditionsString ( const std::string &  typeStr,
const int &  number 
)

Definition at line 1900 of file L1GtVhdlWriterCore.cc.

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

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

1902 {
1903  std::string initstr=stringConstantConstantNr_+typeStr+" : integer := "+int2str(number)
1904  +";";
1905 
1906  return initstr;
1907 }
static std::string int2str(const int &integerValue)
converts a integer into a string
static const std::string stringConstantConstantNr_
L1GtVhdlTemplateFile L1GtVhdlWriterCore::retrunCommonHeader ( )

returns the common header

Definition at line 1319 of file L1GtVhdlWriterCore.cc.

References commonHeader_.

Referenced by L1GtVhdlWriter::analyze().

1320 {
1321  return commonHeader_;
1322 }
L1GtVhdlTemplateFile commonHeader_
common header for all files
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 93 of file L1GtVhdlWriterCore.cc.

References mps_update::status.

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

98 {
99  bool status = false;
100 
101  ConditionMap::const_iterator condIter = map.begin();
102  while (condIter!=map.end())
103  {
104  if (condIter->second->condCategory()==category
105  && condIter->second->condType()==type && (condIter->second->objectType())[0]==object)
106  {
107  outputMap[condIter->first]=condIter->second;
108  status = true;
109  }
110  condIter++;
111  }
112 
113  return status;
114 }
type
Definition: HCALResponse.h:21
std::string L1GtVhdlWriterCore::sp ( const std::string &  name)

converts string name to substiution parameter synthax; name –>

Definition at line 1914 of file L1GtVhdlWriterCore.cc.

Referenced by buildDefValuesBuffer(), and writeDefValPkg().

1915 {
1916  return "$("+name+")";
1917 }
void L1GtVhdlWriterCore::writeAlgoSetup ( std::vector< std::map< int, std::string > > &  algoStrings)

builds the prealgo_and_or setup

Definition at line 1247 of file L1GtVhdlWriterCore.cc.

References chip2OutputSubDir(), eostools::chmod(), corrVsCorr::filename, L1GtVhdlTemplateFile::findAndReplaceString(), mps_fire::i, int2str(), gen::k, openVhdlFileWithCommonHeader(), postProcessorL1Gen_cff::outputFileName, L1GtVhdlTemplateFile::save(), AlCaHLTBitMon_QueryRunRegistry::string, L1GtVhdlDefinitions::stringConstantAlgo_, L1GtVhdlTemplateFile::substitute(), L1GtVhdlDefinitions::substParamAlgos_, indexGen::templateFile, and L1GtVhdlDefinitions::vhdlTemplateAlgoAndOr_.

Referenced by makeFirmware().

1248 {
1249  // loop over the two condition chips
1250  for (unsigned int i=1; i<=2; i++)
1251  {
1253 
1254  // output file name
1256  L1GtVhdlTemplateFile::findAndReplaceString(outputFileName, ".",
1257  int2str(i)+".");
1258 
1260  filename, outputFileName);
1261 
1262  std::ostringstream buffer;
1263 
1264  unsigned int algoPinsPerChip = 96;
1265 
1266  for (unsigned int k=1; k<=algoPinsPerChip; k++)
1267  {
1268 
1269  buffer<< stringConstantAlgo_<<"("<<k<<")";
1270  if (algoStrings.at(i-1)[k]!="")
1271  buffer<<" <= "<<algoStrings.at(i-1)[k]<<";"<<std::endl;
1272  else
1273  buffer<<" <= '0';"<<std::endl;
1274  }
1275 
1276  templateFile.substitute(substParamAlgos_, buffer.str());
1277  templateFile.save(chip2OutputSubDir(i)+filename);
1278  chmod((chip2OutputSubDir(i)+filename).c_str(), 0666);
1279  }
1280 
1281 }
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:293
int k[5][pyjets_maxn]
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
templateFile
Definition: indexGen.py:50
void L1GtVhdlWriterCore::writeCond2intMap2File ( )

produces a control output file for condition to integer conversion

Definition at line 1427 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().

1428 {
1429 
1430 
1431  for (unsigned int i=0; i<=1;i++)
1432  {
1433  ConditionMap::const_iterator iterCond =
1434  conditionMap_->at(i).begin();
1435 
1436  std::string filename=chip2OutputSubDir(i+1)+"cond_names_integer.txt";
1437 
1438  std::ofstream outputFile(filename.c_str());
1439 
1440  while (iterCond!=conditionMap_->at(i).end())
1441  {
1442  conditionToIntegerMap_[(*iterCond).first];
1443 
1444  outputFile<<(iterCond->first)<<": "<<conditionToIntegerMap_[(*iterCond).first]<<std::endl;
1445  iterCond++;
1446  }
1447 
1448  outputFile.close();
1449 
1450  chmod(filename.c_str(), 0666);
1451 
1452 
1453  }
1454 
1455  /*
1456 
1457 
1458  const std::vector<ConditionMap> * conditionMap_;
1459 
1460  std::string filename=outputDir_+"cond_names_integer.txt";
1461  std::ofstream outputFile(filename.c_str());
1462 
1463  for (std::map<std::string,int>::const_iterator iterCond =
1464  conditionToIntegerMap_.begin(); iterCond
1465  != conditionToIntegerMap_.end(); iterCond++)
1466  {
1467  outputFile<<(iterCond->first)<<": "<<(iterCond->second)<<std::endl;
1468  }
1469 
1470  */
1471 
1472 }
def chmod(path, mode)
Definition: eostools.py:293
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
void L1GtVhdlWriterCore::writeCondChipPkg ( const int &  chip)

Definition at line 1873 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().

1874 {
1875 
1876  // build filename
1877 
1879 
1880  if (chip==1)
1881  filename = vhdlTemplateCondChipPkg1_;
1882  else if (chip==2)
1883  filename = vhdlTemplateCondChipPkg2_;
1884 
1885  // write the output
1886  L1GtVhdlTemplateFile myTemplate = openVhdlFileWithCommonHeader(filename,
1887  filename);
1888 
1889  myTemplate.substitute("version",version_);
1890 
1891  myTemplate.insert("$(conditions_nr)", numberOfConditions_.at(chip-1));
1892 
1895 
1896  myTemplate.save(chip2OutputSubDir(chip)+filename);
1897  chmod((chip2OutputSubDir(chip)+filename).c_str(), 0666);
1898 }
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:293
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
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 1202 of file L1GtVhdlWriterCore.cc.

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

Referenced by makeFirmware().

1206 {
1207 
1208  // get filename
1210 
1211  // build output filename
1213  L1GtVhdlTemplateFile::findAndReplaceString(outputFileName, ".",
1214  int2str(chip)+".");
1215 
1216  L1GtVhdlTemplateFile myTemplate = openVhdlFileWithCommonHeader(filename,
1217  outputFileName);
1218 
1219  // map containing the subsitution parameters with their content (as L1GtVhdlTemplateFile file object)
1220  std::map<std::string, L1GtVhdlTemplateFile>::const_iterator iter=
1221  templates.begin();
1222 
1223  while (iter != templates.end())
1224  {
1225 
1226  myTemplate.insert("$("+(iter->first)+")", iter->second);
1227 
1228  iter++;
1229  }
1230 
1231  // subsitutes common parameters
1232  std::map<std::string, std::string>::const_iterator iter2= common.begin();
1233 
1234  while (iter2 != common.end())
1235  {
1236 
1237  myTemplate.substitute((iter2->first), iter2->second);
1238 
1239  iter2++;
1240  }
1241 
1242  myTemplate.save(chip2OutputSubDir(chip)+filename);
1243  chmod((chip2OutputSubDir(chip)+filename).c_str(), 0666);
1244 
1245 }
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:293
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_
void L1GtVhdlWriterCore::writeDefValPkg ( const std::vector< ConditionMap > &  conditionMap,
const int &  chip 
)

writes def_val_pkg.vhd

Definition at line 1530 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().

1532 {
1533  // open internal template file
1534  L1GtVhdlTemplateFile internalTemplate;
1535  internalTemplate.open(vhdlDir_+"InternalTemplates/defvalpkg", true);
1536 
1537  // to write the def_value_pkg file it has to be looped over all POSSIBLE types of conditions
1538  // POSSIBLE: calo_3 eg. does not exist and therefore makes no sense..
1539 
1540  // Process muon conditions first
1541 
1542  // temporary buffers for the default value blocks (see internal templates) of the different types.
1543  // in the end those buffers are simply appended to the actual template!
1544  L1GtVhdlTemplateFile muonDefValuesBuffer, caloDefValuesBuffer,
1545  jetCountsDefValuesBuffer, esumsDefValBuffer;
1546 
1547  // Get the default value type strings from internal template
1548  std::vector<std::string> muonDefValTypes;
1549  muonDefValTypes.push_back(internalTemplate.getInternalParameter(stringConstantPtl_));
1550  muonDefValTypes.push_back(internalTemplate.getInternalParameter(stringConstantPth_));
1551  muonDefValTypes.push_back(internalTemplate.getInternalParameter(stringConstantQuality_));
1552  muonDefValTypes.push_back(internalTemplate.getInternalParameter(substParamCharge_));
1553 
1554  int jetCountsMaxIndex = 11;
1555 
1556  // fill jet counts vector (from 1 to 11)
1557  std::vector<std::string> jetCountsDefValTypes;
1558  for (int i = 0; i<=jetCountsMaxIndex; i++)
1559  {
1560  jetCountsDefValTypes.push_back(int2str(i));
1561  }
1562 
1563  // only one default value for calo objects therefore only a empty string
1564  std::vector<std::string> caloDefValTypes;
1565  caloDefValTypes.push_back("");
1566 
1567  // get types of esums defvalues (as firmware strings) from the internal templates
1568  std::vector<std::string> esumsDefValTypes;
1569  esumsDefValTypes.push_back(internalTemplate.getInternalParameter(stringConstantEsumsLow_));
1570  esumsDefValTypes.push_back(internalTemplate.getInternalParameter(stringConstantEsumsHigh_));
1571 
1572  std::map<L1GtConditionType,std::string>::iterator typeIter;
1573 
1574  // prepare a map with all muon relevant types by removing
1575  // obsolete types from a copy of condType2Str_ map
1576  // should be improved
1577  std::map<L1GtConditionType,std::string> muonTypes = condType2Str_;
1578 
1579  typeIter=muonTypes.find(Type2cor);
1580  muonTypes.erase(typeIter);
1581  typeIter=muonTypes.find(TypeETM);
1582  muonTypes.erase(typeIter);
1583  typeIter=muonTypes.find(TypeETT);
1584  muonTypes.erase(typeIter);
1585  typeIter=muonTypes.find(TypeHTT);
1586  muonTypes.erase(typeIter);
1587  typeIter=muonTypes.find(TypeJetCounts);
1588  muonTypes.erase(typeIter);
1589 
1590  std::map<L1GtConditionType,std::string> caloTypes = muonTypes;
1591  typeIter=caloTypes.find(Type3s);
1592  caloTypes.erase(typeIter);
1593 
1594  // dummy type in order to be able to use the same code as for calo and muon
1595  // this map is also used for esums since there is no difference in treatment
1596  std::map<L1GtConditionType,std::string> jetCountsTypes;
1597  jetCountsTypes[TypeJetCounts] = "";
1598 
1599  // here the DefValuesBuffer are build (=objects of the class L1GtVhdlTemplateFile
1600  // that are containing all default values and finally can be inserted into the
1601  // def_val_pkg.vhd template
1602 
1603  buildDefValuesBuffer(muonDefValuesBuffer, muonTypes, muonDefValTypes, Mu);
1604 
1605  // loop over all possible calo objects here
1606  for (unsigned int i=0; i<caloObjects_.size(); i++)
1607  {
1608  buildDefValuesBuffer(caloDefValuesBuffer, caloTypes, caloDefValTypes,
1609  caloObjects_.at(i));
1610  }
1611 
1612  // loop over all possible esums objects here
1613  for (unsigned int i=0; i<esumObjects_.size(); i++)
1614  {
1615  buildDefValuesBuffer(esumsDefValBuffer, jetCountsTypes,
1616  esumsDefValTypes, esumObjects_.at(i));
1617  }
1618 
1619  // same procedure for jet counts
1620  buildDefValuesBuffer(esumsDefValBuffer, jetCountsTypes,
1621  jetCountsDefValTypes, JetCounts);
1622 
1623  //----------------------In this section the actual output file is written----------------
1624 
1625  // now open the actual template file:
1626 
1628 
1630 
1631  // modify output filename
1633  +".");
1635  filename, outputFile);
1636 
1637  // insert the temporary buffers to the template
1638 
1639  // muon default values
1640  defValTemplate.insert(sp(substParamMuonDefVals_), muonDefValuesBuffer);
1641 
1642  // calo default values
1643  defValTemplate.insert(sp(substParamCaloDefVals_), caloDefValuesBuffer);
1644 
1645  // esums default values
1646  defValTemplate.insert(sp(substParamEsumsDefVals_), esumsDefValBuffer);
1647 
1648  // jet counts default values
1649  defValTemplate.insert(sp(substParamJetsDefVals_), jetCountsDefValuesBuffer);
1650 
1651  // close and save the file
1652 
1653  L1GtVhdlTemplateFile::findAndReplaceString(outputFile, "1","");
1654  L1GtVhdlTemplateFile::findAndReplaceString(outputFile, "2","");
1655 
1656  defValTemplate.save(chip2OutputSubDir(chip)+outputFile);
1657  chmod((chip2OutputSubDir(chip)+outputFile).c_str(), 0666);
1658 
1659 }
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_
std::map< L1GtConditionType, std::string > condType2Str_
converts L1GtConditionType to firmware string
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:293
static const std::string stringConstantEsumsHigh_
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:30
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_
void L1GtVhdlWriterCore::writeEtmSetup ( std::string &  etmString,
const int &  condChip 
)

builds etm setup files

Definition at line 1283 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().

1285 {
1286 
1287  // get filename
1290 
1291  L1GtVhdlTemplateFile myTemplate;
1292 
1293  // modify output filename
1294  myTemplate.findAndReplaceString(outputFile, ".", int2str(condChip)+".");
1295 
1296  myTemplate = openVhdlFileWithCommonHeader(filename, filename);
1297 
1298  // replace all occurances of $(particle)
1299  while (myTemplate.substitute("particle", "etm"))
1300  while (myTemplate.substitute("particle", "etm"))
1301  ;
1302 
1303  // delete last char if it is \n
1304  if (etmString[etmString.length()-1] == '\n')
1305  etmString = etmString.substr(0, etmString.length()-1);
1306 
1307  myTemplate.substitute("phi", etmString);
1308 
1309  myTemplate.save(chip2OutputSubDir(condChip)+filename);
1310  chmod((chip2OutputSubDir(condChip)+filename).c_str(), 0666);
1311 
1312 }
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:293
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
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 1082 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().

1085 {
1087 
1088  L1GtVhdlTemplateFile muonTemplate, internalTemplate, internalTemplateCopy;
1089 
1090  // choose the correct template file name
1091  if (particle=="muon")
1092  {
1093  filename = vhdlTemplateMuonSetup_;
1094  internalTemplate.open(vhdlDir_+"InternalTemplates/muonsetup", true);
1095  } else
1096  {
1097  filename = vhdlTemplateCaloSetup_;
1098  internalTemplate.open(vhdlDir_+"InternalTemplates/calosetup", true);
1099  }
1100 
1102  outputFile = filename;
1103 
1104  // modify filename
1105  if (particle!="muon")
1106  muonTemplate.findAndReplaceString(outputFile, "calo", particle);
1107 
1108  // add condition chip index to output filename
1109  //muonTemplate.findAndReplaceString(outputFile, ".", int2str(condChip)+".");
1110 
1111  // open the template file and insert header
1112  muonTemplate = openVhdlFileWithCommonHeader(filename, outputFile);
1113 
1114  std::map<std::string,std::string> parameterMap =
1115  internalTemplate.returnParameterMap();
1116 
1117  std::vector<std::string> substitutionParameters;
1118 
1119  // fills the map with all substitution parameters of the template file
1120  substitutionParameters=muonTemplate.getSubstitutionParametersFromTemplate();
1121 
1122  // insert a emty line at the end of each block
1123  internalTemplate.append("");
1124 
1125  std::map<std::string, std::string>::iterator iter;
1126 
1127  // loop over all substitution parameters that have been extracted from the template file
1128  for (unsigned int i=0; i<substitutionParameters.size(); i++)
1129  {
1130  // make a working copy of the template file
1131  internalTemplateCopy = internalTemplate;
1132 
1133  // choose which of the three constant template strings to take - only for calo!
1134  if (particle!="muon")
1135  {
1136 
1137  if (substitutionParameters.at(i).substr(0, 3) == "eta")
1138  internalTemplateCopy.substitute("constant", parameterMap["eta"]);
1139  else if (substitutionParameters.at(i).substr(0, 3) == "phi")
1140  internalTemplateCopy.substitute("constant", parameterMap["phi"]);
1141  else if (substitutionParameters.at(i).substr(0, 3) == "del"/*ta*/)
1142  {
1143  internalTemplateCopy.substitute("constant",
1144  parameterMap["delta"]);
1145  while (internalTemplateCopy.substitute("delta",
1146  substitutionParameters[i]))
1147  internalTemplateCopy.substitute("delta",
1148  substitutionParameters[i]);
1149 
1150  }
1151  }
1152 
1153  if (particle=="muon")
1154  {
1155  // final preparation of the internal template before it is inserted in the actual template file
1156  internalTemplateCopy.substitute("type", substitutionParameters[i]);
1157  } else
1158 
1159  {
1160  internalTemplateCopy.substitute("type", substitutionParameters[i].substr(4));
1161  }
1162 
1163  // subsitute the second occurance of type without "_l" and "_h"
1164 
1165  std::string paramCopy = substitutionParameters[i];
1166 
1167  internalTemplateCopy.findAndReplaceString(paramCopy, "_l", "");
1168  internalTemplateCopy.findAndReplaceString(paramCopy, "_h", "");
1169 
1170  internalTemplateCopy.substitute("type2", paramCopy);
1171 
1172  internalTemplateCopy.substitute("others",
1173  parameterMap[substitutionParameters[i]]);
1174 
1175  // replace all the occurances of "particle"
1176  while (muonTemplate.substitute("particle", particle))
1177  muonTemplate.substitute("particle", particle);
1178 
1179  // remove the the parameter $(content) if its empty
1180  iter=muonParameters.find(substitutionParameters[i]);
1181 
1182  // check weather this parameter exists
1183  if (iter!=muonParameters.end())
1184  {
1185  if ((*iter).second[(*iter).second.length()-1]=='\n')
1186  (*iter).second[(*iter).second.length()-1]=' ';
1187  internalTemplateCopy.substitute("content", (*iter).second);
1188  } else
1189  internalTemplateCopy.removeLineWithContent("$(content)");
1190 
1191  // insert the processed internal template in the muon template file
1192  muonTemplate.insert("$("+substitutionParameters[i]+")",
1193  internalTemplateCopy);
1194  }
1195 
1196  // save the muon template file
1197  muonTemplate.save(chip2OutputSubDir(condChip)+outputFile);
1198  chmod((chip2OutputSubDir(condChip)+outputFile).c_str(), 0666);
1199 
1200 }
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:293
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::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 ...
std::map< std::string, std::string > returnParameterMap() const
returns parameter map
void L1GtVhdlWriterCore::writeQsfSetupFiles ( const std::string &  version)

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

Definition at line 1324 of file L1GtVhdlWriterCore.cc.

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

Referenced by makeFirmware().

1325 {
1326 
1327  std::vector<std::string> filenames;
1328  filenames.push_back(quartusSetupFileChip1_);
1329  filenames.push_back(quartusSetupFileChip2_);
1330 
1331  for (unsigned int i=0; i<filenames.size(); i++)
1332  {
1333  L1GtVhdlTemplateFile myTemplate;
1334 
1335  myTemplate.open(vhdlDir_+"Templates/"+filenames.at(i));
1336  myTemplate.substitute("version", version);
1337 
1338  std::string tempStr = filenames.at(i);
1339 
1340  if (i==0)
1341  L1GtVhdlTemplateFile::findAndReplaceString(tempStr , "cond1","cond");
1342  if (i==1)
1343  L1GtVhdlTemplateFile::findAndReplaceString(tempStr , "cond2","cond");
1344 
1345  myTemplate.save(chip2OutputSubDir(i+1)+tempStr);
1346  chmod((chip2OutputSubDir(i+1)+tempStr).c_str(), 0666);
1347  }
1348 
1349 }
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:293
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

const AlgorithmMap* L1GtVhdlWriterCore::algorithmMap_
private

algorithm map

Definition at line 197 of file L1GtVhdlWriterCore.h.

Referenced by makeFirmware().

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

list of all possible calo objects

Definition at line 212 of file L1GtVhdlWriterCore.h.

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

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

converts L1GtObject to calo_nr

Definition at line 206 of file L1GtVhdlWriterCore.h.

Referenced by getCondChipVhdContentFromTriggerMenu(), and L1GtVhdlWriterCore().

L1GtVhdlTemplateFile L1GtVhdlWriterCore::commonHeader_
private

common header for all files

Definition at line 229 of file L1GtVhdlWriterCore.h.

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

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

condition map

Definition at line 194 of file L1GtVhdlWriterCore.h.

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

std::map<std::string,int> L1GtVhdlWriterCore::conditionToIntegerMap_
private
std::map<L1GtConditionType,std::string> L1GtVhdlWriterCore::condType2Str_
private
bool L1GtVhdlWriterCore::debugMode_
private
std::vector<L1GtObject> L1GtVhdlWriterCore::esumObjects_
private

list of all possible esums objects

Definition at line 215 of file L1GtVhdlWriterCore.h.

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

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

Definition at line 231 of file L1GtVhdlWriterCore.h.

Referenced by getMsgBuf(), and msg().

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

vector containing the initialization of all conditions

Definition at line 234 of file L1GtVhdlWriterCore.h.

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

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

Definition at line 226 of file L1GtVhdlWriterCore.h.

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

std::string L1GtVhdlWriterCore::vhdlDir_
private