CMS 3D CMS Logo

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

#include <L1GtTextToRaw.h>

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

Public Member Functions

 L1GtTextToRaw (const edm::ParameterSet &)
 constructor(s) More...
 
virtual ~L1GtTextToRaw ()
 destructor More...
 
- 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
 
 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 & itemsToGetFromEvent () 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 ()
 beginning of job stuff More...
 
virtual void cleanTextFile ()
 clean the text file, if needed More...
 
virtual void endJob ()
 end of job stuff More...
 
virtual int getDataSize ()
 get the size of the record More...
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 loop over events More...
 

Private Attributes

int m_daqGtFedId
 FED ID for the system. More...
 
int m_rawDataSize
 raw event size (including header and trailer) in units of 8 bits More...
 
std::ifstream m_textFile
 the file itself More...
 
std::string m_textFileName
 file name for the text file More...
 
std::string m_textFileType
 file type for the text file More...
 

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: generate raw data from dumped text file.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna

Definition at line 36 of file L1GtTextToRaw.h.

Constructor & Destructor Documentation

L1GtTextToRaw::L1GtTextToRaw ( const edm::ParameterSet pSet)
explicit

constructor(s)

Definition at line 40 of file L1GtTextToRaw.cc.

References Exception, edm::ParameterSet::getUntrackedParameter(), recoMuon::in, LogDebug, m_daqGtFedId, m_rawDataSize, m_textFile, m_textFileName, m_textFileType, FEDNumbering::MAXTriggerGTPFEDID, and AlCaHLTBitMon_QueryRunRegistry::string.

41 {
42 
43  m_textFileType = pSet.getUntrackedParameter<std::string>("TextFileType", "VmeSpyDump");
44 
45  LogDebug("L1GtTextToRaw")
46  << "\nText file type: " << m_textFileType << "\n"
47  << std::endl;
48 
49  m_textFileName = pSet.getUntrackedParameter<std::string>("TextFileName", "gtfe.dmp");
50 
51  LogDebug("L1GtTextToRaw")
52  << "\nText file name: " << m_textFileName << "\n"
53  << std::endl;
54 
55  // event size
56  m_rawDataSize = pSet.getUntrackedParameter<int>("RawDataSize");
57 
58  LogDebug("L1GtTextToRaw")
59  << "\nRaw data size (units of 8 bits): " << m_rawDataSize
60  << "\n If negative value, the size is retrieved from the trailer." << "\n"
61  << std::endl;
62 
63  // FED Id for GT DAQ record
64  // default value defined in DataFormats/FEDRawData/src/FEDNumbering.cc
65  // default value: assume the DAQ record is the last GT record
67  "DaqGtFedId", FEDNumbering::MAXTriggerGTPFEDID);
68 
69  LogDebug("L1GtTextToRaw")
70  << "\nFED Id for DAQ GT record: "
71  << m_daqGtFedId << " \n"
72  << std::endl;
73 
74  // open test file
75  m_textFile.open(m_textFileName.c_str(), std::ios::in);
76  if( !m_textFile.good() ) {
77  throw cms::Exception("NotFound")
78  << "\nError: failed to open text file = " << m_textFileName << "\n"
79  << std::endl;
80  }
81 
82  //
83  produces<FEDRawDataCollection>();
84 
85 }
#define LogDebug(id)
T getUntrackedParameter(std::string const &, T const &) const
int m_daqGtFedId
FED ID for the system.
Definition: L1GtTextToRaw.h:76
std::string m_textFileName
file name for the text file
Definition: L1GtTextToRaw.h:70
std::string m_textFileType
file type for the text file
Definition: L1GtTextToRaw.h:67
int m_rawDataSize
raw event size (including header and trailer) in units of 8 bits
Definition: L1GtTextToRaw.h:73
std::ifstream m_textFile
the file itself
Definition: L1GtTextToRaw.h:79
L1GtTextToRaw::~L1GtTextToRaw ( )
virtual

destructor

Definition at line 88 of file L1GtTextToRaw.cc.

89 {
90 
91  // empty now
92 
93 }

Member Function Documentation

void L1GtTextToRaw::beginJob ( void  )
privatevirtual

beginning of job stuff

Reimplemented from edm::EDProducer.

Definition at line 98 of file L1GtTextToRaw.cc.

References cleanTextFile().

99 {
100 
101  cleanTextFile();
102 
103 }
virtual void cleanTextFile()
clean the text file, if needed
void L1GtTextToRaw::cleanTextFile ( )
privatevirtual

clean the text file, if needed

Definition at line 106 of file L1GtTextToRaw.cc.

References LogDebug.

Referenced by beginJob().

107 {
108 
109  LogDebug("L1GtTextToRaw")
110  << "\nCleaning the text file\n"
111  << std::endl;
112 
113 
114 
115 }
#define LogDebug(id)
void L1GtTextToRaw::endJob ( void  )
privatevirtual

end of job stuff

Reimplemented from edm::EDProducer.

Definition at line 214 of file L1GtTextToRaw.cc.

215 {
216 
217  // empty now
218 }
int L1GtTextToRaw::getDataSize ( )
privatevirtual

get the size of the record

Definition at line 118 of file L1GtTextToRaw.cc.

References LogDebug.

Referenced by produce().

119 {
120 
121  LogDebug("L1GtTextToRaw")
122  << "\nComputing raw data size with getRecordSize() method."
123  << std::endl;
124 
125  int rawDataSize = 0;
126 
127  LogDebug("L1GtTextToRaw")
128  << "\nComputed raw data size: " << rawDataSize
129  << std::endl;
130 
131 
132  return rawDataSize;
133 
134 }
#define LogDebug(id)
void L1GtTextToRaw::produce ( edm::Event iEvent,
const edm::EventSetup evSetup 
)
privatevirtual

loop over events

Definition at line 138 of file L1GtTextToRaw.cc.

References FEDRawData::data(), TauDecayModes::dec, getDataSize(), LogDebug, LogTrace, m_daqGtFedId, m_rawDataSize, m_textFile, eostools::move(), edm::Event::put(), FEDRawData::resize(), FEDRawData::size(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

139 {
140 
141  // get the size of the record
142 
143  int rawDataSize = 0;
144 
145  if (m_rawDataSize < 0) {
146  rawDataSize = getDataSize();
147  } else {
148  rawDataSize = m_rawDataSize;
149 
150  }
151 
152  // define new FEDRawDataCollection
153  // it contains ALL FEDs in an event
154  std::unique_ptr<FEDRawDataCollection> fedRawColl(new FEDRawDataCollection);
155 
156  FEDRawData& rawData = fedRawColl->FEDData(m_daqGtFedId);
157  // resize, GT raw data record has variable length,
158  // depending on active boards (read in GTFE)
159  rawData.resize(rawDataSize);
160 
161 
162  LogDebug("L1GtTextToRaw")
163  << "\n Size of raw data: " << rawData.size() << "\n"
164  << std::endl;
165 
166 
167  // read the text file
168  // the file must have one 64 bits per line (usually in hex format)
169  // events are separated by empty lines
170 
171  std::string lineString;
172 
173  cms_uint64_t lineInt = 0ULL;
174  int sizeL = sizeof(lineInt);
175 
176  int fedBlockSize = 8; // block size in bits for FedRawData
177  int maskBlock = 0xff; // fedBlockSize and maskBlock must be consistent
178 
179  int iLine = 0;
180 
181  while (std::getline(m_textFile, lineString)) {
182 
183  if (lineString.empty()) {
184  break;
185  }
186 
187  // convert string to int
188  std::istringstream iss(lineString);
189 
190  iss >> std::hex >> lineInt;
191 
192  LogTrace("L1GtTextToRaw")
193  << std::dec << std::setw(4) << std::setfill('0') << iLine << ": "
194  << std::hex << std::setw(sizeL*2) << lineInt
195  << std::dec << std::setfill(' ')
196  << std::endl;
197 
198  // copy data
199  for (int j = 0; j < sizeL; j++) {
200  char blockContent = (lineInt >> (fedBlockSize * j)) & maskBlock;
201  rawData.data()[iLine*sizeL + j] = blockContent;
202  }
203 
204 
205  ++iLine;
206  }
207 
208  // put the raw data in the event
209  iEvent.put(std::move(fedRawColl));
210 }
#define LogDebug(id)
virtual int getDataSize()
get the size of the record
int m_daqGtFedId
FED ID for the system.
Definition: L1GtTextToRaw.h:76
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
void resize(size_t newsize)
Definition: FEDRawData.cc:32
int m_rawDataSize
raw event size (including header and trailer) in units of 8 bits
Definition: L1GtTextToRaw.h:73
#define LogTrace(id)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
unsigned long long cms_uint64_t
Definition: typedefs.h:17
std::ifstream m_textFile
the file itself
Definition: L1GtTextToRaw.h:79
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

int L1GtTextToRaw::m_daqGtFedId
private

FED ID for the system.

Definition at line 76 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw(), and produce().

int L1GtTextToRaw::m_rawDataSize
private

raw event size (including header and trailer) in units of 8 bits

Definition at line 73 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw(), and produce().

std::ifstream L1GtTextToRaw::m_textFile
private

the file itself

Definition at line 79 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw(), and produce().

std::string L1GtTextToRaw::m_textFileName
private

file name for the text file

Definition at line 70 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw().

std::string L1GtTextToRaw::m_textFileType
private

file type for the text file

Definition at line 67 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw().