CMS 3D CMS Logo

Classes | Functions | Variables
L1GTObjectBoardWriter.cc File Reference
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/allowedValues.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "L1Trigger/DemonstratorTools/interface/BoardDataWriter.h"
#include "L1Trigger/DemonstratorTools/interface/utilities.h"
#include "L1Trigger/DemonstratorTools/interface/codecs/etsums.h"
#include "L1Trigger/DemonstratorTools/interface/codecs/htsums.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "DataFormats/L1Trigger/interface/TkJetWord.h"
#include "DataFormats/L1Trigger/interface/VertexWord.h"
#include "DataFormats/L1TMuonPhase2/interface/SAMuon.h"
#include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h"
#include "DataFormats/L1TParticleFlow/interface/PFJet.h"
#include "DataFormats/L1TCorrelator/interface/TkEmFwd.h"
#include "DataFormats/L1TCorrelator/interface/TkEm.h"
#include "DataFormats/L1TCorrelator/interface/TkElectronFwd.h"
#include "DataFormats/L1TCorrelator/interface/TkElectron.h"
#include "DataFormats/L1TParticleFlow/interface/PFTau.h"
#include "DataFormats/L1Trigger/interface/EtSum.h"
#include "DataFormats/L1Trigger/interface/P2GTCandidate.h"
#include <vector>
#include <algorithm>
#include <string>
#include <type_traits>
#include <optional>
#include <array>
#include <unordered_map>

Go to the source code of this file.

Classes

class  L1GTObjectBoardWriter
 

Functions

template<typename T >
static std::vector< Toperator+ (std::vector< T > &&lhs, std::vector< T > &&rhs)
 
template<typename T , P2GTCandidate::ObjectType type = P2GTCandidate::Undefined>
static std::vector< ap_uint< 64 > > packCollection (const std::vector< T > &collection)
 
static const edm::ParameterSetDescriptionFillerPluginFactory::PMaker< edm::ParameterSetDescriptionFiller< L1GTObjectBoardWriter > > s_filler_0__LINE__ ("L1GTObjectBoardWriter")
 
static const edm::MakerPluginFactory ::PMaker< edm::WorkerMaker< L1GTObjectBoardWriter > > s_maker__LINE__ ("L1GTObjectBoardWriter")
 
template<typename T1 , typename T2 >
static std::vector< T1 > vconvert (std::vector< T2 > ivec)
 

Variables

static constexpr std::array< const char *, 27 > AVAILABLE_COLLECTIONS
 

Function Documentation

◆ operator+()

template<typename T >
static std::vector<T> operator+ ( std::vector< T > &&  lhs,
std::vector< T > &&  rhs 
)
static

Definition at line 308 of file L1GTObjectBoardWriter.cc.

References eostools::move().

308  {
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));
313  return concat;
314 }
def move(src, dest)
Definition: eostools.py:511

◆ packCollection()

template<typename T , P2GTCandidate::ObjectType type = P2GTCandidate::Undefined>
static std::vector<ap_uint<64> > packCollection ( const std::vector< T > &  collection)
static

Definition at line 212 of file L1GTObjectBoardWriter.cc.

References l1tGTBoardWriter_cff::CL2EtSum, l1tGTBoardWriter_cff::CL2HtSum, universalConfigTemplate::collection, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), l1t::demo::codecs::encodeEtSum(), l1t::demo::codecs::encodeHtSum(), l1gt::Scales::ETAPHI_LSB, l1tGTBoardWriter_cff::GTTDisplacedHtSum, l1tGTBoardWriter_cff::GTTEtSum, l1tGTBoardWriter_cff::GTTPromptHtSum, heavyIonCSV_trainingSettings::idx, l1tJetFileWriter_cfi::mht, and getGTfromDQMFile::obj.

Referenced by L1GTObjectBoardWriter::analyze().

212  {
213  std::vector<ap_uint<64>> packed;
214  std::optional<ap_uint<64>> next_packed;
215 
216  for (std::size_t idx = 0; idx < collection.size() && idx < 12; idx++) {
217  const T& obj = collection[idx];
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>) {
224  packed.emplace_back(l1t::demo::codecs::encodeEtSum(obj));
226  packed.emplace_back(l1t::demo::codecs::encodeHtSum(obj));
227  } else if constexpr (type == P2GTCandidate::CL2EtSum) {
228  l1gt::Sum sum{true /* valid */, obj.pt(), obj.phi() / l1gt::Scales::ETAPHI_LSB, 0 /* scalar sum */};
229  packed.emplace_back(sum.pack_ap());
230  } else if constexpr (type == P2GTCandidate::CL2HtSum) {
231  // Make interfaces great again!
232  const EtSum& ht = collection[0];
233  const EtSum& mht = collection[1];
234 
235  l1gt::Sum sum{true /* valid */, mht.pt(), mht.phi() / l1gt::Scales::ETAPHI_LSB, ht.pt()};
236  packed.emplace_back(sum.pack_ap());
237  }
238  break;
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());
247  next_packed.reset();
248  } else {
249  next_packed = word[1];
250  }
251 
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());
260  next_packed.reset();
261  } else {
262  next_packed = word(95, 64);
263  }
264 
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());
270  next_packed.reset();
271  } else {
272  next_packed = word[1];
273  }
274 
275  packed.emplace_back(word[0]);
276  }
277  }
278 
279  // Filling up remaining words with 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);
283  }
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) {
287  if (next_packed) {
288  packed.emplace_back(next_packed.value());
289  next_packed.reset();
290  } else {
291  packed.emplace_back(0);
292  }
293  }
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);
297  }
298  } else if constexpr (std::is_same_v<T, EtSum>) {
299  if (packed.size() < 1) {
300  packed.emplace_back(0);
301  }
302  }
303 
304  return packed;
305 }
ap_uint< 64 > encodeEtSum(const l1t::EtSum &v)
Definition: codecs_etsums.cc:6
ap_uint< 64 > encodeHtSum(const l1t::EtSum &v)
Definition: codecs_htsums.cc:6
uint64_t word
constexpr float ETAPHI_LSB
Definition: gt_datatypes.h:45
long double T

◆ s_filler_0__LINE__()

static const edm::ParameterSetDescriptionFillerPluginFactory::PMaker<edm::ParameterSetDescriptionFiller< L1GTObjectBoardWriter > > s_filler_0__LINE__ ( "L1GTObjectBoardWriter"  )
static

◆ s_maker__LINE__()

static const edm::MakerPluginFactory ::PMaker< edm::WorkerMaker< L1GTObjectBoardWriter > > s_maker__LINE__ ( "L1GTObjectBoardWriter"  )
static

◆ vconvert()

template<typename T1 , typename T2 >
static std::vector<T1> vconvert ( std::vector< T2 >  ivec)
static

Definition at line 89 of file L1GTObjectBoardWriter.cc.

89  {
90  return std::vector<T1>(ivec.begin(), ivec.end());
91 }

Variable Documentation

◆ AVAILABLE_COLLECTIONS

constexpr std::array<const char*, 27> AVAILABLE_COLLECTIONS
static
Initial value:
{{"GTTPromptJets",
"GTTDisplacedJets",
"GTTPromptHtSum",
"GTTDisplacedHtSum",
"GTTEtSum",
"GTTHadronicTaus",
"CL2JetsSC4",
"CL2JetsSC8",
"CL2Taus",
"CL2HtSum",
"CL2EtSum",
"GCTNonIsoEg",
"GCTIsoEg",
"GCTJets",
"GCTTaus",
"GCTHtSum",
"GCTEtSum",
"GMTSaPromptMuons",
"GMTSaDisplacedMuons",
"GMTTkMuons",
"GMTTopo",
"CL2Electrons",
"CL2Photons",
"GTTPhiCandidates",
"GTTRhoCandidates",
"GTTBsCandidates",
"GTTPrimaryVert"}}

Definition at line 93 of file L1GTObjectBoardWriter.cc.

Referenced by L1GTObjectBoardWriter::analyze(), L1GTObjectBoardWriter::fillDescriptions(), and L1GTObjectBoardWriter::L1GTObjectBoardWriter().