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
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 (const std::string &iProcessName, std::vector< const char * > &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::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", 8);
95  slinkTrailerSize_ = config.getUntrackedParameter<int>("lenSlinkTrailer", 8);
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 193 of file L1TDigiToRaw.cc.

194  {
195  }
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 199 of file L1TDigiToRaw.cc.

199  {
200  }
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 236 of file L1TDigiToRaw.cc.

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

236  {
237  //The following says we do not know what parameters are allowed so do no validation
238  // Please change this to state exactly what you do use, even if it is no parameters
240  desc.setUnknown();
241  descriptions.addDefault(desc);
242  }
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, l1t::MP7, 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 amc_no = item.first.first;
116  auto board = item.first.second;
117  auto packers = item.second;
118 
119  Blocks block_load;
120  for (const auto& packer: packers) {
121  LogDebug("L1T") << "Adding packed blocks";
122  auto blocks = packer->pack(event, tokens_.get());
123  block_load.insert(block_load.end(), blocks.begin(), blocks.end());
124  }
125 
126  std::sort(block_load.begin(), block_load.end());
127 
128  LogDebug("L1T") << "Concatenating blocks";
129 
130  std::vector<uint32_t> load32;
131  // TODO this is an empty word to be replaced with a proper MP7
132  // header containing at least the firmware version
133  load32.push_back(0);
134  for (const auto& block: block_load) {
135  LogDebug("L1T") << "Adding block " << block.header().getID() << " with size " << block.payload().size();
136  auto load = block.payload();
137 
138 #ifdef EDM_ML_DEBUG
139  std::stringstream s("");
140  s << "Block content:" << std::endl << std::hex << std::setfill('0');
141  for (const auto& word: load)
142  s << std::setw(8) << word << std::endl;
143  LogDebug("L1T") << s.str();
144 #endif
145 
146  load32.push_back(block.header().raw(MP7));
147  load32.insert(load32.end(), load.begin(), load.end());
148  }
149 
150  LogDebug("L1T") << "Converting payload";
151 
152  std::vector<uint64_t> load64;
153  for (unsigned int i = 0; i < load32.size(); i += 2) {
154  uint64_t word = load32[i];
155  if (i + 1 < load32.size())
156  word |= static_cast<uint64_t>(load32[i + 1]) << 32;
157  load64.push_back(word);
158  }
159 
160  LogDebug("L1T") << "Creating AMC packet";
161 
162  amc13.add(amc_no, board, load64);
163  }
164 
165  std::auto_ptr<FEDRawDataCollection> raw_coll(new FEDRawDataCollection());
166  FEDRawData& fed_data = raw_coll->FEDData(fedId_);
167 
168  unsigned int size = slinkHeaderSize_ + slinkTrailerSize_ + amc13.size() * 8;
169  fed_data.resize(size);
170  unsigned char * payload = fed_data.data();
171  unsigned char * payload_start = payload;
172 
173  auto bxId = event.bunchCrossing();
174  auto evtId = event.id().event();
175 
176  FEDHeader header(payload);
177  header.set(payload, evtType_, evtId, bxId, fedId_);
178 
179  payload += slinkHeaderSize_;
180 
181  amc13.write(event, payload, size - slinkHeaderSize_ - slinkTrailerSize_);
182 
183  payload += amc13.size() * 8;
184 
185  FEDTrailer trailer(payload);
186  trailer.set(payload, size / 8, evf::compute_crc(payload_start, size), 0, 0);
187 
188  event.put(raw_coll);
189  }
#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
Definition: Block.h:10
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:64
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().