CMS 3D CMS Logo

L1GTAlgoBoardWriter.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 L1GTAlgoBoardWriter(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::array<unsigned int, 2> channels_;
41  const std::array<unsigned long long, 9> algoBitMask_;
44 
45  std::map<l1t::demo::LinkId, std::vector<ap_uint<64>>> linkData_;
46  std::size_t tmuxCounter_;
47 };
48 
50  : channels_(config.getParameter<std::array<unsigned int, 2>>("channels")),
51  algoBitMask_(config.getParameter<std::array<unsigned long long, 9>>("algoBitMask")),
52  algoBlocksToken_(consumes<P2GTAlgoBlockMap>(config.getParameter<edm::InputTag>("algoBlocksTag"))),
53  boardDataWriter_(
54  l1t::demo::parseFileFormat(config.getParameter<std::string>("patternFormat")),
55  config.getParameter<std::string>("outputFilename"),
56  config.getParameter<std::string>("outputFileExtension"),
57  9,
58  2,
59  config.getParameter<unsigned int>("maxLines"),
60  [](const std::array<unsigned int, 2>& channels) {
62  for (unsigned int channel : channels) {
63  channelMap.insert({l1t::demo::LinkId{"Algos", channel}, {l1t::demo::ChannelSpec{2, 0, 0}, {channel}}});
64  }
65  return channelMap;
66  }(channels_)),
67  linkData_(),
68  tmuxCounter_(0) {}
69 
71  const P2GTAlgoBlockMap& algoBlocks = event.get(algoBlocksToken_);
72 
73  auto algoBlockIt = algoBlocks.begin();
74  auto algoMaskIt = algoBitMask_.begin();
75 
76  for (unsigned int channel : channels_) {
77  if (tmuxCounter_ == 0) {
78  linkData_[{"Algos", channel}] = std::vector<ap_uint<64>>(18, 0);
79  }
80 
81  for (std::size_t word = 0; word < 9; word++) {
82  ap_uint<64> mask = algoMaskIt != algoBitMask_.end() ? *algoMaskIt++ : ~static_cast<unsigned long long>(0);
83 
84  for (std::size_t idx = 0; idx < 64 && algoBlockIt != algoBlocks.end(); idx++, algoBlockIt++) {
85  auto& [algoName, algoBlock] = *algoBlockIt;
86  linkData_[{"Algos", channel}][word + tmuxCounter_ * 9].set(
87  idx, algoBlock.decisionBeforeBxMaskAndPrescale() && mask.bit(idx));
88  }
89  }
90  }
91 
92  if (tmuxCounter_ == 1) {
94  }
95 
96  tmuxCounter_ = (tmuxCounter_ + 1) % 2;
97 }
98 
100  if (tmuxCounter_ == 1) {
102  }
103 
105 }
106 
109  desc.add<std::string>("outputFilename");
110  desc.add<std::string>("outputFileExtension", "txt");
111  desc.add<edm::InputTag>("algoBlocksTag");
112  desc.add<std::vector<unsigned int>>("channels");
113  desc.add<std::vector<unsigned long long>>("algoBitMask",
114  {0xffffffffffffffffull,
115  0xffffffffffffffffull,
116  0xffffffffffffffffull,
117  0xffffffffffffffffull,
118  0xffffffffffffffffull,
119  0xffffffffffffffffull,
120  0xffffffffffffffffull,
121  0xffffffffffffffffull,
122  0xffffffffffffffffull});
123  desc.add<unsigned int>("maxLines", 1024);
124  desc.add<std::string>("patternFormat", "EMPv2");
125 
126  descriptions.addDefault(desc);
127 }
128 
const std::array< unsigned long long, 9 > algoBitMask_
Logical ID for link within any given time slice (e.g. ["tracks", 0] -> ["tracks", 17] for links from ...
Definition: LinkId.h:10
const edm::EDGetTokenT< P2GTAlgoBlockMap > algoBlocksToken_
void addEvent(const EventData &data)
std::map< std::string, P2GTAlgoBlock > P2GTAlgoBlockMap
Definition: P2GTAlgoBlock.h:11
FileFormat parseFileFormat(const std::string &)
Definition: utilities.cc:73
delete x;
Definition: CaloConfig.h:22
Definition: config.py:1
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
void analyze(const edm::Event &, const edm::EventSetup &) override
uint64_t word
void addDefault(ParameterSetDescription const &psetDescription)
L1GTAlgoBoardWriter(const edm::ParameterSet &)
const std::array< unsigned int, 2 > channels_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::map< LinkId, std::pair< ChannelSpec, std::vector< size_t > > > ChannelMap_t
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::map< l1t::demo::LinkId, std::vector< ap_uint< 64 > > > linkData_
HLT enums.
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
l1t::demo::BoardDataWriter boardDataWriter_
Definition: event.py:1