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...
 
 ~L1GtTextToRaw () override
 destructor More...
 
- 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
 
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)
 
 ~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
 
ESProxyIndex const * esGetTokenIndices (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::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
 
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
 beginning of job stuff More...
 
virtual void cleanTextFile ()
 clean the text file, if needed More...
 
void endJob () override
 end of job stuff More...
 
virtual int getDataSize ()
 get the size of the record More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 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
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 wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 33 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.

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

destructor

Definition at line 68 of file L1GtTextToRaw.cc.

68  {
69  // empty now
70 }

Member Function Documentation

void L1GtTextToRaw::beginJob ( void  )
overrideprivatevirtual

beginning of job stuff

Reimplemented from edm::EDProducer.

Definition at line 75 of file L1GtTextToRaw.cc.

References cleanTextFile().

75 { cleanTextFile(); }
virtual void cleanTextFile()
clean the text file, if needed
void L1GtTextToRaw::cleanTextFile ( )
privatevirtual

clean the text file, if needed

Definition at line 78 of file L1GtTextToRaw.cc.

References LogDebug.

Referenced by beginJob().

78 { LogDebug("L1GtTextToRaw") << "\nCleaning the text file\n" << std::endl; }
#define LogDebug(id)
void L1GtTextToRaw::endJob ( void  )
overrideprivatevirtual

end of job stuff

Reimplemented from edm::EDProducer.

Definition at line 155 of file L1GtTextToRaw.cc.

155  {
156  // empty now
157 }
int L1GtTextToRaw::getDataSize ( )
privatevirtual

get the size of the record

Definition at line 81 of file L1GtTextToRaw.cc.

References LogDebug.

Referenced by produce().

81  {
82  LogDebug("L1GtTextToRaw") << "\nComputing raw data size with getRecordSize() method." << std::endl;
83 
84  int rawDataSize = 0;
85 
86  LogDebug("L1GtTextToRaw") << "\nComputed raw data size: " << rawDataSize << std::endl;
87 
88  return rawDataSize;
89 }
#define LogDebug(id)
void L1GtTextToRaw::produce ( edm::Event iEvent,
const edm::EventSetup evSetup 
)
overrideprivate

loop over events

Definition at line 92 of file L1GtTextToRaw.cc.

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

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

92  {
93  // get the size of the record
94 
95  int rawDataSize = 0;
96 
97  if (m_rawDataSize < 0) {
98  rawDataSize = getDataSize();
99  } else {
100  rawDataSize = m_rawDataSize;
101  }
102 
103  // define new FEDRawDataCollection
104  // it contains ALL FEDs in an event
105  std::unique_ptr<FEDRawDataCollection> fedRawColl(new FEDRawDataCollection);
106 
107  FEDRawData& rawData = fedRawColl->FEDData(m_daqGtFedId);
108  // resize, GT raw data record has variable length,
109  // depending on active boards (read in GTFE)
110  rawData.resize(rawDataSize);
111 
112  LogDebug("L1GtTextToRaw") << "\n Size of raw data: " << rawData.size() << "\n" << std::endl;
113 
114  // read the text file
115  // the file must have one 64 bits per line (usually in hex format)
116  // events are separated by empty lines
117 
118  std::string lineString;
119 
120  cms_uint64_t lineInt = 0ULL;
121  int sizeL = sizeof(lineInt);
122 
123  int fedBlockSize = 8; // block size in bits for FedRawData
124  int maskBlock = 0xff; // fedBlockSize and maskBlock must be consistent
125 
126  int iLine = 0;
127 
128  while (std::getline(m_textFile, lineString)) {
129  if (lineString.empty()) {
130  break;
131  }
132 
133  // convert string to int
134  std::istringstream iss(lineString);
135 
136  iss >> std::hex >> lineInt;
137 
138  LogTrace("L1GtTextToRaw") << std::dec << std::setw(4) << std::setfill('0') << iLine << ": " << std::hex
139  << std::setw(sizeL * 2) << lineInt << std::dec << std::setfill(' ') << std::endl;
140 
141  // copy data
142  for (int j = 0; j < sizeL; j++) {
143  char blockContent = (lineInt >> (fedBlockSize * j)) & maskBlock;
144  rawData.data()[iLine * sizeL + j] = blockContent;
145  }
146 
147  ++iLine;
148  }
149 
150  // put the raw data in the event
151  iEvent.put(std::move(fedRawColl));
152 }
#define LogDebug(id)
virtual int getDataSize()
get the size of the record
int m_daqGtFedId
FED ID for the system.
Definition: L1GtTextToRaw.h:71
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
void resize(size_t newsize)
Definition: FEDRawData.cc:28
int m_rawDataSize
raw event size (including header and trailer) in units of 8 bits
Definition: L1GtTextToRaw.h:68
#define LogTrace(id)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
unsigned long long cms_uint64_t
Definition: typedefs.h:17
std::ifstream m_textFile
the file itself
Definition: L1GtTextToRaw.h:74
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

int L1GtTextToRaw::m_daqGtFedId
private

FED ID for the system.

Definition at line 71 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 68 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw(), and produce().

std::ifstream L1GtTextToRaw::m_textFile
private

the file itself

Definition at line 74 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw(), and produce().

std::string L1GtTextToRaw::m_textFileName
private

file name for the text file

Definition at line 65 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw().

std::string L1GtTextToRaw::m_textFileType
private

file type for the text file

Definition at line 62 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw().