Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:54:34

0001 #ifndef GlobalTriggerAnalyzer_L1GtPatternWriter_h
0002 #define GlobalTriggerAnalyzer_L1GtPatternWriter_h
0003 
0004 /**
0005  * \class L1GtPatternWriter
0006  * 
0007  * 
0008  * Description: Formats L1GtPatternMaps into text files.
0009  *
0010  * Implementation:
0011  *    <TODO: enter implementation details>
0012  *   
0013  * \author: Thomas Themel - HEPHY Vienna
0014  * 
0015  *
0016  */
0017 
0018 #include <iosfwd>
0019 #include <string>
0020 #include <vector>
0021 #include <cstdint>
0022 
0023 class L1GtPatternMap;
0024 class L1GtPatternLine;
0025 
0026 /** The L1GtPatternWriter object is responsible for the actual formatting 
0027     of the content of one or more L1GtPatternMaps into a text file. */
0028 class L1GtPatternWriter {
0029 public:
0030   /** Construct a new pattern writer. 
0031    *  @param destination  output stream to write to
0032    *  @param header       string to be written before pattern lines
0033    *  @param footer       string to be written after pattern lines
0034    *  @param columns      vector of column names for each pattern line
0035    *  @param length       vector of column lengths (in bits!) for each pattern line
0036    *  @param defaults     vector of default values (written if the pattern data does not contain entries
0037    *                      for the column). Indexed like columns.
0038    *  @param bx           vector of bunch crossing numbers to print (empty for 'all')
0039    *  @param debug        set to true to enable extensive debug logging
0040    */
0041   L1GtPatternWriter(std::ostream& destination,
0042                     const std::string& header,
0043                     const std::string& footer,
0044                     const std::vector<std::string>& columns,
0045                     const std::vector<uint32_t>& lengths,
0046                     const std::vector<uint32_t>& defaultValues,
0047                     const std::vector<int>& bx,
0048                     bool debug = false);
0049 
0050   /** Write the lines from a pattern map to the output stream. */
0051   void writePatterns(const L1GtPatternMap& patterns);
0052 
0053   /** Format a single line. */
0054   virtual void writePatternLine(const L1GtPatternLine& line);
0055 
0056   /** Close the output stream */
0057   void close();
0058 
0059   virtual ~L1GtPatternWriter();
0060 
0061 protected:
0062   /** Returns an and-mask to truncate an uint32_t to a specified
0063       length. */
0064   static uint32_t mask(uint32_t length);
0065 
0066 private:
0067   std::ostream& m_dest;
0068   std::string m_header;
0069   std::string m_footer;
0070   std::vector<std::string> m_columns;
0071   std::vector<uint32_t> m_lengths;
0072   std::vector<uint32_t> m_defaults;
0073   std::vector<int> m_bx;
0074   bool m_debug;
0075 
0076   uint32_t m_lineNo;
0077 };
0078 
0079 #endif /*GlobalTriggerAnalyzer_L1GtPatternWriter_h*/