CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
TextToRaw Class Reference

#include <L1Triggr/TextToDigi/src/TextToRaw.cc>

Inheritance diagram for TextToRaw:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 TextToRaw (const edm::ParameterSet &)
 
 ~TextToRaw () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginJob () override
 
void endJob () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void putEmptyDigi (edm::Event &)
 Append empty digi collection. More...
 

Private Attributes

char data_ [EVT_MAX_SIZE]
 
int fedId_
 
std::ifstream file_
 
int fileEventOffset_
 
std::string filename_
 
int nevt_
 

Static Private Attributes

static const unsigned EVT_MAX_SIZE = 8192
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
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
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
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)
 
template<Transition B>
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 (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Description: Convert ASCII dump of a raw event to FEDRawData format for unpacking

Implementation: Input format is a 32 bit hex string per line (LSW first). Events separated with blank line.

Definition at line 41 of file TextToRaw.h.

Constructor & Destructor Documentation

◆ TextToRaw()

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

Definition at line 28 of file TextToRaw.cc.

29  : fedId_(iConfig.getUntrackedParameter<int>("fedId", 745)),
30  filename_(iConfig.getUntrackedParameter<std::string>("filename", "slinkOutput.txt")),
31  fileEventOffset_(iConfig.getUntrackedParameter<int>("FileEventOffset", 0)),
32  nevt_(0) {
33  edm::LogInfo("TextToDigi") << "Reading ASCII dump from " << filename_ << std::endl;
34 
35  // register the products
36  produces<FEDRawDataCollection>();
37 }

References filename_.

◆ ~TextToRaw()

TextToRaw::~TextToRaw ( )
override

Definition at line 39 of file TextToRaw.cc.

39  {
40  // do anything here that needs to be done at desctruction time
41  // (e.g. close files, deallocate resources etc.)
42 }

Member Function Documentation

◆ beginJob()

void TextToRaw::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 132 of file TextToRaw.cc.

132  {
133  // open VME file
134  file_.open(filename_.c_str(), std::ios::in);
135  if (!file_.good()) {
136  edm::LogInfo("TextToDigi") << "Failed to open ASCII file " << filename_ << std::endl;
137  }
138 }

References file_, filename_, and recoMuon::in.

◆ endJob()

void TextToRaw::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 142 of file TextToRaw.cc.

142 { file_.close(); }

References file_.

◆ produce()

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

Implements edm::EDProducer.

Definition at line 53 of file TextToRaw.cc.

53  {
54  using namespace edm;
55 
56  // Skip event if required
57  if (nevt_ < fileEventOffset_) {
59  nevt_++;
60  return;
61  } else if (nevt_ == 0 && fileEventOffset_ < 0) {
63  // skip first fileEventOffset input crossings
64  for (unsigned i = 0; i < (unsigned)abs(fileEventOffset_); i++) {
65  unsigned iline = 0;
66  while (getline(file_, line) && !line.empty()) {
67  iline++;
68  if (iline * 4 >= EVT_MAX_SIZE)
69  throw cms::Exception("TextToRawEventSizeOverflow") << "TextToRaw::produce() : "
70  << " read too many lines (" << iline << ": " << line << ")"
71  << ", maximum event size is " << EVT_MAX_SIZE << std::endl;
72  }
73  }
74  }
75 
76  nevt_++;
77 
78  // read file
80  unsigned i = 0; // count 32-bit words
81 
82  // while not encountering dumb errors
83  while (getline(file_, line) && !line.empty()) {
84  // bail if we reached the EVT_MAX_SIZE
85  if (i * 4 >= EVT_MAX_SIZE) {
86  throw cms::Exception("TextToRaw") << "Read too many lines from file. Maximum event size is " << EVT_MAX_SIZE
87  << " lines" << std::endl;
88  }
89 
90  // convert string to int
91  std::istringstream iss(line);
92  unsigned long d;
93  iss >> std::hex >> d;
94 
95  // copy data
96  for (int j = 0; j < 4; j++) {
97  if ((i * 4 + j) < EVT_MAX_SIZE) {
98  char c = (d >> (8 * j)) & 0xff;
99  data_[i * 4 + j] = c;
100  }
101  }
102 
103  ++i;
104 
105  // bail if we reached the EVT_MAX_SIZE
106  if (i >= EVT_MAX_SIZE) {
107  throw cms::Exception("TextToRaw") << "Read too many lines from file. Maximum event size is " << EVT_MAX_SIZE
108  << " lines" << std::endl;
109  }
110  }
111 
112  unsigned evtSize = i * 4;
113 
114  // create the collection
115  std::unique_ptr<FEDRawDataCollection> rawColl(new FEDRawDataCollection());
116  // retrieve the target buffer
117  FEDRawData &feddata = rawColl->FEDData(fedId_);
118  // Allocate space for header+trailer+payload
119  feddata.resize(evtSize);
120 
121  // fill FEDRawData object
122  for (unsigned i = 0; i < evtSize; ++i) {
123  feddata.data()[i] = data_[i];
124  }
125 
126  // put the collection in the event
127  iEvent.put(std::move(rawColl));
128 }

References funct::abs(), c, ztail::d, FEDRawData::data(), data_, EVT_MAX_SIZE, Exception, fedId_, EcalFEDMonitor_cfi::FEDRawDataCollection, file_, fileEventOffset_, mps_fire::i, iEvent, ntuplemaker::iline, dqmiolumiharvest::j, mps_splice::line, eostools::move(), nevt_, putEmptyDigi(), FEDRawData::resize(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ putEmptyDigi()

void TextToRaw::putEmptyDigi ( edm::Event iEvent)
private

Append empty digi collection.

Definition at line 45 of file TextToRaw.cc.

45  {
46  std::unique_ptr<FEDRawDataCollection> rawColl(new FEDRawDataCollection());
47  // FEDRawData& feddata=rawColl->FEDData(fedId_);
48  // feddata.data()[0] = 0;
49  iEvent.put(std::move(rawColl));
50 }

References EcalFEDMonitor_cfi::FEDRawDataCollection, iEvent, and eostools::move().

Referenced by produce().

Member Data Documentation

◆ data_

char TextToRaw::data_[EVT_MAX_SIZE]
private

Definition at line 61 of file TextToRaw.h.

Referenced by produce().

◆ EVT_MAX_SIZE

const unsigned TextToRaw::EVT_MAX_SIZE = 8192
staticprivate

Definition at line 60 of file TextToRaw.h.

Referenced by produce().

◆ fedId_

int TextToRaw::fedId_
private

Definition at line 53 of file TextToRaw.h.

Referenced by produce().

◆ file_

std::ifstream TextToRaw::file_
private

Definition at line 57 of file TextToRaw.h.

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

◆ fileEventOffset_

int TextToRaw::fileEventOffset_
private

Definition at line 63 of file TextToRaw.h.

Referenced by produce().

◆ filename_

std::string TextToRaw::filename_
private

Definition at line 56 of file TextToRaw.h.

Referenced by beginJob(), and TextToRaw().

◆ nevt_

int TextToRaw::nevt_
private

Definition at line 64 of file TextToRaw.h.

Referenced by produce().

TextToRaw::data_
char data_[EVT_MAX_SIZE]
Definition: TextToRaw.h:61
mps_fire.i
i
Definition: mps_fire.py:428
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
TextToRaw::EVT_MAX_SIZE
static const unsigned EVT_MAX_SIZE
Definition: TextToRaw.h:60
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
FEDRawData
Definition: FEDRawData.h:19
EcalFEDMonitor_cfi.FEDRawDataCollection
FEDRawDataCollection
Definition: EcalFEDMonitor_cfi.py:6
TextToRaw::fedId_
int fedId_
Definition: TextToRaw.h:53
TextToRaw::nevt_
int nevt_
Definition: TextToRaw.h:64
TextToRaw::putEmptyDigi
void putEmptyDigi(edm::Event &)
Append empty digi collection.
Definition: TextToRaw.cc:45
recoMuon::in
Definition: RecoMuonEnumerators.h:6
iEvent
int iEvent
Definition: GenABIO.cc:224
ntuplemaker.iline
iline
Definition: ntuplemaker.py:186
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
eostools.move
def move(src, dest)
Definition: eostools.py:511
TextToRaw::filename_
std::string filename_
Definition: TextToRaw.h:56
Exception
Definition: hltDiff.cc:245
FEDRawData::resize
void resize(size_t newsize)
Definition: FEDRawData.cc:28
ztail.d
d
Definition: ztail.py:151
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
mps_splice.line
line
Definition: mps_splice.py:76
TextToRaw::file_
std::ifstream file_
Definition: TextToRaw.h:57
TextToRaw::fileEventOffset_
int fileEventOffset_
Definition: TextToRaw.h:63