test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 (unsigned short *buf, CSCDCCExaminer *examiner=NULL)
 
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 (unsigned short *buf, CSCDCCExaminer *examiner=NULL)
 

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::CSCDCCEventData ( int  sourceId,
int  nDDUs,
int  bx,
int  l1a 
)

Definition at line 22 of file CSCDCCEventData.cc.

References theDDUData.

23 : theDCCHeader(bx, l1a, sourceId)
24 {
25  theDDUData.reserve(nDDUs);
26 }
CSCDCCHeader theDCCHeader
std::vector< CSCDDUEventData > theDDUData
CSCDCCEventData::CSCDCCEventData ( unsigned short *  buf,
CSCDCCExaminer examiner = NULL 
)
explicit

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

Definition at line 28 of file CSCDCCEventData.cc.

References unpack_data().

29 {
30  unpack_data(buf, examiner);
31 }
void unpack_data(unsigned short *buf, CSCDCCExaminer *examiner=NULL)
CSCDCCEventData::~CSCDCCEventData ( )

Definition at line 33 of file CSCDCCEventData.cc.

34 {
35 }

Member Function Documentation

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 112 of file CSCDCCEventData.cc.

References dccHeader(), i, CSCDCCHeader::setDAV(), and theDDUData.

113 {
114  // first, find this DDU
115  std::vector<CSCDDUEventData>::iterator dduItr;
116  int dduIndex = -1;
117  int nDDUs = theDDUData.size();
118  for(int i = 0; dduIndex == -1 && i < nDDUs; ++i)
119  {
120  if(theDDUData[i].header().source_id() == dduID) dduIndex = i;
121  }
122 
124  unsigned ddu_fmt_version = 0x6; // 2005 Format
125  if (format_version == 2013) ddu_fmt_version = 0x7;
126 
127  if(dduIndex == -1)
128  {
129  // make a new one
130  CSCDDUHeader newDDUHeader(dccHeader().getCDFBunchCounter(),
131  dccHeader().getCDFEventNumber(), dduID, ddu_fmt_version);
132  theDDUData.push_back(CSCDDUEventData(newDDUHeader));
133  dduIndex = nDDUs;
134  dccHeader().setDAV(dduSlot);
135  }
136  theDDUData[dduIndex].add( chamber, dmbID, dduInput, format_version);
137 }
int i
Definition: DBlmapReader.cc:9
void setDAV(int dduSlot)
Definition: CSCDCCHeader.cc:52
CSCDCCHeader dccHeader() const
std::vector< CSCDDUEventData > theDDUData
bool CSCDCCEventData::check ( ) const

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

Definition at line 100 of file CSCDCCEventData.cc.

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

101 {
102  // the trailer counts in 64-bit words
103  if (debug)
104  {
105  LogTrace ("CSCDCCEventData|CSCRawToDigi") << "size in Words () = " << std::dec << sizeInWords();
106  }
107 
108  return theDCCHeader.check() && theDCCTrailer.check();
109 }
bool check() const
Definition: CSCDCCTrailer.h:49
CSCDCCHeader theDCCHeader
int sizeInWords() const
CSCDCCTrailer theDCCTrailer
static std::atomic< bool > debug
bool check() const
Definition: CSCDCCHeader.h:24
#define LogTrace(id)
CSCDCCHeader CSCDCCEventData::dccHeader ( ) const
inline

Definition at line 28 of file CSCDCCEventData.h.

References theDCCHeader.

Referenced by addChamber().

28 {return theDCCHeader;}
CSCDCCHeader theDCCHeader
CSCDCCTrailer CSCDCCEventData::dccTrailer ( ) const
inline

Definition at line 29 of file CSCDCCEventData.h.

References theDCCTrailer.

Referenced by pack().

29 {return theDCCTrailer;}
CSCDCCTrailer theDCCTrailer
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(), CSCValidation::doTimeMonitoring(), and CSCChamberDataItr::next().

25 {return theDDUData;}
std::vector< CSCDDUEventData > theDDUData
std::vector<CSCDDUEventData>& CSCDCCEventData::dduData ( )
inline

Definition at line 26 of file CSCDCCEventData.h.

References theDDUData.

26 {return theDDUData;}
std::vector< CSCDDUEventData > theDDUData
boost::dynamic_bitset CSCDCCEventData::pack ( )

packs data into bits

Definition at line 140 of file CSCDCCEventData.cc.

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

Referenced by pyrootRender.interactiveRender::draw().

141 {
142  boost::dynamic_bitset<> result( theDCCHeader.sizeInWords()*16);
144  //std::cout <<"SANDRIK DCC size of header in words"<< theDCCHeader.sizeInWords()*16 <<std::endl;
145  //std::cout <<"SANDRIK DCC size of header in bits"<< result.size()<<std::endl;
146  //for(size_t i = 0; i < result.size(); ++i) {
147  // std::cout<<result[i];
148  // if (((i+1)%32)==0) std::cout<<std::endl;
149  //}
150 
151  for(size_t i = 0; i < theDDUData.size(); ++i)
152  {
153  result = bitset_utilities::append(result,theDDUData[i].pack());
154  //std::cout <<"SANDRIK here is ddu data check ";
155  //theDDUData[i].header().check();
156  //std::cout <<std::endl;
157  //bitset_utilities::printWords(result);
158  }
159 
160  //std::cout <<"SANDRIK packed dcc size is "<<result.size()<<std::endl;
161  //for(size_t i = 0; i < result.size(); ++i) {
162  // std::cout<<result[i];
163  // if (((i+1)%32)==0) std::cout<<std::endl;
164  //}
165 
167  theDCCTrailer.data());
168  result = bitset_utilities::append(result,dccTrailer);
169  // bitset_utilities::printWords(result);
170  return result;
171 }
int i
Definition: DBlmapReader.cc:9
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:50
CSCDCCTrailer theDCCTrailer
CSCDCCTrailer dccTrailer() const
tuple result
Definition: mps_fire.py:83
boost::dynamic_bitset pack()
packs data into bits
std::vector< CSCDDUEventData > theDDUData
static unsigned sizeInWords()
Definition: CSCDCCHeader.h:26
static unsigned sizeInWords()
Definition: CSCDCCTrailer.h:47
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:25
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
int CSCDCCEventData::sizeInWords ( ) const
inline

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

Definition at line 39 of file CSCDCCEventData.h.

References theSizeInWords.

Referenced by check().

39 {return theSizeInWords;}
void CSCDCCEventData::unpack_data ( unsigned short *  buf,
CSCDCCExaminer examiner = NULL 
)
protected

loop over DDUEventDatas

Definition at line 38 of file CSCDCCEventData.cc.

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

Referenced by CSCDCCEventData().

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

Member Data Documentation

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

Definition at line 55 of file CSCDCCEventData.h.

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

CSCDCCTrailer CSCDCCEventData::theDCCTrailer
protected

Definition at line 58 of file CSCDCCEventData.h.

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

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

Definition at line 57 of file CSCDCCEventData.h.

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

int CSCDCCEventData::theSizeInWords
protected

Definition at line 59 of file CSCDCCEventData.h.

Referenced by sizeInWords().