CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
l1t::L1TDigiToRaw Class Reference
Inheritance diagram for l1t::L1TDigiToRaw:
edm::stream::EDProducer<>

Public Member Functions

 L1TDigiToRaw (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

bool ctp7_mode_
 
int evtType_
 
int fedId_
 
unsigned fwId_
 
std::unique_ptr< PackingSetupsetup_
 
int slinkHeaderSize_
 
int slinkTrailerSize_
 
std::unique_ptr< PackerTokenstokens_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 47 of file L1TDigiToRaw.cc.

Constructor & Destructor Documentation

◆ L1TDigiToRaw()

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

Definition at line 73 of file L1TDigiToRaw.cc.

References gpuPixelDoublets::cc, evtType_, fwId_, l1t::PackingSetupFactory::get(), l1t::PackingSetupFactory::make(), setup_, slinkHeaderSize_, slinkTrailerSize_, AlCaHLTBitMon_QueryRunRegistry::string, and tokens_.

74  : fedId_(config.getParameter<int>("FedId")), ctp7_mode_(config.getUntrackedParameter<bool>("CTP7")) {
75  // Register products
76  produces<FEDRawDataCollection>();
77 
78  fwId_ = config.getParameter<unsigned int>("FWId");
79  evtType_ = config.getUntrackedParameter<int>("eventType", 1);
80 
81  auto cc = edm::ConsumesCollector(consumesCollector());
82 
83  setup_ = PackingSetupFactory::get()->make(config.getParameter<std::string>("Setup"));
84  tokens_ = setup_->registerConsumes(config, cc);
85 
86  slinkHeaderSize_ = config.getUntrackedParameter<int>("lenSlinkHeader", 8);
87  slinkTrailerSize_ = config.getUntrackedParameter<int>("lenSlinkTrailer", 8);
88  }
std::unique_ptr< PackerTokens > tokens_
Definition: L1TDigiToRaw.cc:66
std::unique_ptr< PackingSetup > setup_
Definition: L1TDigiToRaw.cc:65
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
Definition: config.py:1
std::unique_ptr< PackingSetup > make(const std::string &) const
static const PackingSetupFactory * get()

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 229 of file L1TDigiToRaw.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, l1t::PackingSetupFactory::fillDescription(), l1t::PackingSetupFactory::get(), ProducerED_cfi::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

229  {
231  desc.add<unsigned int>("FWId", -1);
232  desc.add<int>("FedId");
233  desc.addUntracked<int>("eventType", 1);
234  desc.add<std::string>("Setup");
235  desc.addOptional<edm::InputTag>("InputLabel", edm::InputTag(""));
236  desc.addOptional<edm::InputTag>("InputLabel2", edm::InputTag(""));
237  desc.addUntracked<int>("lenSlinkHeader", 8);
238  desc.addUntracked<int>("lenSlinkTrailer", 8);
239  desc.addUntracked<bool>("CTP7", false);
240 
242 
243  descriptions.add("l1tDigiToRaw", desc);
244  }
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static const PackingSetupFactory * get()
void fillDescription(edm::ParameterSetDescription &) const

◆ produce()

void L1TDigiToRaw::produce ( edm::Event event,
const edm::EventSetup setup 
)
overrideprivate

Definition at line 91 of file L1TDigiToRaw.cc.

References groupFilesInBlocks::block, gather_cfg::blocks, evf::compute_crc(), l1t::CTP7, ctp7_mode_, FEDRawData::data(), evtType_, fedId_, EcalFEDMonitor_cfi::FEDRawDataCollection, fwId_, RecoTauValidation_cfi::header, mps_fire::i, B2GTnPMonitor_cfi::item, svgfig::load(), LogDebug, eostools::move(), jetsAK4_Puppi_cff::payload, FEDRawData::resize(), alignCSCRings::s, FEDTrailer::set(), setup_, slinkHeaderSize_, slinkTrailerSize_, jetUpdater_cfi::sort, and tokens_.

91  {
92  using namespace edm;
93 
94  LogDebug("L1T") << "Packing data with FED ID " << fedId_;
95 
97 
98  auto bxId = event.bunchCrossing();
99  // Note: L1ID != event ID
100  // See e.g. triggerCount vs. eventNumber
101  // in EventFilter/FEDInterface/interface/FED1024.h
102  // But the trigger count is not stored in cmssw event class
103  auto evtId = event.id().event();
104  auto orbit = event.eventAuxiliary().orbitNumber();
105  LogDebug("L1T") << "Forming FED with metadata bxId=" << bxId << ", l1ID=" << evtId << ", orbit=" << orbit;
106 
107  // Create all the AMC payloads to pack into the AMC13
108  for (const auto& item : setup_->getPackers(fedId_, fwId_)) {
109  auto amc_no = item.first.first;
110  auto board = item.first.second;
111  auto packers = item.second;
112 
113  Blocks block_load;
114  for (const auto& packer : packers) {
115  LogDebug("L1T") << "Adding packed blocks";
116  packer->setBoard(board);
117  auto blocks = packer->pack(event, tokens_.get());
118  block_load.insert(block_load.end(), blocks.begin(), blocks.end());
119  }
120 
121  std::sort(block_load.begin(), block_load.end());
122 
123  LogDebug("L1T") << "Concatenating blocks";
124 
125  std::vector<uint32_t> load32;
126  // CTP7 stores this info in AMC user header
127  if (not ctp7_mode_) {
128  // TODO Infrastructure firmware version. Currently not used.
129  // Would change the way the payload has to be unpacked.
130  load32.push_back(0);
131  load32.push_back(fwId_);
132  }
133  for (const auto& block : block_load) {
134  LogDebug("L1T") << "Adding block " << block.header().getID() << " with size " << block.payload().size();
135  auto load = block.payload();
136 
137 #ifdef EDM_ML_DEBUG
138  std::stringstream s("");
139  s << "Block content:" << std::endl << std::hex << std::setfill('0');
140  for (const auto& word : load)
141  s << std::setw(8) << word << std::endl;
142  LogDebug("L1T") << s.str();
143 #endif
144 
145  if (block.header().getType() == CTP7) {
146  // Header is two words for CTP7, first word is just a magic
147  load32.push_back(0xA110CA7E);
148  }
149  load32.push_back(block.header().raw());
150  load32.insert(load32.end(), load.begin(), load.end());
151  }
152 
153  LogDebug("L1T") << "Converting payload";
154 
155  std::vector<uint64_t> load64;
156  for (unsigned int i = 0; i < load32.size(); i += 2) {
157  uint64_t word = load32[i];
158  if (i + 1 < load32.size()) {
159  word |= static_cast<uint64_t>(load32[i + 1]) << 32;
160  } else {
161  word |= static_cast<uint64_t>(0xffffffff) << 32;
162  }
163  load64.push_back(word);
164  }
165 
166  LogDebug("L1T") << "Creating AMC packet";
167 
168  unsigned amc_user_header = 0;
169  if (ctp7_mode_)
170  amc_user_header = fwId_;
171  amc13.add(amc_no, board, evtId, orbit, bxId, load64, amc_user_header);
172  }
173 
174  std::unique_ptr<FEDRawDataCollection> raw_coll(new FEDRawDataCollection());
175  FEDRawData& fed_data = raw_coll->FEDData(fedId_);
176 
177  unsigned int size = slinkHeaderSize_ + slinkTrailerSize_ + amc13.size() * 8;
178  fed_data.resize(size);
179  unsigned char* payload = fed_data.data();
180  unsigned char* payload_start = payload;
181 
183  header.set(payload, evtType_, evtId, bxId, fedId_);
184 
186 
188  payload += amc13.size() * 8;
189 
190  FEDTrailer trailer(payload);
191  trailer.set(payload, size / 8, evf::compute_crc(payload_start, size), 0, 0);
192 
193  event.put(std::move(raw_coll));
194  }
size
Write out results.
std::unique_ptr< PackerTokens > tokens_
Definition: L1TDigiToRaw.cc:66
std::unique_ptr< PackingSetup > setup_
Definition: L1TDigiToRaw.cc:65
uint64_t word
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:46
std::vector< Block > Blocks
Definition: Block.h:99
unsigned long long uint64_t
Definition: Time.h:13
def load(fileName)
Definition: svgfig.py:547
void resize(size_t newsize, size_t wordsize=8)
Definition: FEDRawData.cc:28
HLT enums.
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
#define LogDebug(id)

Member Data Documentation

◆ ctp7_mode_

bool l1t::L1TDigiToRaw::ctp7_mode_
private

Definition at line 68 of file L1TDigiToRaw.cc.

Referenced by produce().

◆ evtType_

int l1t::L1TDigiToRaw::evtType_
private

Definition at line 57 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().

◆ fedId_

int l1t::L1TDigiToRaw::fedId_
private

Definition at line 58 of file L1TDigiToRaw.cc.

Referenced by produce().

◆ fwId_

unsigned l1t::L1TDigiToRaw::fwId_
private

Definition at line 59 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().

◆ setup_

std::unique_ptr<PackingSetup> l1t::L1TDigiToRaw::setup_
private

◆ slinkHeaderSize_

int l1t::L1TDigiToRaw::slinkHeaderSize_
private

Definition at line 62 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().

◆ slinkTrailerSize_

int l1t::L1TDigiToRaw::slinkTrailerSize_
private

Definition at line 63 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().

◆ tokens_

std::unique_ptr<PackerTokens> l1t::L1TDigiToRaw::tokens_
private

Definition at line 66 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().