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