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::L1TDigiToRaw Class Reference
Inheritance diagram for l1t::L1TDigiToRaw:
edm::one::EDProducer< edm::one::SharedResources, edm::one::WatchRuns, edm::one::WatchLuminosityBlocks > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 L1TDigiToRaw (const edm::ParameterSet &)
 
 ~L1TDigiToRaw ()
 
- Public Member Functions inherited from edm::one::EDProducer< edm::one::SharedResources, edm::one::WatchRuns, edm::one::WatchLuminosityBlocks >
 EDProducer ()=default
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
 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
 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 (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) 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::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual void beginJob () override
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &) override
 
virtual void endJob () 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 evtType_
 
int fedId_
 
unsigned fwId_
 
std::auto_ptr< PackingSetupsetup_
 
int slinkHeaderSize_
 
int slinkTrailerSize_
 
std::unique_ptr< PackerTokenstokens_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 46 of file L1TDigiToRaw.cc.

Constructor & Destructor Documentation

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

Definition at line 80 of file L1TDigiToRaw.cc.

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

80  :
81  fedId_(config.getParameter<int>("FedId"))
82  {
83  // Register products
84  produces<FEDRawDataCollection>();
85 
86  fwId_ = config.getParameter<unsigned int>("FWId");
87  evtType_ = config.getUntrackedParameter<int>("eventType", 1);
88 
90 
92  tokens_ = setup_->registerConsumes(config, cc);
93 
94  slinkHeaderSize_ = config.getUntrackedParameter<int>("lenSlinkHeader", 16);
95  slinkTrailerSize_ = config.getUntrackedParameter<int>("lenSlinkTrailer", 16);
96  }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< PackerTokens > tokens_
Definition: L1TDigiToRaw.cc:75
std::auto_ptr< PackingSetup > setup_
Definition: L1TDigiToRaw.cc:74
std::auto_ptr< PackingSetup > make(const std::string &) const
Definition: PackingSetup.cc:12
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
static const PackingSetupFactory * get()
Definition: PackingSetup.h:46
L1TDigiToRaw::~L1TDigiToRaw ( )

Definition at line 99 of file L1TDigiToRaw.cc.

100  {
101  }

Member Function Documentation

void L1TDigiToRaw::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDProducerBase.

Definition at line 192 of file L1TDigiToRaw.cc.

193  {
194  }
virtual void l1t::L1TDigiToRaw::beginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
inlineoverrideprivatevirtual

Definition at line 62 of file L1TDigiToRaw.cc.

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

Definition at line 60 of file L1TDigiToRaw.cc.

60 {};
void L1TDigiToRaw::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDProducerBase.

Definition at line 198 of file L1TDigiToRaw.cc.

198  {
199  }
virtual void l1t::L1TDigiToRaw::endLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &   
)
inlineoverrideprivatevirtual

Definition at line 63 of file L1TDigiToRaw.cc.

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

Definition at line 61 of file L1TDigiToRaw.cc.

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

Definition at line 235 of file L1TDigiToRaw.cc.

References edm::ConfigurationDescriptions::addDefault(), and edm::ParameterSetDescription::setUnknown().

235  {
236  //The following says we do not know what parameters are allowed so do no validation
237  // Please change this to state exactly what you do use, even if it is no parameters
239  desc.setUnknown();
240  descriptions.addDefault(desc);
241  }
void addDefault(ParameterSetDescription const &psetDescription)
void L1TDigiToRaw::produce ( edm::Event event,
const edm::EventSetup setup 
)
overrideprivatevirtual

Implements edm::one::EDProducerBase.

Definition at line 105 of file L1TDigiToRaw.cc.

References createPayload::block, gather_cfg::blocks, evf::compute_crc(), evtType_, fedId_, fwId_, i, svgfig::load(), LogDebug, alignCSCRings::s, FEDTrailer::set(), FEDHeader::set(), setup_, findQualityFiles::size, slinkHeaderSize_, slinkTrailerSize_, python.multivaluedict::sort(), and tokens_.

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

106  {
107  using namespace edm;
108 
109  LogDebug("L1T") << "Packing data with FED ID " << fedId_;
110 
111  amc13::Packet amc13;
112 
113  // Create all the AMC payloads to pack into the AMC13
114  for (const auto& item: setup_->getPackers(fedId_, fwId_)) {
115  auto board = item.first;
116  auto packers = item.second;
117 
118  Blocks block_load;
119  for (const auto& packer: packers) {
120  LogDebug("L1T") << "Adding packed blocks";
121  auto blocks = packer->pack(event, tokens_.get());
122  block_load.insert(block_load.end(), blocks.begin(), blocks.end());
123  }
124 
125  std::sort(block_load.begin(), block_load.end());
126 
127  LogDebug("L1T") << "Concatenating blocks";
128 
129  std::vector<uint32_t> load32;
130  // TODO this is an empty word to be replaced with a proper MP7
131  // header containing at least the firmware version
132  load32.push_back(0);
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  load32.push_back(block.header().raw());
146  load32.insert(load32.end(), load.begin(), load.end());
147  }
148 
149  LogDebug("L1T") << "Converting payload";
150 
151  std::vector<uint64_t> load64;
152  for (unsigned int i = 0; i < load32.size(); i += 2) {
153  uint64_t word = load32[i];
154  if (i + 1 < load32.size())
155  word |= static_cast<uint64_t>(load32[i + 1]) << 32;
156  load64.push_back(word);
157  }
158 
159  LogDebug("L1T") << "Creating AMC packet";
160 
161  amc13.add(board, load64);
162  }
163 
164  std::auto_ptr<FEDRawDataCollection> raw_coll(new FEDRawDataCollection());
165  FEDRawData& fed_data = raw_coll->FEDData(fedId_);
166 
167  unsigned int size = slinkHeaderSize_ + slinkTrailerSize_ + amc13.size() * 8;
168  fed_data.resize(size);
169  unsigned char * payload = fed_data.data();
170  unsigned char * payload_start = payload;
171 
172  auto bxId = event.bunchCrossing();
173  auto evtId = event.id().event();
174 
175  FEDHeader header(payload);
176  header.set(payload, evtType_, evtId, bxId, fedId_);
177 
178  payload += slinkHeaderSize_;
179 
180  amc13.write(event, payload, size - slinkHeaderSize_ - slinkTrailerSize_);
181 
182  payload += amc13.size() * 8;
183 
184  FEDTrailer trailer(payload);
185  trailer.set(payload, size / 8, evf::compute_crc(payload_start, size), 0, 0);
186 
187  event.put(raw_coll);
188  }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
std::unique_ptr< PackerTokens > tokens_
Definition: L1TDigiToRaw.cc:75
std::auto_ptr< PackingSetup > setup_
Definition: L1TDigiToRaw.cc:74
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:67
def load
Definition: svgfig.py:546
std::vector< Block > Blocks
Definition: Block.h:45
unsigned long long uint64_t
Definition: Time.h:15
list blocks
Definition: gather_cfg.py:90
tuple size
Write out results.

Member Data Documentation

int l1t::L1TDigiToRaw::evtType_
private

Definition at line 63 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().

int l1t::L1TDigiToRaw::fedId_
private

Definition at line 67 of file L1TDigiToRaw.cc.

Referenced by produce().

unsigned l1t::L1TDigiToRaw::fwId_
private

Definition at line 68 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().

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

Definition at line 74 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().

int l1t::L1TDigiToRaw::slinkHeaderSize_
private

Definition at line 71 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().

int l1t::L1TDigiToRaw::slinkTrailerSize_
private

Definition at line 72 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().

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

Definition at line 75 of file L1TDigiToRaw.cc.

Referenced by L1TDigiToRaw(), and produce().