CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
L1TCtL2EgProducer::PatternWriter Class Reference

Classes

struct  RegionLinkMetadata
 

Public Member Functions

void addEvent (const l1t::demo::EventData &eventData)
 
void flush ()
 
 PatternWriter (const edm::ParameterSet &conf)
 
const RegionLinkMetadataregion2Link (unsigned int region) const
 

Private Attributes

std::unique_ptr< l1t::demo::BoardDataWriterdataWriter_
 
uint32_t enventIndex_
 
uint32_t nEvPerFile_
 
std::vector< RegionLinkMetadataregion2link_
 

Detailed Description

Definition at line 76 of file L1TCtL2EgProducer.cc.

Constructor & Destructor Documentation

◆ PatternWriter()

L1TCtL2EgProducer::PatternWriter::PatternWriter ( const edm::ParameterSet conf)
inline

Definition at line 78 of file L1TCtL2EgProducer.cc.

References edm::ParameterSet::getParameter(), createfilelist::int, l1ctLayer2EG_cff::interface, l1ctLayer2EG_cff::nFramesPerBX, l1t::demo::parseFileFormat(), and AlCaHLTBitMon_QueryRunRegistry::string.

79  : region2link_(5),
80  dataWriter_(nullptr),
81  nEvPerFile_(conf.getParameter<uint32_t>("eventsPerFile")),
82  enventIndex_(0) {
83  unsigned int nFramesPerBX = conf.getParameter<uint32_t>("nFramesPerBX");
84 
85  std::map<l1t::demo::LinkId, std::pair<l1t::demo::ChannelSpec, std::vector<size_t>>> channelSpecs;
86 
87  for (const auto &channelConf : conf.getParameter<std::vector<edm::ParameterSet>>("channels")) {
88  unsigned int inTMUX = channelConf.getParameter<uint32_t>("TMUX");
89  unsigned int eventGap =
90  inTMUX * nFramesPerBX - channelConf.getParameter<uint32_t>("nWords"); // assuming 96bit (= 3/2 word)
91  // words = TMUX*9-2*3/2*words
92 
93  std::vector<uint32_t> chns = channelConf.getParameter<std::vector<uint32_t>>("channels");
94 
95  std::string interface = channelConf.getParameter<std::string>("interface");
96  unsigned int chId = channelConf.getParameter<uint32_t>("id");
97  l1t::demo::LinkId linkId{interface, size_t(chId)};
98  channelSpecs[linkId] = std::make_pair(l1t::demo::ChannelSpec{inTMUX, eventGap},
99  std::vector<size_t>(std::begin(chns), std::end(chns)));
100 
101  // NOTE: this could be parametrized from CFG
102  if (inTMUX == 6) {
103  if (interface == "eglayer1Barrel" || interface == "eglayer1Endcap") {
104  // Layer1 TMUX=6 => each one of the regions is mapped to a link
105  // with the same ID
106  // # of words = 16 (pho) + 2*16 (ele) = 48
107  // no filling words needed
108  region2link_[chId] = RegionLinkMetadata{linkId, 0};
109  }
110  } else if (inTMUX == 18) {
111  if (interface == "eglayer1Barrel") {
112  // Layer1 TMUX=18 => 3 regions are mapped to the same link
113  // one every 6 BX x 9 words = 54 words
114  // # of data words = 16 (pho) + 2*16 (ele) = 48
115  // # we fill with 54-48 = 6 empty words
116  region2link_[0] = RegionLinkMetadata{linkId, 6};
117  region2link_[1] = RegionLinkMetadata{linkId, 6};
118  region2link_[2] = RegionLinkMetadata{linkId, 0};
119  } else if (interface == "eglayer1Endcap") {
120  // Layer1 TMUX=18 => 2 endcap regions are mapped to the same link
121  // one every 9 BX x 9 words = 81 words
122  // # of data words = 16 (pho) + 2*16 (ele) = 48
123  // # we fill with 81-48 = 33 empty words
124  region2link_[3] = RegionLinkMetadata{linkId, 33};
125  region2link_[4] = RegionLinkMetadata{linkId, 0};
126  }
127  }
128  }
129 
130  dataWriter_ = std::make_unique<l1t::demo::BoardDataWriter>(
132  conf.getParameter<std::string>("outputFilename"),
133  conf.getParameter<std::string>("outputFileExtension"),
134  nFramesPerBX,
135  conf.getParameter<uint32_t>("TMUX"),
136  conf.getParameter<uint32_t>("maxLinesPerFile"),
137  channelSpecs);
138  }
std::unique_ptr< l1t::demo::BoardDataWriter > dataWriter_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
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
std::vector< RegionLinkMetadata > region2link_

Member Function Documentation

◆ addEvent()

void L1TCtL2EgProducer::PatternWriter::addEvent ( const l1t::demo::EventData eventData)
inline

Definition at line 145 of file L1TCtL2EgProducer.cc.

145  {
146  dataWriter_->addEvent(eventData);
147  enventIndex_++;
148  if (enventIndex_ % nEvPerFile_ == 0)
149  dataWriter_->flush();
150  }
std::unique_ptr< l1t::demo::BoardDataWriter > dataWriter_

◆ flush()

void L1TCtL2EgProducer::PatternWriter::flush ( )
inline

Definition at line 152 of file L1TCtL2EgProducer.cc.

152 { dataWriter_->flush(); }
std::unique_ptr< l1t::demo::BoardDataWriter > dataWriter_

◆ region2Link()

const RegionLinkMetadata& L1TCtL2EgProducer::PatternWriter::region2Link ( unsigned int  region) const
inline

Definition at line 154 of file L1TCtL2EgProducer.cc.

References cms::cuda::assert(), and nano_mu_digi_cff::region.

154  {
155  assert(region < region2link_.size());
156  return region2link_.at(region);
157  }
assert(be >=bs)
std::vector< RegionLinkMetadata > region2link_

Member Data Documentation

◆ dataWriter_

std::unique_ptr<l1t::demo::BoardDataWriter> L1TCtL2EgProducer::PatternWriter::dataWriter_
private

Definition at line 162 of file L1TCtL2EgProducer.cc.

◆ enventIndex_

uint32_t L1TCtL2EgProducer::PatternWriter::enventIndex_
private

Definition at line 164 of file L1TCtL2EgProducer.cc.

◆ nEvPerFile_

uint32_t L1TCtL2EgProducer::PatternWriter::nEvPerFile_
private

Definition at line 163 of file L1TCtL2EgProducer.cc.

◆ region2link_

std::vector<RegionLinkMetadata> L1TCtL2EgProducer::PatternWriter::region2link_
private

Definition at line 160 of file L1TCtL2EgProducer.cc.