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 ()
 
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::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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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 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 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.8
Author
M. Zanetti - INFN Padova

Definition at line 21 of file DTROS8FileReader.h.

Constructor & Destructor Documentation

◆ DTROS8FileReader()

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

Constructor.

Definition at line 31 of file DTROS8FileReader.cc.

31  : runNum(1), eventNum(0) {
32  //const string & filename = pset.getParameter<string>("fileName"); // Don't work, it produces an error saying that the DTNewROS8FileReader plugin doesn't exist!!!
33 
34  const string& filename = pset.getUntrackedParameter<string>("fileName");
35 
36  inputFile.open(filename.c_str());
37  if (inputFile.fail()) {
38  throw cms::Exception("InputFileMissing") << "DTROS8FileReader: the input file: " << filename << " is not present";
39  }
40 
41  produces<FEDRawDataCollection>();
42 }

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

◆ ~DTROS8FileReader()

DTROS8FileReader::~DTROS8FileReader ( )
override

Destructor.

Definition at line 44 of file DTROS8FileReader.cc.

44 { inputFile.close(); }

References RawFile::close(), and inputFile.

Member Function Documentation

◆ checkEndOfFile()

bool DTROS8FileReader::checkEndOfFile ( )
virtual

Definition at line 143 of file DTROS8FileReader.cc.

143  {
144  bool retval = false;
145  if (inputFile.eof())
146  retval = true;
147  return retval;
148 }

References RawFile::eof(), and inputFile.

Referenced by fillRawData().

◆ fillRawData()

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

Generate and fill FED raw data for a full event.

Definition at line 46 of file DTROS8FileReader.cc.

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

References checkEndOfFile(), filterCSVwithJSON::copy, gather_cfg::cout, data, MillePedeFileConverter_cfg::e, l1t_dqm_sourceclient-live_cfg::fedRawData, EcalFEDMonitor_cfi::FEDRawDataCollection, mps_fire::i, inputFile, FEDNumbering::MINDTFEDID, RawFile::read(), ros8WordLenght, and mitigatedMETSequence_cff::U.

Referenced by produce().

◆ produce()

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

Implements edm::EDProducer.

Definition at line 135 of file DTROS8FileReader.cc.

135  {
137  FEDRawDataCollection* fedcoll = nullptr;
138  fillRawData(e, fedcoll);
139  std::unique_ptr<FEDRawDataCollection> bare_product(fedcoll);
140  e.put(std::move(bare_product));
141 }

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

Member Data Documentation

◆ eventNum

edm::EventNumber_t DTROS8FileReader::eventNum
private

Definition at line 42 of file DTROS8FileReader.h.

◆ inputFile

RawFile DTROS8FileReader::inputFile
private

◆ ros8WordLenght

const int DTROS8FileReader::ros8WordLenght = 4
staticprivate

Definition at line 44 of file DTROS8FileReader.h.

Referenced by fillRawData().

◆ runNum

edm::RunNumber_t DTROS8FileReader::runNum
private

Definition at line 41 of file DTROS8FileReader.h.

DTROS8FileReader::fillRawData
virtual int fillRawData(edm::Event &e, FEDRawDataCollection *&data)
Generate and fill FED raw data for a full event.
Definition: DTROS8FileReader.cc:46
mps_fire.i
i
Definition: mps_fire.py:428
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DTROS8FileReader::eventNum
edm::EventNumber_t eventNum
Definition: DTROS8FileReader.h:42
FEDRawDataCollection
Definition: FEDRawDataCollection.h:18
gather_cfg.cout
cout
Definition: gather_cfg.py:144
RawFile::eof
int eof()
Check end of file.
Definition: RawFile.cc:94
edm::Handle< FEDRawDataCollection >
FEDRawData
Definition: FEDRawData.h:19
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
DTROS8FileReader::inputFile
RawFile inputFile
Definition: DTROS8FileReader.h:39
DTROS8FileReader::ros8WordLenght
static const int ros8WordLenght
Definition: DTROS8FileReader.h:44
DTROS8FileReader::checkEndOfFile
virtual bool checkEndOfFile()
Definition: DTROS8FileReader.cc:143
RawFile::open
RawFile * open(const char *path)
Open file.
Definition: RawFile.cc:19
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:245
DTROS8FileReader::runNum
edm::RunNumber_t runNum
Definition: DTROS8FileReader.h:41
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
FEDNumbering::MINDTFEDID
Definition: FEDNumbering.h:55
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