CMS 3D CMS Logo

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

Public Member Functions

 AMCDumpToRaw (const edm::ParameterSet &)
 
 ~AMCDumpToRaw () override
 
- Public Member Functions inherited from edm::one::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDProducerBase () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

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

void beginJob () override
 
void endJob () override
 
void formatAMC (amc13::Packet &amc13, const std::vector< uint32_t > &load32)
 
void formatRaw (edm::Event &iEvent, amc13::Packet &amc13, FEDRawData &fed_data)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void readEvent (std::vector< uint32_t > &load32)
 

Private Attributes

int boardId_
 
int evType_
 
int fedId_
 
std::ifstream file_
 
std::string filename_
 
int fwVer_
 
int iAmc_
 
int slinkHeaderSize_
 
int slinkTrailerSize_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 49 of file AMCDumpToRaw.cc.

Constructor & Destructor Documentation

◆ AMCDumpToRaw()

AMCDumpToRaw::AMCDumpToRaw ( const edm::ParameterSet iConfig)
explicit

Definition at line 92 of file AMCDumpToRaw.cc.

93  : filename_(iConfig.getUntrackedParameter<std::string>("filename", "data.txt")),
94  fedId_(iConfig.getUntrackedParameter<int>("fedId", 1)),
95  iAmc_(iConfig.getUntrackedParameter<int>("iAmc", 1)),
96  boardId_(iConfig.getUntrackedParameter<int>("boardId", 1)),
97  evType_(iConfig.getUntrackedParameter<int>("eventType", 1)),
98  fwVer_(iConfig.getUntrackedParameter<int>("fwVersion", 1)),
99  slinkHeaderSize_(iConfig.getUntrackedParameter<int>("lenSlinkHeader", 8)),
100  slinkTrailerSize_(iConfig.getUntrackedParameter<int>("lenSlinkTrailer", 8)) {
101  produces<FEDRawDataCollection>();
102  }
T getUntrackedParameter(std::string const &, T const &) const
std::string filename_
Definition: AMCDumpToRaw.cc:69

◆ ~AMCDumpToRaw()

AMCDumpToRaw::~AMCDumpToRaw ( )
override

Definition at line 104 of file AMCDumpToRaw.cc.

104  {
105  // do anything here that needs to be done at desctruction time
106  // (e.g. close files, deallocate resources etc.)
107  }

Member Function Documentation

◆ beginJob()

void AMCDumpToRaw::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDProducerBase.

Definition at line 195 of file AMCDumpToRaw.cc.

References file_, filename_, and recoMuon::in.

195  {
196  // open VME file
197  file_.open(filename_.c_str(), std::ios::in);
198  if (!file_.good()) {
199  edm::LogInfo("TextToDigi") << "Failed to open ASCII file " << filename_ << std::endl;
200  }
201  }
Log< level::Info, false > LogInfo
std::string filename_
Definition: AMCDumpToRaw.cc:69
std::ifstream file_
Definition: AMCDumpToRaw.cc:68

◆ endJob()

void AMCDumpToRaw::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDProducerBase.

Definition at line 204 of file AMCDumpToRaw.cc.

References file_.

204 { file_.close(); }
std::ifstream file_
Definition: AMCDumpToRaw.cc:68

◆ fillDescriptions()

void AMCDumpToRaw::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 207 of file AMCDumpToRaw.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

207  {
208  //The following says we do not know what parameters are allowed so do no validation
209  // Please change this to state exactly what you do use, even if it is no parameters
211  desc.setUnknown();
212  descriptions.addDefault(desc);
213  }
void addDefault(ParameterSetDescription const &psetDescription)

◆ formatAMC()

void AMCDumpToRaw::formatAMC ( amc13::Packet amc13,
const std::vector< uint32_t > &  load32 
)
private

Definition at line 154 of file AMCDumpToRaw.cc.

References boardId_, mps_fire::i, iAmc_, and LogDebug.

Referenced by produce().

154  {
155  // TODO this is an empty word to be replaced with a proper MP7
156  // header containing at least the firmware version
157 
158  std::vector<uint64_t> load64;
159  for (unsigned int i = 0; i < load32.size(); i += 2) {
160  uint64_t word = load32[i];
161  if (i + 1 < load32.size())
162  word |= static_cast<uint64_t>(load32[i + 1]) << 32;
163  load64.push_back(word);
164  }
165 
166  LogDebug("L1T") << "Creating AMC packet " << iAmc_;
167 
168  amc13.add(iAmc_, boardId_, 0, 0, 0, load64);
169  }
uint64_t word
unsigned long long uint64_t
Definition: Time.h:13
#define LogDebug(id)

◆ formatRaw()

void AMCDumpToRaw::formatRaw ( edm::Event iEvent,
amc13::Packet amc13,
FEDRawData fed_data 
)
private

Definition at line 171 of file AMCDumpToRaw.cc.

References evf::compute_crc(), FEDRawData::data(), evType_, fedId_, RecoTauValidation_cfi::header, iEvent, LogDebug, jetsAK4_Puppi_cff::payload, FEDRawData::resize(), FEDTrailer::set(), slinkHeaderSize_, and slinkTrailerSize_.

Referenced by produce().

171  {
172  unsigned int size = slinkHeaderSize_ + slinkTrailerSize_ + amc13.size() * 8;
173  fed_data.resize(size);
174  unsigned char* payload = fed_data.data();
175  unsigned char* payload_start = payload;
176 
177  auto bxId = iEvent.bunchCrossing();
178  auto evtId = iEvent.id().event();
179 
180  LogDebug("L1T") << "Creating FEDRawData ID " << fedId_ << ", size " << size;
181 
183  header.set(payload, evType_, evtId, bxId, fedId_);
184 
186 
188  payload += amc13.size() * 8;
189 
190  FEDTrailer trailer(payload);
191  trailer.set(payload, size / 8, evf::compute_crc(payload_start, size), 0, 0);
192  }
size
Write out results.
int iEvent
Definition: GenABIO.cc:224
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:46
void resize(size_t newsize, size_t wordsize=8)
Definition: FEDRawData.cc:28
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
#define LogDebug(id)

◆ produce()

void AMCDumpToRaw::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDProducerBase.

Definition at line 114 of file AMCDumpToRaw.cc.

References fedId_, EcalFEDMonitor_cfi::FEDRawDataCollection, formatAMC(), formatRaw(), iEvent, LogDebug, eostools::move(), readEvent(), and FEDRawData::size().

114  {
115  using namespace edm;
116 
117  // create AMC 13 packet
119 
120  std::vector<uint32_t> load32;
121 
122  readEvent(load32);
123 
124  formatAMC(amc13, load32);
125 
126  LogDebug("L1T") << "AMC13 size " << amc13.size();
127 
128  // prepare the raw data collection
129  std::unique_ptr<FEDRawDataCollection> raw_coll(new FEDRawDataCollection());
130  FEDRawData& fed_data = raw_coll->FEDData(fedId_);
131 
132  formatRaw(iEvent, amc13, fed_data);
133 
134  LogDebug("L1T") << "Packing FED ID " << fedId_ << " size " << fed_data.size();
135 
136  // put the collection in the event
137  iEvent.put(std::move(raw_coll));
138  }
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:48
int iEvent
Definition: GenABIO.cc:224
void readEvent(std::vector< uint32_t > &load32)
HLT enums.
void formatAMC(amc13::Packet &amc13, const std::vector< uint32_t > &load32)
void formatRaw(edm::Event &iEvent, amc13::Packet &amc13, FEDRawData &fed_data)
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

◆ readEvent()

void AMCDumpToRaw::readEvent ( std::vector< uint32_t > &  load32)
private

Definition at line 140 of file AMCDumpToRaw.cc.

References ztail::d, file_, mps_splice::line, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by produce().

140  {
141  // read file
143 
144  // while not encountering dumb errors
145  while (getline(file_, line) && !line.empty()) {
146  std::istringstream iss(line);
147  unsigned long d;
148  iss >> std::hex >> d;
149 
150  load32.push_back(d);
151  }
152  }
d
Definition: ztail.py:151
std::ifstream file_
Definition: AMCDumpToRaw.cc:68

Member Data Documentation

◆ boardId_

int l1t::AMCDumpToRaw::boardId_
private

Definition at line 74 of file AMCDumpToRaw.cc.

Referenced by formatAMC().

◆ evType_

int l1t::AMCDumpToRaw::evType_
private

Definition at line 75 of file AMCDumpToRaw.cc.

Referenced by formatRaw().

◆ fedId_

int l1t::AMCDumpToRaw::fedId_
private

Definition at line 72 of file AMCDumpToRaw.cc.

Referenced by formatRaw(), and produce().

◆ file_

std::ifstream l1t::AMCDumpToRaw::file_
private

Definition at line 68 of file AMCDumpToRaw.cc.

Referenced by beginJob(), endJob(), and readEvent().

◆ filename_

std::string l1t::AMCDumpToRaw::filename_
private

Definition at line 69 of file AMCDumpToRaw.cc.

Referenced by beginJob().

◆ fwVer_

int l1t::AMCDumpToRaw::fwVer_
private

Definition at line 76 of file AMCDumpToRaw.cc.

◆ iAmc_

int l1t::AMCDumpToRaw::iAmc_
private

Definition at line 73 of file AMCDumpToRaw.cc.

Referenced by formatAMC().

◆ slinkHeaderSize_

int l1t::AMCDumpToRaw::slinkHeaderSize_
private

Definition at line 77 of file AMCDumpToRaw.cc.

Referenced by formatRaw().

◆ slinkTrailerSize_

int l1t::AMCDumpToRaw::slinkTrailerSize_
private

Definition at line 78 of file AMCDumpToRaw.cc.

Referenced by formatRaw().