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