CMS 3D CMS Logo

CSCCLCTData Class Reference

#include <EventFilter/CSCRawToDigi/interface/CSCCLCTData.h>

List of all members.

Public Member Functions

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

Static Public Member Functions

static void selfTest ()
static void setDebug (const bool value)
 turns on/off debug flag for this class

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 11 of file CSCCLCTData.cc.

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

00012 : ncfebs_(tmbHeader->NCFEBs()), ntbins_(tmbHeader->NTBins())
00013 {
00014   size_ = nlines();
00015   zero();
00016 }

CSCCLCTData::CSCCLCTData ( int  ncfebs,
int  ntbins 
)

Definition at line 19 of file CSCCLCTData.cc.

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

00020 : ncfebs_(ncfebs), ntbins_(ntbins) 
00021 {
00022   size_ = nlines();
00023   zero();
00024 }

CSCCLCTData::CSCCLCTData ( int  ncfebs,
int  ntbins,
const unsigned short *  e0bbuf 
)

Definition at line 29 of file CSCCLCTData.cc.

References nlines(), size_, and theData.

00030 : ncfebs_(ncfebs), ntbins_(ntbins) 
00031 {
00032   // add two more for odd ntbins, plus one for the e0c
00033   // Oct 2004 Rick: e0c line belongs to CSCTMBTrailer
00034   size_ = (nlines()%2==1)? nlines()+2 : nlines();
00035   
00036   memcpy(theData, buf, size_*2);
00037   
00038 }


Member Function Documentation

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

TODO for packing. Doesn't do flipping yet.

Definition at line 182 of file CSCCLCTData.cc.

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

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

00183 {
00184   //FIXME do flipping
00185   int strip = digi.getStrip();
00186   int halfStrip = (strip-1)*2 + digi.getComparator();
00187   int cfeb = (strip-1)/16;
00188   int distrip = ((strip-1)%16) / 2;
00189   assert(distrip < 8 && cfeb < 6 && halfStrip < 161);
00190 
00191   std::vector<int> timeBinsOn = digi.getTimeBinsOn();
00192   for(std::vector<int>::const_iterator tbinItr = timeBinsOn.begin();
00193       tbinItr != timeBinsOn.end(); ++tbinItr)
00194   {
00195     int tbin = *tbinItr;
00196     if(tbin >= 0 && tbin < ntbins_-2) {
00197       // First triad bit indicates the presence of the hit
00198       dataWord(cfeb, tbin, layer).set(distrip, true);
00199       // Second bit indicates which of the two strips contains the hit
00200       if (strip%2 == 0)
00201         dataWord(cfeb, tbin+1, layer).set(distrip, true);
00202       // Third bit indicates whether the hit is located on the left or on the
00203       // right side of the strip.
00204       if (digi.getComparator())
00205         dataWord(cfeb, tbin+2, layer).set(distrip, true);
00206     }
00207   }
00208 }

bool CSCCLCTData::bitValue ( int  cfeb,
int  tbin,
int  layer,
int  distrip 
) [inline]

Definition at line 58 of file CSCCLCTData.h.

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

Referenced by comparatorDigis().

00058                                                             {
00059     return dataWord(cfeb, tbin, layer).value(distrip);
00060   }

bool CSCCLCTData::check (  )  const

first do some checks

Definition at line 211 of file CSCCLCTData.cc.

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

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

00212 {
00213   bool result = true;
00214   for(int cfeb = 0; cfeb < ncfebs_; ++cfeb) 
00215     {
00216       for(int tbin = 0; tbin < ntbins_; ++tbin)
00217         {
00218           for(int layer = 1; layer <= 6; ++layer) 
00219             {
00221               const CSCCLCTDataWord & word = dataWord(cfeb, tbin, layer);
00222               bool wordIsGood = (word.tbin_ == tbin) && (word.cfeb_ == cfeb);
00223               result = result && wordIsGood;
00224               if(!wordIsGood && debug)
00225                 {
00226                   LogTrace("CSCCLCTData|CSCRawToDigi") << "Bad CLCT data  in layer " << layer 
00227                                                << " expect CFEB " << cfeb << " tbin " << tbin;
00228                   LogTrace("CSCCLCTData|CSCRawToDigi") << " See " << word.cfeb_ << " " 
00229                                                << word.tbin_;
00230                 }
00231             }
00232         }
00233     }
00234   if(!result) LogTrace("CSCCLCTData|CSCRawToDigi") << "++ Bad CLCT Data ++ ";
00235   return result;
00236 }

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 57 of file CSCCLCTData.cc.

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

00058 {
00059   static const bool doStripSwapping = false;
00060   bool me1a = (CSCDetId::station(idlayer)==1) && (CSCDetId::ring(idlayer)==4);
00061   bool zplus = (CSCDetId::endcap(idlayer) == 1); 
00062   bool me1b = (CSCDetId::station(idlayer)==1) && (CSCDetId::ring(idlayer)==1);
00063   unsigned layer = CSCDetId::layer(idlayer);
00064 
00065   //looking for comp output on layer
00066   std::vector<CSCComparatorDigi> result;
00067   assert(layer>0 && layer<= 6);
00068   // this is pretty sparse data, so I wish we could check the
00069   // data word by word, not bit by bit, but I don't see how to
00070   // do the time sequencing that way.
00071   for(int distrip = 0; distrip < 8; ++distrip) 
00072     {
00073       uint16_t tbinbitsS0HS0=0;
00074       uint16_t tbinbitsS0HS1=0;
00075       uint16_t tbinbitsS1HS0=0;
00076       uint16_t tbinbitsS1HS1=0;
00077       for(int tbin = 0; tbin < ntbins_-2; ++tbin) 
00078         {
00079           if(bitValue(cfeb, tbin, layer, distrip))
00080             {
00082               CSCCLCTDataWord word = dataWord(cfeb, tbin, layer);
00083               assert(word.tbin_ == tbin);
00084               assert(word.cfeb_ == cfeb);
00085               // we have a hit.  The next two time samples
00086               // are the other two bits in the triad
00087               int bit2 = bitValue(cfeb, tbin+1, layer, distrip);
00088               int bit3 = bitValue(cfeb, tbin+2, layer, distrip);
00089               // should count from zero
00090               int chamberDistrip = distrip + cfeb*8;
00091               int HalfStrip = 4*chamberDistrip + bit2*2 + bit3;
00092               int output = 4 + bit2*2 + bit3;
00093               /*
00094                * Handles distrip logic; comparator output is for pairs of strips:
00095                * hit  bin  dec
00096                * x--- 100   4
00097                * -x-- 101   5
00098                * --x- 110   6
00099                * ---x 111   7
00100                *
00101                */
00102 
00103         if (debug)
00104           LogTrace ("CSCCLCTData|CSCRawToDigi")
00105                   << "fillComparatorOutputs: layer = "
00106                   << layer << " timebin = " << tbin
00107                   << " cfeb = " << cfeb << " distrip = " << chamberDistrip
00108                   << " HalfStrip = " << HalfStrip
00109                   << " Output " << output << std::endl;
00111 
00113               if (output==4) tbinbitsS0HS0=tbinbitsS0HS0+(1<<tbin);      
00114               if (output==5) tbinbitsS0HS1=tbinbitsS0HS1+(1<<tbin);
00115               if (output==6) tbinbitsS1HS0=tbinbitsS1HS0+(1<<tbin);
00116               if (output==7) tbinbitsS1HS1=tbinbitsS1HS1+(1<<tbin);
00117               
00118               tbin += 2;
00119             }
00120         }//end of loop over time bins
00121       //we do not have to check over the last couple of time bins if there are no hits since
00122       //comparators take 3 time bins
00123 
00124       // Store digis each of possible four halfstrips for given distrip:
00125       if (tbinbitsS0HS0 || tbinbitsS0HS1 || tbinbitsS1HS0 || tbinbitsS1HS1) {
00126         unsigned int cfeb_corr    = cfeb;
00127         unsigned int distrip_corr = distrip;
00128 
00129         if (doStripSwapping) {
00130           // Fix ordering of strips and CFEBs in ME1/1.
00131           // SV, 27/05/08: keep CFEB=4 for ME1/a until CLCT trigger logic
00132           // stops combining it with the info from the other 4 CFEBs (ME1/b).
00133           // if ( me1a )           { cfeb_corr = 0; } // reset 4 to 0
00134           if ( me1a &&  zplus ) {distrip_corr = 7-distrip;} // 0-7 -> 7-0
00135           if ( me1b && !zplus ) {distrip_corr = 7-distrip; cfeb_corr = 3-cfeb;}
00136         }
00137 
00138         int strip = 16*cfeb_corr + 2*distrip_corr + 1;
00139 
00140         if (debug)
00141           LogTrace ("CSCCLCTData|CSCRawToDigi")
00142             << "fillComparatorOutputs: cfeb_corr = " << cfeb_corr
00143             << " distrip_corr = " << distrip_corr << " strip = " << strip;
00144 
00145         if (doStripSwapping && (( me1a && zplus ) || ( me1b && !zplus ))) {
00146           // Half-strips need to be flipped too.
00147           if (tbinbitsS1HS1) result.push_back(CSCComparatorDigi(strip, 0, tbinbitsS1HS1));
00148           if (tbinbitsS1HS0) result.push_back(CSCComparatorDigi(strip, 1, tbinbitsS1HS0));
00149           if (tbinbitsS0HS1) result.push_back(CSCComparatorDigi(strip+1, 0, tbinbitsS0HS1));
00150           if (tbinbitsS0HS0) result.push_back(CSCComparatorDigi(strip+1, 1, tbinbitsS0HS0));
00151         }
00152         else {
00153           if (tbinbitsS0HS0) result.push_back(CSCComparatorDigi(strip, 0, tbinbitsS0HS0));
00154           if (tbinbitsS0HS1) result.push_back(CSCComparatorDigi(strip, 1, tbinbitsS0HS1));
00155           if (tbinbitsS1HS0) result.push_back(CSCComparatorDigi(strip+1, 0, tbinbitsS1HS0));
00156           if (tbinbitsS1HS1) result.push_back(CSCComparatorDigi(strip+1, 1, tbinbitsS1HS1));
00157         }
00158         //uh oh ugly ugly ugly!
00159       }
00160     }//end of loop over distrips
00161   return result;
00162 }

std::vector< CSCComparatorDigi > CSCCLCTData::comparatorDigis ( int  layer  ) 

layers count from one

Definition at line 166 of file CSCCLCTData.cc.

References ncfebs_, and HLT_VtxMuL3::result.

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

00167 {
00168   //returns comparators for one layer for all cfebs
00169   std::vector<CSCComparatorDigi> result;
00170   assert(layer>0 && layer<= 6);
00171 
00172   for(int cfeb = 0; cfeb < ncfebs_; ++cfeb) 
00173     {
00174       std::vector<CSCComparatorDigi> oneCfebDigi = comparatorDigis(layer,cfeb);
00175       result.insert(result.end(), oneCfebDigi.begin(), oneCfebDigi.end());      
00176     }
00177 
00178   return result;
00179 }

unsigned short* CSCCLCTData::data (  )  [inline]

Definition at line 38 of file CSCCLCTData.h.

References theData.

Referenced by CSCTMBData::pack().

00038 {return theData;}

CSCCLCTDataWord& CSCCLCTData::dataWord ( int  cfeb,
int  tbin,
int  layer 
) const [inline]

Definition at line 53 of file CSCCLCTData.h.

References dataWord(), and ntbins_.

00053                                                                   {
00054     int iline = (layer-1) + tbin*6 + cfeb*6*ntbins_;
00055     return dataWord(iline);
00056   }

CSCCLCTDataWord& CSCCLCTData::dataWord ( int  iline  )  const [inline]

Definition at line 46 of file CSCCLCTData.h.

References nlines(), and theData.

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

00046                                               {
00047 #ifdef ASSERTS
00048     assert(iline < nlines());
00049 #endif
00050     return *(CSCCLCTDataWord *)(theData+iline);
00051   }

int CSCCLCTData::nlines (  )  const [inline]

Definition at line 41 of file CSCCLCTData.h.

References ncfebs_, and ntbins_.

Referenced by CSCCLCTData(), and dataWord().

00041 { return ncfebs_*ntbins_*6; }

void CSCCLCTData::selfTest (  )  [static]

Definition at line 239 of file CSCCLCTData.cc.

References add(), and comparatorDigis().

00240 {
00241   CSCCLCTData clctData(5, 16);
00242   // aim for output 4 in 5th time bin, = 0000000000010000
00243   CSCComparatorDigi comparatorDigi1(1, 0, 0x10);
00244   // aim for output 5 in 6th time bin, = 0000 0000 1010 0000
00245   CSCComparatorDigi comparatorDigi2(39, 1, 0xA0);
00246   // aim for output 7 in 7th time bin, = 000 0001 1100 0000
00247   CSCComparatorDigi comparatorDigi3(80, 1, 0x1C0);
00248 
00249   clctData.add(comparatorDigi1,1);
00250   clctData.add(comparatorDigi2,4);
00251   clctData.add(comparatorDigi3,6);
00252 
00253   CSCDetId layer1(1,4,1,2,1);  
00254   CSCDetId layer4(1,4,1,2,4);
00255   CSCDetId layer6(1,4,1,2,6);
00256 
00257   std::vector<CSCComparatorDigi> digis1 = clctData.comparatorDigis(1);
00258   std::vector<CSCComparatorDigi> digis2 = clctData.comparatorDigis(4);
00259   std::vector<CSCComparatorDigi> digis3 = clctData.comparatorDigis(6);
00260 
00261   assert(digis1.size() == 1);
00262   assert(digis2.size() == 1);
00263   assert(digis3.size() == 1);
00264 
00265   assert(digis1[0].getStrip() == 1);
00266   assert(digis1[0].getComparator() == 0);
00267   assert(digis1[0].getTimeBin() == 4);
00268 
00269   assert(digis2[0].getStrip() == 39);
00270   assert(digis2[0].getComparator() == 1);
00271   assert(digis2[0].getTimeBin() == 5);
00272 
00273   assert(digis3[0].getStrip() == 80);
00274   assert(digis3[0].getComparator() == 1);
00275   assert(digis3[0].getTimeBin() == 6);
00276 }

static void CSCCLCTData::setDebug ( const bool  value  )  [inline, static]

turns on/off debug flag for this class

Definition at line 29 of file CSCCLCTData.h.

References debug.

Referenced by CSCDCCUnpacker::CSCDCCUnpacker().

00029 {debug = value;};

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().

00040 { return size_;}

void CSCCLCTData::zero (  )  [private]

Definition at line 41 of file CSCCLCTData.cc.

References dataWord(), ncfebs_, and ntbins_.

Referenced by CSCCLCTData().

00042 {
00043   for(int ifeb = 0; ifeb < ncfebs_; ++ifeb)
00044     {
00045       for(int tbin = 0; tbin < ntbins_; ++tbin)
00046         {
00047           for(int layer = 1; layer <= 6; ++layer)
00048             {
00049               dataWord(ifeb, tbin, layer) = CSCCLCTDataWord(ifeb, tbin, 0);
00050             }
00051         }
00052     }
00053 
00054 }


Member Data Documentation

bool CSCCLCTData::debug = false [static, private]

Definition at line 74 of file CSCCLCTData.h.

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

int CSCCLCTData::ncfebs_ [private]

Definition at line 75 of file CSCCLCTData.h.

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

int CSCCLCTData::ntbins_ [private]

Definition at line 76 of file CSCCLCTData.h.

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

int CSCCLCTData::size_ [private]

Definition at line 77 of file CSCCLCTData.h.

Referenced by CSCCLCTData(), and sizeInWords().

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

Definition at line 78 of file CSCCLCTData.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:17:08 2009 for CMSSW by  doxygen 1.5.4