CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GtVhdlWriter.cc
Go to the documentation of this file.
1 
17 // this class header
19 
20 // system include files
21 #include <iostream>
22 #include <sys/stat.h>
23 
24 // user include files
25 #include "boost/filesystem.hpp"
26 
27 // base class
29 
36 
39 
42 
43 // constructor(s)
45 {
46 
47  // directory in /data for the VHDL templates
48  vhdlDir_ = parSet.getParameter<std::string>("VhdlTemplatesDir");
49  outputDir_ = parSet.getParameter<std::string>("OutputDir");
50 
51  if (vhdlDir_[vhdlDir_.length()-1]!= '/')
52  vhdlDir_+="/";
53  if (outputDir_[outputDir_.length()-1]!= '/')
54  outputDir_+="/";
55 
56  // // def.xml file
57  // std::string defXmlFileName = parSet.getParameter<std::string>("DefXmlFile");
58  //
59  // edm::FileInPath f1("L1TriggerConfig/L1GtConfigProducers/data/" +
60  // vhdlDir + "/" + defXmlFileName);
61  //
62  // m_defXmlFile = f1.fullPath();
63 
64  edm::LogInfo("L1GtConfigProducers") << "\n\nL1 GT VHDL directory: "
65  << vhdlDir_ << "\n\n" << std::endl;
66 
67 }
68 
69 // destructor
71 {
72  // empty
73 }
74 
75 // loop over events
77  const edm::EventSetup& evSetup)
78 {
79 
81  evSetup.get< L1GtTriggerMenuRcd >().get(l1GtMenu) ;
82 
83  std::vector<ConditionMap> conditionMap = l1GtMenu->gtConditionMap();
84  AlgorithmMap algorithmMap = l1GtMenu->gtAlgorithmMap();
85 
86  // print with various level of verbosities
87  int printVerbosity = 0;
88  l1GtMenu->print(std::cout, printVerbosity);
89 
90  //---------------------Here the VHDL files will be created---------------------------------------
91 
92  // information that will be delivered by the parser in future
93  std::map<std::string,std::string> headerParameters;
94  std::vector<std::string> channelVector;
95 
96  headerParameters["vhdl_path"]="/vhdllibrarypath";
97  headerParameters["designer_date"]="20.05.1986";
98  headerParameters["designer_name"]="Philipp Wagner";
99  headerParameters["version"]="2.0";
100  headerParameters["designer_comments"]="produced in CMSSW";
101  headerParameters["gtl_setup_name"]="L1Menu2007NovGR";
102 
103  channelVector.push_back("-- ca1: ieg");
104  channelVector.push_back("-- ca2: eg");
105  channelVector.push_back("-- ca3: jet");
106  channelVector.push_back("-- ca4: fwdjet");
107  channelVector.push_back("-- ca5: tau");
108  channelVector.push_back("-- ca6: esums");
109  channelVector.push_back("-- ca7: jet_cnts");
110  channelVector.push_back("-- ca8: free");
111  channelVector.push_back("-- ca9: free");
112  channelVector.push_back("-- ca10: free");
113 
114  // check, weather output directory exists and create it on the fly if not
115  if (boost::filesystem::is_directory(outputDir_))
116  {
117  std::cout<<std::endl<<"Ok - Output directory exists!"<<std::endl;
118  } else
119  {
120  if (!mkdir(outputDir_.c_str(), 0666))
121  std::cout<<std::endl<<"Directory: "<<outputDir_<<" has been created!"<<std::endl;
122  else
123  std::cout<<std::endl<<"Error while creating directory: "<<outputDir_<<" !"<<std::endl;
124  }
125 
126  // prepare a core with common header
127  L1GtVhdlWriterCore vhdlWriter(vhdlDir_, outputDir_, true);
128  vhdlWriter.buildCommonHeader(headerParameters, channelVector);
129  // write the firmware
130  if (vhdlWriter.makeFirmware(conditionMap, algorithmMap))
131  {
132  std::cout << std::endl << std::endl
133  <<"*********************** I'm ready ;-) **************************"
134  <<std::endl <<std::endl
135  <<"You can find the firmware in dircetory: " <<outputDir_
136  <<std::endl <<std::endl
137  <<"******************************************************************"
138  <<std::endl;
139  }
140 
141  // Create the VME - XML
142  std::string vmeFile = "vme.xml";
143 
144  L1GtVmeWriterCore vmeWriter(outputDir_, vmeFile);
145  vmeWriter.writeVME(conditionMap, vhdlWriter.getCond2IntMap(),
146  vhdlWriter.retrunCommonHeader());
147 }
T getParameter(std::string const &) const
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:243
void writeVME(const std::vector< ConditionMap > &conditionMap, std::map< std::string, int > cond2intMap, L1GtVhdlTemplateFile header, const int spacesPerLevel=2)
bool makeFirmware(const std::vector< ConditionMap > &conditionMap, const AlgorithmMap &algorithmMap)
produces the firmware code
virtual void analyze(const edm::Event &, const edm::EventSetup &)
virtual ~L1GtVhdlWriter()
destructor
L1GtVhdlTemplateFile retrunCommonHeader()
returns the common header
const T & get() const
Definition: EventSetup.h:55
std::map< std::string, int > getCond2IntMap()
tuple cout
Definition: gather_cfg.py:121
void buildCommonHeader(std::map< std::string, std::string > &headerParameters, const std::vector< std::string > &connectedChannels)
builds the common header for all files