CMS 3D CMS Logo

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

#include <DTNewROS8FileReader.h>

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

Public Member Functions

virtual bool checkEndOfFile ()
 
 DTNewROS8FileReader (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
 
 ~DTNewROS8FileReader () 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
 
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 eventNum
 
RawFile inputFile
 
edm::RunNumber_t runNumber
 

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::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>
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)
 
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 From DTROS8FileReader

Date
2015/12/17

Definition at line 19 of file DTNewROS8FileReader.h.

Constructor & Destructor Documentation

◆ DTNewROS8FileReader()

DTNewROS8FileReader::DTNewROS8FileReader ( const edm::ParameterSet pset)

Constructor.

Definition at line 34 of file DTNewROS8FileReader.cc.

34  : runNumber(1), eventNum(0) {
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  << "DTNewROS8FileReader: the input file: " << filename << " is not present";
41  }
42 
43  produces<FEDRawDataCollection>();
44 }

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

◆ ~DTNewROS8FileReader()

DTNewROS8FileReader::~DTNewROS8FileReader ( )
override

Destructor.

Definition at line 46 of file DTNewROS8FileReader.cc.

46 { inputFile.close(); }

References RawFile::close(), and inputFile.

Member Function Documentation

◆ checkEndOfFile()

bool DTNewROS8FileReader::checkEndOfFile ( )
virtual

Definition at line 185 of file DTNewROS8FileReader.cc.

185  {
186  bool retval = false;
187  if (inputFile.eof())
188  retval = true;
189  return retval;
190 }

References RawFile::eof(), and inputFile.

Referenced by fillRawData().

◆ fillRawData()

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

Generate and fill FED raw data for a full event.

Definition at line 48 of file DTNewROS8FileReader.cc.

50  {
51  EventID eID = e.id();
52  data = new FEDRawDataCollection();
53 
54  try {
55  /* Structure of the DATA
56 
57  1.- NUMBER OF WORDS (it includes this word and the last counter)
58  2.- HEADER: 8 Words
59  Header word 0: run number
60  Header word 1: spill number
61  Header word 2: event number
62  Header word 3: reserved
63  Header word 4: ROS data offset
64  Header word 5: PU data offset
65  Header word 6: reserved
66  Header word 7: reserved
67  3.- ROS DATA ==> DECODE BY THE DTROS8Unpacker.cc in EventFilter
68  3.1 NUMBER OF ROS WORDS (it includes this counter)
69  3.2 Lock status Word
70  3.3 ROS DATA
71  3.3.1 ROS BOARD ID/ROS CHANNEL - 1 word
72  3.3.2 GLOBAL HEADER - 1 word
73  3.3.3 TDC Data Words - X words (depends on event)
74  3.3.4 GLOBAL TRAILER
75  4.- PU DATA (trigger) ==> DECODE BY THE DTROS8Unpacker.cc in EventFilter
76  Not always. If chamber is autotriggered doesn't have PU data except
77  the Number of PU words
78  4.1.- NUMBER OF WORDS (it includes this word, always present
79  even if there is not PU data)
80  4.2.- PATTERN UNIT ID - 1 word (data counter & PU-ID)
81  4.3.- DATA - X Words ?????
82  5.- NUMBER OF WORDS (include this word and the first counter)
83  */
84 
85  if (checkEndOfFile())
86  throw 1;
87 
88  // Number of words in the header, including the first word of header that is the number of words in the event
89  int numberEventHeadWords = 8;
90 
91  //1.- Get the total NUMBER OF WORDs from the 1st word in the payload
92  int numberOfWords = 0;
93  int nread = 0;
94  nread = inputFile.read(dataPointer<int>(&numberOfWords), ros8WordLenght); // ros8WordLength=4
95  if (nread <= 0)
96  throw 1;
97 
98  // inputFile.ignore(4*(numberEventHeadWords-1)); // Skip the header. The first word of header has been already read
99 
100  //2.- Get the HEADER ============================================================================
101  int datahead[numberEventHeadWords];
102  for (int iih = 0; iih < numberEventHeadWords; iih++) {
103  nread = inputFile.read(dataPointer<int>(&datahead[iih]), ros8WordLenght);
104  }
105 
106  //3.- ROS DATA & 4.- PU DATA (Trigger) =======================================================
107  // Get the event data (all words but the header and the first and the last counter)
108  int numberOfDataWords = numberOfWords - numberEventHeadWords - 2;
109  int* eventData = new int[numberOfDataWords];
110  nread = inputFile.read(dataPointer<int>(eventData), numberOfDataWords * ros8WordLenght);
111  if (nread <= 0)
112  throw 1;
113 
114  //5.- Get the total NUMBER OF WORDs from the last word in the payload
115  // Check that the event data size corresponds to the 1st word datum
116  int LastCounter = 0;
117  nread = inputFile.read(dataPointer<int>(&LastCounter), ros8WordLenght);
118  if (nread <= 0)
119  throw 1;
120 
121  if (LastCounter != numberOfWords) {
122  cout << "[DTNewROS8FileReader]: word counter mismatch exception: " << numberOfWords << " " << LastCounter << endl;
123  throw 99;
124  }
125 
126  //The first word in the header is the run number
127  runNumber = datahead[0];
128  cout << "[DTNewROS8FileReader]: Run Number: " << dec << runNumber << endl;
129 
130  //The third word in the header is the event number (without any reset)
131  //eventNum= datahead[2]; //francos system
132  eventNum = datahead[1]; //linux system
133  //cout<<"ëventNum "<<dec<<eventNum<<endl;
134  if (eventNum < 1)
135  eventNum = 1; // Event number must start at 1 but at TDCs it starts at cero,if not the program crashes
136  // files used for testing start in 1, but... just in case...
137 
138  eID = EventID(runNumber, 1U, eventNum);
139 
140  //cout << " EEEEE eID: " << eID << endl;
141  // Even if we have introducing the correct runNumber when running the runNumber appears always as =1
142 
143  int eventDataSize = numberOfDataWords * ros8WordLenght;
144  int adjustment = (eventDataSize / 4) % 2 == 1 ? 4 : 0;
145 
146  // The FED ID is always the first in the DT range
148  fedRawData.resize(eventDataSize + adjustment); // the size must be multiple of 8 bytes
149 
150  // Passing the data to the Event
151  copy(reinterpret_cast<unsigned char*>(eventData),
152  reinterpret_cast<unsigned char*>(eventData) + eventDataSize,
153  fedRawData.data());
154 
155  // needed to get rid of memory leaks (?)
156  delete[] eventData;
157 
158  return true;
159 
160  } catch (int i) {
161  if (i == 1) {
162  cout << "[DTNewROS8FileReader]: END OF FILE REACHED. "
163  << "No information read for the requested event" << endl;
164  delete data;
165  data = nullptr;
166  return false;
167  } else {
168  cout << "[DTNewROS8FileReader]: PROBLEM WITH EVENT INFORMATION ON THE FILE. "
169  << "EVENT DATA READING FAILED code= " << i << endl;
170  delete data;
171  data = nullptr;
172  return false;
173  }
174  }
175 }

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

Referenced by produce().

◆ produce()

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

Implements edm::EDProducer.

Definition at line 177 of file DTNewROS8FileReader.cc.

177  {
179  FEDRawDataCollection* fedcoll = nullptr;
180  fillRawData(e, fedcoll);
181  std::unique_ptr<FEDRawDataCollection> bare_product(fedcoll);
182  e.put(std::move(bare_product));
183 }

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

Member Data Documentation

◆ eventNum

edm::EventNumber_t DTNewROS8FileReader::eventNum
private

Definition at line 40 of file DTNewROS8FileReader.h.

Referenced by fillRawData().

◆ inputFile

RawFile DTNewROS8FileReader::inputFile
private

◆ ros8WordLenght

const int DTNewROS8FileReader::ros8WordLenght = 4
staticprivate

Definition at line 42 of file DTNewROS8FileReader.h.

Referenced by fillRawData().

◆ runNumber

edm::RunNumber_t DTNewROS8FileReader::runNumber
private

Definition at line 39 of file DTNewROS8FileReader.h.

Referenced by fillRawData().

DTNewROS8FileReader::eventNum
edm::EventNumber_t eventNum
Definition: DTNewROS8FileReader.h:40
mps_fire.i
i
Definition: mps_fire.py:355
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
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
Definition: AssociativeIterator.h:50
FEDRawData
Definition: FEDRawData.h:19
DTNewROS8FileReader::fillRawData
virtual int fillRawData(edm::Event &e, FEDRawDataCollection *&data)
Generate and fill FED raw data for a full event.
Definition: DTNewROS8FileReader.cc:48
l1t_dqm_sourceclient-live_cfg.fedRawData
fedRawData
Definition: l1t_dqm_sourceclient-live_cfg.py:182
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
DTNewROS8FileReader::inputFile
RawFile inputFile
Definition: DTNewROS8FileReader.h:37
FEDNumbering::MINDTFEDID
Definition: FEDNumbering.h:55
RawFile::open
RawFile * open(const char *path)
Open file.
Definition: RawFile.cc:19
DTNewROS8FileReader::ros8WordLenght
static const int ros8WordLenght
Definition: DTNewROS8FileReader.h:42
DTNewROS8FileReader::runNumber
edm::RunNumber_t runNumber
Definition: DTNewROS8FileReader.h:39
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:246
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
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
DTNewROS8FileReader::checkEndOfFile
virtual bool checkEndOfFile()
Definition: DTNewROS8FileReader.cc:185
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37