CMS 3D CMS Logo

GTTFileReader.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1Trigger/DemonstratorTools
4 // Class: GTTFileReader
5 //
15 //
16 // Original Author: Thomas Williams <thomas.williams@stfc.ac.uk>
17 // Created: Fri, 19 Feb 2021 01:10:55 GMT
18 //
19 //
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
33 
38 
39 //
40 // class declaration
41 //
42 
44 public:
45  explicit GTTFileReader(const edm::ParameterSet&);
46 
47  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
48 
49 private:
50  // ----------constants, enums and typedefs ---------
51  // NOTE: At least some of the info from these constants will eventually come from config files
52  static constexpr size_t kFramesPerTMUXPeriod = 9;
53  static constexpr size_t kGapLength = 44;
54  static constexpr size_t kVertexTMUX = 6;
55  static constexpr size_t kVertexChanIndex = 0;
56  static constexpr size_t kEmptyFrames = 10;
57 
59  /* logical channel within time slice -> {{link TMUX, inter-packet gap}, vector of channel indices} */
60  {{"vertices", 0}, {{kVertexTMUX, kGapLength}, {kVertexChanIndex}}}};
61 
62  // ----------member functions ----------------------
63  void produce(edm::Event&, const edm::EventSetup&) override;
64 
65  // ----------member data ---------------------------
67 };
68 
69 //
70 // class implementation
71 //
72 
74  : fileReader_(l1t::demo::parseFileFormat(iConfig.getUntrackedParameter<std::string>("format")),
75  iConfig.getParameter<std::vector<std::string>>("files"),
76  kFramesPerTMUXPeriod,
77  kVertexTMUX,
78  kEmptyFrames,
79  kChannelSpecs) {
80  produces<l1t::VertexWordCollection>();
81 }
82 
83 // ------------ method called to produce the data ------------
85  using namespace edm;
86  using namespace l1t::demo::codecs;
87 
89 
90  l1t::VertexWordCollection vertices(decodeVertices(eventData.at({"vertices", 0})));
91 
92  edm::LogInfo("GTTFileReader") << vertices.size() << " vertices found";
93 
94  iEvent.put(std::make_unique<l1t::VertexWordCollection>(vertices));
95 }
96 
97 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
99  // GTTFileReader
101  desc.add<std::vector<std::string>>("files",
102  {
103  "gttOutput_0.txt",
104  });
105  desc.addUntracked<std::string>("format", "APx");
106  descriptions.add("GTTFileReader", desc);
107 }
108 
109 //define this as a plug-in
void produce(edm::Event &, const edm::EventSetup &) override
const l1t::demo::BoardDataReader::ChannelMap_t kChannelSpecs
FileFormat parseFileFormat(const std::string &)
Definition: utilities.cc:73
delete x;
Definition: CaloConfig.h:22
static constexpr size_t kGapLength
l1t::demo::BoardDataReader fileReader_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iEvent
Definition: GenABIO.cc:224
static constexpr size_t kVertexTMUX
std::vector< l1t::VertexWord > decodeVertices(const std::vector< ap_uint< 64 >> &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< VertexWord > VertexWordCollection
Definition: VertexWord.h:197
static constexpr size_t kFramesPerTMUXPeriod
static constexpr size_t kVertexChanIndex
Log< level::Info, false > LogInfo
static constexpr size_t kEmptyFrames
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
std::map< LinkId, std::pair< ChannelSpec, std::vector< size_t > > > ChannelMap_t
GTTFileReader(const edm::ParameterSet &)
Class representing information phase-2 ATCA I/O data corresponding to a single event, with logical channel IDs (essentially string-uint pairs, e.g. tracks-0 to tracks-17).
Definition: EventData.h:28