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...
 
void produce (edm::Event &, edm::EventSetup const &) override
 
void swap (uint32_t &word)
 swapping the lsBits with the msBits More...
 
 ~DTROS25FileReader () override
 Destructor. More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
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
 
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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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
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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
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)
 
template<Transition B>
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 (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (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::DTROS25FileReader ( const edm::ParameterSet pset)

Constructor.

Definition at line 31 of file DTROS25FileReader.cc.

31  : runNumber(1), eventNumber(0) {
32  const string& filename = pset.getUntrackedParameter<string>("fileName");
33 
34  inputFile.open(filename.c_str());
35  if (inputFile.fail()) {
36  throw cms::Exception("InputFileMissing") << "DTROS25FileReader: the input file: " << filename << " is not present";
37  }
38  produces<FEDRawDataCollection>();
39 }

References Exception, RawFile::fail(), corrVsCorr::filename, inputFile, RawFile::open(), and muonDTDigis_cfi::pset.

◆ ~DTROS25FileReader()

DTROS25FileReader::~DTROS25FileReader ( )
override

Destructor.

Definition at line 41 of file DTROS25FileReader.cc.

41 { inputFile.close(); }

References RawFile::close(), and inputFile.

Member Function Documentation

◆ checkEndOfFile()

bool DTROS25FileReader::checkEndOfFile ( )
virtual

Definition at line 154 of file DTROS25FileReader.cc.

154  {
155  bool retval = false;
156  if (inputFile.eof())
157  retval = true;
158  return retval;
159 }

References RawFile::eof(), and inputFile.

◆ fillRawData()

int DTROS25FileReader::fillRawData ( edm::Event e,
FEDRawDataCollection *&  data 
)
virtual

Generate and fill FED raw data for a full event.

Definition at line 43 of file DTROS25FileReader.cc.

45  {
46  EventID eID = e.id();
47  data = new FEDRawDataCollection();
48 
49  vector<uint32_t> eventData;
50  size_t estimatedEventDimension = 102400; // dimensione hardcoded
51  eventData.reserve(estimatedEventDimension);
52  uint32_t word = 0;
53 
54  try {
55  bool marked = false;
56 
57  // getting the data word by word from the file
58  // do it until you get the ROS25 trailer
59  while (!isTrailer(word)) {
60  // get the first word
61  int nread = inputFile.read(dataPointer<uint32_t>(&word), rosWordLenght);
62 
63  // WARNING!!! ||swapping it|| (Check whether it is necessary)
64  swap(word);
65 
66  if (nread <= 0)
67  throw 1;
68 
69  // get the ROS25 header
70  if (isHeader(word))
71  marked = true;
72 
73  // from now on fill the eventData with the ROS data
74  if (marked) {
75  eventData.push_back(word);
76  }
77  }
78 
79  // next event reading will start with meaningless trailer+header from DTLocalDAQ
80  // those will be skipped automatically when seeking for the ROS25 header
81 
82  //if (eventData.size() > estimatedEventDimension) throw 2;
83 
84  // Setting the Event ID
85  eID = EventID(runNumber, 1U, eventNumber);
86 
87  // eventDataSize = (Number Of Words)* (Word Size)
88  int eventDataSize = eventData.size() * rosWordLenght;
89  // It has to be a multiple of 8 bytes. if not, adjust the size of the FED payload
90  int adjustment = (eventDataSize / 4) % 2 == 1 ? 4 : 0;
91 
92  // The FED ID is always the first in the DT range
94  fedRawData.resize(eventDataSize + adjustment);
95 
96  copy(reinterpret_cast<unsigned char*>(&eventData[0]),
97  reinterpret_cast<unsigned char*>(&eventData[0]) + eventDataSize,
98  fedRawData.data());
99 
100  return true;
101  }
102 
103  catch (int i) {
104  if (i == 1) {
105  cout << "[DTROS25FileReader]: ERROR! failed to get the trailer" << endl;
106  delete data;
107  data = nullptr;
108  return false;
109  } else {
110  cout << "[DTROS25FileReader]:"
111  << " ERROR! ROS data exceeding estimated event dimension. Event size = " << eventData.size() << endl;
112  delete data;
113  data = nullptr;
114  return false;
115  }
116  }
117 }

References filterCSVwithJSON::copy, gather_cfg::cout, data, MillePedeFileConverter_cfg::e, eventNumber, l1t_dqm_sourceclient-live_cfg::fedRawData, EcalFEDMonitor_cfi::FEDRawDataCollection, mps_fire::i, inputFile, isHeader(), isTrailer(), FEDNumbering::MINDTFEDID, RawFile::read(), rosWordLenght, runNumber, swap(), and mitigatedMETSequence_cff::U.

Referenced by produce().

◆ isHeader()

bool DTROS25FileReader::isHeader ( uint32_t  word)

check for a 32 bits word to be a ROS25 header

Definition at line 135 of file DTROS25FileReader.cc.

135  {
136  bool it_is = false;
137  if ((word >> 24) == 31) {
138  it_is = true;
139  ++eventNumber;
140  }
141 
142  return it_is;
143 }

References eventNumber.

Referenced by fillRawData().

◆ isTrailer()

bool DTROS25FileReader::isTrailer ( uint32_t  word)

check for a 32 bits word to be a ROS25 trailer

Definition at line 145 of file DTROS25FileReader.cc.

145  {
146  bool it_is = false;
147  if ((word >> 24) == 63) {
148  it_is = true;
149  }
150 
151  return it_is;
152 }

Referenced by fillRawData().

◆ produce()

void DTROS25FileReader::produce ( edm::Event e,
edm::EventSetup const &  es 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 119 of file DTROS25FileReader.cc.

119  {
121  FEDRawDataCollection* fedcoll = nullptr;
122  fillRawData(e, fedcoll);
123  std::unique_ptr<FEDRawDataCollection> bare_product(fedcoll);
124  e.put(std::move(bare_product));
125 }

References MillePedeFileConverter_cfg::e, fillRawData(), and eostools::move().

◆ swap()

void DTROS25FileReader::swap ( uint32_t &  word)

swapping the lsBits with the msBits

Definition at line 127 of file DTROS25FileReader.cc.

127  {
128  twoNibble* newWorld = reinterpret_cast<twoNibble*>(&word);
129 
130  uint16_t msBits_tmp = newWorld->msBits;
131  newWorld->msBits = newWorld->lsBits;
132  newWorld->lsBits = msBits_tmp;
133 }

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

Referenced by fillRawData().

Member Data Documentation

◆ eventNumber

edm::EventNumber_t DTROS25FileReader::eventNumber
private

Definition at line 53 of file DTROS25FileReader.h.

Referenced by fillRawData(), and isHeader().

◆ inputFile

RawFile DTROS25FileReader::inputFile
private

◆ rosWordLenght

const int DTROS25FileReader::rosWordLenght = 4
staticprivate

Definition at line 55 of file DTROS25FileReader.h.

Referenced by fillRawData().

◆ runNumber

edm::RunNumber_t DTROS25FileReader::runNumber
private

Definition at line 52 of file DTROS25FileReader.h.

Referenced by fillRawData().

DTROS25FileReader::runNumber
edm::RunNumber_t runNumber
Definition: DTROS25FileReader.h:52
DTROS25FileReader::isHeader
bool isHeader(uint32_t word)
check for a 32 bits word to be a ROS25 header
Definition: DTROS25FileReader.cc:135
mps_fire.i
i
Definition: mps_fire.py:428
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DTROS25FileReader::eventNumber
edm::EventNumber_t eventNumber
Definition: DTROS25FileReader.h:53
DTROS25FileReader::rosWordLenght
static const int rosWordLenght
Definition: DTROS25FileReader.h:55
FEDRawDataCollection
Definition: FEDRawDataCollection.h:18
DTROS25FileReader::isTrailer
bool isTrailer(uint32_t word)
check for a 32 bits word to be a ROS25 trailer
Definition: DTROS25FileReader.cc:145
gather_cfg.cout
cout
Definition: gather_cfg.py:144
RawFile::eof
int eof()
Check end of file.
Definition: RawFile.cc:94
DTROS25FileReader::inputFile
RawFile inputFile
Definition: DTROS25FileReader.h:50
edm::Handle
Definition: AssociativeIterator.h:50
FEDRawData
Definition: FEDRawData.h:19
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
l1t_dqm_sourceclient-live_cfg.fedRawData
fedRawData
Definition: l1t_dqm_sourceclient-live_cfg.py:188
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
EcalFEDMonitor_cfi.FEDRawDataCollection
FEDRawDataCollection
Definition: EcalFEDMonitor_cfi.py:6
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
DTROS25FileReader::fillRawData
virtual int fillRawData(edm::Event &e, FEDRawDataCollection *&data)
Generate and fill FED raw data for a full event.
Definition: DTROS25FileReader.cc:43
twoNibble::msBits
uint16_t msBits
Definition: DTFileReaderHelpers.h:29
FEDNumbering::MINDTFEDID
Definition: FEDNumbering.h:55
RawFile::open
RawFile * open(const char *path)
Open file.
Definition: RawFile.cc:19
eostools.move
def move(src, dest)
Definition: eostools.py:511
DTROS25FileReader::swap
void swap(uint32_t &word)
swapping the lsBits with the msBits
Definition: DTROS25FileReader.cc:127
twoNibble
Definition: DTFileReaderHelpers.h:27
Exception
Definition: hltDiff.cc:246
twoNibble::lsBits
uint16_t lsBits
Definition: DTFileReaderHelpers.h:28
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
RawFile::read
int read(void *data, size_t nbytes)
Read from file.
Definition: RawFile.cc:76
edm::EventID
Definition: EventID.h:31
RawFile::fail
bool fail()
It is not OK.
Definition: RawFile.cc:72
RawFile::close
int close()
Close file if necessary.
Definition: RawFile.cc:52
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37