CMS 3D CMS Logo

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

#include <DAQSourceModelsFRD.h>

Inheritance diagram for DataModeFRD:
DataMode

Public Member Functions

bool checksumValid () override
 
bool dataBlockCompleted () const override
 
bool dataBlockInitialized () const override
 
uint64_t dataBlockSize () const override
 
 DataModeFRD (DAQSource *daqSource)
 
int dataVersion () const override
 
std::pair< bool, std::vector< std::string > > defineAdditionalFiles (std::string const &primaryName, bool) const override
 
void detectVersion (unsigned char *fileBuf, uint32_t fileHeaderOffset) override
 
edm::Timestamp fillFEDRawDataCollection (FEDRawDataCollection &rawData, bool &tcdsInRange, unsigned char *&tcds_pointer)
 
bool fitToBuffer () const override
 
std::string getChecksumError () const override
 
uint32_t headerSize () const override
 
bool isRealData () const override
 
std::vector< std::shared_ptr< const edm::DaqProvenanceHelper > > & makeDaqProvenanceHelpers () override
 
void makeDataBlockView (unsigned char *addr, size_t maxSize, std::vector< uint64_t > const &fileSizes, size_t fileHeaderSize) override
 
void makeDirectoryEntries (std::vector< std::string > const &baseDirs, std::vector< int > const &numSources, std::string const &runDir) override
 
bool nextEventView () override
 
void readEvent (edm::EventPrincipal &eventPrincipal) override
 
bool requireHeader () const override
 
uint32_t run () const override
 
void setDataBlockInitialized (bool) override
 
void setTCDSSearchRange (uint16_t MINTCDSuTCAFEDID, uint16_t MAXTCDSuTCAFEDID) override
 
bool versionCheck () const override
 
 ~DataModeFRD () override
 
- Public Member Functions inherited from DataMode
 DataMode (DAQSource *daqSource)
 
virtual bool isMultiDir ()
 
void setTesting (bool testing)
 
virtual ~DataMode ()=default
 

Private Attributes

uint32_t crc_ = 0
 
std::vector< std::shared_ptr< const edm::DaqProvenanceHelper > > daqProvenanceHelpers_
 
unsigned char * dataBlockAddr_ = nullptr
 
size_t dataBlockMax_ = 0
 
uint16_t detectedFRDversion_ = 0
 
std::unique_ptr< edm::streamer::FRDEventMsgViewevent_
 
bool eventCached_ = false
 
size_t fileHeaderSize_ = 0
 
size_t headerSize_ = 0
 
uint16_t MAXTCDSuTCAFEDID_ = FEDNumbering::MAXTCDSuTCAFEDID
 
uint16_t MINTCDSuTCAFEDID_ = FEDNumbering::MINTCDSuTCAFEDID
 

Additional Inherited Members

- Protected Attributes inherited from DataMode
DAQSourcedaqSource_
 
bool testing_ = false
 

Detailed Description

Definition at line 10 of file DAQSourceModelsFRD.h.

Constructor & Destructor Documentation

◆ DataModeFRD()

DataModeFRD::DataModeFRD ( DAQSource daqSource)
inline

Definition at line 12 of file DAQSourceModelsFRD.h.

12 : DataMode(daqSource) {}
DataMode(DAQSource *daqSource)

◆ ~DataModeFRD()

DataModeFRD::~DataModeFRD ( )
inlineoverride

Definition at line 13 of file DAQSourceModelsFRD.h.

13 {};

Member Function Documentation

◆ checksumValid()

bool DataModeFRD::checksumValid ( )
overridevirtual

Implements DataMode.

Definition at line 138 of file DAQSourceModelsFRD.cc.

References crc32c().

138  {
139  crc_ = 0;
140  if (event_->version() >= 5) {
141  crc_ = crc32c(crc_, (const unsigned char*)event_->payload(), event_->eventSize());
142  if (crc_ != event_->crc32c())
143  return false;
144  }
145  return true;
146 }
std::unique_ptr< edm::streamer::FRDEventMsgView > event_
uint32_t crc32c(uint32_t crc, const unsigned char *buf, size_t len)
Definition: crc32c.cc:340

◆ dataBlockCompleted()

bool DataModeFRD::dataBlockCompleted ( ) const
inlineoverridevirtual

Implements DataMode.

Definition at line 53 of file DAQSourceModelsFRD.h.

53 { return true; }

◆ dataBlockInitialized()

bool DataModeFRD::dataBlockInitialized ( ) const
inlineoverridevirtual

Implements DataMode.

Definition at line 58 of file DAQSourceModelsFRD.h.

58 { return true; }

◆ dataBlockSize()

uint64_t DataModeFRD::dataBlockSize ( ) const
inlineoverridevirtual

Implements DataMode.

Definition at line 31 of file DAQSourceModelsFRD.h.

References event_.

31 { return event_->size(); }
std::unique_ptr< edm::streamer::FRDEventMsgView > event_

◆ dataVersion()

int DataModeFRD::dataVersion ( ) const
inlineoverridevirtual

Implements DataMode.

Definition at line 22 of file DAQSourceModelsFRD.h.

References detectedFRDversion_.

22 { return detectedFRDversion_; }
uint16_t detectedFRDversion_

◆ defineAdditionalFiles()

std::pair<bool, std::vector<std::string> > DataModeFRD::defineAdditionalFiles ( std::string const &  primaryName,
bool   
) const
inlineoverridevirtual

Implements DataMode.

Definition at line 71 of file DAQSourceModelsFRD.h.

71  {
72  return std::make_pair(true, std::vector<std::string>());
73  }

◆ detectVersion()

void DataModeFRD::detectVersion ( unsigned char *  fileBuf,
uint32_t  fileHeaderOffset 
)
inlineoverridevirtual

Implements DataMode.

Definition at line 23 of file DAQSourceModelsFRD.h.

References detectedFRDversion_.

23  {
24  detectedFRDversion_ = *((uint16_t*)(fileBuf + fileHeaderOffset));
25  }
uint16_t detectedFRDversion_

◆ fillFEDRawDataCollection()

edm::Timestamp DataModeFRD::fillFEDRawDataCollection ( FEDRawDataCollection rawData,
bool &  tcdsInRange,
unsigned char *&  tcds_pointer 
)

Definition at line 71 of file DAQSourceModelsFRD.cc.

References cms::cuda::assert(), FEDRawData::data(), Exception, l1tstage2_dqm_sourceclient-live_cfg::fedId, FEDTrailer::fragmentLength(), FEDHeader::length, FEDTrailer::length, FEDNumbering::MAXFEDID, FEDNumbering::MAXTCDSuTCAFEDID, FEDNumbering::MINTCDSuTCAFEDID, l1tstage2_dqm_sourceclient-live_cfg::rawData, FEDRawData::resize(), FEDHeader::sourceID(), and hcalRecHitTable_cff::time.

73  {
75  timeval stv;
76  gettimeofday(&stv, nullptr);
77  time = stv.tv_sec;
78  time = (time << 32) + stv.tv_usec;
79  edm::Timestamp tstamp(time);
80 
81  uint32_t eventSize = event_->eventSize();
82  unsigned char* event = (unsigned char*)event_->payload();
83  tcds_pointer = nullptr;
84  tcdsInRange = false;
85  uint16_t selectedTCDSFed = 0;
86  while (eventSize > 0) {
87  assert(eventSize >= FEDTrailer::length);
88  eventSize -= FEDTrailer::length;
89  const FEDTrailer fedTrailer(event + eventSize);
90  const uint32_t fedSize = fedTrailer.fragmentLength() << 3; //trailer length counts in 8 bytes
91  assert(eventSize >= fedSize - FEDHeader::length);
92  eventSize -= (fedSize - FEDHeader::length);
93  const FEDHeader fedHeader(event + eventSize);
94  const uint16_t fedId = fedHeader.sourceID();
96  throw cms::Exception("DAQSource::fillFEDRawDataCollection") << "Out of range FED ID : " << fedId;
97  } else if (fedId >= MINTCDSuTCAFEDID_ && fedId <= MAXTCDSuTCAFEDID_) {
98  if (!selectedTCDSFed) {
99  selectedTCDSFed = fedId;
100  tcds_pointer = event + eventSize;
102  tcdsInRange = true;
103  }
104  } else
105  throw cms::Exception("DAQSource::fillFEDRawDataCollection")
106  << "Second TCDS FED ID " << fedId << " found. First ID: " << selectedTCDSFed;
107  }
108  //take event ID from GTPE FED
109  FEDRawData& fedData = rawData.FEDData(fedId);
110  fedData.resize(fedSize);
111  memcpy(fedData.data(), event + eventSize, fedSize);
112  }
113  assert(eventSize == 0);
114 
115  return tstamp;
116 }
static const uint32_t length
Definition: FEDTrailer.h:57
static const uint32_t length
Definition: FEDHeader.h:54
assert(be >=bs)
std::unique_ptr< edm::streamer::FRDEventMsgView > event_
unsigned long long TimeValue_t
Definition: Timestamp.h:21
void resize(size_t newsize, size_t wordsize=8)
Definition: FEDRawData.cc:28
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
uint16_t MINTCDSuTCAFEDID_
uint16_t MAXTCDSuTCAFEDID_
Definition: event.py:1

◆ fitToBuffer()

bool DataModeFRD::fitToBuffer ( ) const
inlineoverridevirtual

Implements DataMode.

Definition at line 57 of file DAQSourceModelsFRD.h.

57 { return false; }

◆ getChecksumError()

std::string DataModeFRD::getChecksumError ( ) const
overridevirtual

Implements DataMode.

Definition at line 148 of file DAQSourceModelsFRD.cc.

References contentValuesCheck::ss.

148  {
149  std::stringstream ss;
150  ss << "Found a wrong crc32c checksum: expected 0x" << std::hex << event_->crc32c() << " but calculated 0x" << crc_;
151  return ss.str();
152 }
std::unique_ptr< edm::streamer::FRDEventMsgView > event_

◆ headerSize()

uint32_t DataModeFRD::headerSize ( ) const
inlineoverridevirtual

Implements DataMode.

Definition at line 27 of file DAQSourceModelsFRD.h.

References detectedFRDversion_, and edm::streamer::FRDHeaderVersionSize.

constexpr std::array< uint32, FRDHeaderMaxVersion+1 > FRDHeaderVersionSize
uint16_t detectedFRDversion_

◆ isRealData()

bool DataModeFRD::isRealData ( ) const
inlineoverridevirtual

Implements DataMode.

Definition at line 48 of file DAQSourceModelsFRD.h.

References event_.

48 { return event_->isRealData(); }
std::unique_ptr< edm::streamer::FRDEventMsgView > event_

◆ makeDaqProvenanceHelpers()

std::vector< std::shared_ptr< const edm::DaqProvenanceHelper > > & DataModeFRD::makeDaqProvenanceHelpers ( )
overridevirtual

Implements DataMode.

Definition at line 118 of file DAQSourceModelsFRD.cc.

118  {
119  //set FRD data collection
120  daqProvenanceHelpers_.clear();
121  daqProvenanceHelpers_.emplace_back(std::make_shared<const edm::DaqProvenanceHelper>(
122  edm::TypeID(typeid(FEDRawDataCollection)), "FEDRawDataCollection", "FEDRawDataCollection", "DAQSource"));
123  return daqProvenanceHelpers_;
124 }
std::vector< std::shared_ptr< const edm::DaqProvenanceHelper > > daqProvenanceHelpers_

◆ makeDataBlockView()

void DataModeFRD::makeDataBlockView ( unsigned char *  addr,
size_t  maxSize,
std::vector< uint64_t > const &  fileSizes,
size_t  fileHeaderSize 
)
inlineoverridevirtual

◆ makeDirectoryEntries()

void DataModeFRD::makeDirectoryEntries ( std::vector< std::string > const &  baseDirs,
std::vector< int > const &  numSources,
std::string const &  runDir 
)
inlineoverridevirtual

Implements DataMode.

Definition at line 67 of file DAQSourceModelsFRD.h.

69  {}

◆ nextEventView()

bool DataModeFRD::nextEventView ( )
overridevirtual

Implements DataMode.

Definition at line 126 of file DAQSourceModelsFRD.cc.

References Exception.

Referenced by makeDataBlockView().

126  {
127  if (eventCached_)
128  return true;
129  event_ = std::make_unique<FRDEventMsgView>(dataBlockAddr_);
130  if (event_->size() > dataBlockMax_) {
131  throw cms::Exception("DAQSource::getNextEvent")
132  << " event id:" << event_->event() << " lumi:" << event_->lumi() << " run:" << event_->run()
133  << " of size:" << event_->size() << " bytes does not fit into a chunk of size:" << dataBlockMax_ << " bytes";
134  }
135  return true;
136 }
std::unique_ptr< edm::streamer::FRDEventMsgView > event_
unsigned char * dataBlockAddr_

◆ readEvent()

void DataModeFRD::readEvent ( edm::EventPrincipal eventPrincipal)
overridevirtual

Implements DataMode.

Definition at line 34 of file DAQSourceModelsFRD.cc.

References printConversionInfo::aux, runTheMatrix::const, Exception, FEDHeader::length, evf::evtn::makeEventAuxiliary(), eostools::move(), edm::EventAuxiliary::PhysicsTrigger, edm::EventPrincipal::put(), l1tstage2_dqm_sourceclient-live_cfg::rawData, and FEDHeader::triggerType().

34  {
35  std::unique_ptr<FEDRawDataCollection> rawData(new FEDRawDataCollection);
36  bool tcdsInRange;
37  unsigned char* tcds_pointer = nullptr;
38  edm::Timestamp tstamp = fillFEDRawDataCollection(*rawData, tcdsInRange, tcds_pointer);
39 
40  if (daqSource_->useL1EventID()) {
41  uint32_t L1EventID = event_->event();
44  eventID, daqSource_->processGUID(), tstamp, event_->isRealData(), edm::EventAuxiliary::PhysicsTrigger);
45  aux.setProcessHistoryID(daqSource_->processHistoryID());
46  daqSource_->makeEventWrapper(eventPrincipal, aux);
47  } else if (tcds_pointer == nullptr) {
48  uint32_t L1EventID = event_->event();
49  throw cms::Exception("DAQSource::read") << "No TCDS FED in event with FEDHeader EID -: " << L1EventID;
50  } else {
51  const FEDHeader fedHeader(tcds_pointer);
52  tcds::Raw_v1 const* tcds = reinterpret_cast<tcds::Raw_v1 const*>(tcds_pointer + FEDHeader::length);
55  daqSource_->eventRunNumber(), //TODO_ eventRunNumber_
56  daqSource_->currentLumiSection(), //currentLumiSection_
57  event_->isRealData(),
58  static_cast<edm::EventAuxiliary::ExperimentType>(fedHeader.triggerType()),
61  !tcdsInRange);
62  aux.setProcessHistoryID(daqSource_->processHistoryID());
63  daqSource_->makeEventWrapper(eventPrincipal, aux);
64  }
65 
66  std::unique_ptr<edm::WrapperBase> edp(new edm::Wrapper<FEDRawDataCollection>(std::move(rawData)));
67  eventPrincipal.put(
68  daqProvenanceHelpers_[0]->branchDescription(), std::move(edp), daqProvenanceHelpers_[0]->dummyProvenance());
69 }
static const uint32_t length
Definition: FEDHeader.h:54
edm::Timestamp fillFEDRawDataCollection(FEDRawDataCollection &rawData, bool &tcdsInRange, unsigned char *&tcds_pointer)
std::vector< std::shared_ptr< const edm::DaqProvenanceHelper > > daqProvenanceHelpers_
std::unique_ptr< edm::streamer::FRDEventMsgView > event_
edm::EventAuxiliary makeEventAuxiliary(const tcds::Raw_v1 *, unsigned int runNumber, unsigned int lumiSection, bool isRealData, const edm::EventAuxiliary::ExperimentType &, const std::string &processGUID, bool verifyLumiSection, bool suppressWarning)
int currentLumiSection() const
Definition: DAQSource.h:52
void put(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp, ProductProvenance const &productProvenance) const
Definition: TCDSRaw.h:16
std::string const & processGUID() const
Accessor for global process identifier.
Definition: InputSource.h:226
bool useL1EventID() const
Definition: DAQSource.h:51
void makeEventWrapper(edm::EventPrincipal &eventPrincipal, edm::EventAuxiliary &aux)
Definition: DAQSource.h:54
edm::ProcessHistoryID & processHistoryID()
Definition: DAQSource.h:59
bool fileListLoopMode()
Definition: DAQSource.h:57
DAQSource * daqSource_
int eventRunNumber() const
Definition: DAQSource.h:53
def move(src, dest)
Definition: eostools.py:511

◆ requireHeader()

bool DataModeFRD::requireHeader ( ) const
inlineoverridevirtual

Implements DataMode.

Definition at line 55 of file DAQSourceModelsFRD.h.

55 { return true; }

◆ run()

uint32_t DataModeFRD::run ( ) const
inlineoverridevirtual

Implements DataMode.

Definition at line 50 of file DAQSourceModelsFRD.h.

References event_.

Referenced by Types.EventID::cppID(), and Types.LuminosityBlockID::cppID().

50 { return event_->run(); }
std::unique_ptr< edm::streamer::FRDEventMsgView > event_

◆ setDataBlockInitialized()

void DataModeFRD::setDataBlockInitialized ( bool  )
inlineoverridevirtual

Implements DataMode.

Definition at line 60 of file DAQSourceModelsFRD.h.

60 {};

◆ setTCDSSearchRange()

void DataModeFRD::setTCDSSearchRange ( uint16_t  MINTCDSuTCAFEDID,
uint16_t  MAXTCDSuTCAFEDID 
)
inlineoverridevirtual

Implements DataMode.

Definition at line 62 of file DAQSourceModelsFRD.h.

References MAXTCDSuTCAFEDID_, and MINTCDSuTCAFEDID_.

62  {
63  MINTCDSuTCAFEDID_ = MINTCDSuTCAFEDID;
64  MAXTCDSuTCAFEDID_ = MAXTCDSuTCAFEDID;
65  }
uint16_t MINTCDSuTCAFEDID_
uint16_t MAXTCDSuTCAFEDID_

◆ versionCheck()

bool DataModeFRD::versionCheck ( ) const
inlineoverridevirtual

Implements DataMode.

Definition at line 29 of file DAQSourceModelsFRD.h.

References detectedFRDversion_, and edm::streamer::FRDHeaderMaxVersion.

constexpr size_t FRDHeaderMaxVersion
uint16_t detectedFRDversion_

Member Data Documentation

◆ crc_

uint32_t DataModeFRD::crc_ = 0
private

Definition at line 80 of file DAQSourceModelsFRD.h.

◆ daqProvenanceHelpers_

std::vector<std::shared_ptr<const edm::DaqProvenanceHelper> > DataModeFRD::daqProvenanceHelpers_
private

Definition at line 76 of file DAQSourceModelsFRD.h.

◆ dataBlockAddr_

unsigned char* DataModeFRD::dataBlockAddr_ = nullptr
private

Definition at line 81 of file DAQSourceModelsFRD.h.

Referenced by makeDataBlockView().

◆ dataBlockMax_

size_t DataModeFRD::dataBlockMax_ = 0
private

Definition at line 82 of file DAQSourceModelsFRD.h.

Referenced by makeDataBlockView().

◆ detectedFRDversion_

uint16_t DataModeFRD::detectedFRDversion_ = 0
private

Definition at line 77 of file DAQSourceModelsFRD.h.

Referenced by dataVersion(), detectVersion(), headerSize(), and versionCheck().

◆ event_

std::unique_ptr<edm::streamer::FRDEventMsgView> DataModeFRD::event_
private

Definition at line 79 of file DAQSourceModelsFRD.h.

Referenced by dataBlockSize(), isRealData(), and run().

◆ eventCached_

bool DataModeFRD::eventCached_ = false
private

Definition at line 86 of file DAQSourceModelsFRD.h.

Referenced by makeDataBlockView().

◆ fileHeaderSize_

size_t DataModeFRD::fileHeaderSize_ = 0
private

Definition at line 83 of file DAQSourceModelsFRD.h.

◆ headerSize_

size_t DataModeFRD::headerSize_ = 0
private

Definition at line 78 of file DAQSourceModelsFRD.h.

◆ MAXTCDSuTCAFEDID_

uint16_t DataModeFRD::MAXTCDSuTCAFEDID_ = FEDNumbering::MAXTCDSuTCAFEDID
private

Definition at line 85 of file DAQSourceModelsFRD.h.

Referenced by setTCDSSearchRange().

◆ MINTCDSuTCAFEDID_

uint16_t DataModeFRD::MINTCDSuTCAFEDID_ = FEDNumbering::MINTCDSuTCAFEDID
private

Definition at line 84 of file DAQSourceModelsFRD.h.

Referenced by setTCDSSearchRange().