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 ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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::vector< ModuleDescription const * > &modules, 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
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
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
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)
 
- 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

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 40 of file TextToRaw.h.

Constructor & Destructor Documentation

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

Definition at line 28 of file TextToRaw.cc.

References filename_.

28  :
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 {
34  edm::LogInfo("TextToDigi") << "Reading ASCII dump from " << filename_ << std::endl;
35 
36  //register the products
37  produces<FEDRawDataCollection>();
38 
39 }
T getUntrackedParameter(std::string const &, T const &) const
int fileEventOffset_
Definition: TextToRaw.h:63
int nevt_
Definition: TextToRaw.h:64
std::string filename_
Definition: TextToRaw.h:56
int fedId_
Definition: TextToRaw.h:53
TextToRaw::~TextToRaw ( )

Definition at line 42 of file TextToRaw.cc.

43 {
44 
45  // do anything here that needs to be done at desctruction time
46  // (e.g. close files, deallocate resources etc.)
47 
48 }

Member Function Documentation

void TextToRaw::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 149 of file TextToRaw.cc.

References file_, filename_, and recoMuon::in.

150 {
151  // open VME file
152  file_.open(filename_.c_str(), std::ios::in);
153  if(!file_.good()) { edm::LogInfo("TextToDigi") << "Failed to open ASCII file " << filename_ << std::endl; }
154 }
std::ifstream file_
Definition: TextToRaw.h:57
std::string filename_
Definition: TextToRaw.h:56
void TextToRaw::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 159 of file TextToRaw.cc.

References file_.

159  {
160  file_.close();
161 }
std::ifstream file_
Definition: TextToRaw.h:57
void TextToRaw::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Definition at line 63 of file TextToRaw.cc.

References funct::abs(), EnergyCorrector::c, edmIntegrityCheck::d, FEDRawData::data(), data_, EVT_MAX_SIZE, Exception, fedId_, file_, fileEventOffset_, mps_fire::i, ntuplemaker::iline, geometryCSVtoXML::line, eostools::move(), nevt_, edm::Event::put(), putEmptyDigi(), FEDRawData::resize(), and AlCaHLTBitMon_QueryRunRegistry::string.

64 {
65  using namespace edm;
66 
67  // Skip event if required
68  if (nevt_ < fileEventOffset_){
69  putEmptyDigi(iEvent);
70  nevt_++;
71  return;
72  } else if (nevt_==0 && fileEventOffset_<0) {
74  //skip first fileEventOffset input crossings
75  for(unsigned i=0; i<(unsigned)abs(fileEventOffset_); i++) {
76  unsigned iline=0;
77  while (getline(file_, line) && !line.empty()) {
78  iline++;
79  if(iline*4>=EVT_MAX_SIZE)
80  throw cms::Exception("TextToRawEventSizeOverflow")
81  << "TextToRaw::produce() : "
82  << " read too many lines (" << iline << ": " << line << ")"
83  << ", maximum event size is " << EVT_MAX_SIZE
84  << std::endl;
85  }
86  }
87  }
88 
89  nevt_++;
90 
91  // read file
93  unsigned i=0; // count 32-bit words
94 
95  // while not encountering dumb errors
96  while (getline(file_, line) && !line.empty() ) {
97 
98  // bail if we reached the EVT_MAX_SIZE
99  if (i*4>=EVT_MAX_SIZE) {
100  throw cms::Exception("TextToRaw")
101  << "Read too many lines from file. Maximum event size is " << EVT_MAX_SIZE << " lines" << std::endl;
102  }
103 
104  // convert string to int
105  std::istringstream iss(line);
106  unsigned long d;
107  iss >> std::hex >> d;
108 
109  // copy data
110  for (int j=0; j<4; j++) {
111  if ( (i*4+j) < EVT_MAX_SIZE ) {
112  char c = (d>>(8*j))&0xff;
113  data_[i*4+j] = c;
114  }
115  }
116 
117  ++i;
118 
119  // bail if we reached the EVT_MAX_SIZE
120  if (i>=EVT_MAX_SIZE) {
121  throw cms::Exception("TextToRaw")
122  << "Read too many lines from file. Maximum event size is " << EVT_MAX_SIZE << " lines" << std::endl;
123  }
124 
125  }
126 
127  unsigned evtSize = i * 4;
128 
129  // create the collection
130  std::unique_ptr<FEDRawDataCollection> rawColl(new FEDRawDataCollection());
131  // retrieve the target buffer
132  FEDRawData& feddata=rawColl->FEDData(fedId_);
133  // Allocate space for header+trailer+payload
134  feddata.resize(evtSize);
135 
136  // fill FEDRawData object
137  for (unsigned i=0; i<evtSize; ++i) {
138  feddata.data()[i] = data_[i];
139  }
140 
141  // put the collection in the event
142  iEvent.put(std::move(rawColl));
143 
144 }
std::ifstream file_
Definition: TextToRaw.h:57
void putEmptyDigi(edm::Event &)
Append empty digi collection.
Definition: TextToRaw.cc:53
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
int fileEventOffset_
Definition: TextToRaw.h:63
int nevt_
Definition: TextToRaw.h:64
char data_[EVT_MAX_SIZE]
Definition: TextToRaw.h:61
static const unsigned EVT_MAX_SIZE
Definition: TextToRaw.h:60
void resize(size_t newsize)
Definition: FEDRawData.cc:32
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int fedId_
Definition: TextToRaw.h:53
HLT enums.
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
def move(src, dest)
Definition: eostools.py:510
void TextToRaw::putEmptyDigi ( edm::Event iEvent)
private

Append empty digi collection.

Definition at line 53 of file TextToRaw.cc.

References eostools::move(), and edm::Event::put().

Referenced by produce().

53  {
54  std::unique_ptr<FEDRawDataCollection> rawColl(new FEDRawDataCollection());
55  //FEDRawData& feddata=rawColl->FEDData(fedId_);
56  //feddata.data()[0] = 0;
57  iEvent.put(std::move(rawColl));
58 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

char TextToRaw::data_[EVT_MAX_SIZE]
private

Definition at line 61 of file TextToRaw.h.

Referenced by produce().

const unsigned TextToRaw::EVT_MAX_SIZE =8192
staticprivate

Definition at line 60 of file TextToRaw.h.

Referenced by produce().

int TextToRaw::fedId_
private

Definition at line 53 of file TextToRaw.h.

Referenced by produce().

std::ifstream TextToRaw::file_
private

Definition at line 57 of file TextToRaw.h.

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

int TextToRaw::fileEventOffset_
private

Definition at line 63 of file TextToRaw.h.

Referenced by produce().

std::string TextToRaw::filename_
private

Definition at line 56 of file TextToRaw.h.

Referenced by beginJob(), and TextToRaw().

int TextToRaw::nevt_
private

Definition at line 64 of file TextToRaw.h.

Referenced by produce().