CMS 3D CMS Logo

L1GtVhdlWriter.cc
Go to the documentation of this file.
1 
15 // this class header
17 
18 // system include files
19 #include <filesystem>
20 #include <iostream>
21 #include <sys/stat.h>
22 
23 // base class
25 
32 
35 
38 
39 // constructor(s)
41  // directory in /data for the VHDL templates
42  vhdlDir_ = parSet.getParameter<std::string>("VhdlTemplatesDir");
43  outputDir_ = parSet.getParameter<std::string>("OutputDir");
45 
46  if (vhdlDir_[vhdlDir_.length() - 1] != '/')
47  vhdlDir_ += "/";
48  if (outputDir_[outputDir_.length() - 1] != '/')
49  outputDir_ += "/";
50 
51  // // def.xml file
52  // std::string defXmlFileName = parSet.getParameter<std::string>("DefXmlFile");
53  //
54  // edm::FileInPath f1("L1TriggerConfig/L1GtConfigProducers/data/" +
55  // vhdlDir + "/" + defXmlFileName);
56  //
57  // m_defXmlFile = f1.fullPath();
58 
59  edm::LogInfo("L1GtConfigProducers") << "\n\nL1 GT VHDL directory: " << vhdlDir_ << "\n\n" << std::endl;
60 }
61 
62 // loop over events
65 
66  std::vector<ConditionMap> const& conditionMap = l1GtMenu->gtConditionMap();
67  AlgorithmMap const& algorithmMap = l1GtMenu->gtAlgorithmMap();
68 
69  // print with various level of verbosities
70  int printVerbosity = 0;
71  l1GtMenu->print(std::cout, printVerbosity);
72 
73  //---------------------Here the VHDL files will be created---------------------------------------
74 
75  // information that will be delivered by the parser in future
76  std::map<std::string, std::string> headerParameters;
77  std::vector<std::string> channelVector;
78 
79  headerParameters["vhdl_path"] = "/vhdllibrarypath";
80  headerParameters["designer_date"] = "20.05.1986";
81  headerParameters["designer_name"] = "Philipp Wagner";
82  headerParameters["version"] = "2.0";
83  headerParameters["designer_comments"] = "produced in CMSSW";
84  headerParameters["gtl_setup_name"] = "L1Menu2007NovGR";
85 
86  channelVector.reserve(10);
87  channelVector.push_back("-- ca1: ieg");
88  channelVector.push_back("-- ca2: eg");
89  channelVector.push_back("-- ca3: jet");
90  channelVector.push_back("-- ca4: fwdjet");
91  channelVector.push_back("-- ca5: tau");
92  channelVector.push_back("-- ca6: esums");
93  channelVector.push_back("-- ca7: jet_cnts");
94  channelVector.push_back("-- ca8: free");
95  channelVector.push_back("-- ca9: free");
96  channelVector.push_back("-- ca10: free");
97 
98  // check, weather output directory exists and create it on the fly if not
99  if (std::filesystem::is_directory(outputDir_)) {
100  std::cout << std::endl << "Ok - Output directory exists!" << std::endl;
101  } else {
102  if (!mkdir(outputDir_.c_str(), 0666))
103  std::cout << std::endl << "Directory: " << outputDir_ << " has been created!" << std::endl;
104  else
105  std::cout << std::endl << "Error while creating directory: " << outputDir_ << " !" << std::endl;
106  }
107 
108  // prepare a core with common header
109  L1GtVhdlWriterCore vhdlWriter(vhdlDir_, outputDir_, true);
110  vhdlWriter.buildCommonHeader(headerParameters, channelVector);
111  // write the firmware
112  if (vhdlWriter.makeFirmware(conditionMap, algorithmMap)) {
113  std::cout << std::endl
114  << std::endl
115  << "*********************** I'm ready ;-) **************************" << std::endl
116  << std::endl
117  << "You can find the firmware in dircetory: " << outputDir_ << std::endl
118  << std::endl
119  << "******************************************************************" << std::endl;
120  }
121 
122  // Create the VME - XML
123  std::string vmeFile = "vme.xml";
124 
125  L1GtVmeWriterCore vmeWriter(outputDir_, vmeFile);
126  vmeWriter.writeVME(conditionMap, vhdlWriter.getCond2IntMap(), vhdlWriter.retrunCommonHeader());
127 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
L1GtVhdlWriter(const edm::ParameterSet &)
constructor
std::string outputDir_
output directory
std::string vhdlDir_
templates directory
int iEvent
Definition: GenABIO.cc:224
void writeVME(const std::vector< ConditionMap > &conditionMap, const std::map< std::string, int > &cond2intMap, const L1GtVhdlTemplateFile &header, const int spacesPerLevel=2)
bool makeFirmware(const std::vector< ConditionMap > &conditionMap, const AlgorithmMap &algorithmMap)
produces the firmware code
void analyze(const edm::Event &, const edm::EventSetup &) override
void print(std::ostream &, int &) const
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
const std::vector< ConditionMap > & gtConditionMap() const
get / set / build the condition maps
L1GtVhdlTemplateFile retrunCommonHeader()
returns the common header
Log< level::Info, false > LogInfo
std::map< std::string, int > getCond2IntMap()
def mkdir(path)
Definition: eostools.py:251
void buildCommonHeader(std::map< std::string, std::string > &headerParameters, const std::vector< std::string > &connectedChannels)
builds the common header for all files
const AlgorithmMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
edm::ESGetToken< L1GtTriggerMenu, L1GtTriggerMenuRcd > menuToken_