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::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< 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 136 of file DAQSourceModelsFRD.cc.

References crc32c(), crc_, and event_.

136  {
137  crc_ = 0;
138  if (event_->version() >= 5) {
139  crc_ = crc32c(crc_, (const unsigned char*)event_->payload(), event_->eventSize());
140  if (crc_ != event_->crc32c())
141  return false;
142  }
143  return true;
144 }
std::unique_ptr< 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< 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 69 of file DAQSourceModelsFRD.h.

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

◆ 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 69 of file DAQSourceModelsFRD.cc.

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

Referenced by readEvent().

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

References crc_, event_, and contentValuesCheck::ss.

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

◆ headerSize()

uint32_t DataModeFRD::headerSize ( ) const
inlineoverridevirtual

Implements DataMode.

Definition at line 27 of file DAQSourceModelsFRD.h.

References detectedFRDversion_, and FRDHeaderVersionSize.

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

◆ 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< FRDEventMsgView > event_

◆ makeDaqProvenanceHelpers()

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

Implements DataMode.

Definition at line 116 of file DAQSourceModelsFRD.cc.

References daqProvenanceHelpers_.

116  {
117  //set FRD data collection
118  daqProvenanceHelpers_.clear();
119  daqProvenanceHelpers_.emplace_back(std::make_shared<const edm::DaqProvenanceHelper>(
120  edm::TypeID(typeid(FEDRawDataCollection)), "FEDRawDataCollection", "FEDRawDataCollection", "DAQSource"));
121  return daqProvenanceHelpers_;
122 }
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::string const &  runDir 
)
inlineoverridevirtual

Implements DataMode.

Definition at line 67 of file DAQSourceModelsFRD.h.

67 {}

◆ nextEventView()

bool DataModeFRD::nextEventView ( )
overridevirtual

Implements DataMode.

Definition at line 124 of file DAQSourceModelsFRD.cc.

References dataBlockAddr_, dataBlockMax_, event_, eventCached_, and Exception.

Referenced by makeDataBlockView().

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

◆ readEvent()

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

Implements DataMode.

Definition at line 32 of file DAQSourceModelsFRD.cc.

References printConversionInfo::aux, runTheMatrix::const, DAQSource::currentLumiSection(), daqProvenanceHelpers_, DataMode::daqSource_, event_, DAQSource::eventRunNumber(), Exception, DAQSource::fileListLoopMode(), fillFEDRawDataCollection(), FEDHeader::length, evf::evtn::makeEventAuxiliary(), DAQSource::makeEventWrapper(), eostools::move(), edm::EventAuxiliary::PhysicsTrigger, edm::InputSource::processGUID(), DAQSource::processHistoryID(), edm::EventPrincipal::put(), l1tstage2_dqm_sourceclient-live_cfg::rawData, FEDHeader::triggerType(), and DAQSource::useL1EventID().

32  {
33  std::unique_ptr<FEDRawDataCollection> rawData(new FEDRawDataCollection);
34  bool tcdsInRange;
35  unsigned char* tcds_pointer = nullptr;
36  edm::Timestamp tstamp = fillFEDRawDataCollection(*rawData, tcdsInRange, tcds_pointer);
37 
38  if (daqSource_->useL1EventID()) {
39  uint32_t L1EventID = event_->event();
42  eventID, daqSource_->processGUID(), tstamp, event_->isRealData(), edm::EventAuxiliary::PhysicsTrigger);
43  aux.setProcessHistoryID(daqSource_->processHistoryID());
44  daqSource_->makeEventWrapper(eventPrincipal, aux);
45  } else if (tcds_pointer == nullptr) {
46  uint32_t L1EventID = event_->event();
47  throw cms::Exception("DAQSource::read") << "No TCDS FED in event with FEDHeader EID -: " << L1EventID;
48  } else {
49  const FEDHeader fedHeader(tcds_pointer);
50  tcds::Raw_v1 const* tcds = reinterpret_cast<tcds::Raw_v1 const*>(tcds_pointer + FEDHeader::length);
53  daqSource_->eventRunNumber(), //TODO_ eventRunNumber_
54  daqSource_->currentLumiSection(), //currentLumiSection_
55  event_->isRealData(),
56  static_cast<edm::EventAuxiliary::ExperimentType>(fedHeader.triggerType()),
59  !tcdsInRange);
60  aux.setProcessHistoryID(daqSource_->processHistoryID());
61  daqSource_->makeEventWrapper(eventPrincipal, aux);
62  }
63 
64  std::unique_ptr<edm::WrapperBase> edp(new edm::Wrapper<FEDRawDataCollection>(std::move(rawData)));
65  eventPrincipal.put(
66  daqProvenanceHelpers_[0]->branchDescription(), std::move(edp), daqProvenanceHelpers_[0]->dummyProvenance());
67 }
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< 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:197
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< 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 FRDHeaderMaxVersion.

constexpr size_t FRDHeaderMaxVersion
uint16_t detectedFRDversion_

Member Data Documentation

◆ crc_

uint32_t DataModeFRD::crc_ = 0
private

Definition at line 78 of file DAQSourceModelsFRD.h.

Referenced by checksumValid(), and getChecksumError().

◆ daqProvenanceHelpers_

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

Definition at line 74 of file DAQSourceModelsFRD.h.

Referenced by makeDaqProvenanceHelpers(), and readEvent().

◆ dataBlockAddr_

unsigned char* DataModeFRD::dataBlockAddr_ = nullptr
private

Definition at line 79 of file DAQSourceModelsFRD.h.

Referenced by makeDataBlockView(), and nextEventView().

◆ dataBlockMax_

size_t DataModeFRD::dataBlockMax_ = 0
private

Definition at line 80 of file DAQSourceModelsFRD.h.

Referenced by makeDataBlockView(), and nextEventView().

◆ detectedFRDversion_

uint16_t DataModeFRD::detectedFRDversion_ = 0
private

Definition at line 75 of file DAQSourceModelsFRD.h.

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

◆ event_

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

◆ eventCached_

bool DataModeFRD::eventCached_ = false
private

Definition at line 84 of file DAQSourceModelsFRD.h.

Referenced by makeDataBlockView(), and nextEventView().

◆ fileHeaderSize_

size_t DataModeFRD::fileHeaderSize_ = 0
private

Definition at line 81 of file DAQSourceModelsFRD.h.

◆ headerSize_

size_t DataModeFRD::headerSize_ = 0
private

Definition at line 76 of file DAQSourceModelsFRD.h.

◆ MAXTCDSuTCAFEDID_

uint16_t DataModeFRD::MAXTCDSuTCAFEDID_ = FEDNumbering::MAXTCDSuTCAFEDID
private

Definition at line 83 of file DAQSourceModelsFRD.h.

Referenced by fillFEDRawDataCollection(), and setTCDSSearchRange().

◆ MINTCDSuTCAFEDID_

uint16_t DataModeFRD::MINTCDSuTCAFEDID_ = FEDNumbering::MINTCDSuTCAFEDID
private

Definition at line 82 of file DAQSourceModelsFRD.h.

Referenced by fillFEDRawDataCollection(), and setTCDSSearchRange().