CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
l1t::L1TRawToDigi Class Reference
Inheritance diagram for l1t::L1TRawToDigi:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 L1TRawToDigi (const edm::ParameterSet &)
 
 ~L1TRawToDigi ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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::vector< ModuleDescription const * > &modules, 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
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

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

Private Member Functions

virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &) override
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
virtual void endRun (edm::Run const &, edm::EventSetup const &) override
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

int amc13HeaderSize_
 
int amc13TrailerSize_
 
int amcHeaderSize_
 
int amcTrailerSize_
 
bool ctp7_mode_
 
bool debug_
 
edm::EDGetTokenT< FEDRawDataCollectionfedData_
 
std::vector< int > fedIds_
 
unsigned int fwId_
 
bool fwOverride_
 
unsigned int minFeds_
 
bool mtf7_mode_
 
std::unique_ptr< PackingSetupprov_
 
int slinkHeaderSize_
 
int slinkTrailerSize_
 
int warnsa_
 
int warnsb_
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- 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)
 
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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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)
 

Detailed Description

Definition at line 43 of file L1TRawToDigi.cc.

Constructor & Destructor Documentation

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

Definition at line 89 of file L1TRawToDigi.cc.

References amc13HeaderSize_, amc13TrailerSize_, amcHeaderSize_, amcTrailerSize_, ctp7_mode_, debug_, Exception, fedData_, l1t::PackingSetupFactory::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), l1t::PackingSetupFactory::make(), mtf7_mode_, prov_, slinkHeaderSize_, slinkTrailerSize_, AlCaHLTBitMon_QueryRunRegistry::string, warnsa_, and warnsb_.

89  :
90  fedIds_(config.getParameter<std::vector<int>>("FedIds")),
91  minFeds_(config.getParameter<unsigned int>("MinFeds")),
92  fwId_(config.getParameter<unsigned int>("FWId")),
93  fwOverride_(config.getParameter<bool>("FWOverride")),
94  ctp7_mode_(config.getUntrackedParameter<bool>("CTP7")),
95  mtf7_mode_(config.getUntrackedParameter<bool>("MTF7"))
96  {
97  fedData_ = consumes<FEDRawDataCollection>(config.getParameter<edm::InputTag>("InputLabel"));
98 
99  if (ctp7_mode_ and mtf7_mode_) {
100  throw cms::Exception("L1TRawToDigi") << "Can only use one unpacking mode concurrently!";
101  }
102 
104  prov_->registerProducts(*this);
105 
106  slinkHeaderSize_ = config.getUntrackedParameter<int>("lenSlinkHeader");
107  slinkTrailerSize_ = config.getUntrackedParameter<int>("lenSlinkTrailer");
108  amcHeaderSize_ = config.getUntrackedParameter<int>("lenAMCHeader");
109  amcTrailerSize_ = config.getUntrackedParameter<int>("lenAMCTrailer");
110  amc13HeaderSize_ = config.getUntrackedParameter<int>("lenAMC13Header");
111  amc13TrailerSize_ = config.getUntrackedParameter<int>("lenAMC13Trailer");
112 
113  debug_ = config.getUntrackedParameter<bool>("debug");
114  warnsa_ = 0;
115  warnsb_ = 0;
116  }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< int > fedIds_
Definition: L1TRawToDigi.cc:60
std::unique_ptr< PackingSetup > make(const std::string &) const
unsigned int fwId_
Definition: L1TRawToDigi.cc:62
static const PackingSetupFactory * get()
unsigned int minFeds_
Definition: L1TRawToDigi.cc:61
std::unique_ptr< PackingSetup > prov_
Definition: L1TRawToDigi.cc:65
edm::EDGetTokenT< FEDRawDataCollection > fedData_
Definition: L1TRawToDigi.cc:56
L1TRawToDigi::~L1TRawToDigi ( )

Definition at line 119 of file L1TRawToDigi.cc.

120  {
121  }

Member Function Documentation

virtual void l1t::L1TRawToDigi::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
inlineoverrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 55 of file L1TRawToDigi.cc.

55 {};
virtual void l1t::L1TRawToDigi::beginRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 53 of file L1TRawToDigi.cc.

53 {};
virtual void l1t::L1TRawToDigi::endLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
inlineoverrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 56 of file L1TRawToDigi.cc.

56 {};
virtual void l1t::L1TRawToDigi::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 54 of file L1TRawToDigi.cc.

54 {};
void L1TRawToDigi::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 286 of file L1TRawToDigi.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), DEFINE_FWK_MODULE, and AlCaHLTBitMon_QueryRunRegistry::string.

286  {
288  // These parameters are part of the L1T/HLT interface, avoid changing if possible:
289  desc.add<std::vector<int>>("FedIds", {})->setComment("required parameter: default value is invalid");
290  desc.add<std::string>("Setup", "")->setComment("required parameter: default value is invalid");
291  // These parameters have well defined default values and are not currently
292  // part of the L1T/HLT interface. They can be cleaned up or updated at will:
293  desc.add<unsigned int>("FWId",0)->setComment("Ignored unless FWOverride is true. Calo Stage1: 32 bits: if the first eight bits are 0xff, will read the 74x MC format.\n");
294  desc.add<bool>("FWOverride", false)->setComment("Firmware version should be taken as FWId parameters");
295  desc.addUntracked<bool>("CTP7", false);
296  desc.addUntracked<bool>("MTF7", false);
297  desc.add<edm::InputTag>("InputLabel",edm::InputTag("rawDataCollector"));
298  desc.addUntracked<int>("lenSlinkHeader", 8);
299  desc.addUntracked<int>("lenSlinkTrailer", 8);
300  desc.addUntracked<int>("lenAMCHeader", 8);
301  desc.addUntracked<int>("lenAMCTrailer", 0);
302  desc.addUntracked<int>("lenAMC13Header", 8);
303  desc.addUntracked<int>("lenAMC13Trailer", 8);
304  desc.addUntracked<bool>("debug", false)->setComment("turn on verbose output");
305  desc.add<unsigned int>("MinFeds", 0)->setComment("optional parameter: warn if less than MinFeds non-empty FED ids unpacked.");
306  descriptions.add("l1tRawToDigi", desc);
307  }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void L1TRawToDigi::produce ( edm::Event event,
const edm::EventSetup setup 
)
overrideprivatevirtual

Definition at line 130 of file L1TRawToDigi.cc.

References amc13HeaderSize_, amc13TrailerSize_, amcHeaderSize_, amcTrailerSize_, groupFilesInBlocks::block, FEDHeader::bxID(), FEDTrailer::check(), FEDHeader::check(), coll, gather_cfg::cout, FEDTrailer::crc(), ctp7_mode_, FEDRawData::data(), data, debug_, TauDecayModes::dec, end, FEDTrailer::evtStatus(), FEDRawDataCollection::FEDData(), fedData_, fedIds_, fwId_, fwOverride_, RecoTauValidation_cfi::header, edm::HandleBase::isValid(), FEDTrailer::lenght(), LogDebug, FEDHeader::lvl1ID(), minFeds_, mtf7_mode_, amc13::Packet::parse(), jetCorrFactors_cfi::payload, amc13::Packet::payload(), prov_, FEDRawData::size(), slinkHeaderSize_, slinkTrailerSize_, FEDHeader::sourceID(), FEDHeader::triggerType(), FEDTrailer::ttsBits(), FEDHeader::version(), warnsa_, and warnsb_.

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

131  {
132  using namespace edm;
133 
134  std::unique_ptr<UnpackerCollections> coll = prov_->getCollections(event);
135 
137  event.getByToken(fedData_, feds);
138 
139  if (!feds.isValid()) {
140  LogError("L1T") << "Cannot unpack: no FEDRawDataCollection found";
141  return;
142  }
143 
144  unsigned valid_count = 0;
145  for (const auto& fedId: fedIds_) {
146  const FEDRawData& l1tRcd = feds->FEDData(fedId);
147 
148  LogDebug("L1T") << "Found FEDRawDataCollection with ID " << fedId << " and size " << l1tRcd.size();
149 
151  if (l1tRcd.size() > 0) {
152  LogError("L1T") << "Cannot unpack: invalid L1T raw data (size = "
153  << l1tRcd.size() << ") for ID " << fedId << ". Returning empty collections!";
154  } else if (warnsa_ < 5){
155  warnsa_++;
156  LogInfo("L1T") << "During unpacking, encountered empty L1T raw data (size = "
157  << l1tRcd.size() << ") for FED ID " << fedId << ".";
158  }
159  continue;
160  } else {
161  valid_count++;
162  }
163 
164  const unsigned char *data = l1tRcd.data();
165  FEDHeader header(data);
166 
167  if (header.check()) {
168  LogDebug("L1T") << "Found SLink header:"
169  << " Trigger type " << header.triggerType()
170  << " L1 event ID " << header.lvl1ID()
171  << " BX Number " << header.bxID()
172  << " FED source " << header.sourceID()
173  << " FED version " << header.version();
174  } else {
175  LogWarning("L1T") << "Did not find a SLink header!";
176  }
177 
178  FEDTrailer trailer(data + (l1tRcd.size() - slinkTrailerSize_));
179 
180  if (trailer.check()) {
181  LogDebug("L1T") << "Found SLink trailer:"
182  << " Length " << trailer.lenght()
183  << " CRC " << trailer.crc()
184  << " Status " << trailer.evtStatus()
185  << " Throttling bits " << trailer.ttsBits();
186  } else {
187  LogWarning("L1T") << "Did not find a SLink trailer!";
188  }
189 
190  // FIXME Hard-coded firmware version for first 74x MC campaigns.
191  // Will account for differences in the AMC payload, MP7 payload,
192  // and unpacker setup.
193  bool legacy_mc = fwOverride_ && ((fwId_ >> 24) == 0xff);
194 
195  amc13::Packet packet;
196  if (!packet.parse(
197  (const uint64_t*) data,
198  (const uint64_t*) (data + slinkHeaderSize_),
199  (l1tRcd.size() - slinkHeaderSize_ - slinkTrailerSize_) / 8,
200  header.lvl1ID(),
201  header.bxID(),
202  legacy_mc,
203  mtf7_mode_)) {
204  LogError("L1T")
205  << "Could not extract AMC13 Packet.";
206  return;
207  }
208 
209  for (auto& amc: packet.payload()) {
210  if (amc.size() == 0)
211  continue;
212 
213  auto payload64 = amc.data();
214  const uint32_t * start = (const uint32_t*) payload64.get();
215  // Want to have payload size in 32 bit words, but AMC measures
216  // it in 64 bit words → factor 2.
217  const uint32_t * end = start + (amc.size() * 2);
218 
219  std::unique_ptr<Payload> payload;
220  if (ctp7_mode_) {
221  LogDebug("L1T") << "Using CTP7 mode";
222  payload.reset(new CTP7Payload(start, end));
223  } else if (mtf7_mode_) {
224  LogDebug("L1T") << "Using MTF7 mode";
225  payload.reset(new MTF7Payload(start, end));
226  } else {
227  LogDebug("L1T") << "Using MP7 mode";
228  payload.reset(new MP7Payload(start, end, legacy_mc));
229  }
230  unsigned fw = payload->getAlgorithmFWVersion();
231 
232  // Let parameterset value override FW version
233  if (fwOverride_)
234  fw = fwId_;
235 
236  unsigned board = amc.blockHeader().getBoardID();
237  unsigned amc_no = amc.blockHeader().getAMCNumber();
238 
239  auto unpackers = prov_->getUnpackers(fedId, board, amc_no, fw);
240 
241  // getBlock() returns a non-null unique_ptr on success
242  std::unique_ptr<Block> block;
243  while ((block = payload->getBlock()).get()) {
244  if (debug_) {
245  std::cout << ">>> block to unpack <<<" << std::endl
246  << "hdr: " << std::hex << std::setw(8) << std::setfill('0') << block->header().raw() << std::dec
247  << " (ID " << block->header().getID() << ", size " << block->header().getSize()
248  << ", CapID 0x" << std::hex << std::setw(2) << std::setfill('0') << block->header().getCapID()
249  << ")" << std::dec << std::endl;
250  for (const auto& word: block->payload()) {
251  if (debug_)
252  std::cout << "data: " << std::hex << std::setw(8) << std::setfill('0') << word << std::dec << std::endl;
253  }
254  }
255 
256  auto unpacker = unpackers.find(block->header().getID());
257 
258  block->amc(amc.header());
259 
260  if (unpacker == unpackers.end()) {
261  LogDebug("L1T") << "Cannot find an unpacker for"
262  << "\n\tblock: ID " << block->header().getID() << ", size " << block->header().getSize()
263  << "\n\tAMC: # " << amc_no << ", board ID 0x" << std::hex << board << std::dec
264  << "\n\tFED ID " << fedId << ", and FW ID " << fw;
265  // TODO Handle error
266  } else if (!unpacker->second->unpack(*block, coll.get())) {
267  LogDebug("L1T") << "Error unpacking data for block ID "
268  << block->header().getID() << ", AMC # " << amc_no
269  << ", board ID " << board << ", FED ID " << fedId
270  << ", and FW ID " << fw << "!";
271  // TODO Handle error
272  }
273  }
274  }
275  }
276  if (valid_count < minFeds_){
277  if (warnsb_ < 5){
278  warnsb_++;
279  LogWarning("L1T") << "Unpacked " << valid_count << " non-empty FED IDs but minimum is set to " << minFeds_ << "\n";
280  }
281  }
282  }
#define LogDebug(id)
Definition: start.py:1
std::vector< amc::Packet > payload() const
Definition: AMC13Spec.h:80
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
payload
payload postfix for testing
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
std::vector< int > fedIds_
Definition: L1TRawToDigi.cc:60
#define end
Definition: vmac.h:37
bool isValid() const
Definition: HandleBase.h:74
JetCorrectorParametersCollection coll
Definition: classes.h:10
unsigned long long uint64_t
Definition: Time.h:15
bool parse(const uint64_t *start, const uint64_t *data, unsigned int size, unsigned int lv1, unsigned int bx, bool legacy_mc=false, bool mtf7_mode=false)
Definition: AMC13Spec.cc:70
unsigned int fwId_
Definition: L1TRawToDigi.cc:62
unsigned int minFeds_
Definition: L1TRawToDigi.cc:61
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::unique_ptr< PackingSetup > prov_
Definition: L1TRawToDigi.cc:65
edm::EDGetTokenT< FEDRawDataCollection > fedData_
Definition: L1TRawToDigi.cc:56
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
Definition: AMCSpec.h:8

Member Data Documentation

int l1t::L1TRawToDigi::amc13HeaderSize_
private

Definition at line 72 of file L1TRawToDigi.cc.

Referenced by L1TRawToDigi(), and produce().

int l1t::L1TRawToDigi::amc13TrailerSize_
private

Definition at line 73 of file L1TRawToDigi.cc.

Referenced by L1TRawToDigi(), and produce().

int l1t::L1TRawToDigi::amcHeaderSize_
private

Definition at line 70 of file L1TRawToDigi.cc.

Referenced by L1TRawToDigi(), and produce().

int l1t::L1TRawToDigi::amcTrailerSize_
private

Definition at line 71 of file L1TRawToDigi.cc.

Referenced by L1TRawToDigi(), and produce().

bool l1t::L1TRawToDigi::ctp7_mode_
private

Definition at line 75 of file L1TRawToDigi.cc.

Referenced by L1TRawToDigi(), and produce().

bool l1t::L1TRawToDigi::debug_
private

Definition at line 77 of file L1TRawToDigi.cc.

Referenced by L1TRawToDigi(), and produce().

edm::EDGetTokenT<FEDRawDataCollection> l1t::L1TRawToDigi::fedData_
private

Definition at line 56 of file L1TRawToDigi.cc.

Referenced by L1TRawToDigi(), and produce().

std::vector<int> l1t::L1TRawToDigi::fedIds_
private

Definition at line 60 of file L1TRawToDigi.cc.

Referenced by produce().

unsigned int l1t::L1TRawToDigi::fwId_
private

Definition at line 62 of file L1TRawToDigi.cc.

Referenced by produce().

bool l1t::L1TRawToDigi::fwOverride_
private

Definition at line 63 of file L1TRawToDigi.cc.

Referenced by produce().

unsigned int l1t::L1TRawToDigi::minFeds_
private

Definition at line 61 of file L1TRawToDigi.cc.

Referenced by produce().

bool l1t::L1TRawToDigi::mtf7_mode_
private

Definition at line 76 of file L1TRawToDigi.cc.

Referenced by L1TRawToDigi(), and produce().

std::unique_ptr<PackingSetup> l1t::L1TRawToDigi::prov_
private

Definition at line 65 of file L1TRawToDigi.cc.

Referenced by L1TRawToDigi(), and produce().

int l1t::L1TRawToDigi::slinkHeaderSize_
private

Definition at line 68 of file L1TRawToDigi.cc.

Referenced by L1TRawToDigi(), and produce().

int l1t::L1TRawToDigi::slinkTrailerSize_
private

Definition at line 69 of file L1TRawToDigi.cc.

Referenced by L1TRawToDigi(), and produce().

int l1t::L1TRawToDigi::warnsa_
private

Definition at line 78 of file L1TRawToDigi.cc.

Referenced by L1TRawToDigi(), and produce().

int l1t::L1TRawToDigi::warnsb_
private

Definition at line 79 of file L1TRawToDigi.cc.

Referenced by L1TRawToDigi(), and produce().