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 Attributes | Static Private Attributes
DTROS25FileReader Class Reference

#include <DTROS25FileReader.h>

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

Public Member Functions

virtual bool checkEndOfFile ()
 
 DTROS25FileReader (const edm::ParameterSet &pset)
 Constructor. More...
 
virtual int fillRawData (edm::Event &e, FEDRawDataCollection *&data)
 Generate and fill FED raw data for a full event. More...
 
bool isHeader (uint32_t word)
 check for a 32 bits word to be a ROS25 header More...
 
bool isTrailer (uint32_t word)
 check for a 32 bits word to be a ROS25 trailer More...
 
virtual void produce (edm::Event &, edm::EventSetup const &)
 
void swap (uint32_t &word)
 swapping the lsBits with the msBits More...
 
virtual ~DTROS25FileReader ()
 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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::EventNumber_t eventNumber
 
RawFile inputFile
 
edm::RunNumber_t runNumber
 

Static Private Attributes

static const int rosWordLenght = 4
 

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

Read DT ROS8 raw data files

Date:
2010/02/03 16:58:24
Revision:
1.6
Author
M. Zanetti - INFN Padova

Definition at line 23 of file DTROS25FileReader.h.

Constructor & Destructor Documentation

DTROS25FileReader::DTROS25FileReader ( const edm::ParameterSet pset)

Constructor.

Definition at line 32 of file DTROS25FileReader.cc.

References Exception, RawFile::fail(), lut2db_cfg::filename, edm::ParameterSet::getUntrackedParameter(), inputFile, and RawFile::open().

32  :
33  runNumber(1), eventNumber(0) {
34 
35  const string & filename = pset.getUntrackedParameter<string>("fileName");
36 
37  inputFile.open(filename.c_str());
38  if( inputFile.fail() ) {
39  throw cms::Exception("InputFileMissing")
40  << "DTROS25FileReader: the input file: " << filename <<" is not present";
41  }
42  produces<FEDRawDataCollection>();
43 }
T getUntrackedParameter(std::string const &, T const &) const
edm::RunNumber_t runNumber
edm::EventNumber_t eventNumber
RawFile * open(const char *path)
Open file.
Definition: RawFile.cc:29
bool fail()
It is not OK.
Definition: RawFile.cc:88
tuple filename
Definition: lut2db_cfg.py:20
DTROS25FileReader::~DTROS25FileReader ( )
virtual

Destructor.

Definition at line 46 of file DTROS25FileReader.cc.

References RawFile::close(), and inputFile.

46  {
47  inputFile.close();
48 }
int close()
Close file if necessary.
Definition: RawFile.cc:66

Member Function Documentation

bool DTROS25FileReader::checkEndOfFile ( )
virtual

Definition at line 172 of file DTROS25FileReader.cc.

References RawFile::eof(), and inputFile.

172  {
173 
174  bool retval=false;
175  if ( inputFile.eof() ) retval=true;
176  return retval;
177 
178 }
int eof()
Check end of file.
Definition: RawFile.cc:118
int DTROS25FileReader::fillRawData ( edm::Event e,
FEDRawDataCollection *&  data 
)
virtual

Generate and fill FED raw data for a full event.

Definition at line 51 of file DTROS25FileReader.cc.

References filterCSVwithJSON::copy, gather_cfg::cout, FEDRawData::data(), data, eventNumber, FEDRawDataCollection::FEDData(), i, edm::EventBase::id(), inputFile, isHeader(), isTrailer(), FEDNumbering::MINDTFEDID, RawFile::read(), FEDRawData::resize(), rosWordLenght, runNumber, and swap().

Referenced by produce().

53  {
54  EventID eID = e.id();
55  data = new FEDRawDataCollection();
56 
57  vector<uint32_t> eventData;
58  size_t estimatedEventDimension = 102400; // dimensione hardcoded
59  eventData.reserve(estimatedEventDimension);
60  uint32_t word = 0;
61 
62 
63  try {
64 
65  bool marked = false;
66 
67  // getting the data word by word from the file
68  // do it until you get the ROS25 trailer
69  while ( !isTrailer(word) ) {
70 
71  // get the first word
72  int nread = inputFile.read(dataPointer<uint32_t>( &word ), rosWordLenght);
73 
74  // WARNING!!! ||swapping it|| (Check whether it is necessary)
75  swap(word);
76 
77  if ( nread<=0 ) throw 1;
78 
79  // get the ROS25 header
80  if (isHeader(word)) marked=true;
81 
82  // from now on fill the eventData with the ROS data
83  if (marked) {
84  eventData.push_back(word);
85 
86  }
87  }
88 
89  // next event reading will start with meaningless trailer+header from DTLocalDAQ
90  // those will be skipped automatically when seeking for the ROS25 header
91 
92  //if (eventData.size() > estimatedEventDimension) throw 2;
93 
94  // Setting the Event ID
95  eID = EventID( runNumber, 1U, eventNumber);
96 
97  // eventDataSize = (Number Of Words)* (Word Size)
98  int eventDataSize = eventData.size()*rosWordLenght;
99  // It has to be a multiple of 8 bytes. if not, adjust the size of the FED payload
100  int adjustment = (eventDataSize/4)%2 == 1 ? 4 : 0;
101 
102  // The FED ID is always the first in the DT range
103  FEDRawData& fedRawData = data->FEDData( FEDNumbering::MINDTFEDID );
104  fedRawData.resize(eventDataSize+adjustment);
105 
106  copy(reinterpret_cast<unsigned char*>(&eventData[0]),
107  reinterpret_cast<unsigned char*>(&eventData[0]) + eventDataSize, fedRawData.data());
108 
109  return true;
110  }
111 
112  catch( int i ) {
113 
114  if ( i == 1 ){
115  cout<<"[DTROS25FileReader]: ERROR! failed to get the trailer"<<endl;
116  delete data; data=0;
117  return false;
118  }
119  else {
120  cout<<"[DTROS25FileReader]:"
121  <<" ERROR! ROS data exceeding estimated event dimension. Event size = "
122  <<eventData.size()<<endl;
123  delete data; data=0;
124  return false;
125  }
126 
127  }
128 
129 }
int i
Definition: DBlmapReader.cc:9
edm::RunNumber_t runNumber
edm::EventNumber_t eventNumber
static const int rosWordLenght
int read(void *data, size_t nbytes)
Read from file.
Definition: RawFile.cc:94
bool isTrailer(uint32_t word)
check for a 32 bits word to be a ROS25 trailer
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:32
edm::EventID id() const
Definition: EventBase.h:59
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void swap(uint32_t &word)
swapping the lsBits with the msBits
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
tuple cout
Definition: gather_cfg.py:145
bool isHeader(uint32_t word)
check for a 32 bits word to be a ROS25 header
bool DTROS25FileReader::isHeader ( uint32_t  word)

check for a 32 bits word to be a ROS25 header

Definition at line 149 of file DTROS25FileReader.cc.

References eventNumber.

Referenced by fillRawData().

149  {
150 
151  bool it_is = false;
152  if ( (word >> 24 ) == 31 ) {
153  it_is = true;
154  ++eventNumber;
155  }
156 
157  return it_is;
158 }
edm::EventNumber_t eventNumber
bool DTROS25FileReader::isTrailer ( uint32_t  word)

check for a 32 bits word to be a ROS25 trailer

Definition at line 161 of file DTROS25FileReader.cc.

Referenced by fillRawData().

161  {
162 
163  bool it_is = false;
164  if ( (word >> 24 ) == 63 ) {
165  it_is = true;
166  }
167 
168  return it_is;
169 }
void DTROS25FileReader::produce ( edm::Event e,
edm::EventSetup const &  es 
)
virtual

Implements edm::EDProducer.

Definition at line 131 of file DTROS25FileReader.cc.

References fillRawData(), edm::Event::put(), and lumiPlot::rawdata.

131  {
133  FEDRawDataCollection *fedcoll = 0;
134  fillRawData(e,fedcoll);
135  std::auto_ptr<FEDRawDataCollection> bare_product(fedcoll);
136  e.put(bare_product);
137  }
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
virtual int fillRawData(edm::Event &e, FEDRawDataCollection *&data)
Generate and fill FED raw data for a full event.
dictionary rawdata
Definition: lumiPlot.py:393
void DTROS25FileReader::swap ( uint32_t &  word)

swapping the lsBits with the msBits

Definition at line 139 of file DTROS25FileReader.cc.

References twoNibble::lsBits, and twoNibble::msBits.

Referenced by fillRawData().

139  {
140 
141  twoNibble* newWorld = reinterpret_cast<twoNibble*>(&word);
142 
143  uint16_t msBits_tmp = newWorld->msBits;
144  newWorld->msBits = newWorld->lsBits;
145  newWorld->lsBits = msBits_tmp;
146 }

Member Data Documentation

edm::EventNumber_t DTROS25FileReader::eventNumber
private

Definition at line 56 of file DTROS25FileReader.h.

Referenced by fillRawData(), and isHeader().

RawFile DTROS25FileReader::inputFile
private
const int DTROS25FileReader::rosWordLenght = 4
staticprivate

Definition at line 58 of file DTROS25FileReader.h.

Referenced by fillRawData().

edm::RunNumber_t DTROS25FileReader::runNumber
private

Definition at line 55 of file DTROS25FileReader.h.

Referenced by fillRawData().