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, int correctionToALCTbx) 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 18 of file CSCGEMData.cc.

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

18  : ntbins_(ntbins), size_(0) {
19  theData[0] = 0x6C04;
20  ntbins_ = ntbins;
21  gems_enabled_ = gems_fibers;
22  ngems_ = 0;
23  /* Not implemented in the firmware yet */
24  /*
25  for (int i=0; i<4; i++)
26  ngems_ += (gems_fibers>>i) & 0x1;
27  */
28  ngems_ = 4;
29  size_ = 2 + ntbins_ * ngems_ * 4;
30 
32  for (int i = 0; i < (size_ - 2); i++) {
33  int gem_chamber = (i % 16) / 8;
34  theData[i + 1] = 0x3FFF | (gem_chamber << 14);
35  }
36 
37  theData[size_ - 1] = 0x6D04;
38 }
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 40 of file CSCGEMData.cc.

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

40  : size_(length) {
41  size_ = length;
42  ngems_ = 0;
43  /* Not implemented in the firmware yet */
44  /*
45  for (int i=0; i<4; i++)
46  ngems_ += (gems_fibers>>i) & 0x1;
47  */
48  ngems_ = 4;
49  ntbins_ = (size_ - 2) / (4 * ngems_);
50  gems_enabled_ = gems_fibers;
51  memcpy(theData, buf, size_ * 2);
52 }
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 191 of file CSCGEMData.cc.

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

Referenced by CSCEventData::add().

191  {
192  int bx = digi.bx();
194  if ((gem_chamber < 2) && (bx < ntbins_)) {
195  int gem_layer = gem_chamber & 0x1;
196  int cluster_size = digi.pads().size() - 1;
197  int pad = digi.pads()[0];
198  int eta = eta_roll;
199  int cl_word = (gem_layer << 14) + (pad & 0xff) + ((eta & 0x7) << 8) + ((cluster_size & 0x7) << 11);
200  int dataAddr = 1 + bx * 16 + 8 * gem_layer;
201  int cluster_num = 0;
203  while (((theData[dataAddr + cluster_num] & 0x3fff) != 0x3fff) && (cluster_num < 8)) {
204  cluster_num++;
205  }
207  if (((theData[dataAddr + cluster_num] & 0x3fff) == 0x3fff) && (cluster_num < 8)) {
208  theData[dataAddr + cluster_num] = cl_word;
209  }
210  }
211 }
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 67 of file CSCGEMData.cc.

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

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

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

References debug, TauDecayModes::dec, PVValHelper::eta, FCDTask_cfi::fiber, mps_fire::i, LogTrace, beam_dqm_sourceclient-live_cfg::maxClusters, ntbins_, mps_fire::result, GEMPadDigiCluster::setAlctMatchTime(), theData, and testProducerWithPsetDescEmpty_cfi::x1.

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

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

References generateTowerEtThresholdLUT::addr.

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

◆ getPartitionStripNumber()

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

Definition at line 63 of file CSCGEMData.cc.

63  {
64  return address - (nPads * etaPart);
65 }

◆ 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 54 of file CSCGEMData.cc.

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

54  {
55  LogTrace("CSCGEMData|CSCRawToDigi") << "CSCGEMData.Print";
56  for (int line = 0; line < ((size_)); ++line) {
57  LogTrace("CSCGEMData|CSCRawToDigi") << std::hex << theData[line];
58  }
59 }
#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().