CMS 3D CMS Logo

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

#include <CSCGEMData.h>

Public Member Functions

void addEtaPadCluster (const GEMPadDigiCluster &digi, int gem_chamber, int eta_roll)
 Add and pack GEMPadDigiCluster digis. More...
 
bool check () const
 
 CSCGEMData (int ntbins=12, int gem_fibers_mask=0xf)
 default constructor More...
 
 CSCGEMData (const unsigned short *c04buf, int length, int gem_fibers_mask=0xf)
 
unsigned short * data ()
 
std::vector< GEMPadDigiClusterdigis (int gem_chamber) const
 
std::vector< GEMPadDigiClusteretaDigis (int gem_chamber, int eta) const
 
int gemFibersMask () const
 
int nTbins () const
 
int numGEMEnabledFibers () const
 
int numGEMs () const
 
void print () const
 
int sizeInWords () const
 

Static Public Member Functions

static void setDebug (bool debugValue)
 turns on the debug flag for this class More...
 

Private Member Functions

int getPartitionNumber (int address, int nPads) const
 
int getPartitionStripNumber (int address, int nPads, int etaPart) const
 

Private Attributes

int gems_enabled_
 
int ngems_
 
int ntbins_
 
int size_
 
unsigned short theData [8 *2 *32+2]
 

Static Private Attributes

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

Detailed Description

Definition at line 11 of file CSCGEMData.h.

Constructor & Destructor Documentation

◆ CSCGEMData() [1/2]

CSCGEMData::CSCGEMData ( int  ntbins = 12,
int  gem_fibers_mask = 0xf 
)

default constructor

initialize GEM data

Definition at line 16 of file CSCGEMData.cc.

References gems_enabled_, mps_fire::i, ngems_, ntbins_, size_, and theData.

16  : ntbins_(ntbins), size_(0) {
17  theData[0] = 0x6C04;
18  ntbins_ = ntbins;
19  gems_enabled_ = gems_fibers;
20  ngems_ = 0;
21  /* Not implemented in the firmware yet */
22  /*
23  for (int i=0; i<4; i++)
24  ngems_ += (gems_fibers>>i) & 0x1;
25  */
26  ngems_ = 4;
27  size_ = 2 + ntbins_ * ngems_ * 4;
28 
30  for (int i = 0; i < (size_ - 2); i++) {
31  int gem_chamber = (i % 16) / 8;
32  theData[i + 1] = 0x3FFF | (gem_chamber << 14);
33  }
34 
35  theData[size_ - 1] = 0x6D04;
36 }
int ngems_
Definition: CSCGEMData.h:51
unsigned short theData[8 *2 *32+2]
Definition: CSCGEMData.h:53
int ntbins_
Definition: CSCGEMData.h:49
int gems_enabled_
Definition: CSCGEMData.h:50

◆ CSCGEMData() [2/2]

CSCGEMData::CSCGEMData ( const unsigned short *  c04buf,
int  length,
int  gem_fibers_mask = 0xf 
)

Definition at line 38 of file CSCGEMData.cc.

References visDQMUpload::buf, gems_enabled_, ngems_, ntbins_, size_, and theData.

38  : size_(length) {
39  size_ = length;
40  ngems_ = 0;
41  /* Not implemented in the firmware yet */
42  /*
43  for (int i=0; i<4; i++)
44  ngems_ += (gems_fibers>>i) & 0x1;
45  */
46  ngems_ = 4;
47  ntbins_ = (size_ - 2) / (4 * ngems_);
48  gems_enabled_ = gems_fibers;
49  memcpy(theData, buf, size_ * 2);
50 }
int ngems_
Definition: CSCGEMData.h:51
unsigned short theData[8 *2 *32+2]
Definition: CSCGEMData.h:53
int ntbins_
Definition: CSCGEMData.h:49
int gems_enabled_
Definition: CSCGEMData.h:50

Member Function Documentation

◆ addEtaPadCluster()

void CSCGEMData::addEtaPadCluster ( const GEMPadDigiCluster digi,
int  gem_chamber,
int  eta_roll 
)

Add and pack GEMPadDigiCluster digis.

Add/pack GEMPadDigiCluster digi trigger objects per eta/roll gem_chamber - GEM GE11 layer gemA/B [0,1] eta_roll - GEM eta/roll 8 rolls per GEM layer [0-7]

Check that bx < GEM data max allocated tbins and that gem_chamber/layer is in 0,1 range

search for first free/empty cluster word

fill free cluster word if it was found

Definition at line 188 of file CSCGEMData.cc.

References GEMPadDigiCluster::bx(), simKBmtfDigis_cfi::bx, PVValHelper::eta, ntbins_, GEMPadDigiCluster::pads(), and theData.

Referenced by CSCEventData::add().

188  {
189  int bx = digi.bx();
191  if ((gem_chamber < 2) && (bx < ntbins_)) {
192  int gem_layer = gem_chamber & 0x1;
193  int cluster_size = digi.pads().size() - 1;
194  int pad = digi.pads()[0];
195  int eta = eta_roll;
196  int cl_word = (gem_layer << 14) + (pad & 0xff) + ((eta & 0x7) << 8) + ((cluster_size & 0x7) << 11);
197  int dataAddr = 1 + bx * 16 + 8 * gem_layer;
198  int cluster_num = 0;
200  while (((theData[dataAddr + cluster_num] & 0x3fff) != 0x3fff) && (cluster_num < 8)) {
201  cluster_num++;
202  }
204  if (((theData[dataAddr + cluster_num] & 0x3fff) == 0x3fff) && (cluster_num < 8)) {
205  theData[dataAddr + cluster_num] = cl_word;
206  }
207  }
208 }
const std::vector< uint16_t > & pads() const
unsigned short theData[8 *2 *32+2]
Definition: CSCGEMData.h:53
int ntbins_
Definition: CSCGEMData.h:49

◆ check()

bool CSCGEMData::check ( ) const
inline

Definition at line 29 of file CSCGEMData.h.

References size_, and theData.

29 { return ((theData[0] == 0x6C04) && (theData[size_ - 1] == 0x6D04)); }
unsigned short theData[8 *2 *32+2]
Definition: CSCGEMData.h:53

◆ data()

unsigned short* CSCGEMData::data ( )
inline

Definition at line 37 of file CSCGEMData.h.

References theData.

Referenced by CSCTMBData::pack().

37 { return theData; }
unsigned short theData[8 *2 *32+2]
Definition: CSCGEMData.h:53

◆ digis()

std::vector< GEMPadDigiCluster > CSCGEMData::digis ( int  gem_chamber) const

GEM data format v2

GEM data format v1 It is not used in the production Keeping this commented code just for v1 unpacking algo reference

Definition at line 65 of file CSCGEMData.cc.

References debug, TauDecayModes::dec, PVValHelper::eta, mps_fire::i, LogTrace, beam_dqm_sourceclient-live_cfg::maxClusters, ntbins_, mps_fire::result, theData, and testProducerWithPsetDescEmpty_cfi::x1.

Referenced by cscdqm::EventProcessor::processCSC().

65  {
67  std::vector<GEMPadDigiCluster> result;
68  result.clear();
69  int nPads = 192; // From geometry
70  int maxClusters = 4;
71  int nGEMs = 4;
72  // nGEMs = ngems_; // based on enabled fibers. not implemented in the firmware yet
73  for (int i = 0; i < ntbins_; i++) {
74  for (int fiber = 0; fiber < nGEMs; fiber++) {
75  for (int cluster = 0; cluster < maxClusters; cluster++) {
76  int dataAddr = 1 + (i * nGEMs + fiber) * maxClusters + cluster;
77  int gem_layer = (theData[dataAddr] >> 14) & 0x1; // gemA=0 or gemB=1
78  if (gem_layer == gem_chamber) {
79  int cl_word = theData[dataAddr] & 0x3fff;
80  int pad = theData[dataAddr] & 0xff;
81  int eta = (theData[dataAddr] >> 8) & 0x7;
82  int cluster_size = (theData[dataAddr] >> 11) & 0x7;
83  if (pad < nPads) {
84  int padInPart = eta * nPads + pad;
85  if (debug)
86  LogTrace("CSCGEMData|CSCRawToDigi")
87  << "GEMlayer" << gem_layer << " cl_word" << dataAddr << ": 0x" << std::hex << cl_word << std::dec
88  << " tbin: " << i << " fiber#: " << (fiber + 1) << " cluster#: " << (cluster + 1)
89  << " padInPart: " << padInPart << " pad: " << pad << " eta: " << eta
90  << " cluster_size: " << cluster_size << std::endl;
91  std::vector<short unsigned int> pads;
92  for (int iP = 0; iP <= cluster_size; ++iP)
93  pads.push_back(padInPart + iP);
94  GEMPadDigiCluster pad_cluster(pads, i);
95  result.push_back(pad_cluster);
96  }
97  }
98  }
99  }
100  }
101 
105  /*
106  std::vector<GEMPadDigiCluster> result;
107  result.clear();
108  int nPads = 192; // From geometry
109  int maxAddr = 1536;
110  int nGEMs = 2;
111  int maxClusters = 8;
112  // std::cout << std::hex << "markers " << theData[0] << ": " << theData[size_-1] << std::dec << " size: " << size_ << std::endl;
113  for (int i=0; i<ntbins_; i++)
114  {
115  for (int gem=0; gem<nGEMs; gem++)
116  {
117  if (gem==gem_chamber) // Return only digis for specified GEM chamber
118  {
119  for (int TMBCluster=0; TMBCluster<maxClusters; TMBCluster++)
120  {
121  int dataAddr = 1 + (i*nGEMs+gem)*maxClusters + TMBCluster;
122  int address = theData[dataAddr] & 0x7ff;
123  // std::cout << dataAddr << ": " << address <<std::endl;
124  int nExtraPads = (theData[dataAddr] >>11)&0x7;
125  if (address<maxAddr)
126  {
127  int etaPart = getPartitionNumber(address,nPads);
128  int padInPart = getPartitionStripNumber(address,nPads,etaPart);
129  vector<short unsigned int> pads;
130  for(int iP = 0; iP <= nExtraPads; ++iP)
131  pads.push_back(padInPart + iP );
132  GEMPadDigiCluster cluster ( pads, i);
133  result.push_back(cluster);
134  }
135  }
136  }
137  }
138  }
139  */
140  return result;
141 }
static std::atomic< bool > debug
Definition: CSCGEMData.h:46
#define LogTrace(id)
unsigned short theData[8 *2 *32+2]
Definition: CSCGEMData.h:53
int ntbins_
Definition: CSCGEMData.h:49

◆ etaDigis()

std::vector< GEMPadDigiCluster > CSCGEMData::etaDigis ( int  gem_chamber,
int  eta_roll 
) const

Unpack GEMPadDigiCluster digi trigger objects per eta/roll gem_chamber - GEM GE11 layer gemA/B [0,1] eta_roll - GEM eta/roll 8 rolls per GEM layer [0-7]

GEM data format v2

Definition at line 146 of file CSCGEMData.cc.

References debug, TauDecayModes::dec, PVValHelper::eta, mps_fire::i, LogTrace, beam_dqm_sourceclient-live_cfg::maxClusters, ntbins_, mps_fire::result, theData, and testProducerWithPsetDescEmpty_cfi::x1.

Referenced by cscdqm::EventProcessor::processCSC().

146  {
148  std::vector<GEMPadDigiCluster> result;
149  result.clear();
150  int nPads = 192; // From geometry
151  int maxClusters = 4;
152  int nGEMs = 4;
153  // nGEMs = ngems_; // based on enabled fibers. currently not implemented in the firmware
154  for (int i = 0; i < ntbins_; i++) {
155  for (int fiber = 0; fiber < nGEMs; fiber++) {
156  for (int cluster = 0; cluster < maxClusters; cluster++) {
157  int dataAddr = 1 + (i * nGEMs + fiber) * maxClusters + cluster;
158  int gem_layer = (theData[dataAddr] >> 14) & 0x1; // gemA=0 or gemB=1
159  if (gem_layer == gem_chamber) {
160  int cl_word = theData[dataAddr] & 0x3fff;
161  int pad = theData[dataAddr] & 0xff;
162  int eta = (theData[dataAddr] >> 8) & 0x7;
163  int cluster_size = (theData[dataAddr] >> 11) & 0x7;
164  if ((pad < nPads) && (eta == eta_roll)) {
165  int padInPart = pad;
166  if (debug)
167  LogTrace("CSCGEMData|CSCRawToDigi")
168  << "GEMlayer" << gem_layer << " cl_word" << dataAddr << ": 0x" << std::hex << cl_word << std::dec
169  << " tbin: " << i << " fiber#: " << (fiber + 1) << " cluster#: " << (cluster + 1)
170  << " padInPart: " << padInPart << " pad: " << pad << " eta: " << eta
171  << " cluster_size: " << cluster_size << std::endl;
172  std::vector<short unsigned int> pads;
173  for (int iP = 0; iP <= cluster_size; ++iP)
174  pads.push_back(padInPart + iP);
175  GEMPadDigiCluster pad_cluster(pads, i);
176  result.push_back(pad_cluster);
177  }
178  }
179  }
180  }
181  }
182  return result;
183 }
static std::atomic< bool > debug
Definition: CSCGEMData.h:46
#define LogTrace(id)
unsigned short theData[8 *2 *32+2]
Definition: CSCGEMData.h:53
int ntbins_
Definition: CSCGEMData.h:49

◆ gemFibersMask()

int CSCGEMData::gemFibersMask ( ) const
inline

Definition at line 25 of file CSCGEMData.h.

References gems_enabled_.

25 { return gems_enabled_; }
int gems_enabled_
Definition: CSCGEMData.h:50

◆ getPartitionNumber()

int CSCGEMData::getPartitionNumber ( int  address,
int  nPads 
) const
private

Definition at line 59 of file CSCGEMData.cc.

References generateTowerEtThresholdLUT::addr.

59 { return addr / (npads - 1); }

◆ getPartitionStripNumber()

int CSCGEMData::getPartitionStripNumber ( int  address,
int  nPads,
int  etaPart 
) const
private

Definition at line 61 of file CSCGEMData.cc.

61  {
62  return address - (nPads * etaPart);
63 }

◆ nTbins()

int CSCGEMData::nTbins ( ) const
inline

Definition at line 27 of file CSCGEMData.h.

References ntbins_.

27 { return ntbins_; }
int ntbins_
Definition: CSCGEMData.h:49

◆ numGEMEnabledFibers()

int CSCGEMData::numGEMEnabledFibers ( ) const
inline

Definition at line 26 of file CSCGEMData.h.

References ngems_.

26 { return ngems_; }
int ngems_
Definition: CSCGEMData.h:51

◆ numGEMs()

int CSCGEMData::numGEMs ( ) const
inline

Definition at line 22 of file CSCGEMData.h.

Referenced by cscdqm::EventProcessor::processCSC().

22  {
23  return 2; // !!! TODO actual number of GEM chambers in readout
24  }

◆ print()

void CSCGEMData::print ( void  ) const

Definition at line 52 of file CSCGEMData.cc.

References mps_splice::line, LogTrace, size_, and theData.

52  {
53  LogTrace("CSCGEMData|CSCRawToDigi") << "CSCGEMData.Print";
54  for (int line = 0; line < ((size_)); ++line) {
55  LogTrace("CSCGEMData|CSCRawToDigi") << std::hex << theData[line];
56  }
57 }
#define LogTrace(id)
unsigned short theData[8 *2 *32+2]
Definition: CSCGEMData.h:53

◆ setDebug()

static void CSCGEMData::setDebug ( bool  debugValue)
inlinestatic

turns on the debug flag for this class

Definition at line 32 of file CSCGEMData.h.

References debug.

32 { debug = debugValue; }
static std::atomic< bool > debug
Definition: CSCGEMData.h:46

◆ sizeInWords()

int CSCGEMData::sizeInWords ( ) const
inline

Definition at line 21 of file CSCGEMData.h.

References size_.

Referenced by CSCTMBData::CSCTMBData(), CSCTMBData::pack(), and CSCTMBData::UnpackTMB().

21 { return size_; }

Member Data Documentation

◆ debug

std::atomic< bool > CSCGEMData::debug {false}
staticprivate

◆ gems_enabled_

int CSCGEMData::gems_enabled_
private

Definition at line 50 of file CSCGEMData.h.

Referenced by CSCGEMData(), and gemFibersMask().

◆ ngems_

int CSCGEMData::ngems_
private

Definition at line 51 of file CSCGEMData.h.

Referenced by CSCGEMData(), and numGEMEnabledFibers().

◆ ntbins_

int CSCGEMData::ntbins_
private

Definition at line 49 of file CSCGEMData.h.

Referenced by addEtaPadCluster(), CSCGEMData(), digis(), etaDigis(), and nTbins().

◆ size_

int CSCGEMData::size_
private

Definition at line 52 of file CSCGEMData.h.

Referenced by check(), CSCGEMData(), print(), and sizeInWords().

◆ theData

unsigned short CSCGEMData::theData[8 *2 *32+2]
private

Definition at line 53 of file CSCGEMData.h.

Referenced by addEtaPadCluster(), check(), CSCGEMData(), data(), digis(), etaDigis(), and print().