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::one::EDProducer<> edm::one::EDProducerBase 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::one::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 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 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.

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

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

◆ ~DTNewROS8FileReader()

DTNewROS8FileReader::~DTNewROS8FileReader ( )
override

Destructor.

Definition at line 46 of file DTNewROS8FileReader.cc.

References RawFile::close(), and inputFile.

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

Member Function Documentation

◆ checkEndOfFile()

bool DTNewROS8FileReader::checkEndOfFile ( )
virtual

Definition at line 185 of file DTNewROS8FileReader.cc.

References RawFile::eof(), and inputFile.

Referenced by fillRawData().

185  {
186  bool retval = false;
187  if (inputFile.eof())
188  retval = true;
189  return retval;
190 }
int eof()
Check end of file.
Definition: RawFile.cc:94

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

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

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 }
edm::EventNumber_t eventNum
int read(void *data, size_t nbytes)
Read from file.
Definition: RawFile.cc:76
static const int ros8WordLenght
virtual bool checkEndOfFile()
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
edm::RunNumber_t runNumber

◆ produce()

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

Implements edm::one::EDProducerBase.

Definition at line 177 of file DTNewROS8FileReader.cc.

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

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

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