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::one::EDProducer<> edm::one::EDProducerBase 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::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

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

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

Constructor.

connecting to XDAQ note ("0.0.0.0" = localhost)

Definition at line 31 of file DTSpyReader.cc.

References DTCtcp::Connect(), gather_cfg::cout, dduID, debug, mySpy, and muonDTDigis_cfi::pset.

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

◆ ~DTSpyReader()

DTSpyReader::~DTSpyReader ( )
override

Destructor.

Definition at line 50 of file DTSpyReader.cc.

References mySpy.

50 { delete mySpy; }
DTSpy * mySpy
Definition: DTSpyReader.h:53

Member Function Documentation

◆ dmaUnpack()

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

pre-unpack the data if read via DMA

Definition at line 147 of file DTSpyReader.cc.

References HLTBitAnalyser_cfi::isData.

Referenced by fillRawData().

147  {
148  uint32_t unpackedData[2] = {0, 0};
149  // adjust 4 32-bits words into 2 32-bits words
150  unpackedData[0] |= dmaData[3] & 0x3ffff;
151  unpackedData[0] |= (dmaData[2] << 18) & 0xfffc0000;
152  unpackedData[1] |= (dmaData[2] >> 14) & 0x0f;
153  unpackedData[1] |= (dmaData[1] << 4) & 0x3ffff0;
154  unpackedData[1] |= (dmaData[0] << 22) & 0xffc00000;
155 
156  isData = (dmaData[0] >> 10) & 0x01;
157 
158  //printf ("Lower part: %x \n", unpackedData[0]);
159  //printf ("Upper part: %x \n", unpackedData[1]);
160 
161  // push_back to a 64 word
162  uint64_t dduWord = (uint64_t(unpackedData[1]) << 32) | unpackedData[0];
163 
164  return dduWord;
165 }
unsigned long long uint64_t
Definition: Time.h:13

◆ fillRawData()

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

Generate and fill FED raw data for a full event.

Definition at line 52 of file DTSpyReader.cc.

References filterCSVwithJSON::copy, gather_cfg::cout, data, gctErrorAnalyzer_cfi::dataTag, dduID, dduWordLength, debug, dmaUnpack(), MillePedeFileConverter_cfg::e, eventNumber, l1t_dqm_sourceclient-live_cfg::fedRawData, EcalFEDMonitor_cfi::FEDRawDataCollection, DTSpy::getEventPointer(), DTSpy::getNextBuffer(), DTSpy::getRunNo(), isHeader(), isTrailer(), mySpy, runNumber, DTSpy::setlastPointer(), swap(), and mitigatedMETSequence_cff::U.

Referenced by produce().

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

◆ isHeader()

bool DTSpyReader::isHeader ( uint64_t  word,
bool  dataTag 
)

check for a 64 bits word to be a DDU header

Definition at line 167 of file DTSpyReader.cc.

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

Referenced by fillRawData().

167  {
168  bool it_is = false;
169  FEDHeader candidate(reinterpret_cast<const unsigned char*>(&word));
170  if (candidate.check()) {
171  // if ( candidate.check() && !dataTag) {
172  it_is = true;
173  dduID = candidate.sourceID();
174  eventNumber++;
175  }
176  return it_is;
177 }
edm::EventNumber_t eventNumber
Definition: DTSpyReader.h:56
uint64_t word

◆ isTrailer()

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 179 of file DTSpyReader.cc.

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

Referenced by fillRawData().

179  {
180  bool it_is = false;
181  FEDTrailer candidate(reinterpret_cast<const unsigned char*>(&word));
182  if (candidate.check()) {
183  // if ( candidate.check() && !dataTag) {
184  if (wordCount == candidate.fragmentLength())
185  it_is = true;
186  }
187  return it_is;
188 }
uint64_t word

◆ produce()

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

Implements edm::one::EDProducerBase.

Definition at line 131 of file DTSpyReader.cc.

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

131  {
133  FEDRawDataCollection* fedcoll = nullptr;
134  fillRawData(e, fedcoll);
135  std::unique_ptr<FEDRawDataCollection> bare_product(fedcoll);
136  e.put(std::move(bare_product));
137 }
virtual int fillRawData(edm::Event &e, FEDRawDataCollection *&data)
Generate and fill FED raw data for a full event.
Definition: DTSpyReader.cc:52
def move(src, dest)
Definition: eostools.py:511

◆ swap()

void DTSpyReader::swap ( uint64_t &  word)

swapping the lsBits with the msBits

Definition at line 139 of file DTSpyReader.cc.

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

Referenced by fillRawData().

139  {
140  twoNibble64* newWorld = reinterpret_cast<twoNibble64*>(&word);
141 
142  uint32_t msBits_tmp = newWorld->msBits;
143  newWorld->msBits = newWorld->lsBits;
144  newWorld->lsBits = msBits_tmp;
145 }
uint64_t word

Member Data Documentation

◆ dduID

int DTSpyReader::dduID
private

Definition at line 59 of file DTSpyReader.h.

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

◆ dduWordLength

const int DTSpyReader::dduWordLength = 8
staticprivate

Definition at line 61 of file DTSpyReader.h.

Referenced by fillRawData().

◆ debug

bool DTSpyReader::debug
private

◆ eventNumber

edm::EventNumber_t DTSpyReader::eventNumber
private

Definition at line 56 of file DTSpyReader.h.

Referenced by fillRawData(), and isHeader().

◆ mySpy

DTSpy* DTSpyReader::mySpy
private

Definition at line 53 of file DTSpyReader.h.

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

◆ runNumber

edm::RunNumber_t DTSpyReader::runNumber
private

Definition at line 55 of file DTSpyReader.h.

Referenced by fillRawData().