CMS 3D CMS Logo

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)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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(), corrVsCorr::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:20
bool fail()
It is not OK.
Definition: RawFile.cc:71
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:52

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:93
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 popcon2dropbox::copy(), gather_cfg::cout, FEDRawData::data(), data, eventNumber, FEDRawDataCollection::FEDData(), mps_fire::i, edm::EventBase::id(), inputFile, isHeader(), isTrailer(), FEDNumbering::MINDTFEDID, RawFile::read(), FEDRawData::resize(), rosWordLenght, runNumber, swap(), and mitigatedMETSequence_cff::U.

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 }
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:75
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:60
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
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(), eostools::move(), edm::Event::put(), and matplotRender::rawdata.

131  {
133  FEDRawDataCollection *fedcoll = 0;
134  fillRawData(e,fedcoll);
135  std::unique_ptr<FEDRawDataCollection> bare_product(fedcoll);
136  e.put(std::move(bare_product));
137  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
virtual int fillRawData(edm::Event &e, FEDRawDataCollection *&data)
Generate and fill FED raw data for a full event.
def move(src, dest)
Definition: eostools.py:510
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
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().