CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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");
44 
45  if (vhdlDir_[vhdlDir_.length() - 1] != '/')
46  vhdlDir_ += "/";
47  if (outputDir_[outputDir_.length() - 1] != '/')
48  outputDir_ += "/";
49 
50  // // def.xml file
51  // std::string defXmlFileName = parSet.getParameter<std::string>("DefXmlFile");
52  //
53  // edm::FileInPath f1("L1TriggerConfig/L1GtConfigProducers/data/" +
54  // vhdlDir + "/" + defXmlFileName);
55  //
56  // m_defXmlFile = f1.fullPath();
57 
58  edm::LogInfo("L1GtConfigProducers") << "\n\nL1 GT VHDL directory: " << vhdlDir_ << "\n\n" << std::endl;
59 }
60 
61 // destructor
63  // empty
64 }
65 
66 // loop over events
69  evSetup.get<L1GtTriggerMenuRcd>().get(l1GtMenu);
70 
71  std::vector<ConditionMap> conditionMap = l1GtMenu->gtConditionMap();
72  AlgorithmMap algorithmMap = l1GtMenu->gtAlgorithmMap();
73 
74  // print with various level of verbosities
75  int printVerbosity = 0;
76  l1GtMenu->print(std::cout, printVerbosity);
77 
78  //---------------------Here the VHDL files will be created---------------------------------------
79 
80  // information that will be delivered by the parser in future
81  std::map<std::string, std::string> headerParameters;
82  std::vector<std::string> channelVector;
83 
84  headerParameters["vhdl_path"] = "/vhdllibrarypath";
85  headerParameters["designer_date"] = "20.05.1986";
86  headerParameters["designer_name"] = "Philipp Wagner";
87  headerParameters["version"] = "2.0";
88  headerParameters["designer_comments"] = "produced in CMSSW";
89  headerParameters["gtl_setup_name"] = "L1Menu2007NovGR";
90 
91  channelVector.push_back("-- ca1: ieg");
92  channelVector.push_back("-- ca2: eg");
93  channelVector.push_back("-- ca3: jet");
94  channelVector.push_back("-- ca4: fwdjet");
95  channelVector.push_back("-- ca5: tau");
96  channelVector.push_back("-- ca6: esums");
97  channelVector.push_back("-- ca7: jet_cnts");
98  channelVector.push_back("-- ca8: free");
99  channelVector.push_back("-- ca9: free");
100  channelVector.push_back("-- ca10: free");
101 
102  // check, weather output directory exists and create it on the fly if not
103  if (std::filesystem::is_directory(outputDir_)) {
104  std::cout << std::endl << "Ok - Output directory exists!" << std::endl;
105  } else {
106  if (!mkdir(outputDir_.c_str(), 0666))
107  std::cout << std::endl << "Directory: " << outputDir_ << " has been created!" << std::endl;
108  else
109  std::cout << std::endl << "Error while creating directory: " << outputDir_ << " !" << std::endl;
110  }
111 
112  // prepare a core with common header
113  L1GtVhdlWriterCore vhdlWriter(vhdlDir_, outputDir_, true);
114  vhdlWriter.buildCommonHeader(headerParameters, channelVector);
115  // write the firmware
116  if (vhdlWriter.makeFirmware(conditionMap, algorithmMap)) {
117  std::cout << std::endl
118  << std::endl
119  << "*********************** I'm ready ;-) **************************" << std::endl
120  << std::endl
121  << "You can find the firmware in dircetory: " << outputDir_ << std::endl
122  << std::endl
123  << "******************************************************************" << std::endl;
124  }
125 
126  // Create the VME - XML
127  std::string vmeFile = "vme.xml";
128 
129  L1GtVmeWriterCore vmeWriter(outputDir_, vmeFile);
130  vmeWriter.writeVME(conditionMap, vhdlWriter.getCond2IntMap(), vhdlWriter.retrunCommonHeader());
131 }
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
L1GtVhdlTemplateFile retrunCommonHeader()
returns the common header
Log< level::Info, false > LogInfo
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::map< std::string, int > getCond2IntMap()
def mkdir
Definition: eostools.py:251
T get() const
Definition: EventSetup.h:82
tuple cout
Definition: gather_cfg.py:144
void buildCommonHeader(std::map< std::string, std::string > &headerParameters, const std::vector< std::string > &connectedChannels)
builds the common header for all files
~L1GtVhdlWriter() override
destructor