CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::ProductRegistryHelper

Public Member Functions

 L1GtTextToRaw (const edm::ParameterSet &)
 constructor(s) More...
 
virtual ~L1GtTextToRaw ()
 destructor More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Description: generate raw data from dumped text file.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna

$Date$ $Revision$

Definition at line 38 of file L1GtTextToRaw.h.

Constructor & Destructor Documentation

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

constructor(s)

Definition at line 42 of file L1GtTextToRaw.cc.

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

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

destructor

Definition at line 90 of file L1GtTextToRaw.cc.

91 {
92 
93  // empty now
94 
95 }

Member Function Documentation

void L1GtTextToRaw::beginJob ( void  )
privatevirtual

beginning of job stuff

Reimplemented from edm::EDProducer.

Definition at line 100 of file L1GtTextToRaw.cc.

References cleanTextFile().

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

clean the text file, if needed

Definition at line 108 of file L1GtTextToRaw.cc.

References LogDebug.

Referenced by beginJob().

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

end of job stuff

Reimplemented from edm::EDProducer.

Definition at line 216 of file L1GtTextToRaw.cc.

217 {
218 
219  // empty now
220 }
int L1GtTextToRaw::getDataSize ( )
privatevirtual

get the size of the record

Definition at line 120 of file L1GtTextToRaw.cc.

References LogDebug.

Referenced by produce().

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

loop over events

Implements edm::EDProducer.

Definition at line 140 of file L1GtTextToRaw.cc.

References FEDRawData::data(), getDataSize(), j, LogDebug, LogTrace, m_daqGtFedId, m_rawDataSize, m_textFile, edm::Event::put(), FEDRawData::resize(), and FEDRawData::size().

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

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

Member Data Documentation

int L1GtTextToRaw::m_daqGtFedId
private

FED ID for the system.

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

Referenced by L1GtTextToRaw(), and produce().

std::ifstream L1GtTextToRaw::m_textFile
private

the file itself

Definition at line 81 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw(), and produce().

std::string L1GtTextToRaw::m_textFileName
private

file name for the text file

Definition at line 72 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw().

std::string L1GtTextToRaw::m_textFileType
private

file type for the text file

Definition at line 69 of file L1GtTextToRaw.h.

Referenced by L1GtTextToRaw().