CMS 3D CMS Logo

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 &)
 
 ~L1TDigiToRaw () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 47 of file L1TDigiToRaw.cc.

Constructor & Destructor Documentation

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

Definition at line 81 of file L1TDigiToRaw.cc.

References evtType_, fwId_, l1t::PackingSetupFactory::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), l1t::PackingSetupFactory::make(), setup_, slinkHeaderSize_, slinkTrailerSize_, AlCaHLTBitMon_QueryRunRegistry::string, and tokens_.

81  :
82  fedId_(config.getParameter<int>("FedId")),
83  ctp7_mode_(config.getUntrackedParameter<bool>("CTP7"))
84  {
85  // Register products
86  produces<FEDRawDataCollection>();
87 
88  fwId_ = config.getParameter<unsigned int>("FWId");
89  evtType_ = config.getUntrackedParameter<int>("eventType", 1);
90 
91  auto cc = edm::ConsumesCollector(consumesCollector());
92 
94  tokens_ = setup_->registerConsumes(config, cc);
95 
96  slinkHeaderSize_ = config.getUntrackedParameter<int>("lenSlinkHeader", 8);
97  slinkTrailerSize_ = config.getUntrackedParameter<int>("lenSlinkTrailer", 8);
98  }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< PackerTokens > tokens_
Definition: L1TDigiToRaw.cc:74
std::unique_ptr< PackingSetup > setup_
Definition: L1TDigiToRaw.cc:73
std::unique_ptr< PackingSetup > make(const std::string &) const
static const PackingSetupFactory * get()
L1TDigiToRaw::~L1TDigiToRaw ( )
override

Definition at line 101 of file L1TDigiToRaw.cc.

102  {
103  }

Member Function Documentation

void l1t::L1TDigiToRaw::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
inlineoverrideprivate

Definition at line 61 of file L1TDigiToRaw.cc.

61 {};
void l1t::L1TDigiToRaw::beginRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverrideprivate

Definition at line 59 of file L1TDigiToRaw.cc.

59 {};
void l1t::L1TDigiToRaw::endLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
inlineoverrideprivate

Definition at line 62 of file L1TDigiToRaw.cc.

62 {};
void l1t::L1TDigiToRaw::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverrideprivate

Definition at line 60 of file L1TDigiToRaw.cc.

60 {};
void L1TDigiToRaw::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 246 of file L1TDigiToRaw.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), edm::ParameterSetDescription::addUntracked(), DEFINE_FWK_MODULE, l1t::PackingSetupFactory::fillDescription(), l1t::PackingSetupFactory::get(), and AlCaHLTBitMon_QueryRunRegistry::string.

246  {
248  desc.add<unsigned int>("FWId", -1);
249  desc.add<int>("FedId");
250  desc.addUntracked<int>("eventType", 1);
251  desc.add<std::string>("Setup");
252  desc.addOptional<edm::InputTag>("InputLabel",edm::InputTag(""));
253  desc.addOptional<edm::InputTag>("InputLabel2",edm::InputTag(""));
254  desc.addUntracked<int>("lenSlinkHeader", 8);
255  desc.addUntracked<int>("lenSlinkTrailer", 8);
256  desc.addUntracked<bool>("CTP7", false);
257 
259 
260  descriptions.add("l1tDigiToRaw", desc);
261  }
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void fillDescription(edm::ParameterSetDescription &) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static const PackingSetupFactory * get()
void L1TDigiToRaw::produce ( edm::Event event,
const edm::EventSetup setup 
)
overrideprivate

Definition at line 107 of file L1TDigiToRaw.cc.

References amc13::Packet::add(), groupFilesInBlocks::block, gather_cfg::blocks, evf::compute_crc(), l1t::CTP7, ctp7_mode_, FEDRawData::data(), evtType_, fedId_, fwId_, RecoTauValidation_cfi::header, mps_fire::i, svgfig::load(), LogDebug, eostools::move(), jets_cff::payload, FEDRawData::resize(), alignCSCRings::s, FEDHeader::set(), FEDTrailer::set(), setup_, amc13::Packet::size(), findQualityFiles::size, slinkHeaderSize_, slinkTrailerSize_, jetUpdater_cfi::sort, tokens_, and amc13::Packet::write().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

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

Member Data Documentation

bool l1t::L1TDigiToRaw::ctp7_mode_
private

Definition at line 76 of file L1TDigiToRaw.cc.

Referenced by produce().

int l1t::L1TDigiToRaw::evtType_
private

Definition at line 62 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().

int l1t::L1TDigiToRaw::fedId_
private

Definition at line 66 of file L1TDigiToRaw.cc.

Referenced by produce().

unsigned l1t::L1TDigiToRaw::fwId_
private

Definition at line 67 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().

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

Definition at line 73 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().

int l1t::L1TDigiToRaw::slinkHeaderSize_
private

Definition at line 70 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().

int l1t::L1TDigiToRaw::slinkTrailerSize_
private

Definition at line 71 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().

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

Definition at line 74 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().