CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
< FEDRawDataCollection
fedData_
 
std::vector< int > fedIds_
 
unsigned int fwId_
 
bool fwOverride_
 
bool mtf7_mode_
 
std::auto_ptr< PackingSetupprov_
 
int slinkHeaderSize_
 
int slinkTrailerSize_
 

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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
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 44 of file L1TRawToDigi.cc.

Constructor & Destructor Documentation

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

Definition at line 87 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_, and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 114 of file L1TRawToDigi.cc.

115  {
116  }

Member Function Documentation

virtual void l1t::L1TRawToDigi::beginLuminosityBlock ( 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::beginRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 54 of file L1TRawToDigi.cc.

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

Reimplemented from edm::stream::EDProducerBase.

Definition at line 57 of file L1TRawToDigi.cc.

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

Reimplemented from edm::stream::EDProducerBase.

Definition at line 55 of file L1TRawToDigi.cc.

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

Definition at line 265 of file L1TRawToDigi.cc.

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

265  {
267  // These parameters are part of the L1T/HLT interface, avoid changing if possible:
268  desc.add<std::vector<int>>("FedIds", {})->setComment("required parameter: default value is invalid");
269  desc.add<std::string>("Setup", "")->setComment("required parameter: default value is invalid");
270  // These parameters have well defined default values and are not currently
271  // part of the L1T/HLT interface. They can be cleaned up or updated at will:
272  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");
273  desc.add<bool>("FWOverride", false)->setComment("Firmware version should be taken as FWId parameters");
274  desc.addUntracked<bool>("CTP7", false);
275  desc.addUntracked<bool>("MTF7", false);
276  desc.add<edm::InputTag>("InputLabel",edm::InputTag("rawDataCollector"));
277  desc.addUntracked<int>("lenSlinkHeader", 8);
278  desc.addUntracked<int>("lenSlinkTrailer", 8);
279  desc.addUntracked<int>("lenAMCHeader", 8);
280  desc.addUntracked<int>("lenAMCTrailer", 0);
281  desc.addUntracked<int>("lenAMC13Header", 8);
282  desc.addUntracked<int>("lenAMC13Trailer", 8);
283  desc.addUntracked<bool>("debug", false)->setComment("turn on verbose output");
284  descriptions.add("l1tRawToDigi", desc);
285  }
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

Implements edm::stream::EDProducerBase.

Definition at line 125 of file L1TRawToDigi.cc.

References amc, amc13HeaderSize_, amc13TrailerSize_, amcHeaderSize_, amcTrailerSize_, createPayload::block, FEDHeader::bxID(), FEDTrailer::check(), FEDHeader::check(), coll, gather_cfg::cout, FEDTrailer::crc(), ctp7_mode_, FEDRawData::data(), data, debug_, TauDecayModes::dec, end, FEDTrailer::evtStatus(), fedData_, stage2MP7BufferRaw_cfi::fedId, fedIds_, HcalMonitorModule_cfi::feds, fwId_, fwOverride_, FEDTrailer::lenght(), LogDebug, FEDHeader::lvl1ID(), mtf7_mode_, amc13::Packet::parse(), amc13::Packet::payload(), prov_, FEDRawData::size(), slinkHeaderSize_, slinkTrailerSize_, FEDHeader::sourceID(), dqm_diff::start, FEDHeader::triggerType(), FEDTrailer::ttsBits(), dt_dqm_sourceclient_common_cff::unpackers, and FEDHeader::version().

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

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

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 57 of file L1TRawToDigi.cc.

Referenced by L1TRawToDigi(), and produce().

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

Definition at line 61 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().

bool l1t::L1TRawToDigi::mtf7_mode_
private

Definition at line 76 of file L1TRawToDigi.cc.

Referenced by L1TRawToDigi(), and produce().

std::auto_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().