#include <CSCCFEBData.h>
Public Member Functions | |
unsigned | adcCounts (unsigned layer, unsigned channel, unsigned timeBin) const |
unsigned | adcOverflow (unsigned layer, unsigned channel, unsigned timeBin) const |
void | add (const CSCStripDigi &, int layer) |
unsigned | boardNumber () const |
bool | check () const |
makes sure each time slice has a trailer | |
unsigned | controllerData (unsigned uglay, unsigned ugchan, unsigned timeBin) const |
CSCCFEBData (unsigned boardNumber, unsigned short *buf) | |
read from an existing data stream. | |
CSCCFEBData (unsigned boardNumber, bool sixteenSamples) | |
create, | |
unsigned short * | data () |
void | digis (uint32_t idlayer, std::vector< CSCStripDigi > &result) |
faster way to get to digis | |
std::vector< CSCStripDigi > | digis (unsigned idlayer) |
unsigned | errorstat (unsigned layer, unsigned channel, unsigned timeBin) const |
unsigned | nTimeSamples () const |
unsigned | overlappedSampleFlag (unsigned layer, unsigned channel, unsigned timeBin) const |
void | setBoardNumber (int cfeb) |
unsigned | sizeInWords () const |
CSCCFEBStatusDigi | statusDigi () const |
returns one status digi per cfeb | |
std::vector< std::vector < CSCStripDigi > > | stripDigis () |
deprecated. Use the above method. | |
const CSCCFEBTimeSlice * | timeSlice (unsigned i) const |
count from 0. User should check if it's a bad slice | |
Static Public Member Functions | |
static void | selfTest () |
Private Attributes | |
unsigned | boardNumber_ |
std::vector< uint16_t > | bWords |
unsigned short | theData [1600] |
unsigned | theNumberOfSamples |
int | theSize |
in words | |
std::vector< std::pair< int, bool > > | theSliceStarts |
Friends | |
std::ostream & | operator<< (std::ostream &os, const CSCCFEBData &) |
Definition at line 14 of file CSCCFEBData.h.
CSCCFEBData::CSCCFEBData | ( | unsigned | boardNumber, |
unsigned short * | buf | ||
) |
read from an existing data stream.
Definition at line 11 of file CSCCFEBData.cc.
References bWords, CSCBadCFEBTimeSlice::check(), CSCCFEBTimeSlice::check(), CSCBadCFEBWord::data(), LogTrace, pos, CSCCFEBTimeSlice::sixteenSamples(), CSCCFEBTimeSlice::sizeInWords(), CSCBadCFEBTimeSlice::sizeInWords(), theData, theNumberOfSamples, theSize, theSliceStarts, and CSCBadCFEBTimeSlice::word().
: theSize(0), boardNumber_(number), theNumberOfSamples(0) { // I may be grabbing too many words, but that's OK // parse for time slices unsigned pos = 0; // to be set later unsigned maxSamples = 8; theSliceStarts.reserve(8); while(theNumberOfSamples < maxSamples) { // first see if it's a bad slice CSCBadCFEBTimeSlice * badSlice = reinterpret_cast<CSCBadCFEBTimeSlice *>(buf+pos); if(badSlice->check()) { //show that a bad slice starts here theSliceStarts.push_back(std::pair<int, bool>(pos, false)); pos += badSlice->sizeInWords(); //store bad word for status digis bWords.push_back(badSlice->word(1).data()); //all 4 words are assumed identical so saving #1 only } else { // OK. Maybe it's good. CSCCFEBTimeSlice * goodSlice = reinterpret_cast<CSCCFEBTimeSlice *>(buf+pos); if(goodSlice->check()) { // show that a good slice starts here theSliceStarts.push_back(std::pair<int, bool>(pos, true)); // it will just be an array of CSCCFEBTimeSlices, so we'll // grab the number of time slices from the first good one maxSamples = goodSlice->sixteenSamples() ? 16 : 8; pos += goodSlice->sizeInWords(); } else { LogTrace ("CSCCFEBData|CSCRawToDigi") << "CORRUPT CFEB DATA slice " << theNumberOfSamples << std::hex << " " << *(buf+pos+3) << " " << *(buf+pos+2) << " " << *(buf+pos+1) << " "<< *(buf+pos); //ok slice is bad but try another one at 100 words after it theSliceStarts.push_back(std::pair<int, bool>(pos, false)); pos += 100; } } ++theNumberOfSamples; } theSize = pos; memcpy(theData, buf, theSize*2); }
CSCCFEBData::CSCCFEBData | ( | unsigned | boardNumber, |
bool | sixteenSamples | ||
) |
create,
Definition at line 58 of file CSCCFEBData.cc.
References i, pos, CSCCFEBTimeSlice::setControllerWord(), theData, theNumberOfSamples, theSize, theSliceStarts, and CSCCFEBSCAControllerWord::ts_flag.
: boardNumber_(number), theNumberOfSamples(sixteenSamples ? 16 : 8) { theSliceStarts.reserve(theNumberOfSamples); // fill the SCA controller words CSCCFEBSCAControllerWord scaWord; scaWord.ts_flag = sixteenSamples; // make a template slice to copy into theData buffer CSCCFEBTimeSlice slice; slice.setControllerWord(scaWord); for(unsigned i = 0; i < theNumberOfSamples; ++i) { unsigned short * pos = theData+i*100; memcpy(pos, &slice, 200); theSliceStarts.push_back(std::pair<int,bool>(i*100, true)); } theSize = theNumberOfSamples*100; }
unsigned CSCCFEBData::adcCounts | ( | unsigned | layer, |
unsigned | channel, | ||
unsigned | timeBin | ||
) | const |
Definition at line 114 of file CSCCFEBData.cc.
References CSCCFEBDataWord::adcCounts, query::result, CSCCFEBTimeSlice::timeSample(), and timeSlice().
Referenced by operator<<().
{ unsigned result = 0; const CSCCFEBTimeSlice * slice = timeSlice(timeBin); // zero is returned for bad slices if(slice) result = slice->timeSample(layer, channel)->adcCounts; return result; }
unsigned CSCCFEBData::adcOverflow | ( | unsigned | layer, |
unsigned | channel, | ||
unsigned | timeBin | ||
) | const |
Definition at line 122 of file CSCCFEBData.cc.
References CSCCFEBDataWord::adcOverflow, query::result, CSCCFEBTimeSlice::timeSample(), and timeSlice().
{ unsigned result = 0; const CSCCFEBTimeSlice * slice = timeSlice(timeBin); // zero is returned for bad slices if(slice) result = slice->timeSample(layer, channel)->adcOverflow; return result; }
void CSCCFEBData::add | ( | const CSCStripDigi & | digi, |
int | layer | ||
) |
=VB= Set CRC value for simulated data
Definition at line 80 of file CSCCFEBData.cc.
References CSCCFEBDataWord::adcCounts, CSCStripDigi::getADCCounts(), CSCStripDigi::getStrip(), theNumberOfSamples, CSCCFEBTimeSlice::timeSample(), timeSlice(), and relativeConstraints::value.
Referenced by CSCEventData::add().
{ std::vector<int> scaCounts = digi.getADCCounts(); for(unsigned itime = 0; itime < theNumberOfSamples; ++itime) { unsigned channel = (digi.getStrip()-1) % 16 + 1; unsigned value = scaCounts[itime] & 0xFFF; // 12-bit // assume it's good, since we're working with simulation const CSCCFEBTimeSlice * slice = timeSlice(itime); assert(slice != 0); slice->timeSample(layer, channel)->adcCounts = value; ((CSCCFEBTimeSlice *)slice)->setCRC(); } }
unsigned CSCCFEBData::boardNumber | ( | ) | const [inline] |
bool CSCCFEBData::check | ( | ) | const |
makes sure each time slice has a trailer
Definition at line 290 of file CSCCFEBData.cc.
References i, query::result, theNumberOfSamples, and timeSlice().
Referenced by cscdqm::EventProcessor::processCSC().
unsigned CSCCFEBData::controllerData | ( | unsigned | uglay, |
unsigned | ugchan, | ||
unsigned | timeBin | ||
) | const |
Definition at line 131 of file CSCCFEBData.cc.
References CSCCFEBDataWord::controllerData, query::result, CSCCFEBTimeSlice::timeSample(), and timeSlice().
Referenced by digis().
{ // The argument notation is // uglay = un-Gray Coded layer index 1-6 // ugchan = un-Gray Coded channel index 1-16 // The point being that the SCAC is serially encoded directly in the data stream (without Gray Coding) // so the layer and channel indexes here are just the direct ordering into the data stream. unsigned result = 0; const CSCCFEBTimeSlice * slice = timeSlice(timeBin); // zero is returned for bad slices if(slice) result = slice->timeSample( (ugchan-1)*6+uglay-1 )->controllerData; return result; }
unsigned short* CSCCFEBData::data | ( | ) | [inline] |
void CSCCFEBData::digis | ( | uint32_t | idlayer, |
std::vector< CSCStripDigi > & | result | ||
) |
faster way to get to digis
Fill strip digis for layer with raw detid = idlayer WARNING: these digis have no comparator information.
for bad or missing data word will be zero
Definition at line 202 of file CSCCFEBData.cc.
References CSCCFEBDataWord::adcCounts, CSCCFEBDataWord::adcOverflow, boardNumber_, controllerData(), CSCDetId, Reference_intrackfit_cff::endcap, CSCCFEBDataWord::errorstat, CSCDetId::layer(), LogTrace, nTimeSamples(), muon::overlap(), CSCCFEBDataWord::overlappedSampleFlag, CSCDetId::ring(), relativeConstraints::station, strip(), CSCCFEBTimeSlice::timeSample(), timeSlice(), and SurfaceOrientation::zplus.
Referenced by digis(), stripDigis(), and CSCEventData::stripDigis().
{ // assert(layer>0 && layer <= 6); LogTrace("CSCCFEBData|CSCRawToDigi") << "nTimeSamples in CSCCFEBData::digis = " << nTimeSamples(); if (nTimeSamples()==0) { LogTrace("CSCCFEBData|CSCRawToDigi") << "nTimeSamples is zero - CFEB data corrupt?"; return; } result.reserve(16); std::vector<int> sca(nTimeSamples()); std::vector<uint16_t> overflow(nTimeSamples()); std::vector<uint16_t> overlap(nTimeSamples()); std::vector<uint16_t> errorfl(nTimeSamples()); bool me1a = (CSCDetId::station(idlayer)==1) && (CSCDetId::ring(idlayer)==4); bool zplus = (CSCDetId::endcap(idlayer) == 1); bool me1b = (CSCDetId::station(idlayer)==1) && (CSCDetId::ring(idlayer)==1); unsigned layer = CSCDetId::layer(idlayer); std::vector<uint16_t> l1a_phase(nTimeSamples()); for(unsigned itime = 0; itime < nTimeSamples(); ++itime) { l1a_phase[itime] = controllerData(layer, 13, itime); // will be zero if timeslice bad LogTrace("CSCCFEBData|CSCRawToDigi") << CSCDetId(idlayer) << " time sample " << itime+1 << " l1a_phase = " << controllerData(layer, 13, itime); LogTrace("CSCCFEBData|CSCRawToDigi") << CSCDetId(idlayer) << " time sample " << itime+1 << " lct_phase = " << controllerData(layer, 14, itime); LogTrace("CSCCFEBData|CSCRawToDigi") << CSCDetId(idlayer) << " time sample " << itime+1 << " # samples = " << controllerData(layer, 16, itime); }; for(unsigned ichannel = 1; ichannel <= 16; ++ichannel) { // What is the point of testing here? Move it outside this loop // if (nTimeSamples()==0) // { // LogTrace("CSCCFEBData|CSCRawToDigi") << "nTimeSamples is zero - CFEB data corrupt?"; // break; // } for(unsigned itime = 0; itime < nTimeSamples(); ++itime) { const CSCCFEBTimeSlice * slice = timeSlice(itime); if (slice) { CSCCFEBDataWord * word; word = slice->timeSample(layer, ichannel); if (word) { sca[itime] = word->adcCounts; overflow[itime] = word->adcOverflow; overlap[itime] = word->overlappedSampleFlag; errorfl[itime] = word->errorstat; // Stick the l1a_phase bit into 'overlap' too (so we can store it in CSCStripDigi // without changing CSCStripDigi format). // Put it in the 9th bit of the overlap word which is only 1-bit anyway. overlap[itime] = (( l1a_phase[itime] & 0x1 ) << 8 ) | ( word->overlappedSampleFlag & 0x1 ); } } } if (sca.empty()) { LogTrace("CSCCFEBData|CSCRawToDigi") << "ADC counts empty - CFEB data corrupt?"; break; } int strip = ichannel + 16*boardNumber_; if ( me1a ) strip = strip%64; // reset 65-80 to 1-16 digi if ( me1a && zplus ) { strip = 17-strip; } // 1-16 -> 16-1 if ( me1b && !zplus) { strip = 65 - strip;} // 1-64 -> 64-1 ... result.push_back(CSCStripDigi(strip, sca, overflow, overlap, errorfl)); } }
std::vector< CSCStripDigi > CSCCFEBData::digis | ( | unsigned | idlayer | ) |
Definition at line 279 of file CSCCFEBData.cc.
References digis(), and query::result.
unsigned CSCCFEBData::errorstat | ( | unsigned | layer, |
unsigned | channel, | ||
unsigned | timeBin | ||
) | const |
Definition at line 155 of file CSCCFEBData.cc.
References CSCCFEBDataWord::errorstat, query::result, CSCCFEBTimeSlice::timeSample(), and timeSlice().
{ unsigned result = 0; const CSCCFEBTimeSlice * slice = timeSlice(timeBin); // zero is returned for bad slices if(slice) result = slice->timeSample(layer, channel)->errorstat; return result; }
unsigned CSCCFEBData::nTimeSamples | ( | ) | const [inline] |
Definition at line 21 of file CSCCFEBData.h.
References theNumberOfSamples.
Referenced by digis(), operator<<(), and statusDigi().
{ return theNumberOfSamples;}
unsigned CSCCFEBData::overlappedSampleFlag | ( | unsigned | layer, |
unsigned | channel, | ||
unsigned | timeBin | ||
) | const |
Definition at line 147 of file CSCCFEBData.cc.
References CSCCFEBDataWord::overlappedSampleFlag, query::result, CSCCFEBTimeSlice::timeSample(), and timeSlice().
{ unsigned result = 0; const CSCCFEBTimeSlice * slice = timeSlice(timeBin); // zero is returned for bad slices if(slice) result = slice->timeSample(layer, channel)->overlappedSampleFlag; return result; }
static void CSCCFEBData::selfTest | ( | ) | [static] |
void CSCCFEBData::setBoardNumber | ( | int | cfeb | ) | [inline] |
unsigned CSCCFEBData::sizeInWords | ( | ) | const [inline] |
CSCCFEBStatusDigi CSCCFEBData::statusDigi | ( | ) | const |
returns one status digi per cfeb
returns one status digi per cfeb contains bWord if slice is bad also contains crc word and controller word
here layer=1 bec this word repeats 6 times for each layer
Definition at line 165 of file CSCCFEBData.cc.
References boardNumber_, bWords, CSCCFEBDataWord::controllerData, CSCCFEBTimeSlice::get_crc(), i, LogTrace, nTimeSamples(), query::result, CSCCFEBTimeSlice::timeSample(), and timeSlice().
{ std::vector<uint16_t> crcWords(nTimeSamples()); std::vector<uint16_t> contrWords(nTimeSamples()); if (nTimeSamples()==0) { LogTrace("CSCCFEBData|CSCRawToDigi") << "nTimeSamples is zero - CFEB data corrupt?"; } else { for(unsigned itime = 0; itime < nTimeSamples(); ++itime) { const CSCCFEBTimeSlice * slice = timeSlice(itime); // zero is returned for bad slices if (slice) crcWords[itime] = slice->get_crc(); if (slice) { int layer=1; for(unsigned i = 0; i < 16; ++i) { contrWords[itime] |= slice->timeSample(i*6+layer-1)->controllerData << i; } } } } CSCCFEBStatusDigi result(boardNumber_+1, crcWords, contrWords, bWords); return result; }
std::vector< std::vector< CSCStripDigi > > CSCCFEBData::stripDigis | ( | ) |
deprecated. Use the above method.
Definition at line 320 of file CSCCFEBData.cc.
References digis(), and query::result.
const CSCCFEBTimeSlice * CSCCFEBData::timeSlice | ( | unsigned | i | ) | const |
count from 0. User should check if it's a bad slice
Definition at line 96 of file CSCCFEBData.cc.
References i, query::result, theData, theNumberOfSamples, and theSliceStarts.
Referenced by adcCounts(), adcOverflow(), add(), check(), controllerData(), digis(), errorstat(), overlappedSampleFlag(), and statusDigi().
{ const CSCCFEBTimeSlice * result; assert(i < theNumberOfSamples); std::pair<int,bool> start = theSliceStarts[i]; // give a NULL pointer if this is a bad slice if(!start.second) { result = 0; } else { result = reinterpret_cast<const CSCCFEBTimeSlice *>(theData+start.first); } return result; }
std::ostream& operator<< | ( | std::ostream & | os, |
const CSCCFEBData & | data | ||
) | [friend] |
Definition at line 301 of file CSCCFEBData.cc.
{ os << "printing CFEB data sample by sample " << std::endl; for(unsigned ilayer = 1; ilayer <= 6; ++ilayer) { for(unsigned channel = 1; channel <= 16; ++channel) { unsigned strip = channel + data.boardNumber_*16; os << "Strip " << strip << " "; for(unsigned timeBin = 0; timeBin < data.nTimeSamples(); ++timeBin) { os << data.adcCounts(ilayer, channel, timeBin) << " " ; } os << std::endl; } } return os; }
unsigned CSCCFEBData::boardNumber_ [private] |
Definition at line 64 of file CSCCFEBData.h.
Referenced by boardNumber(), digis(), operator<<(), setBoardNumber(), and statusDigi().
std::vector<uint16_t> CSCCFEBData::bWords [private] |
Definition at line 66 of file CSCCFEBData.h.
Referenced by CSCCFEBData(), and statusDigi().
unsigned short CSCCFEBData::theData[1600] [private] |
Definition at line 58 of file CSCCFEBData.h.
Referenced by CSCCFEBData(), data(), and timeSlice().
unsigned CSCCFEBData::theNumberOfSamples [private] |
Definition at line 65 of file CSCCFEBData.h.
Referenced by add(), check(), CSCCFEBData(), nTimeSamples(), and timeSlice().
int CSCCFEBData::theSize [private] |
in words
Definition at line 63 of file CSCCFEBData.h.
Referenced by CSCCFEBData(), and sizeInWords().
std::vector<std::pair<int,bool> > CSCCFEBData::theSliceStarts [private] |
Shows where in theData the words start. A bad slice will be tagged with a false
Definition at line 61 of file CSCCFEBData.h.
Referenced by CSCCFEBData(), and timeSlice().