CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes | Static Private Attributes
DTROS8FileReader Class Reference

#include <DTROS8FileReader.h>

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

Public Member Functions

virtual bool checkEndOfFile ()
 
 DTROS8FileReader (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...
 
void produce (edm::Event &, edm::EventSetup const &) override
 
 ~DTROS8FileReader () override
 Destructor. More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
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
 
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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

edm::EventNumber_t eventNum
 
RawFile inputFile
 
edm::RunNumber_t runNum
 

Static Private Attributes

static const int ros8WordLenght = 4
 

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::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.8
Author
M. Zanetti - INFN Padova

Definition at line 21 of file DTROS8FileReader.h.

Constructor & Destructor Documentation

DTROS8FileReader::DTROS8FileReader ( const edm::ParameterSet pset)

Constructor.

Definition at line 33 of file DTROS8FileReader.cc.

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

33  :
34  runNum(1), eventNum(0) {
35 
36  //const string & filename = pset.getParameter<string>("fileName"); // Don't work, it produces an error saying that the DTNewROS8FileReader plugin doesn't exist!!!
37 
38  const string & filename = pset.getUntrackedParameter<string>("fileName");
39 
40  inputFile.open(filename.c_str());
41  if( inputFile.fail() ) {
42  throw cms::Exception("InputFileMissing")
43  << "DTROS8FileReader: the input file: " << filename <<" is not present";
44  }
45 
46  produces<FEDRawDataCollection>();
47 }
edm::EventNumber_t eventNum
T getUntrackedParameter(std::string const &, T const &) const
RawFile * open(const char *path)
Open file.
Definition: RawFile.cc:20
bool fail()
It is not OK.
Definition: RawFile.cc:71
edm::RunNumber_t runNum
DTROS8FileReader::~DTROS8FileReader ( )
override

Destructor.

Definition at line 50 of file DTROS8FileReader.cc.

References RawFile::close(), and inputFile.

50  {
51  inputFile.close();
52 }
int close()
Close file if necessary.
Definition: RawFile.cc:52

Member Function Documentation

bool DTROS8FileReader::checkEndOfFile ( )
virtual

Definition at line 156 of file DTROS8FileReader.cc.

References RawFile::eof(), and inputFile.

Referenced by fillRawData().

156  {
157 
158  bool retval=false;
159  if ( inputFile.eof() ) retval=true;
160  return retval;
161 
162 }
int eof()
Check end of file.
Definition: RawFile.cc:93
int DTROS8FileReader::fillRawData ( edm::Event e,
FEDRawDataCollection *&  data 
)
virtual

Generate and fill FED raw data for a full event.

Definition at line 55 of file DTROS8FileReader.cc.

References checkEndOfFile(), popcon2dropbox::copy(), gather_cfg::cout, FEDRawData::data(), data, FEDRawDataCollection::FEDData(), mps_fire::i, edm::EventBase::id(), inputFile, FEDNumbering::MINDTFEDID, RawFile::read(), FEDRawData::resize(), ros8WordLenght, and mitigatedMETSequence_cff::U.

Referenced by produce().

57  {
58  EventID eID = e.id();
59  data = new FEDRawDataCollection();
60 
61  try {
62 
63 
64  if( checkEndOfFile() ) throw 1;
65 
66 
67  // Get the total number of words from the 1st word in the payload
68  int numberOfWords=0;
69  int nread = 0;
70  nread = inputFile.read(dataPointer<int>( &numberOfWords ), ros8WordLenght);
71  if ( nread<=0 ) throw 1;
72 
73 
74  // Get the event data (all words but the 1st)
75  int* eventData = new int[numberOfWords];
76  nread = inputFile.read(dataPointer<int>( eventData + 1 ), (numberOfWords-1) * ros8WordLenght );
77  if ( nread<=0 ) throw 1;
78 
79 
80  // Check that the event data size corresponds to the 1st word datum
81  if ( eventData[numberOfWords-1] != numberOfWords ) {
82  cout << "[DTROS8FileReader]: word counter mismatch exception: "
83  << numberOfWords << " " << eventData[numberOfWords-1] << endl;
84  throw 99;
85  }
86 
87  // The header added by the local DAQ occupies 8 words, starting from the 2nd
88  int* head = eventData + 1;
89 
90  /*
91  Header word 0: run number
92  Header word 1: spill number
93  Header word 2: event number
94  Header word 3: reserved
95  Header word 4: ROS data offset
96  Header word 5: PU data offset
97  Header word 6: reserved
98  Header word 7: reserved
99  */
100 
101  // WARNING: the event number is reset at a new spill
102  eID = EventID( head[0], 1U, head[1]*head[2]);
103 
104  // The pointer to the ROS payload (the 1st word being the ROS words counter)
105  int* rosData = eventData + head[4];
106 
107  // The ROS payload size
108  int eventDataSize = *rosData * ros8WordLenght;
109  // It has to be a multiple of 8 bytes. if not, adjust the size of the FED payload
110  int adjustment = (eventDataSize/4)%2 == 1 ? 4 : 0;
111 
112  //if ( (eventDataSize/4)%2 ) adjustment = 4;
113 
114 
115  // The FED ID is always the first in the DT range
116  FEDRawData& fedRawData = data->FEDData( FEDNumbering::MINDTFEDID );
117  fedRawData.resize(eventDataSize+adjustment);
118 
119  // I pass only the ROS data to the Event
120  copy(reinterpret_cast<unsigned char*>(rosData),
121  reinterpret_cast<unsigned char*>(rosData) + eventDataSize, fedRawData.data());
122 
123  // needed to get rid of memory leaks (?)
124  delete[] eventData;
125 
126  return true;
127  }
128 
129  catch( int i ) {
130 
131  if ( i == 1 ){
132  cout << "[DTROS8FileReader]: END OF FILE REACHED. "
133  << "No information read for the requested event" << endl;
134  delete data; data=nullptr;
135  return false;
136  }
137  else {
138  cout << "[DTROS8FileReader]: PROBLEM WITH EVENT INFORMATION ON THE FILE. "
139  << "EVENT DATA READING FAILED code= " << i << endl;
140  delete data; data=nullptr;
141  return false;
142  }
143 
144  }
145 
146 }
virtual bool checkEndOfFile()
int read(void *data, size_t nbytes)
Read from file.
Definition: RawFile.cc:75
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:32
static const int ros8WordLenght
edm::EventID id() const
Definition: EventBase.h:60
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
void DTROS8FileReader::produce ( edm::Event e,
edm::EventSetup const &  es 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 148 of file DTROS8FileReader.cc.

References fillRawData(), eostools::move(), edm::Event::put(), and matplotRender::rawdata.

148  {
150  FEDRawDataCollection *fedcoll = nullptr;
151  fillRawData(e,fedcoll);
152  std::unique_ptr<FEDRawDataCollection> bare_product(fedcoll);
153  e.put(std::move(bare_product));
154  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
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

Member Data Documentation

edm::EventNumber_t DTROS8FileReader::eventNum
private

Definition at line 43 of file DTROS8FileReader.h.

RawFile DTROS8FileReader::inputFile
private
const int DTROS8FileReader::ros8WordLenght = 4
staticprivate

Definition at line 45 of file DTROS8FileReader.h.

Referenced by fillRawData().

edm::RunNumber_t DTROS8FileReader::runNum
private

Definition at line 42 of file DTROS8FileReader.h.