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
 
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
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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
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>
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)
 
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: 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::L1GtTextToRaw ( const edm::ParameterSet pSet)
explicit

constructor(s)

Definition at line 33 of file L1GtTextToRaw.cc.

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 }

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

◆ ~L1GtTextToRaw()

L1GtTextToRaw::~L1GtTextToRaw ( )
override

destructor

Definition at line 68 of file L1GtTextToRaw.cc.

68  {
69  // empty now
70 }

Member Function Documentation

◆ beginJob()

void L1GtTextToRaw::beginJob ( void  )
overrideprivatevirtual

beginning of job stuff

Reimplemented from edm::EDProducer.

Definition at line 75 of file L1GtTextToRaw.cc.

75 { cleanTextFile(); }

References cleanTextFile().

◆ cleanTextFile()

void L1GtTextToRaw::cleanTextFile ( )
privatevirtual

clean the text file, if needed

Definition at line 78 of file L1GtTextToRaw.cc.

78 { LogDebug("L1GtTextToRaw") << "\nCleaning the text file\n" << std::endl; }

References LogDebug.

Referenced by beginJob().

◆ endJob()

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 }

◆ getDataSize()

int L1GtTextToRaw::getDataSize ( )
privatevirtual

get the size of the record

Definition at line 81 of file L1GtTextToRaw.cc.

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 }

References LogDebug.

Referenced by produce().

◆ produce()

void L1GtTextToRaw::produce ( edm::Event iEvent,
const edm::EventSetup evSetup 
)
overrideprivatevirtual

loop over events

Implements edm::EDProducer.

Definition at line 92 of file L1GtTextToRaw.cc.

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 }

References TauDecayModes::dec, getDataSize(), iEvent, dqmiolumiharvest::j, LogDebug, LogTrace, m_daqGtFedId, m_rawDataSize, m_textFile, eostools::move(), l1tstage2_dqm_sourceclient-live_cfg::rawData, and AlCaHLTBitMon_QueryRunRegistry::string.

Member Data Documentation

◆ m_daqGtFedId

int L1GtTextToRaw::m_daqGtFedId
private

FED ID for the system.

Definition at line 71 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw(), and produce().

◆ m_rawDataSize

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().

◆ m_textFile

std::ifstream L1GtTextToRaw::m_textFile
private

the file itself

Definition at line 74 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw(), and produce().

◆ m_textFileName

std::string L1GtTextToRaw::m_textFileName
private

file name for the text file

Definition at line 65 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw().

◆ m_textFileType

std::string L1GtTextToRaw::m_textFileType
private

file type for the text file

Definition at line 62 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw().

L1GtTextToRaw::m_textFile
std::ifstream m_textFile
the file itself
Definition: L1GtTextToRaw.h:74
L1GtTextToRaw::m_daqGtFedId
int m_daqGtFedId
FED ID for the system.
Definition: L1GtTextToRaw.h:71
FEDRawDataCollection
Definition: FEDRawDataCollection.h:18
l1tstage2_dqm_sourceclient-live_cfg.rawData
rawData
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:156
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
L1GtTextToRaw::getDataSize
virtual int getDataSize()
get the size of the record
Definition: L1GtTextToRaw.cc:81
FEDRawData
Definition: FEDRawData.h:19
FEDNumbering::MAXTriggerGTPFEDID
Definition: FEDNumbering.h:62
L1GtTextToRaw::m_textFileName
std::string m_textFileName
file name for the text file
Definition: L1GtTextToRaw.h:65
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1GtTextToRaw::m_textFileType
std::string m_textFileType
file type for the text file
Definition: L1GtTextToRaw.h:62
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
recoMuon::in
Definition: RecoMuonEnumerators.h:6
iEvent
int iEvent
Definition: GenABIO.cc:224
cms_uint64_t
unsigned long long cms_uint64_t
Definition: typedefs.h:17
L1GtTextToRaw::m_rawDataSize
int m_rawDataSize
raw event size (including header and trailer) in units of 8 bits
Definition: L1GtTextToRaw.h:68
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:246
L1GtTextToRaw::cleanTextFile
virtual void cleanTextFile()
clean the text file, if needed
Definition: L1GtTextToRaw.cc:78
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143