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
 
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)
 
 ~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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 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)
 

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 ( const edm::ParameterSet pset)

Constructor.

Definition at line 36 of file DTNewROS8FileReader.cc.

References Exception, RawFile::fail(), corrVsCorr::filename, edm::ParameterSet::getUntrackedParameter(), inputFile, and RawFile::open().

36  :
37  runNumber(1), eventNum(0) {
38 
39  const string & filename = pset.getUntrackedParameter<string>("fileName");
40 
41  inputFile.open(filename.c_str());
42  if( inputFile.fail() ) {
43  throw cms::Exception("InputFileMissing")
44  << "DTNewROS8FileReader: the input file: " << filename <<" is not present";
45  }
46 
47  produces<FEDRawDataCollection>();
48 }
T getUntrackedParameter(std::string const &, T const &) const
RawFile * open(const char *path)
Open file.
Definition: RawFile.cc:20
bool fail()
It is not OK.
Definition: RawFile.cc:72
edm::EventNumber_t eventNum
edm::RunNumber_t runNumber
DTNewROS8FileReader::~DTNewROS8FileReader ( )
override

Destructor.

Definition at line 51 of file DTNewROS8FileReader.cc.

References RawFile::close(), and inputFile.

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

Member Function Documentation

bool DTNewROS8FileReader::checkEndOfFile ( )
virtual

Definition at line 196 of file DTNewROS8FileReader.cc.

References RawFile::eof(), and inputFile.

Referenced by fillRawData().

196  {
197 
198  bool retval=false;
199  if ( inputFile.eof() ) retval=true;
200  return retval;
201 
202 }
int eof()
Check end of file.
Definition: RawFile.cc:94
int DTNewROS8FileReader::fillRawData ( edm::Event e,
FEDRawDataCollection *&  data 
)
virtual

Generate and fill FED raw data for a full event.

Definition at line 56 of file DTNewROS8FileReader.cc.

References checkEndOfFile(), popcon2dropbox::copy(), gather_cfg::cout, FEDRawData::data(), data, TauDecayModes::dec, eventNum, FEDRawDataCollection::FEDData(), mps_fire::i, edm::EventBase::id(), inputFile, FEDNumbering::MINDTFEDID, RawFile::read(), FEDRawData::resize(), ros8WordLenght, runNumber, and mitigatedMETSequence_cff::U.

Referenced by produce().

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

Implements edm::EDProducer.

Definition at line 186 of file DTNewROS8FileReader.cc.

References fillRawData(), eostools::move(), edm::Event::put(), and matplotRender::rawdata.

186  {
187 
189  FEDRawDataCollection *fedcoll = nullptr;
190  fillRawData(e,fedcoll);
191  std::unique_ptr<FEDRawDataCollection> bare_product(fedcoll);
192  e.put(std::move(bare_product));
193 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
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

edm::EventNumber_t DTNewROS8FileReader::eventNum
private

Definition at line 41 of file DTNewROS8FileReader.h.

Referenced by fillRawData().

RawFile DTNewROS8FileReader::inputFile
private
const int DTNewROS8FileReader::ros8WordLenght = 4
staticprivate

Definition at line 43 of file DTNewROS8FileReader.h.

Referenced by fillRawData().

edm::RunNumber_t DTNewROS8FileReader::runNumber
private

Definition at line 40 of file DTNewROS8FileReader.h.

Referenced by fillRawData().