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 | Private Member Functions | Private Attributes | Static Private Attributes
CSCCLCTData Class Reference

#include <CSCCLCTData.h>

Public Member Functions

void add (const CSCComparatorDigi &digi, int layer)
 TODO for packing. Doesn't do flipping yet. More...
 
bool bitValue (int cfeb, int tbin, int layer, int distrip)
 
bool check () const
 
std::vector< CSCComparatorDigicomparatorDigis (int layer)
 layers count from one More...
 
std::vector< CSCComparatorDigicomparatorDigis (uint32_t idlayer, unsigned icfeb)
 layers count from one More...
 
 CSCCLCTData (const CSCTMBHeader *tmbHeader)
 
 CSCCLCTData (int ncfebs, int ntbins)
 
 CSCCLCTData (int ncfebs, int ntbins, const unsigned short *e0bbuf)
 
unsigned short * data ()
 
CSCCLCTDataWorddataWord (int iline) const
 
CSCCLCTDataWorddataWord (int cfeb, int tbin, int layer) const
 
void dump () const
 
int nlines () const
 
int sizeInWords () const
 in 16-bit words More...
 

Static Public Member Functions

static void selfTest ()
 
static void setDebug (const bool value)
 

Private Member Functions

void zero ()
 

Private Attributes

int ncfebs_
 
int ntbins_
 
int size_
 
unsigned short theData [5 *6 *32]
 

Static Private Attributes

static bool debug = false
 

Detailed Description

Definition at line 20 of file CSCCLCTData.h.

Constructor & Destructor Documentation

CSCCLCTData::CSCCLCTData ( const CSCTMBHeader tmbHeader)
explicit

Definition at line 12 of file CSCCLCTData.cc.

References nlines(), size_, and zero().

13 : ncfebs_(tmbHeader->NCFEBs()), ntbins_(tmbHeader->NTBins())
14 {
15  size_ = nlines();
16  zero();
17 }
uint16_t NTBins() const
Definition: CSCTMBHeader.h:71
int nlines() const
Definition: CSCCLCTData.h:41
uint16_t NCFEBs() const
Definition: CSCTMBHeader.h:74
void zero()
Definition: CSCCLCTData.cc:42
CSCCLCTData::CSCCLCTData ( int  ncfebs,
int  ntbins 
)

Definition at line 20 of file CSCCLCTData.cc.

References nlines(), size_, and zero().

21 : ncfebs_(ncfebs), ntbins_(ntbins)
22 {
23  size_ = nlines();
24  zero();
25 }
int nlines() const
Definition: CSCCLCTData.h:41
void zero()
Definition: CSCCLCTData.cc:42
CSCCLCTData::CSCCLCTData ( int  ncfebs,
int  ntbins,
const unsigned short *  e0bbuf 
)

Definition at line 30 of file CSCCLCTData.cc.

References nlines(), size_, and theData.

31 : ncfebs_(ncfebs), ntbins_(ntbins)
32 {
33  // add two more for odd ntbins, plus one for the e0c
34  // Oct 2004 Rick: e0c line belongs to CSCTMBTrailer
35  size_ = (nlines()%2==1)? nlines()+2 : nlines();
36 
37  memcpy(theData, buf, size_*2);
38 
39 }
int nlines() const
Definition: CSCCLCTData.h:41
unsigned short theData[5 *6 *32]
Definition: CSCCLCTData.h:83

Member Function Documentation

void CSCCLCTData::add ( const CSCComparatorDigi digi,
int  layer 
)

TODO for packing. Doesn't do flipping yet.

Definition at line 183 of file CSCCLCTData.cc.

References dataWord(), CSCComparatorDigi::getComparator(), CSCComparatorDigi::getStrip(), CSCComparatorDigi::getTimeBinsOn(), ntbins_, CSCCLCTDataWord::set(), and strip().

Referenced by CSCEventData::add(), and selfTest().

184 {
185  //FIXME do flipping
186  int strip = digi.getStrip();
187  int halfStrip = (strip-1)*2 + digi.getComparator();
188  int cfeb = (strip-1)/16;
189  int distrip = ((strip-1)%16) / 2;
190  assert(distrip < 8 && cfeb < 6 && halfStrip < 161);
191 
192  std::vector<int> timeBinsOn = digi.getTimeBinsOn();
193  for(std::vector<int>::const_iterator tbinItr = timeBinsOn.begin();
194  tbinItr != timeBinsOn.end(); ++tbinItr)
195  {
196  int tbin = *tbinItr;
197  if(tbin >= 0 && tbin < ntbins_-2) {
198  // First triad bit indicates the presence of the hit
199  dataWord(cfeb, tbin, layer).set(distrip, true);
200  // Second bit indicates which of the two strips contains the hit
201  if (strip%2 == 0)
202  dataWord(cfeb, tbin+1, layer).set(distrip, true);
203  // Third bit indicates whether the hit is located on the left or on the
204  // right side of the strip.
205  if (digi.getComparator())
206  dataWord(cfeb, tbin+2, layer).set(distrip, true);
207  }
208  }
209 }
int getStrip() const
Get the strip number.
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
void set(int distrip, bool value)
@ not right! doesn&#39;t set zero
Definition: CSCCLCTData.h:12
CSCCLCTDataWord & dataWord(int iline) const
Definition: CSCCLCTData.h:46
int getComparator() const
Get Comparator readings.
std::vector< int > getTimeBinsOn() const
bool CSCCLCTData::bitValue ( int  cfeb,
int  tbin,
int  layer,
int  distrip 
)
inline

Definition at line 60 of file CSCCLCTData.h.

References dataWord(), and CSCCLCTDataWord::value().

Referenced by comparatorDigis().

60  {
61  return dataWord(cfeb, tbin, layer).value(distrip);
62  }
CSCCLCTDataWord & dataWord(int iline) const
Definition: CSCCLCTData.h:46
bool value(int distrip)
Definition: CSCCLCTData.h:10
bool CSCCLCTData::check ( ) const

first do some checks

Definition at line 212 of file CSCCLCTData.cc.

References CSCCLCTDataWord::cfeb_, dataWord(), debug, LogTrace, ncfebs_, ntbins_, query::result, and CSCCLCTDataWord::tbin_.

Referenced by cscdqm::EventProcessor::processCSC(), and CSCTMBData::UnpackTMB().

213 {
214  bool result = true;
215  for(int cfeb = 0; cfeb < ncfebs_; ++cfeb)
216  {
217  for(int tbin = 0; tbin < ntbins_; ++tbin)
218  {
219  for(int layer = 1; layer <= 6; ++layer)
220  {
222  const CSCCLCTDataWord & word = dataWord(cfeb, tbin, layer);
223  bool wordIsGood = (word.tbin_ == tbin) && (word.cfeb_ == cfeb);
224  result = result && wordIsGood;
225  if(!wordIsGood && debug)
226  {
227  LogTrace("CSCCLCTData|CSCRawToDigi") << "Bad CLCT data in layer " << layer
228  << " expect CFEB " << cfeb << " tbin " << tbin;
229  LogTrace("CSCCLCTData|CSCRawToDigi") << " See " << word.cfeb_ << " "
230  << word.tbin_;
231  }
232  }
233  }
234  }
235  if(!result) LogTrace("CSCCLCTData|CSCRawToDigi") << "++ Bad CLCT Data ++ ";
236  return result;
237 }
CSCCLCTDataWord & dataWord(int iline) const
Definition: CSCCLCTData.h:46
unsigned short cfeb_
Definition: CSCCLCTData.h:15
tuple result
Definition: query.py:137
#define LogTrace(id)
unsigned short tbin_
Definition: CSCCLCTData.h:14
static bool debug
Definition: CSCCLCTData.h:79
std::vector< CSCComparatorDigi > CSCCLCTData::comparatorDigis ( int  layer)

layers count from one

Definition at line 167 of file CSCCLCTData.cc.

References ncfebs_, and query::result.

Referenced by cscdqm::EventProcessor::processCSC(), and selfTest().

168 {
169  //returns comparators for one layer for all cfebs
170  std::vector<CSCComparatorDigi> result;
171  assert(layer>0 && layer<= 6);
172 
173  for(int cfeb = 0; cfeb < ncfebs_; ++cfeb)
174  {
175  std::vector<CSCComparatorDigi> oneCfebDigi = comparatorDigis(layer,cfeb);
176  result.insert(result.end(), oneCfebDigi.begin(), oneCfebDigi.end());
177  }
178 
179  return result;
180 }
tuple result
Definition: query.py:137
std::vector< CSCComparatorDigi > comparatorDigis(int layer)
layers count from one
Definition: CSCCLCTData.cc:167
std::vector< CSCComparatorDigi > CSCCLCTData::comparatorDigis ( uint32_t  idlayer,
unsigned  icfeb 
)

layers count from one

first do some checks

what is actually stored in comparator digis are 0/1 for left/right halfstrip for each strip

constructing four bitted words for tbits on

Definition at line 58 of file CSCCLCTData.cc.

References bitValue(), CSCCLCTDataWord::cfeb_, dataWord(), debug, CSCDetId::endcap(), CSCDetId::layer(), LogTrace, ntbins_, convertSQLitetoXML_cfg::output, query::result, CSCDetId::ring(), CSCDetId::station(), strip(), CSCCLCTDataWord::tbin_, and SurfaceOrientation::zplus.

59 {
60  static const bool doStripSwapping = true;
61  bool me1a = (CSCDetId::station(idlayer)==1) && (CSCDetId::ring(idlayer)==4);
62  bool zplus = (CSCDetId::endcap(idlayer) == 1);
63  bool me1b = (CSCDetId::station(idlayer)==1) && (CSCDetId::ring(idlayer)==1);
64  unsigned layer = CSCDetId::layer(idlayer);
65 
66  //looking for comp output on layer
67  std::vector<CSCComparatorDigi> result;
68  assert(layer>0 && layer<= 6);
69  // this is pretty sparse data, so I wish we could check the
70  // data word by word, not bit by bit, but I don't see how to
71  // do the time sequencing that way.
72  for(int distrip = 0; distrip < 8; ++distrip)
73  {
74  uint16_t tbinbitsS0HS0=0;
75  uint16_t tbinbitsS0HS1=0;
76  uint16_t tbinbitsS1HS0=0;
77  uint16_t tbinbitsS1HS1=0;
78  for(int tbin = 0; tbin < ntbins_-2; ++tbin)
79  {
80  if(bitValue(cfeb, tbin, layer, distrip))
81  {
83  CSCCLCTDataWord word = dataWord(cfeb, tbin, layer);
84  assert(word.tbin_ == tbin);
85  assert(word.cfeb_ == cfeb);
86  // we have a hit. The next two time samples
87  // are the other two bits in the triad
88  int bit2 = bitValue(cfeb, tbin+1, layer, distrip);
89  int bit3 = bitValue(cfeb, tbin+2, layer, distrip);
90  // should count from zero
91  int chamberDistrip = distrip + cfeb*8;
92  int HalfStrip = 4*chamberDistrip + bit2*2 + bit3;
93  int output = 4 + bit2*2 + bit3;
94  /*
95  * Handles distrip logic; comparator output is for pairs of strips:
96  * hit bin dec
97  * x--- 100 4
98  * -x-- 101 5
99  * --x- 110 6
100  * ---x 111 7
101  *
102  */
103 
104  if (debug)
105  LogTrace ("CSCCLCTData|CSCRawToDigi")
106  << "fillComparatorOutputs: layer = "
107  << layer << " timebin = " << tbin
108  << " cfeb = " << cfeb << " distrip = " << chamberDistrip
109  << " HalfStrip = " << HalfStrip
110  << " Output " << output << std::endl;
112 
114  if (output==4) tbinbitsS0HS0=tbinbitsS0HS0+(1<<tbin);
115  if (output==5) tbinbitsS0HS1=tbinbitsS0HS1+(1<<tbin);
116  if (output==6) tbinbitsS1HS0=tbinbitsS1HS0+(1<<tbin);
117  if (output==7) tbinbitsS1HS1=tbinbitsS1HS1+(1<<tbin);
118 
119  tbin += 2;
120  }
121  }//end of loop over time bins
122  //we do not have to check over the last couple of time bins if there are no hits since
123  //comparators take 3 time bins
124 
125  // Store digis each of possible four halfstrips for given distrip:
126  if (tbinbitsS0HS0 || tbinbitsS0HS1 || tbinbitsS1HS0 || tbinbitsS1HS1) {
127  unsigned int cfeb_corr = cfeb;
128  unsigned int distrip_corr = distrip;
129 
130  if (doStripSwapping) {
131  // Fix ordering of strips and CFEBs in ME1/1.
132  // SV, 27/05/08: keep CFEB=4 for ME1/a until CLCT trigger logic
133  // stops combining it with the info from the other 4 CFEBs (ME1/b).
134  // if ( me1a ) { cfeb_corr = 0; } // reset 4 to 0
135  if ( me1a && zplus ) {distrip_corr = 7-distrip;} // 0-7 -> 7-0
136  if ( me1b && !zplus ) {distrip_corr = 7-distrip; cfeb_corr = 3-cfeb;}
137  }
138 
139  int strip = 16*cfeb_corr + 2*distrip_corr + 1;
140 
141  if (debug)
142  LogTrace ("CSCCLCTData|CSCRawToDigi")
143  << "fillComparatorOutputs: cfeb_corr = " << cfeb_corr
144  << " distrip_corr = " << distrip_corr << " strip = " << strip;
145 
146  if (doStripSwapping && (( me1a && zplus ) || ( me1b && !zplus ))) {
147  // Half-strips need to be flipped too.
148  if (tbinbitsS1HS1) result.push_back(CSCComparatorDigi(strip, 0, tbinbitsS1HS1));
149  if (tbinbitsS1HS0) result.push_back(CSCComparatorDigi(strip, 1, tbinbitsS1HS0));
150  if (tbinbitsS0HS1) result.push_back(CSCComparatorDigi(strip+1, 0, tbinbitsS0HS1));
151  if (tbinbitsS0HS0) result.push_back(CSCComparatorDigi(strip+1, 1, tbinbitsS0HS0));
152  }
153  else {
154  if (tbinbitsS0HS0) result.push_back(CSCComparatorDigi(strip, 0, tbinbitsS0HS0));
155  if (tbinbitsS0HS1) result.push_back(CSCComparatorDigi(strip, 1, tbinbitsS0HS1));
156  if (tbinbitsS1HS0) result.push_back(CSCComparatorDigi(strip+1, 0, tbinbitsS1HS0));
157  if (tbinbitsS1HS1) result.push_back(CSCComparatorDigi(strip+1, 1, tbinbitsS1HS1));
158  }
159  //uh oh ugly ugly ugly!
160  }
161  }//end of loop over distrips
162  return result;
163 }
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
CSCCLCTDataWord & dataWord(int iline) const
Definition: CSCCLCTData.h:46
unsigned short cfeb_
Definition: CSCCLCTData.h:15
int layer() const
Definition: CSCDetId.h:63
int endcap() const
Definition: CSCDetId.h:95
bool bitValue(int cfeb, int tbin, int layer, int distrip)
Definition: CSCCLCTData.h:60
tuple result
Definition: query.py:137
#define LogTrace(id)
int ring() const
Definition: CSCDetId.h:77
unsigned short tbin_
Definition: CSCCLCTData.h:14
static bool debug
Definition: CSCCLCTData.h:79
int station() const
Definition: CSCDetId.h:88
unsigned short* CSCCLCTData::data ( )
inline

Definition at line 38 of file CSCCLCTData.h.

References theData.

Referenced by CSCTMBData::pack().

38 {return theData;}
unsigned short theData[5 *6 *32]
Definition: CSCCLCTData.h:83
CSCCLCTDataWord& CSCCLCTData::dataWord ( int  iline) const
inline

Definition at line 46 of file CSCCLCTData.h.

References ntuplemaker::iline, nlines(), alignCSCRings::s, and theData.

Referenced by add(), bitValue(), check(), comparatorDigis(), dataWord(), and zero().

46  {
47 #ifdef ASSERTS
48  assert(iline < nlines());
49 #endif
50  union dataPtr { const unsigned short * s; CSCCLCTDataWord * d; } mptr;
51  mptr.s = theData+iline;
52  return *(mptr.d);
53  }
int nlines() const
Definition: CSCCLCTData.h:41
unsigned short theData[5 *6 *32]
Definition: CSCCLCTData.h:83
CSCCLCTDataWord& CSCCLCTData::dataWord ( int  cfeb,
int  tbin,
int  layer 
) const
inline

Definition at line 55 of file CSCCLCTData.h.

References dataWord(), ntuplemaker::iline, and ntbins_.

55  {
56  int iline = (layer-1) + tbin*6 + cfeb*6*ntbins_;
57  return dataWord(iline);
58  }
CSCCLCTDataWord & dataWord(int iline) const
Definition: CSCCLCTData.h:46
void CSCCLCTData::dump ( void  ) const

Definition at line 240 of file CSCCLCTData.cc.

References i, size_, and theData.

240  {
241  for (int i=0;i<size_;i++) {
242  printf("%04x %04x %04x %04x\n", theData[i+3], theData[i+2], theData[i+1], theData[i]);
243  i+=3;
244  }
245 }
int i
Definition: DBlmapReader.cc:9
unsigned short theData[5 *6 *32]
Definition: CSCCLCTData.h:83
int CSCCLCTData::nlines ( ) const
inline

Definition at line 41 of file CSCCLCTData.h.

References ncfebs_, and ntbins_.

Referenced by CSCCLCTData(), and dataWord().

41 { return ncfebs_*ntbins_*6; }
void CSCCLCTData::selfTest ( )
static

Definition at line 248 of file CSCCLCTData.cc.

References add(), and comparatorDigis().

249 {
250  CSCCLCTData clctData(5, 16);
251  // aim for output 4 in 5th time bin, = 0000000000010000
252  CSCComparatorDigi comparatorDigi1(1, 0, 0x10);
253  // aim for output 5 in 6th time bin, = 0000 0000 0010 0000
254  CSCComparatorDigi comparatorDigi2(39, 1, 0x20);
255  // aim for output 7 in 7th time bin, = 000 0000 0100 0000
256  CSCComparatorDigi comparatorDigi3(80, 1, 0x40);
257 
258  clctData.add(comparatorDigi1,1);
259  clctData.add(comparatorDigi2,4);
260  clctData.add(comparatorDigi3,6);
261 
262  CSCDetId layer1(1,4,1,2,1);
263  CSCDetId layer4(1,4,1,2,4);
264  CSCDetId layer6(1,4,1,2,6);
265 
266  std::vector<CSCComparatorDigi> digis1 = clctData.comparatorDigis(1);
267  std::vector<CSCComparatorDigi> digis2 = clctData.comparatorDigis(4);
268  std::vector<CSCComparatorDigi> digis3 = clctData.comparatorDigis(6);
269 
270  assert(digis1.size() == 1);
271  assert(digis2.size() == 1);
272  assert(digis3.size() == 1);
273 
274  assert(digis1[0].getStrip() == 1);
275  assert(digis1[0].getComparator() == 0);
276  assert(digis1[0].getTimeBin() == 4);
277 
278  assert(digis2[0].getStrip() == 39);
279  assert(digis2[0].getComparator() == 1);
280  assert(digis2[0].getTimeBin() == 5);
281 
282  assert(digis3[0].getStrip() == 80);
283  assert(digis3[0].getComparator() == 1);
284  assert(digis3[0].getTimeBin() == 6);
285 }
static void CSCCLCTData::setDebug ( const bool  value)
inlinestatic

turns on/off debug flag for this class

Definition at line 29 of file CSCCLCTData.h.

References debug, and relativeConstraints::value.

Referenced by CSCDCCUnpacker::CSCDCCUnpacker().

29 {debug = value;};
static bool debug
Definition: CSCCLCTData.h:79
int CSCCLCTData::sizeInWords ( ) const
inline

in 16-bit words

Definition at line 40 of file CSCCLCTData.h.

References size_.

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

40 { return size_;}
void CSCCLCTData::zero ( )
private

Definition at line 42 of file CSCCLCTData.cc.

References dataWord(), ncfebs_, and ntbins_.

Referenced by CSCCLCTData().

43 {
44  for(int ifeb = 0; ifeb < ncfebs_; ++ifeb)
45  {
46  for(int tbin = 0; tbin < ntbins_; ++tbin)
47  {
48  for(int layer = 1; layer <= 6; ++layer)
49  {
50  dataWord(ifeb, tbin, layer) = CSCCLCTDataWord(ifeb, tbin, 0);
51  }
52  }
53  }
54 
55 }
CSCCLCTDataWord & dataWord(int iline) const
Definition: CSCCLCTData.h:46

Member Data Documentation

bool CSCCLCTData::debug = false
staticprivate

Definition at line 79 of file CSCCLCTData.h.

Referenced by check(), comparatorDigis(), and setDebug().

int CSCCLCTData::ncfebs_
private

Definition at line 80 of file CSCCLCTData.h.

Referenced by check(), comparatorDigis(), nlines(), and zero().

int CSCCLCTData::ntbins_
private

Definition at line 81 of file CSCCLCTData.h.

Referenced by add(), check(), comparatorDigis(), dataWord(), nlines(), and zero().

int CSCCLCTData::size_
private

Definition at line 82 of file CSCCLCTData.h.

Referenced by CSCCLCTData(), dump(), and sizeInWords().

unsigned short CSCCLCTData::theData[5 *6 *32]
private

Definition at line 83 of file CSCCLCTData.h.

Referenced by CSCCLCTData(), data(), dataWord(), and dump().