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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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 selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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.

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

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 }
edm::RunNumber_t runNumber
edm::EventNumber_t eventNumber
RawFile * open(const char *path)
Open file.
Definition: RawFile.cc:19
bool fail()
It is not OK.
Definition: RawFile.cc:72

◆ ~DTROS25FileReader()

DTROS25FileReader::~DTROS25FileReader ( )
override

Destructor.

Definition at line 41 of file DTROS25FileReader.cc.

References RawFile::close(), and inputFile.

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

Member Function Documentation

◆ checkEndOfFile()

bool DTROS25FileReader::checkEndOfFile ( )
virtual

Definition at line 154 of file DTROS25FileReader.cc.

References RawFile::eof(), and inputFile.

154  {
155  bool retval = false;
156  if (inputFile.eof())
157  retval = true;
158  return retval;
159 }
int eof()
Check end of file.
Definition: RawFile.cc:94

◆ 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.

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().

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 }
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:76
bool isTrailer(uint32_t word)
check for a 32 bits word to be a ROS25 trailer
uint64_t word
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void swap(uint32_t &word)
swapping the lsBits with the msBits
bool isHeader(uint32_t word)
check for a 32 bits word to be a ROS25 header

◆ 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.

References eventNumber.

Referenced by fillRawData().

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

◆ 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.

Referenced by fillRawData().

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

◆ produce()

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

Implements edm::EDProducer.

Definition at line 119 of file DTROS25FileReader.cc.

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

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 }
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:511

◆ swap()

void DTROS25FileReader::swap ( uint32_t &  word)

swapping the lsBits with the msBits

Definition at line 127 of file DTROS25FileReader.cc.

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

Referenced by fillRawData().

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 }
uint64_t word

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().