CMS 3D CMS Logo

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

#include <DTSpyReader.h>

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

Public Member Functions

uint64_t dmaUnpack (const uint32_t *dmaData, bool &isData)
 pre-unpack the data if read via DMA More...
 
 DTSpyReader (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 (uint64_t word, bool dataTag)
 check for a 64 bits word to be a DDU header More...
 
bool isTrailer (uint64_t word, bool dataTag, unsigned int wordCount)
 check for a 64 bits word to be a DDU trailer More...
 
void produce (edm::Event &, edm::EventSetup const &) override
 
void swap (uint64_t &word)
 swapping the lsBits with the msBits More...
 
 ~DTSpyReader () 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

int dduID
 
bool debug
 
edm::EventNumber_t eventNumber
 
DTSpymySpy
 
edm::RunNumber_t runNumber
 

Static Private Attributes

static const int dduWordLength = 8
 

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

Date
2010/02/03 16:58:24
Revision
1.4
Author
M. Zanetti - INFN Padova

Definition at line 24 of file DTSpyReader.h.

Constructor & Destructor Documentation

DTSpyReader::DTSpyReader ( const edm::ParameterSet pset)

Constructor.

connecting to XDAQ note ("0.0.0.0" = localhost)

Definition at line 33 of file DTSpyReader.cc.

References DTCtcp::Connect(), gather_cfg::cout, dduID, debug, edm::ParameterSet::getUntrackedParameter(), and mySpy.

33  :
34  runNumber(1), eventNumber(0) {
35 
36  // instatiating Sandro's spy (My name is Bond, Sandro Bond)
37  mySpy = new DTSpy();
38 
40  string connectionParameters = pset.getUntrackedParameter<string>("connectionParameters");
41  mySpy->Connect(connectionParameters.c_str(),10000);
42 
43  cout<<endl;
44  cout<<"DT Local DAQ online spy. Connected to IP "<<connectionParameters.c_str()
45  <<". Waiting for the data to be flushed"<<endl;
46  cout<<endl;
47 
48  debug = pset.getUntrackedParameter<bool>("debug",false);
49  dduID = pset.getUntrackedParameter<int32_t>("dduID",770); // NOT needed
50 
51  produces<FEDRawDataCollection>();
52 }
T getUntrackedParameter(std::string const &, T const &) const
void Connect(const char *hostaddr, int port)
Definition: DTSpyHelper.cc:162
edm::EventNumber_t eventNumber
Definition: DTSpyReader.h:58
Definition: DTSpy.h:17
DTSpy * mySpy
Definition: DTSpyReader.h:55
edm::RunNumber_t runNumber
Definition: DTSpyReader.h:57
DTSpyReader::~DTSpyReader ( )
override

Destructor.

Definition at line 55 of file DTSpyReader.cc.

References mySpy.

55  {
56  delete mySpy;
57 }
DTSpy * mySpy
Definition: DTSpyReader.h:55

Member Function Documentation

uint64_t DTSpyReader::dmaUnpack ( const uint32_t *  dmaData,
bool &  isData 
)

pre-unpack the data if read via DMA

Definition at line 155 of file DTSpyReader.cc.

Referenced by fillRawData().

155  {
156 
157  uint32_t unpackedData[2] = {0, 0};
158  // adjust 4 32-bits words into 2 32-bits words
159  unpackedData[0] |= dmaData[3] & 0x3ffff;
160  unpackedData[0] |= (dmaData[2] << 18 ) & 0xfffc0000;
161  unpackedData[1] |= (dmaData[2] >> 14 ) & 0x0f;
162  unpackedData[1] |= (dmaData[1] << 4 ) & 0x3ffff0;
163  unpackedData[1] |= (dmaData[0] << 22 ) & 0xffc00000;
164 
165  isData = ( dmaData[0] >> 10 ) & 0x01;
166 
167  //printf ("Lower part: %x \n", unpackedData[0]);
168  //printf ("Upper part: %x \n", unpackedData[1]);
169 
170  // push_back to a 64 word
171  uint64_t dduWord = ( uint64_t(unpackedData[1]) << 32 ) | unpackedData[0];
172 
173  return dduWord;
174 }
unsigned long long uint64_t
Definition: Time.h:15
int DTSpyReader::fillRawData ( edm::Event e,
FEDRawDataCollection *&  data 
)
virtual

Generate and fill FED raw data for a full event.

Definition at line 60 of file DTSpyReader.cc.

References popcon2dropbox::copy(), gather_cfg::cout, FEDRawData::data(), dduID, dduWordLength, debug, dmaUnpack(), eventNumber, FEDRawDataCollection::FEDData(), DTSpy::getEventPointer(), DTSpy::getNextBuffer(), DTSpy::getRunNo(), edm::EventBase::id(), isHeader(), isTrailer(), mySpy, FEDRawData::resize(), runNumber, DTSpy::setlastPointer(), swap(), and mitigatedMETSequence_cff::U.

Referenced by produce().

62  {
63 
64  EventID eID = e.id();
65 
66  // ask for a new buffer
68 
69  // get the pointer to the beginning of the buffer
70  const char * rawDTData = mySpy->getEventPointer();
71 
72  const uint32_t * rawDTData32 = reinterpret_cast<const uint32_t*>(rawDTData);
73 
74  // instantiate the FEDRawDataCollection
75  data = new FEDRawDataCollection();
76 
77  vector<uint64_t> eventData; uint64_t word = 0;
78  int wordCount = 0; int wordCountCheck = 0;
79 
80  bool headerTag = false; bool dataTag = true;
81 
82  // Advance at long-word steps until the trailer is reached.
83  // Skipped whatever else is in the buffer (e.g. another event..)
84  while ( !isTrailer(word, dataTag, wordCount) ) {
85 
86  // dma gets 4 32-bits words and create a 64 bit one
87  word = dmaUnpack(rawDTData32, dataTag);
88 
89  // look for the DDU header
90  if (isHeader(word,dataTag)) headerTag=true;
91 
92  // check whether the first word is a DDU header
93  if ( wordCountCheck > 0 && !headerTag && debug)
94  cout<<"[DTSpyReader]: WARNING: header still not found!!"<<endl;
95 
96  // from now on fill the eventData with the ROS data
97  if (headerTag) {
98 
99  // swapping only the 32 bits words
100  if (dataTag) swap(word);
101  // WARNING also the ddu status words have been swapped!
102  // Control the correct interpretation in DDUUnpacker
103 
104  eventData.push_back(word);
105  wordCount++;
106  }
107 
108  // advancing by 4 32-bits words
109  rawDTData32 += 4;
110 
111  // counting the total number of group of 128 bits (=4*32) in the buffer
112  wordCountCheck++;
113  }
114 
115  // Setting the Event ID
116  runNumber = mySpy->getRunNo();
117  eID = EventID( runNumber, 1U, eventNumber);
118 
119  // eventDataSize = (Number Of Words)* (Word Size)
120  int eventDataSize = eventData.size()*dduWordLength;
121 
122  if (debug) cout<<" DDU ID = "<<dduID<<endl;
123 
124  FEDRawData& fedRawData = data->FEDData( dduID );
125  fedRawData.resize(eventDataSize);
126 
127  copy(reinterpret_cast<unsigned char*>(&eventData[0]),
128  reinterpret_cast<unsigned char*>(&eventData[0]) + eventDataSize, fedRawData.data());
129 
130 
131  mySpy->setlastPointer( (char*) rawDTData32 );
132 
133  return true;
134 
135 }
def copy(args, dbName)
static const int dduWordLength
Definition: DTSpyReader.h:63
edm::EventNumber_t eventNumber
Definition: DTSpyReader.h:58
const char * getEventPointer()
Definition: DTSpy.cc:83
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:32
void swap(uint64_t &word)
swapping the lsBits with the msBits
Definition: DTSpyReader.cc:145
unsigned long long uint64_t
Definition: Time.h:15
void setlastPointer(char *data)
Definition: DTSpy.cc:92
int getNextBuffer()
Definition: DTSpy.cc:39
edm::EventID id() const
Definition: EventBase.h:60
DTSpy * mySpy
Definition: DTSpyReader.h:55
edm::RunNumber_t runNumber
Definition: DTSpyReader.h:57
bool isTrailer(uint64_t word, bool dataTag, unsigned int wordCount)
check for a 64 bits word to be a DDU trailer
Definition: DTSpyReader.cc:190
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
bool isHeader(uint64_t word, bool dataTag)
check for a 64 bits word to be a DDU header
Definition: DTSpyReader.cc:176
uint64_t dmaUnpack(const uint32_t *dmaData, bool &isData)
pre-unpack the data if read via DMA
Definition: DTSpyReader.cc:155
int getRunNo()
Definition: DTSpy.cc:76
bool DTSpyReader::isHeader ( uint64_t  word,
bool  dataTag 
)

check for a 64 bits word to be a DDU header

Definition at line 176 of file DTSpyReader.cc.

References FEDHeader::check(), dduID, eventNumber, and FEDHeader::sourceID().

Referenced by fillRawData().

176  {
177 
178  bool it_is = false;
179  FEDHeader candidate(reinterpret_cast<const unsigned char*>(&word));
180  if ( candidate.check() ) {
181  // if ( candidate.check() && !dataTag) {
182  it_is = true;
183  dduID = candidate.sourceID();
184  eventNumber++;
185  }
186  return it_is;
187 }
edm::EventNumber_t eventNumber
Definition: DTSpyReader.h:58
bool DTSpyReader::isTrailer ( uint64_t  word,
bool  dataTag,
unsigned int  wordCount 
)

check for a 64 bits word to be a DDU trailer

Definition at line 190 of file DTSpyReader.cc.

References FEDTrailer::check(), and FEDTrailer::fragmentLength().

Referenced by fillRawData().

190  {
191 
192  bool it_is = false;
193  FEDTrailer candidate(reinterpret_cast<const unsigned char*>(&word));
194  if ( candidate.check() ) {
195  // if ( candidate.check() && !dataTag) {
196  if ( wordCount == candidate.fragmentLength())
197  it_is = true;
198  }
199  return it_is;
200 }
void DTSpyReader::produce ( edm::Event e,
edm::EventSetup const &  es 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 137 of file DTSpyReader.cc.

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

137  {
139  FEDRawDataCollection *fedcoll = nullptr;
140  fillRawData(e,fedcoll);
141  std::unique_ptr<FEDRawDataCollection> bare_product(fedcoll);
142  e.put(std::move(bare_product));
143  }
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.
Definition: DTSpyReader.cc:60
def move(src, dest)
Definition: eostools.py:510
void DTSpyReader::swap ( uint64_t &  word)

swapping the lsBits with the msBits

Definition at line 145 of file DTSpyReader.cc.

References twoNibble64::lsBits, and twoNibble64::msBits.

Referenced by fillRawData().

145  {
146 
147  twoNibble64* newWorld = reinterpret_cast<twoNibble64*>(&word);
148 
149  uint32_t msBits_tmp = newWorld->msBits;
150  newWorld->msBits = newWorld->lsBits;
151  newWorld->lsBits = msBits_tmp;
152 }

Member Data Documentation

int DTSpyReader::dduID
private

Definition at line 61 of file DTSpyReader.h.

Referenced by DTSpyReader(), fillRawData(), and isHeader().

const int DTSpyReader::dduWordLength = 8
staticprivate

Definition at line 63 of file DTSpyReader.h.

Referenced by fillRawData().

bool DTSpyReader::debug
private
edm::EventNumber_t DTSpyReader::eventNumber
private
DTSpy* DTSpyReader::mySpy
private

Definition at line 55 of file DTSpyReader.h.

Referenced by DTSpyReader(), fillRawData(), and ~DTSpyReader().

edm::RunNumber_t DTSpyReader::runNumber
private

Definition at line 57 of file DTSpyReader.h.

Referenced by fillRawData().