42 #include <type_traits> 45 #include <unordered_map> 57 void endJob()
override;
88 template <
typename T1,
typename T2>
89 static std::vector<T1>
vconvert(std::vector<T2> ivec) {
90 return std::vector<T1>(ivec.begin(), ivec.end());
111 "GMTSaDisplacedMuons",
122 : bufferFileType_(
config.getUntrackedParameter<
std::
string>(
"bufferFileType") ==
"input" ? INPUT : OUTPUT),
124 maxEvents_(
config.getUntrackedParameter<unsigned
int>(
"maxEvents")),
132 config.getUntrackedParameter<unsigned
int>(
"maxFrames"),
181 for (std::size_t
i = 0;
i <
channels.size();
i++) {
189 gttPromptJetToken_(consumes<TkJetWordCollection>(
config.getUntrackedParameter<
edm::InputTag>(
"GTTPromptJets"))),
190 gttDisplacedJetToken_(
191 consumes<TkJetWordCollection>(
config.getUntrackedParameter<
edm::InputTag>(
"GTTDisplacedJets"))),
192 gttPromptHtSumToken_(consumes<std::vector<EtSum>>(
config.getUntrackedParameter<
edm::InputTag>(
"GTTPromptHtSum"))),
193 gttDisplacedHtSumToken_(
194 consumes<std::vector<EtSum>>(
config.getUntrackedParameter<
edm::InputTag>(
"GTTDisplacedHtSum"))),
195 gttEtSumToken_(consumes<std::vector<EtSum>>(
config.getUntrackedParameter<
edm::InputTag>(
"GTTEtSum"))),
196 gttPrimaryVertexToken_(
197 consumes<VertexWordCollection>(
config.getUntrackedParameter<
edm::InputTag>(
"GTTPrimaryVert"))),
198 gmtSaPromptMuonToken_(
199 consumes<SAMuonCollection>(
config.getUntrackedParameter<
edm::InputTag>(
"GMTSaPromptMuons"))),
200 gmtSaDisplacedMuonToken_(
201 consumes<SAMuonCollection>(
config.getUntrackedParameter<
edm::InputTag>(
"GMTSaDisplacedMuons"))),
202 gmtTkMuonToken_(consumes<TrackerMuonCollection>(
config.getUntrackedParameter<
edm::InputTag>(
"GMTTkMuons"))),
203 cl2JetSC4Token_(consumes<PFJetCollection>(
config.getUntrackedParameter<
edm::InputTag>(
"CL2JetsSC4"))),
204 cl2JetSC8Token_(consumes<PFJetCollection>(
config.getUntrackedParameter<
edm::InputTag>(
"CL2JetsSC8"))),
205 cl2PhotonToken_(consumes<TkEmCollection>(
config.getUntrackedParameter<
edm::InputTag>(
"CL2Photons"))),
206 cl2ElectronToken_(consumes<TkElectronCollection>(
config.getUntrackedParameter<
edm::InputTag>(
"CL2Electrons"))),
207 cl2TauToken_(consumes<PFTauCollection>(
config.getUntrackedParameter<
edm::InputTag>(
"CL2Taus"))),
208 cl2EtSumToken_(consumes<std::vector<EtSum>>(
config.getUntrackedParameter<
edm::InputTag>(
"CL2EtSum"))),
209 cl2HtSumToken_(consumes<std::vector<EtSum>>(
config.getUntrackedParameter<
edm::InputTag>(
"CL2HtSum"))) {}
211 template <
typename T, P2GTCand
idate::ObjectType type = P2GTCand
idate::Undefined>
213 std::vector<ap_uint<64>> packed;
214 std::optional<ap_uint<64>> next_packed;
218 if constexpr (std::is_same_v<T, TkJetWord>) {
219 ap_uint<128>
word =
obj.tkJetWord();
220 packed.emplace_back(
word(63, 0));
221 packed.emplace_back(
word(127, 64));
222 }
else if constexpr (std::is_same_v<T, EtSum>) {
229 packed.emplace_back(sum.pack_ap());
236 packed.emplace_back(sum.pack_ap());
239 }
else if constexpr (std::is_same_v<T, VertexWord>) {
240 packed.emplace_back(
obj.vertexWord());
241 }
else if constexpr (std::is_same_v<T, SAMuon>) {
242 packed.emplace_back(
obj.word());
243 }
else if constexpr (std::is_same_v<T, TrackerMuon>) {
244 std::array<uint64_t, 2>
word =
obj.word();
245 if (next_packed.has_value()) {
246 packed.emplace_back(
word[1] << 32 | next_packed.value());
249 next_packed =
word[1];
252 packed.emplace_back(
word[0]);
253 }
else if constexpr (std::is_same_v<T, PFJet>) {
254 packed.emplace_back(
obj.encodedJet()[0]);
255 packed.emplace_back(
obj.encodedJet()[1]);
256 }
else if constexpr (std::is_same_v<T, TkEm> || std::is_same_v<T, TkElectron>) {
257 ap_uint<96>
word =
obj.template egBinaryWord<96>();
258 if (next_packed.has_value()) {
259 packed.emplace_back(
word(95, 64) << 32 | next_packed.value());
262 next_packed =
word(95, 64);
265 packed.emplace_back(
word(63, 0));
266 }
else if constexpr (std::is_same_v<T, PFTau>) {
267 std::array<uint64_t, 2>
word =
obj.encodedTau();
268 if (next_packed.has_value()) {
269 packed.emplace_back(
word[1] << 32 | next_packed.value());
272 next_packed =
word[1];
275 packed.emplace_back(
word[0]);
280 if constexpr (std::is_same_v<T, TkJetWord> || std::is_same_v<T, PFJet>) {
281 while (packed.size() < 24) {
282 packed.emplace_back(0);
284 }
else if constexpr (std::is_same_v<T, TrackerMuon> || std::is_same_v<T, TkEm> || std::is_same_v<T, TkElectron> ||
285 std::is_same_v<T, PFTau>) {
286 while (packed.size() < 18) {
288 packed.emplace_back(next_packed.value());
291 packed.emplace_back(0);
294 }
else if constexpr (std::is_same_v<T, SAMuon> || std::is_same_v<T, VertexWord>) {
295 while (packed.size() < 12) {
296 packed.emplace_back(0);
298 }
else if constexpr (std::is_same_v<T, EtSum>) {
299 if (packed.size() < 1) {
300 packed.emplace_back(0);
307 template <
typename T>
308 static std::vector<T>
operator+(std::vector<T>&& lhs, std::vector<T>&& rhs) {
309 std::vector<T> concat;
310 concat.reserve(lhs.size() + rhs.size());
311 std::move(lhs.begin(), lhs.end(), std::back_inserter(concat));
312 std::move(rhs.begin(), rhs.end(), std::back_inserter(concat));
338 packCollection<EtSum, P2GTCandidate::GTTPromptHtSum>(gttPromptHtSum) +
339 packCollection<EtSum, P2GTCandidate::GTTDisplacedHtSum>(gttDisplacedHtSum) +
340 packCollection<EtSum, P2GTCandidate::GTTEtSum>(gttEtSum)},
341 {{
"GTT", 2}, std::vector<ap_uint<64>>(18, 0)},
343 packCollection(cl2JetsSC4) + packCollection<EtSum, P2GTCandidate::CL2HtSum>(cl2HtSum) +
344 packCollection<EtSum, P2GTCandidate::CL2EtSum>(cl2EtSum) +
packCollection(cl2JetsSC8)},
346 {{
"GCT", 1}, std::vector<ap_uint<64>>(50, 0)},
351 {{
"GTT", 3}, std::vector<ap_uint<64>>(39, 0)},
352 {{
"GTT", 4}, std::vector<ap_uint<64>>(36, 0) +
packCollection(gttPrimaryVertices)}}});
354 std::map<demo::LinkId, std::vector<ap_uint<64>>> eventData;
357 std::vector<ap_uint<64>>
data;
364 data = packCollection<EtSum, P2GTCandidate::GTTPromptHtSum>(gttPromptHtSum);
366 data = packCollection<EtSum, P2GTCandidate::GTTDisplacedHtSum>(gttDisplacedHtSum);
368 data = packCollection<EtSum, P2GTCandidate::GTTEtSum>(gttEtSum);
388 data = packCollection<EtSum, P2GTCandidate::CL2EtSum>(cl2EtSum);
390 data = packCollection<EtSum, P2GTCandidate::CL2HtSum>(cl2HtSum);
398 while (eventData[{
name,
i}].size() < 9) {
399 eventData[{
name,
i}].push_back(0);
421 desc.addUntracked<
unsigned int>(
"maxFrames", 1024);
422 desc.addUntracked<
unsigned int>(
"maxEvents", 0);
425 edm::allowedValues<std::string>(
"input",
"output"));
447 inputChannelDesc.
addUntracked<std::vector<unsigned int>>(
"GCT_1");
448 inputChannelDesc.addUntracked<std::vector<unsigned int>>(
"GMT_1");
449 inputChannelDesc.addUntracked<std::vector<unsigned int>>(
"GTT_1");
450 inputChannelDesc.addUntracked<std::vector<unsigned int>>(
"GTT_2");
451 inputChannelDesc.addUntracked<std::vector<unsigned int>>(
"GTT_3");
452 inputChannelDesc.addUntracked<std::vector<unsigned int>>(
"GTT_4");
453 inputChannelDesc.addUntracked<std::vector<unsigned int>>(
"CL2_1");
454 inputChannelDesc.addUntracked<std::vector<unsigned int>>(
"CL2_2");
455 inputChannelDesc.addUntracked<std::vector<unsigned int>>(
"CL2_3");
const edm::EDGetTokenT< std::vector< EtSum > > gttPromptHtSumToken_
std::vector< l1t::TkJetWord > TkJetWordCollection
std::vector< TkElectron > TkElectronCollection
const edm::EDGetTokenT< PFJetCollection > cl2JetSC8Token_
std::vector< l1t::PFTau > PFTauCollection
static void fillDescriptions(edm::ConfigurationDescriptions &)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ap_uint< 64 > encodeEtSum(const l1t::EtSum &v)
void addEvent(const EventData &data)
const edm::EDGetTokenT< std::vector< EtSum > > gttDisplacedHtSumToken_
FileFormat parseFileFormat(const std::string &)
const edm::EDGetTokenT< VertexWordCollection > gttPrimaryVertexToken_
ap_uint< 64 > encodeHtSum(const l1t::EtSum &v)
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
const edm::EDGetTokenT< TkJetWordCollection > gttPromptJetToken_
static std::vector< T > operator+(std::vector< T > &&lhs, std::vector< T > &&rhs)
T getUntrackedParameter(std::string const &, T const &) const
std::vector< l1t::PFJet > PFJetCollection
const edm::EDGetTokenT< std::vector< EtSum > > cl2EtSumToken_
unsigned int eventCounter_
const edm::EDGetTokenT< TkElectronCollection > cl2ElectronToken_
static std::vector< T1 > vconvert(std::vector< T2 > ivec)
std::vector< TkEm > TkEmCollection
void addDefault(ParameterSetDescription const &psetDescription)
L1GTObjectBoardWriter(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
static constexpr std::array< const char *, 27 > AVAILABLE_COLLECTIONS
std::vector< VertexWord > VertexWordCollection
const BufferType bufferFileType_
void analyze(const edm::Event &, const edm::EventSetup &) override
const edm::EDGetTokenT< std::vector< EtSum > > gttEtSumToken_
std::map< LinkId, std::pair< ChannelSpec, std::vector< size_t > > > ChannelMap_t
const edm::EDGetTokenT< TrackerMuonCollection > gmtTkMuonToken_
std::vector< TrackerMuon > TrackerMuonCollection
std::vector< SAMuon > SAMuonCollection
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< TkEmCollection > cl2PhotonToken_
const edm::EDGetTokenT< PFJetCollection > cl2JetSC4Token_
std::unordered_map< std::string, std::size_t > numChannels_
const edm::EDGetTokenT< PFTauCollection > cl2TauToken_
const edm::EDGetTokenT< SAMuonCollection > gmtSaDisplacedMuonToken_
constexpr float ETAPHI_LSB
const edm::EDGetTokenT< TkJetWordCollection > gttDisplacedJetToken_
char data[epos_bytes_allocation]
const edm::EDGetTokenT< std::vector< EtSum > > cl2HtSumToken_
static std::vector< ap_uint< 64 > > packCollection(const std::vector< T > &collection)
demo::BoardDataWriter boardDataWriter_
const edm::EDGetTokenT< SAMuonCollection > gmtSaPromptMuonToken_
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).