CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
L1GTFinOrBoardWriter Class Reference
Inheritance diagram for L1GTFinOrBoardWriter:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 L1GTFinOrBoardWriter (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void endJob () override
 

Private Attributes

const edm::EDGetTokenT< P2GTAlgoBlockMapalgoBlocksToken_
 
l1t::demo::BoardDataWriter boardDataWriter_
 
const unsigned int channelFinOr_
 
const std::array< unsigned int, 3 > channelsHigh_
 
const std::array< unsigned int, 3 > channelsLow_
 
const std::array< unsigned int, 3 > channelsMid_
 
unsigned int eventCounter_
 
std::map< l1t::demo::LinkId, std::vector< ap_uint< 64 > > > linkData_
 
const unsigned int maxEvents_
 
std::size_t tmuxCounter_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 32 of file L1GTFinOrBoardWriter.cc.

Constructor & Destructor Documentation

◆ L1GTFinOrBoardWriter()

L1GTFinOrBoardWriter::L1GTFinOrBoardWriter ( const edm::ParameterSet config)
explicit

Definition at line 67 of file L1GTFinOrBoardWriter.cc.

References channelFinOr_, channelsHigh_, channelsLow_, and channelsMid_.

68  : eventCounter_(0),
69  maxEvents_(config.getUntrackedParameter<unsigned int>("maxEvents")),
70  channelsLow_(convert<unsigned int, 3>(config.getUntrackedParameter<std::vector<unsigned int>>("channelsLow"),
71  "channelsLow")),
72  channelsMid_(convert<unsigned int, 3>(config.getUntrackedParameter<std::vector<unsigned int>>("channelsMid"),
73  "channelsMid")),
74  channelsHigh_(convert<unsigned int, 3>(config.getUntrackedParameter<std::vector<unsigned int>>("channelsHigh"),
75  "channelsHigh")),
76  channelFinOr_(config.getUntrackedParameter<unsigned int>("channelFinOr")),
77  algoBlocksToken_(consumes<P2GTAlgoBlockMap>(config.getUntrackedParameter<edm::InputTag>("algoBlocksTag"))),
78  boardDataWriter_(l1t::demo::parseFileFormat(config.getUntrackedParameter<std::string>("patternFormat")),
79  config.getUntrackedParameter<std::string>("filename"),
80  config.getUntrackedParameter<std::string>("fileExtension"),
81  9,
82  2,
83  config.getUntrackedParameter<unsigned int>("maxFrames"),
84  [&]() {
85  l1t::demo::BoardDataWriter::ChannelMap_t channelMap;
86  channelMap.insert({l1t::demo::LinkId{"BeforeBxMaskAndPrescaleLow", channelsLow_[0]},
87  {l1t::demo::ChannelSpec{2, 0, 0}, {channelsLow_[0]}}});
88  channelMap.insert({l1t::demo::LinkId{"BeforePrescaleLow", channelsLow_[1]},
89  {l1t::demo::ChannelSpec{2, 0, 0}, {channelsLow_[1]}}});
90  channelMap.insert({l1t::demo::LinkId{"FinalLow", channelsLow_[2]},
91  {l1t::demo::ChannelSpec{2, 0, 0}, {channelsLow_[2]}}});
92 
93  channelMap.insert({l1t::demo::LinkId{"BeforeBxMaskAndPrescaleMid", channelsMid_[0]},
94  {l1t::demo::ChannelSpec{2, 0, 0}, {channelsMid_[0]}}});
95  channelMap.insert({l1t::demo::LinkId{"BeforePrescaleMid", channelsMid_[1]},
96  {l1t::demo::ChannelSpec{2, 0, 0}, {channelsMid_[1]}}});
97  channelMap.insert({l1t::demo::LinkId{"FinalMid", channelsMid_[2]},
98  {l1t::demo::ChannelSpec{2, 0, 0}, {channelsMid_[2]}}});
99 
100  channelMap.insert({l1t::demo::LinkId{"BeforeBxMaskAndPrescaleHigh", channelsHigh_[0]},
101  {l1t::demo::ChannelSpec{2, 0, 0}, {channelsHigh_[0]}}});
102  channelMap.insert({l1t::demo::LinkId{"BeforePrescaleHigh", channelsHigh_[1]},
103  {l1t::demo::ChannelSpec{2, 0, 0}, {channelsHigh_[1]}}});
104  channelMap.insert({l1t::demo::LinkId{"FinalHigh", channelsHigh_[2]},
105  {l1t::demo::ChannelSpec{2, 0, 0}, {channelsHigh_[2]}}});
106 
107  channelMap.insert({l1t::demo::LinkId{"FinOr", channelFinOr_},
108  {l1t::demo::ChannelSpec{2, 0, 0}, {channelFinOr_}}});
109 
110  return channelMap;
111  }()),
112  linkData_(),
113  tmuxCounter_(0) {}
std::map< l1t::demo::LinkId, std::vector< ap_uint< 64 > > > linkData_
Logical ID for link within any given time slice (e.g. ["tracks", 0] -> ["tracks", 17] for links from ...
Definition: LinkId.h:10
FileFormat parseFileFormat(const std::string &)
Definition: utilities.cc:73
Definition: config.py:1
const std::array< unsigned int, 3 > channelsMid_
const unsigned int maxEvents_
const edm::EDGetTokenT< P2GTAlgoBlockMap > algoBlocksToken_
const unsigned int channelFinOr_
const std::array< unsigned int, 3 > channelsHigh_
const std::array< unsigned int, 3 > channelsLow_
l1t::demo::BoardDataWriter boardDataWriter_

Member Function Documentation

◆ analyze()

void L1GTFinOrBoardWriter::analyze ( const edm::Event event,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 115 of file L1GTFinOrBoardWriter.cc.

References l1t::demo::BoardDataWriter::addEvent(), algoBlocksToken_, MillePedeAlignmentAlgorithm_cfi::algoName, boardDataWriter_, channelFinOr_, channelsHigh_, channelsLow_, channelsMid_, eventCounter_, l1t::demo::BoardDataWriter::flush(), heavyIonCSV_trainingSettings::idx, linkData_, maxEvents_, and tmuxCounter_.

115  {
116  const P2GTAlgoBlockMap& algoBlocks = event.get(algoBlocksToken_);
117 
118  auto algoBlockIt = algoBlocks.begin();
119 
120  if (tmuxCounter_ == 0) {
121  linkData_[l1t::demo::LinkId{"BeforeBxMaskAndPrescaleLow", channelsLow_[0]}] = std::vector<ap_uint<64>>(18, 0);
122  linkData_[l1t::demo::LinkId{"BeforePrescaleLow", channelsLow_[1]}] = std::vector<ap_uint<64>>(18, 0);
123  linkData_[l1t::demo::LinkId{"FinalLow", channelsLow_[2]}] = std::vector<ap_uint<64>>(18, 0);
124  linkData_[l1t::demo::LinkId{"BeforeBxMaskAndPrescaleMid", channelsMid_[0]}] = std::vector<ap_uint<64>>(18, 0);
125  linkData_[l1t::demo::LinkId{"BeforePrescaleMid", channelsMid_[1]}] = std::vector<ap_uint<64>>(18, 0);
126  linkData_[l1t::demo::LinkId{"FinalMid", channelsMid_[2]}] = std::vector<ap_uint<64>>(18, 0);
127  linkData_[l1t::demo::LinkId{"BeforeBxMaskAndPrescaleHigh", channelsHigh_[0]}] = std::vector<ap_uint<64>>(18, 0);
128  linkData_[l1t::demo::LinkId{"BeforePrescaleHigh", channelsHigh_[1]}] = std::vector<ap_uint<64>>(18, 0);
129  linkData_[l1t::demo::LinkId{"FinalHigh", channelsHigh_[2]}] = std::vector<ap_uint<64>>(18, 0);
130  linkData_[l1t::demo::LinkId{"FinOr", channelFinOr_}] = std::vector<ap_uint<64>>(18, 0);
131  }
132 
133  for (std::size_t word = 0; word < 9; word++) {
134  for (std::size_t idx = 0; idx < 64 && algoBlockIt != algoBlocks.end(); idx++, algoBlockIt++) {
135  auto& [alogName, algoBlock] = *algoBlockIt;
136  linkData_[l1t::demo::LinkId{"BeforeBxMaskAndPrescaleLow", channelsLow_[0]}][word + tmuxCounter_ * 9].set(
137  idx, algoBlock.decisionBeforeBxMaskAndPrescale());
138  linkData_[l1t::demo::LinkId{"BeforePrescaleLow", channelsLow_[1]}][word + tmuxCounter_ * 9].set(
139  idx, algoBlock.decisionBeforePrescale());
140  linkData_[l1t::demo::LinkId{"FinalLow", channelsLow_[2]}][word + tmuxCounter_ * 9].set(idx,
141  algoBlock.decisionFinal());
142  }
143  }
144 
145  for (std::size_t word = 0; word < 9; word++) {
146  for (std::size_t idx = 0; idx < 64 && algoBlockIt != algoBlocks.end(); idx++, algoBlockIt++) {
147  auto& [alogName, algoBlock] = *algoBlockIt;
148  linkData_[l1t::demo::LinkId{"BeforeBxMaskAndPrescaleMid", channelsMid_[0]}][word + tmuxCounter_ * 9].set(
149  idx, algoBlock.decisionBeforeBxMaskAndPrescale());
150  linkData_[l1t::demo::LinkId{"BeforePrescaleMid", channelsMid_[1]}][word + tmuxCounter_ * 9].set(
151  idx, algoBlock.decisionBeforePrescale());
152  linkData_[l1t::demo::LinkId{"FinalMid", channelsMid_[2]}][word + tmuxCounter_ * 9].set(idx,
153  algoBlock.decisionFinal());
154  }
155  }
156 
157  for (std::size_t word = 0; word < 9; word++) {
158  for (std::size_t idx = 0; idx < 64 && algoBlockIt != algoBlocks.end(); idx++, algoBlockIt++) {
159  auto& [algoName, algoBlock] = *algoBlockIt;
160  linkData_[l1t::demo::LinkId{"BeforeBxMaskAndPrescaleHigh", channelsHigh_[0]}][word + tmuxCounter_ * 9].set(
161  idx, algoBlock.decisionBeforeBxMaskAndPrescale());
162  linkData_[l1t::demo::LinkId{"BeforePrescaleHigh", channelsHigh_[1]}][word + tmuxCounter_ * 9].set(
163  idx, algoBlock.decisionBeforePrescale());
164  linkData_[l1t::demo::LinkId{"FinalHigh", channelsHigh_[2]}][word + tmuxCounter_ * 9].set(
165  idx, algoBlock.decisionFinal());
166  }
167  }
168 
169  bool vetoed = false, vetoedPreview = false;
170  int finOrByTypes = 0, finOrPreviewByTypes = 0;
171  for (auto algoBlockIt = algoBlocks.begin(); algoBlockIt != algoBlocks.end(); algoBlockIt++) {
172  auto& [alogName, algoBlock] = *algoBlockIt;
173  vetoed |= (algoBlock.isVeto() && algoBlock.decisionFinal());
174  vetoedPreview |= (algoBlock.isVeto() && algoBlock.decisionFinalPreview());
175  finOrByTypes |= algoBlock.decisionFinal() ? algoBlock.triggerTypes() : 0;
176  finOrPreviewByTypes |= algoBlock.decisionFinalPreview() ? algoBlock.triggerTypes() : 0;
177  }
178 
179  // Add FinOrTrigger bits per https://gitlab.cern.ch/cms-cactus/phase2/firmware/gt-final-or#output-finor-bits
180  ap_uint<64> finOrBits(0);
181  finOrBits(7, 0) = finOrByTypes;
182  finOrBits(15, 8) = finOrPreviewByTypes;
183  finOrBits(23, 16) = vetoed ? 0 : finOrByTypes;
184  finOrBits(31, 24) = vetoedPreview ? 0 : finOrPreviewByTypes;
185 
186  linkData_[l1t::demo::LinkId{"FinOr", channelFinOr_}][0 + tmuxCounter_ * 9] = finOrBits;
187 
188  if (tmuxCounter_ == 1) {
190  }
191 
192  tmuxCounter_ = (tmuxCounter_ + 1) % 2;
193 
194  eventCounter_++;
195 
196  if (maxEvents_ != 0 && eventCounter_ == maxEvents_) {
198  eventCounter_ = 0;
199  }
200 }
std::map< l1t::demo::LinkId, std::vector< ap_uint< 64 > > > linkData_
Logical ID for link within any given time slice (e.g. ["tracks", 0] -> ["tracks", 17] for links from ...
Definition: LinkId.h:10
void addEvent(const EventData &data)
std::map< std::string, P2GTAlgoBlock > P2GTAlgoBlockMap
Definition: P2GTAlgoBlock.h:11
const std::array< unsigned int, 3 > channelsMid_
const unsigned int maxEvents_
uint64_t word
const edm::EDGetTokenT< P2GTAlgoBlockMap > algoBlocksToken_
const unsigned int channelFinOr_
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
const std::array< unsigned int, 3 > channelsHigh_
const std::array< unsigned int, 3 > channelsLow_
l1t::demo::BoardDataWriter boardDataWriter_

◆ endJob()

void L1GTFinOrBoardWriter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 202 of file L1GTFinOrBoardWriter.cc.

References l1t::demo::BoardDataWriter::addEvent(), boardDataWriter_, l1t::demo::BoardDataWriter::flush(), linkData_, and tmuxCounter_.

202  {
203  if (tmuxCounter_ == 1) {
205  }
206 
208 }
std::map< l1t::demo::LinkId, std::vector< ap_uint< 64 > > > linkData_
void addEvent(const EventData &data)
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_

◆ fillDescriptions()

void L1GTFinOrBoardWriter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 210 of file L1GTFinOrBoardWriter.cc.

References edm::ConfigurationDescriptions::addDefault(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

210  {
212  desc.addUntracked<std::string>("filename");
213  desc.addUntracked<std::string>("fileExtension", "txt");
214  desc.addUntracked<edm::InputTag>("algoBlocksTag");
215  desc.addUntracked<std::vector<unsigned int>>("channelsLow");
216  desc.addUntracked<std::vector<unsigned int>>("channelsMid");
217  desc.addUntracked<std::vector<unsigned int>>("channelsHigh");
218  desc.addUntracked<unsigned int>("channelFinOr");
219  desc.addUntracked<unsigned int>("maxFrames", 1024);
220  desc.addUntracked<unsigned int>("maxEvents", 0);
221  desc.addUntracked<std::string>("patternFormat", "EMPv2");
222 
223  descriptions.addDefault(desc);
224 }
void addDefault(ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ algoBlocksToken_

const edm::EDGetTokenT<P2GTAlgoBlockMap> L1GTFinOrBoardWriter::algoBlocksToken_
private

Definition at line 48 of file L1GTFinOrBoardWriter.cc.

Referenced by analyze().

◆ boardDataWriter_

l1t::demo::BoardDataWriter L1GTFinOrBoardWriter::boardDataWriter_
private

Definition at line 49 of file L1GTFinOrBoardWriter.cc.

Referenced by analyze(), and endJob().

◆ channelFinOr_

const unsigned int L1GTFinOrBoardWriter::channelFinOr_
private

Definition at line 47 of file L1GTFinOrBoardWriter.cc.

Referenced by analyze(), and L1GTFinOrBoardWriter().

◆ channelsHigh_

const std::array<unsigned int, 3> L1GTFinOrBoardWriter::channelsHigh_
private

Definition at line 46 of file L1GTFinOrBoardWriter.cc.

Referenced by analyze(), and L1GTFinOrBoardWriter().

◆ channelsLow_

const std::array<unsigned int, 3> L1GTFinOrBoardWriter::channelsLow_
private

Definition at line 44 of file L1GTFinOrBoardWriter.cc.

Referenced by analyze(), and L1GTFinOrBoardWriter().

◆ channelsMid_

const std::array<unsigned int, 3> L1GTFinOrBoardWriter::channelsMid_
private

Definition at line 45 of file L1GTFinOrBoardWriter.cc.

Referenced by analyze(), and L1GTFinOrBoardWriter().

◆ eventCounter_

unsigned int L1GTFinOrBoardWriter::eventCounter_
private

Definition at line 42 of file L1GTFinOrBoardWriter.cc.

Referenced by analyze().

◆ linkData_

std::map<l1t::demo::LinkId, std::vector<ap_uint<64> > > L1GTFinOrBoardWriter::linkData_
private

Definition at line 51 of file L1GTFinOrBoardWriter.cc.

Referenced by analyze(), and endJob().

◆ maxEvents_

const unsigned int L1GTFinOrBoardWriter::maxEvents_
private

Definition at line 43 of file L1GTFinOrBoardWriter.cc.

Referenced by analyze().

◆ tmuxCounter_

std::size_t L1GTFinOrBoardWriter::tmuxCounter_
private

Definition at line 52 of file L1GTFinOrBoardWriter.cc.

Referenced by analyze(), and endJob().