CMS 3D CMS Logo

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

#include <CSCDDUDataItr.h>

Public Member Functions

 CSCDDUDataItr ()
 default constructor More...
 
 CSCDDUDataItr (const char *buf)
 construct from data buffer. so makes a new DDUEventData More...
 
 CSCDDUDataItr (const CSCDDUEventData *dduData)
 uses someone else's data, so doesn't delete More...
 
 CSCDDUDataItr (const CSCDDUDataItr &)
 if I own the data, I need to do special copy & assign More...
 
bool next ()
 
const CSCEventDataoperator* ()
 
void operator= (const CSCDDUDataItr &)
 
 ~CSCDDUDataItr ()
 

Private Attributes

int theCurrentCSC
 
bool theDataIsOwnedByMe
 
const CSCDDUEventDatatheDDUData
 
int theNumberOfCSCs
 

Detailed Description

Definition at line 13 of file CSCDDUDataItr.h.

Constructor & Destructor Documentation

◆ CSCDDUDataItr() [1/4]

CSCDDUDataItr::CSCDDUDataItr ( )

default constructor

Definition at line 7 of file CSCDDUDataItr.cc.

const CSCDDUEventData * theDDUData
Definition: CSCDDUDataItr.h:35
bool theDataIsOwnedByMe
Definition: CSCDDUDataItr.h:38

◆ CSCDDUDataItr() [2/4]

CSCDDUDataItr::CSCDDUDataItr ( const char *  buf)

construct from data buffer. so makes a new DDUEventData

Definition at line 9 of file CSCDDUDataItr.cc.

References visDQMUpload::buf, CSCDDUHeader::check(), CSCDDUEventData::cscData(), LogTrace, theDDUData, and theNumberOfCSCs.

10  : theDDUData(nullptr), theCurrentCSC(-1), theNumberOfCSCs(0), theDataIsOwnedByMe(true) {
11  // check if it's OK first
12  const CSCDDUHeader *dduHeader = reinterpret_cast<const CSCDDUHeader *>(buf);
13  if (dduHeader->check()) {
14  theDDUData = new CSCDDUEventData((const uint16_t *)buf);
16  } else {
17  LogTrace("CSCDDUDataItr|CSCRawToDigi") << "Failed DDU header check.";
18  }
19 }
const CSCDDUEventData * theDDUData
Definition: CSCDDUDataItr.h:35
#define LogTrace(id)
const std::vector< CSCEventData > & cscData() const
accessor to data
bool theDataIsOwnedByMe
Definition: CSCDDUDataItr.h:38
bool check() const
Definition: CSCDDUHeader.cc:43

◆ CSCDDUDataItr() [3/4]

CSCDDUDataItr::CSCDDUDataItr ( const CSCDDUEventData dduData)

uses someone else's data, so doesn't delete

Definition at line 21 of file CSCDDUDataItr.cc.

22  : theDDUData(dduData),
23  theCurrentCSC(-1),
25  theDataIsOwnedByMe(false) {}
const CSCDDUEventData * theDDUData
Definition: CSCDDUDataItr.h:35
const std::vector< CSCEventData > & cscData() const
accessor to data
bool theDataIsOwnedByMe
Definition: CSCDDUDataItr.h:38

◆ ~CSCDDUDataItr()

CSCDDUDataItr::~CSCDDUDataItr ( )

Definition at line 27 of file CSCDDUDataItr.cc.

References theDataIsOwnedByMe, and theDDUData.

27  {
29  delete theDDUData;
30 }
const CSCDDUEventData * theDDUData
Definition: CSCDDUDataItr.h:35
bool theDataIsOwnedByMe
Definition: CSCDDUDataItr.h:38

◆ CSCDDUDataItr() [4/4]

CSCDDUDataItr::CSCDDUDataItr ( const CSCDDUDataItr i)

if I own the data, I need to do special copy & assign

Definition at line 32 of file CSCDDUDataItr.cc.

References mps_fire::i, theDataIsOwnedByMe, and theDDUData.

33  : theCurrentCSC(i.theCurrentCSC), theNumberOfCSCs(i.theNumberOfCSCs), theDataIsOwnedByMe(i.theDataIsOwnedByMe) {
34  if (theDataIsOwnedByMe) {
35  if (i.theDDUData != nullptr) {
36  theDDUData = new CSCDDUEventData(*(i.theDDUData));
37  }
38  } else {
39  theDDUData = i.theDDUData;
40  }
41 }
const CSCDDUEventData * theDDUData
Definition: CSCDDUDataItr.h:35
bool theDataIsOwnedByMe
Definition: CSCDDUDataItr.h:38

Member Function Documentation

◆ next()

bool CSCDDUDataItr::next ( void  )

Definition at line 59 of file CSCDDUDataItr.cc.

References theCurrentCSC, and theNumberOfCSCs.

Referenced by CSCChamberDataItr::next().

59 { return (++theCurrentCSC < theNumberOfCSCs); }

◆ operator*()

const CSCEventData & CSCDDUDataItr::operator* ( void  )

Definition at line 61 of file CSCDDUDataItr.cc.

References cms::cuda::assert(), CSCDDUEventData::cscData(), theCurrentCSC, theDDUData, and theNumberOfCSCs.

61  {
63  return theDDUData->cscData()[theCurrentCSC];
64 }
const CSCDDUEventData * theDDUData
Definition: CSCDDUDataItr.h:35
assert(be >=bs)
const std::vector< CSCEventData > & cscData() const
accessor to data

◆ operator=()

void CSCDDUDataItr::operator= ( const CSCDDUDataItr i)

Definition at line 43 of file CSCDDUDataItr.cc.

References mps_fire::i, theCurrentCSC, theDataIsOwnedByMe, theDDUData, and theNumberOfCSCs.

43  {
44  if (theDataIsOwnedByMe && theDDUData != i.theDDUData) {
45  delete theDDUData;
46  if (i.theDDUData != nullptr) {
47  theDDUData = new CSCDDUEventData(*(i.theDDUData));
48  }
49  } else {
50  theDDUData = i.theDDUData;
51  }
52 
53  theDDUData = i.theDDUData;
54  theCurrentCSC = i.theCurrentCSC;
55  theNumberOfCSCs = i.theNumberOfCSCs;
56  theDataIsOwnedByMe = i.theDataIsOwnedByMe;
57 }
const CSCDDUEventData * theDDUData
Definition: CSCDDUDataItr.h:35
bool theDataIsOwnedByMe
Definition: CSCDDUDataItr.h:38

Member Data Documentation

◆ theCurrentCSC

int CSCDDUDataItr::theCurrentCSC
private

Definition at line 36 of file CSCDDUDataItr.h.

Referenced by next(), operator*(), and operator=().

◆ theDataIsOwnedByMe

bool CSCDDUDataItr::theDataIsOwnedByMe
private

Definition at line 38 of file CSCDDUDataItr.h.

Referenced by CSCDDUDataItr(), operator=(), and ~CSCDDUDataItr().

◆ theDDUData

const CSCDDUEventData* CSCDDUDataItr::theDDUData
private

Definition at line 35 of file CSCDDUDataItr.h.

Referenced by CSCDDUDataItr(), operator*(), operator=(), and ~CSCDDUDataItr().

◆ theNumberOfCSCs

int CSCDDUDataItr::theNumberOfCSCs
private

Definition at line 37 of file CSCDDUDataItr.h.

Referenced by CSCDDUDataItr(), next(), operator*(), and operator=().