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 
29 
32 
35 
36 // constructor(s)
38  // directory in /data for the VHDL templates
39  vhdlDir_ = parSet.getParameter<std::string>("VhdlTemplatesDir");
40  outputDir_ = parSet.getParameter<std::string>("OutputDir");
42 
43  if (vhdlDir_[vhdlDir_.length() - 1] != '/')
44  vhdlDir_ += "/";
45  if (outputDir_[outputDir_.length() - 1] != '/')
46  outputDir_ += "/";
47 
48  // // def.xml file
49  // std::string defXmlFileName = parSet.getParameter<std::string>("DefXmlFile");
50  //
51  // edm::FileInPath f1("L1TriggerConfig/L1GtConfigProducers/data/" +
52  // vhdlDir + "/" + defXmlFileName);
53  //
54  // m_defXmlFile = f1.fullPath();
55 
56  edm::LogInfo("L1GtConfigProducers") << "\n\nL1 GT VHDL directory: " << vhdlDir_ << "\n\n" << std::endl;
57 }
58 
59 // loop over events
62 
63  std::vector<ConditionMap> const& conditionMap = l1GtMenu->gtConditionMap();
64  AlgorithmMap const& algorithmMap = l1GtMenu->gtAlgorithmMap();
65 
66  // print with various level of verbosities
67  int printVerbosity = 0;
68  l1GtMenu->print(std::cout, printVerbosity);
69 
70  //---------------------Here the VHDL files will be created---------------------------------------
71 
72  // information that will be delivered by the parser in future
73  std::map<std::string, std::string> headerParameters;
74  std::vector<std::string> channelVector;
75 
76  headerParameters["vhdl_path"] = "/vhdllibrarypath";
77  headerParameters["designer_date"] = "20.05.1986";
78  headerParameters["designer_name"] = "Philipp Wagner";
79  headerParameters["version"] = "2.0";
80  headerParameters["designer_comments"] = "produced in CMSSW";
81  headerParameters["gtl_setup_name"] = "L1Menu2007NovGR";
82 
83  channelVector.reserve(10);
84  channelVector.push_back("-- ca1: ieg");
85  channelVector.push_back("-- ca2: eg");
86  channelVector.push_back("-- ca3: jet");
87  channelVector.push_back("-- ca4: fwdjet");
88  channelVector.push_back("-- ca5: tau");
89  channelVector.push_back("-- ca6: esums");
90  channelVector.push_back("-- ca7: jet_cnts");
91  channelVector.push_back("-- ca8: free");
92  channelVector.push_back("-- ca9: free");
93  channelVector.push_back("-- ca10: free");
94 
95  // check, weather output directory exists and create it on the fly if not
96  if (std::filesystem::is_directory(outputDir_)) {
97  std::cout << std::endl << "Ok - Output directory exists!" << std::endl;
98  } else {
99  if (!mkdir(outputDir_.c_str(), 0666))
100  std::cout << std::endl << "Directory: " << outputDir_ << " has been created!" << std::endl;
101  else
102  std::cout << std::endl << "Error while creating directory: " << outputDir_ << " !" << std::endl;
103  }
104 
105  // prepare a core with common header
106  L1GtVhdlWriterCore vhdlWriter(vhdlDir_, outputDir_, true);
107  vhdlWriter.buildCommonHeader(headerParameters, channelVector);
108  // write the firmware
109  if (vhdlWriter.makeFirmware(conditionMap, algorithmMap)) {
110  std::cout << std::endl
111  << std::endl
112  << "*********************** I'm ready ;-) **************************" << std::endl
113  << std::endl
114  << "You can find the firmware in dircetory: " << outputDir_ << std::endl
115  << std::endl
116  << "******************************************************************" << std::endl;
117  }
118 
119  // Create the VME - XML
120  std::string vmeFile = "vme.xml";
121 
122  L1GtVmeWriterCore vmeWriter(outputDir_, vmeFile);
123  vmeWriter.writeVME(conditionMap, vhdlWriter.getCond2IntMap(), vhdlWriter.retrunCommonHeader());
124 }
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_