CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
CSCDCCEventData Class Reference

01/20/05 A.Tumanov More...

#include <CSCDCCEventData.h>

Public Member Functions

void addChamber (CSCEventData &chamber, int dduID, int dduSlot, int dduInput, int dmbID, uint16_t format_version=2005)
 
bool check () const
 for making events. Sets the bxnum and lvl1num inside the chamber event More...
 
 CSCDCCEventData (int sourceId, int nDDUs, int bx, int l1a)
 
 CSCDCCEventData (const uint16_t *buf, CSCDCCExaminer *examiner=nullptr)
 
CSCDCCHeader dccHeader () const
 
CSCDCCTrailer dccTrailer () const
 
const std::vector< CSCDDUEventData > & dduData () const
 accessor to dduData More...
 
std::vector< CSCDDUEventData > & dduData ()
 
boost::dynamic_bitset pack ()
 packs data into bits More...
 
int sizeInWords () const
 
 ~CSCDCCEventData ()
 

Static Public Member Functions

static void setDebug (bool value)
 

Static Public Attributes

static std::atomic< bool > debug {false}
 

Protected Member Functions

void unpack_data (const uint16_t *buf, CSCDCCExaminer *examiner=nullptr)
 

Protected Attributes

CSCDCCHeader theDCCHeader
 
CSCDCCTrailer theDCCTrailer
 
std::vector< CSCDDUEventDatatheDDUData
 
int theSizeInWords
 

Detailed Description

01/20/05 A.Tumanov

Definition at line 13 of file CSCDCCEventData.h.

Constructor & Destructor Documentation

◆ CSCDCCEventData() [1/2]

CSCDCCEventData::CSCDCCEventData ( int  sourceId,
int  nDDUs,
int  bx,
int  l1a 
)

Definition at line 22 of file CSCDCCEventData.cc.

References theDDUData.

22  : theDCCHeader(bx, l1a, sourceId) {
23  theDDUData.reserve(nDDUs);
24 }
CSCDCCHeader theDCCHeader
std::vector< CSCDDUEventData > theDDUData

◆ CSCDCCEventData() [2/2]

CSCDCCEventData::CSCDCCEventData ( const uint16_t *  buf,
CSCDCCExaminer examiner = nullptr 
)
explicit

buf may need to stay pinned in memory as long as this data is used. Not sure

Definition at line 26 of file CSCDCCEventData.cc.

References visDQMUpload::buf, and unpack_data().

26 { unpack_data(buf, examiner); }
void unpack_data(const uint16_t *buf, CSCDCCExaminer *examiner=nullptr)

◆ ~CSCDCCEventData()

CSCDCCEventData::~CSCDCCEventData ( )

Definition at line 28 of file CSCDCCEventData.cc.

28 {}

Member Function Documentation

◆ addChamber()

void CSCDCCEventData::addChamber ( CSCEventData chamber,
int  dduID,
int  dduSlot,
int  dduInput,
int  dmbID,
uint16_t  format_version = 2005 
)

Set DDU format_version field in header depending on desired format version

2013 Format

Definition at line 95 of file CSCDCCEventData.cc.

References relativeConstraints::chamber, dccHeader(), RecoTauValidation_cfi::header, mps_fire::i, CSCDCCHeader::setDAV(), and theDDUData.

96  {
97  // first, find this DDU
98  int dduIndex = -1;
99  int nDDUs = theDDUData.size();
100  for (int i = 0; dduIndex == -1 && i < nDDUs; ++i) {
101  if (theDDUData[i].header().source_id() == dduID)
102  dduIndex = i;
103  }
104 
106  unsigned ddu_fmt_version = 0x6; // 2005 Format
107  if (format_version >= 2013)
108  ddu_fmt_version = 0x7;
109 
110  if (dduIndex == -1) {
111  // make a new one
112  CSCDDUHeader newDDUHeader(
113  dccHeader().getCDFBunchCounter(), dccHeader().getCDFEventNumber(), dduID, ddu_fmt_version);
114  theDDUData.push_back(CSCDDUEventData(newDDUHeader));
115  dduIndex = nDDUs;
116  dccHeader().setDAV(dduSlot);
117  }
118  theDDUData[dduIndex].add(chamber, dmbID, dduInput, format_version);
119 }
void setDAV(int dduSlot)
Definition: CSCDCCHeader.cc:28
std::vector< CSCDDUEventData > theDDUData
CSCDCCHeader dccHeader() const

◆ check()

bool CSCDCCEventData::check ( ) const

for making events. Sets the bxnum and lvl1num inside the chamber event

Definition at line 86 of file CSCDCCEventData.cc.

References CSCDCCHeader::check(), CSCDCCTrailer::check(), debug, TauDecayModes::dec, LogTrace, sizeInWords(), theDCCHeader, and theDCCTrailer.

86  {
87  // the trailer counts in 64-bit words
88  if (debug) {
89  LogTrace("CSCDCCEventData|CSCRawToDigi") << "size in Words () = " << std::dec << sizeInWords();
90  }
91 
92  return theDCCHeader.check() && theDCCTrailer.check();
93 }
bool check() const
Definition: CSCDCCTrailer.h:48
CSCDCCHeader theDCCHeader
CSCDCCTrailer theDCCTrailer
#define LogTrace(id)
static std::atomic< bool > debug
int sizeInWords() const
bool check() const
Definition: CSCDCCHeader.h:27

◆ dccHeader()

CSCDCCHeader CSCDCCEventData::dccHeader ( ) const
inline

Definition at line 28 of file CSCDCCEventData.h.

References theDCCHeader.

Referenced by addChamber().

28 { return theDCCHeader; }
CSCDCCHeader theDCCHeader

◆ dccTrailer()

CSCDCCTrailer CSCDCCEventData::dccTrailer ( ) const
inline

Definition at line 29 of file CSCDCCEventData.h.

References theDCCTrailer.

Referenced by pack().

29 { return theDCCTrailer; }
CSCDCCTrailer theDCCTrailer

◆ dduData() [1/2]

const std::vector<CSCDDUEventData>& CSCDCCEventData::dduData ( ) const
inline

accessor to dduData

Definition at line 25 of file CSCDCCEventData.h.

References theDDUData.

Referenced by CSCChamberDataItr::CSCChamberDataItr(), CSCOfflineMonitor::doBXMonitor(), and CSCChamberDataItr::next().

25 { return theDDUData; }
std::vector< CSCDDUEventData > theDDUData

◆ dduData() [2/2]

std::vector<CSCDDUEventData>& CSCDCCEventData::dduData ( )
inline

Definition at line 26 of file CSCDCCEventData.h.

References theDDUData.

26 { return theDDUData; }
std::vector< CSCDDUEventData > theDDUData

◆ pack()

boost::dynamic_bitset CSCDCCEventData::pack ( )

packs data into bits

Definition at line 121 of file CSCDCCEventData.cc.

References bitset_utilities::append(), CSCDCCHeader::data(), CSCDCCTrailer::data(), dccTrailer(), mps_fire::i, mps_fire::result, CSCDCCHeader::sizeInWords(), CSCDCCTrailer::sizeInWords(), theDCCHeader, theDCCTrailer, theDDUData, and bitset_utilities::ushortToBitset().

121  {
122  boost::dynamic_bitset<> result(theDCCHeader.sizeInWords() * 16);
124  //std::cout <<"SANDRIK DCC size of header in words"<< theDCCHeader.sizeInWords()*16 <<std::endl;
125  //std::cout <<"SANDRIK DCC size of header in bits"<< result.size()<<std::endl;
126  //for(size_t i = 0; i < result.size(); ++i) {
127  // std::cout<<result[i];
128  // if (((i+1)%32)==0) std::cout<<std::endl;
129  //}
130 
131  for (size_t i = 0; i < theDDUData.size(); ++i) {
133  //std::cout <<"SANDRIK here is ddu data check ";
134  //theDDUData[i].header().check();
135  //std::cout <<std::endl;
136  //bitset_utilities::printWords(result);
137  }
138 
139  //std::cout <<"SANDRIK packed dcc size is "<<result.size()<<std::endl;
140  //for(size_t i = 0; i < result.size(); ++i) {
141  // std::cout<<result[i];
142  // if (((i+1)%32)==0) std::cout<<std::endl;
143  //}
144 
145  boost::dynamic_bitset<> dccTrailer =
148  // bitset_utilities::printWords(result);
149  return result;
150 }
CSCDCCHeader theDCCHeader
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
unsigned short * data()
Definition: CSCDCCTrailer.h:49
CSCDCCTrailer theDCCTrailer
boost::dynamic_bitset pack()
packs data into bits
std::vector< CSCDDUEventData > theDDUData
CSCDCCTrailer dccTrailer() const
static unsigned sizeInWords()
Definition: CSCDCCHeader.h:29
static unsigned sizeInWords()
Definition: CSCDCCTrailer.h:46
boost::dynamic_bitset ushortToBitset(const unsigned int numberOfBits, unsigned short *buf)
this method takes numberOfBits bits from unsigned short * array and returns them in the bitset obj...
unsigned short * data()
Definition: CSCDCCHeader.h:28

◆ setDebug()

static void CSCDCCEventData::setDebug ( bool  value)
inlinestatic

Definition at line 22 of file CSCDCCEventData.h.

References debug, and relativeConstraints::value.

Referenced by CSCDCCUnpacker::CSCDCCUnpacker().

22 { debug = value; }
static std::atomic< bool > debug

◆ sizeInWords()

int CSCDCCEventData::sizeInWords ( ) const
inline

prints out the error associated with this status from the header or trailer

Definition at line 38 of file CSCDCCEventData.h.

References theSizeInWords.

Referenced by check().

38 { return theSizeInWords; }

◆ unpack_data()

void CSCDCCEventData::unpack_data ( const uint16_t *  buf,
CSCDCCExaminer examiner = nullptr 
)
protected

loop over DDUEventDatas

Definition at line 30 of file CSCDCCEventData.cc.

References visDQMUpload::buf, CSCDDUEventData::check(), CSCDCCTrailer::check(), debug, LogTrace, CSCDCCHeader::setFromBuffer(), CSCDCCTrailer::setFromBuffer(), CSCDCCHeader::sizeInWords(), CSCDDUEventData::sizeInWords(), theDCCHeader, theDCCTrailer, and theDDUData.

Referenced by CSCDCCEventData().

30  {
31  /*
32  for (int i=0;i<20;i++) {
33  printf("%04x %04x %04x %04x\n",buf[i+3],buf[i+2],buf[i+1],buf[i]);
34  i+=3;
35  }
36 */
37 
38  theDDUData.clear();
39  if (debug)
40  LogTrace("CSCDCCEventData|CSCRawToDigi") << "CSCDCCEventData::unpack_data() is called";
41 
42  // decode DCC header (128 bits)
43  if (debug)
44  LogTrace("CSCDCCEventData|CSCRawToDigi") << "unpacking dcc header...";
46  //theDCCHeader = CSCDCCHeader(buf); // direct unpacking instead of bitfields
48 
49  //std::cout <<"Sandrik DCC Id = " << theDCCHeader.getCDFSourceId() << std::endl;
50 
52  while ((buf[7] == 0x8000) && (buf[6] == 0x0001) && (buf[5] == 0x8000)) {
53  CSCDDUEventData dduEventData(buf, examiner);
54  // CSCDDUEventData dduEventData(buf);
55 
56  if (debug)
57  LogTrace("CSCDCCEventData|CSCRawToDigi") << " checking ddu data integrity ";
58  if (dduEventData.check()) {
59  theDDUData.push_back(dduEventData);
60  buf += dduEventData.sizeInWords();
61  } else {
62  if (debug)
63  LogTrace("CSCDCCEventData|CSCRawToDigi") << "DDU Data Check failed! ";
64  break;
65  }
66  }
67 
68  if (debug) {
69  LogTrace("CSCDCCEventData|CSCRawToDigi") << "unpacking dcc trailer ";
70  LogTrace("CSCDCCEventData|CSCRawToDigi") << std::hex << buf[3] << " " << buf[2] << " " << buf[1] << " " << buf[0];
71  }
72 
73  //decode dcc trailer (128 bits)
74  if (debug)
75  LogTrace("CSCDCCEventData|CSCRawToDigi") << "decoding DCC trailer";
77  if (debug)
78  LogTrace("CSCDCCEventData|CSCRawToDigi") << "checking DDU Trailer" << theDCCTrailer.check();
79 
80  // buf += theDCCTrailer.sizeInWords(); /* =VB= Commented out to please static analyzer */
81 
82  //std::cout << " DCC Size: " << std::dec << theSizeInWords << std::endl;
83  //std::cout << "LastBuf: " << std::hex << inputBuf[theSizeInWords-4] << std::endl;
84 }
bool check() const
Definition: CSCDCCTrailer.h:48
CSCDCCHeader theDCCHeader
void setFromBuffer(uint16_t const *buf)
Definition: CSCDCCHeader.h:19
CSCDCCTrailer theDCCTrailer
#define LogTrace(id)
static std::atomic< bool > debug
std::vector< CSCDDUEventData > theDDUData
static unsigned sizeInWords()
Definition: CSCDCCHeader.h:29
void setFromBuffer(uint16_t const *buf)
Definition: CSCDCCTrailer.h:24

Member Data Documentation

◆ debug

std::atomic< bool > CSCDCCEventData::debug {false}
static

◆ theDCCHeader

CSCDCCHeader CSCDCCEventData::theDCCHeader
protected

Definition at line 54 of file CSCDCCEventData.h.

Referenced by check(), dccHeader(), pack(), and unpack_data().

◆ theDCCTrailer

CSCDCCTrailer CSCDCCEventData::theDCCTrailer
protected

Definition at line 57 of file CSCDCCEventData.h.

Referenced by check(), dccTrailer(), pack(), and unpack_data().

◆ theDDUData

std::vector<CSCDDUEventData> CSCDCCEventData::theDDUData
protected

Definition at line 56 of file CSCDCCEventData.h.

Referenced by addChamber(), CSCDCCEventData(), dduData(), pack(), and unpack_data().

◆ theSizeInWords

int CSCDCCEventData::theSizeInWords
protected

Definition at line 58 of file CSCDCCEventData.h.

Referenced by sizeInWords().