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::one::EDProducer<> edm::one::EDProducerBase 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::one::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDProducerBase () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, 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::ESRecordsToProductResolverIndices 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::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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.

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 }
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
T getUntrackedParameter(std::string const &, T const &) const
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
#define LogDebug(id)

◆ ~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::one::EDProducerBase.

Definition at line 75 of file L1GtTextToRaw.cc.

References cleanTextFile().

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

◆ cleanTextFile()

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)

◆ endJob()

void L1GtTextToRaw::endJob ( void  )
overrideprivatevirtual

end of job stuff

Reimplemented from edm::one::EDProducerBase.

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.

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)

◆ produce()

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

loop over events

Implements edm::one::EDProducerBase.

Definition at line 92 of file L1GtTextToRaw.cc.

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.

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 }
virtual int getDataSize()
get the size of the record
int m_daqGtFedId
FED ID for the system.
Definition: L1GtTextToRaw.h:71
#define LogTrace(id)
int iEvent
Definition: GenABIO.cc:224
int m_rawDataSize
raw event size (including header and trailer) in units of 8 bits
Definition: L1GtTextToRaw.h:68
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
#define LogDebug(id)

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