CMS 3D CMS Logo

L1GTBoardWriter.cc
Go to the documentation of this file.
1 
7 
10 
14 
17 
19 
21 
22 #include "ap_int.h"
23 
24 #include <vector>
25 #include <algorithm>
26 #include <string>
27 
28 using namespace l1t;
29 
31 public:
32  explicit L1GTBoardWriter(const edm::ParameterSet&);
33 
34  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
35 
36 private:
37  void analyze(const edm::Event&, const edm::EventSetup&) override;
38  void endJob() override;
39 
40  const std::vector<unsigned int> channels_;
41  const std::vector<unsigned long long> algoBitMask_;
44 };
45 
47  : channels_(config.getParameter<std::vector<unsigned int>>("channels")),
48  algoBitMask_(config.getParameter<std::vector<unsigned long long>>("algoBitMask")),
49  algoBlocksToken_(consumes<P2GTAlgoBlockCollection>(config.getParameter<edm::InputTag>("algoBlocksTag"))),
50  boardDataWriter_(
51  l1t::demo::parseFileFormat(config.getParameter<std::string>("patternFormat")),
52  config.getParameter<std::string>("outputFilename"),
53  config.getParameter<std::string>("outputFileExtension"),
54  9,
55  1,
56  config.getParameter<unsigned int>("maxLines"),
57  [](const std::vector<unsigned int>& channels) {
59  for (unsigned int channel : channels) {
60  channelMap.insert({l1t::demo::LinkId{"Algos", channel}, {l1t::demo::ChannelSpec{1, 0, 0}, {channel}}});
61  }
62  return channelMap;
63  }(channels_)) {}
64 
66  l1t::demo::EventData eventData;
67  const P2GTAlgoBlockCollection& algoBlocks = event.get(algoBlocksToken_);
68 
69  auto algoBlockIt = algoBlocks.begin();
70  auto algoMaskIt = algoBitMask_.begin();
71 
72  for (unsigned int channel : channels_) {
73  std::vector<ap_uint<64>> bits(9, 0);
74  for (std::size_t word = 0; word < 9; word++) {
75  ap_uint<64> mask = algoMaskIt != algoBitMask_.end() ? *algoMaskIt++ : ~static_cast<unsigned long long>(0);
76 
77  for (std::size_t idx = 0; idx < 64 && algoBlockIt != algoBlocks.end(); idx++) {
78  bits[word].set(idx, algoBlockIt->decisionBeforeBxMaskAndPrescale() && mask.bit(idx));
79  algoBlockIt++;
80  }
81  }
82 
83  eventData.add({"Algos", channel}, bits);
84  }
85 
86  boardDataWriter_.addEvent(eventData);
87 }
88 
90 
93  desc.add<std::string>("outputFilename");
94  desc.add<std::string>("outputFileExtension", "txt");
95  desc.add<edm::InputTag>("algoBlocksTag");
96  desc.add<std::vector<unsigned int>>("channels");
97  desc.add<std::vector<unsigned long long>>("algoBitMask", {});
98  desc.add<unsigned int>("maxLines", 1024);
99  desc.add<std::string>("patternFormat", "EMPv2");
100 
101  descriptions.addDefault(desc);
102 }
103 
void analyze(const edm::Event &, const edm::EventSetup &) override
Logical ID for link within any given time slice (e.g. ["tracks", 0] -> ["tracks", 17] for links from ...
Definition: LinkId.h:10
l1t::demo::BoardDataWriter boardDataWriter_
constexpr uint32_t bits
Definition: gpuClustering.h:25
void addEvent(const EventData &data)
FileFormat parseFileFormat(const std::string &)
Definition: utilities.cc:73
delete x;
Definition: CaloConfig.h:22
Definition: config.py:1
void add(const LinkId &, const std::vector< ap_uint< 64 >> &)
Definition: EventData.cc:14
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
constexpr uint32_t mask
Definition: gpuClustering.h:26
uint64_t word
void addDefault(ParameterSetDescription const &psetDescription)
const std::vector< unsigned int > channels_
const edm::EDGetTokenT< P2GTAlgoBlockCollection > algoBlocksToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void endJob() override
std::map< LinkId, std::pair< ChannelSpec, std::vector< size_t > > > ChannelMap_t
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const std::vector< unsigned long long > algoBitMask_
std::vector< P2GTAlgoBlock > P2GTAlgoBlockCollection
Definition: P2GTAlgoBlock.h:12
HLT enums.
L1GTBoardWriter(const edm::ParameterSet &)
const_iterator begin() const
Definition: EventData.cc:10
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
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: event.py:1