19 : theDMBHeader(format_version),
20 theALCTHeader(nullptr),
21 theAnodeData(nullptr),
22 theALCTTrailer(nullptr),
24 theDMBTrailer(format_version),
25 theChamberType(chamberType),
26 alctZSErecovered(nullptr),
28 theFormatVersion(format_version) {
42 const uint16_t* pos =
buf;
44 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"The event data ";
45 for (
int i = 0;
i < 16; ++
i) {
46 LogTrace(
"CSCEventData|CSCRawToDigi") << std::hex << pos[
i] <<
" ";
52 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"Bad DMB Header??? "
53 <<
" first four words: ";
54 for (
int i = 0;
i < 4; ++
i) {
55 LogTrace(
"CSCEventData|CSCRawToDigi") << std::hex << pos[
i] <<
" ";
60 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"nalct = " <<
nalct();
61 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"nclct = " <<
nclct();
76 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"+++WARNING: Corrupt ALCT data - won't attempt to decode";
103 int sizeInWord_ZSE = 0;
112 int nWG_round_up = int(nWGs_per_layer / 12) + (nWGs_per_layer % 3 ? 1 : 0);
114 const uint16_t* posZSE = pos;
115 std::vector<unsigned short> alctZSErecoveredVector;
116 alctZSErecoveredVector.clear();
140 int alctZSErecoveredPos = 0;
141 while (*posZSE != 0xDE0D) {
142 if ((*posZSE == 0x1000) && (*posZSE != 0x3000)) {
143 for (
int j = 0;
j < nWG_round_up;
j++) {
144 alctZSErecoveredVector.push_back(0x0000);
146 alctZSErecoveredPos += nWG_round_up;
148 alctZSErecoveredVector.push_back(*posZSE);
149 ++alctZSErecoveredPos;
158 for (
int l = 0;
l < (int)alctZSErecoveredVector.size();
l++) {
180 pos += sizeInWord_ZSE;
191 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"Error:nalct reported but no ALCT data found!!!";
201 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"Error:nclct reported but no TMB data found!!!";
206 bool dmbTrailerReached =
false;
207 for (
int i = 0;
i < 12000; ++
i)
209 dmbTrailerReached = (*(
i + pos) & 0xF000) == 0xF000 && (*(
i + pos + 1) & 0xF000) == 0xF000 &&
210 (*(
i + pos + 2) & 0xF000) == 0xF000 && (*(
i + pos + 3) & 0xF000) == 0xF000 &&
211 (*(
i + pos + 4) & 0xF000) == 0xE000 && (*(
i + pos + 5) & 0xF000) == 0xE000 &&
212 (*(
i + pos + 6) & 0xF000) == 0xE000 && (*(
i + pos + 7) & 0xF000) == 0xE000;
213 if (dmbTrailerReached) {
219 if (dmbTrailerReached) {
225 if (cfeb_available == 1) {
226 if ((cfebTimeout >> icfeb) & 1) {
228 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"CFEB Timed out! ";
234 bool isDCFEB =
false;
246 LogTrace(
"CSCEventData|CSCRawToDigi") <<
"Critical Error: DMB Trailer was not found!!! ";
253 return (((buf[0] & 0xFFFF) == 0xDB0A) || (((buf[0] & 0xF800) == 0x6000) && ((buf[1] & 0xF800) == 0)));
324 std::vector<CSCStripDigi>
result;
326 std::vector<CSCStripDigi> newDigis =
stripDigis(idlayer, icfeb);
327 result.insert(result.end(), newDigis.begin(), newDigis.end());
333 std::vector<CSCStripDigi>
result;
336 result.insert(result.end(), newDigis.begin(), newDigis.end());
344 return std::vector<CSCWireDigi>();
351 std::vector<std::vector<CSCStripDigi> >
result;
354 result.push_back(digis);
360 std::vector<std::vector<CSCWireDigi> >
result;
468 unsigned cfeb = digi.
getCFEB();
469 bool sixteenSamples =
false;
471 sixteenSamples =
true;
473 bool isDCFEB =
false;
517 for (
auto it : digis) {
525 for (
auto it : digis) {
533 for (
auto it : digis) {
548 int gem_layer = gemdetid.
layer();
549 int eta_roll = gemdetid.
roll();
550 for (
const auto& it : clusters) {
558 std::vector<CSCStripDigi> stripDigis = evt.
stripDigis(ilayer);
561 std::vector<CSCWireDigi> wireDigis = evt.
wireDigis(ilayer);
568 boost::dynamic_bitset<>
result =
572 std::vector<std::pair<unsigned int, unsigned short*> > crcvec;
580 boost::dynamic_bitset<> anodeData =
613 for (
unsigned int n = 0;
n < vec.size();
n++) {
614 for (uint16_t
j = 0,
w = 0;
j < vec[
n].first;
j++) {
615 if (vec[
n].
second !=
nullptr) {
616 w = vec[
n].second[
j] & 0xffff;
617 for (uint32_t
i = 15,
t = 0, ncrc = 0;
i < 16;
i--) {
618 t = ((
w >>
i) & 1) ^ ((CRC >> 21) & 1);
619 ncrc = (CRC << 1) & 0x3ffffc;
620 ncrc |= (
t ^ (CRC & 1)) << 1;
634 std::vector<CSCCLCTDigi> clctDigis;
637 clctDigis.push_back(
CSCCLCTDigi(1, 1, 4, 1, 0, 30, 3, 2, 1));
638 clctDigis.push_back(
CSCCLCTDigi(1, 1, 2, 1, 1, 31, 1, 2, 2));
642 std::vector<CSCCorrelatedLCTDigi> corrDigis;
643 corrDigis.push_back(
CSCCorrelatedLCTDigi(1, 1, 2, 10, 98, 5, 0, 1, 0, 0, 0, 0));
644 corrDigis.push_back(
CSCCorrelatedLCTDigi(2, 1, 2, 20, 15, 9, 1, 0, 0, 0, 0, 0));
646 chamberData.
add(clctDigis);
647 chamberData.
add(corrDigis);
651 chamberData.
add(wireDigi, 3);
652 chamberData.
add(comparatorDigi, 3);
670 std::vector<int> sca(16, 600);
671 std::vector<unsigned short> overflow(16, 0),
overlap(16, 0), errorfl(16, 0);
678 forward.
add(me1a, me1adet1.
layer());
679 forward.
add(me1b, me1bdet1.
layer());
680 backward.
add(me1a, me1adet2.
layer());
681 backward.
add(me1b, me1adet2.
layer());
682 std::vector<CSCStripDigi> me1afs = forward.
stripDigis(me1adet1);
683 std::vector<CSCStripDigi> me1bfs = forward.
stripDigis(me1bdet1);
684 std::vector<CSCStripDigi> me1abs = backward.
stripDigis(me1adet2);
685 std::vector<CSCStripDigi> me1bbs = backward.
stripDigis(me1bdet2);
688 assert(me1afs.size() == 16);
689 assert(me1bfs.size() == 16);
690 assert(me1abs.size() == 16);
691 assert(me1bbs.size() == 16);
693 assert(me1afs[4].getStrip() == 5);
694 assert(me1bfs[7].getStrip() == 8);
695 assert(me1abs[4].getStrip() == 5);
696 assert(me1bbs[7].getStrip() == 8);
void unpack_data(const uint16_t *buf)
CSCComparatorData * comparatorData() const
user must check if nclct > 0
void setEventInformation(int bxnum, int lvl1num)
unsigned short int sizeInWords() const
the amount of the input binary buffer read, in 16-bit words
unsigned int calcALCTcrc(std::vector< std::pair< unsigned int, unsigned short * > > &vec)
unsigned short * alctZSErecovered
Auxiliary bufer to recove the ALCT raw payload from zero suppression.
int nclct() const
the number of CLCTs
uint16_t theFormatVersion
Output Format Version (2005, 2013)
void addEtaPadCluster(const GEMPadDigiCluster &digi, int gem_chamber, int eta_roll)
Add and pack GEMPadDigiCluster digis.
std::vector< std::vector< CSCStripDigi > > stripDigis() const
deprecated. Use the above methods instead
void checkALCTClasses()
makes new ALCT classes, if needed
int getCFEB() const
Get the CFEB number. Counts from 0.
std::vector< std::vector< CSCWireDigi > > wireDigis() const
deprecated. Use the above method instead.
CSCCFEBData * theCFEBData[CSCConstants::MAX_CFEBS_RUN2]
for up to MAX_CFEB CFEB boards
boost::dynamic_bitset pack()
not const because it sets size int TMBTrailer
std::vector< int > const & getADCCounts() const
Get ADC readings.
unsigned cfeb_endtimeout() const
const CSCDMBTrailer * dmbTrailer() const
DMB trailer.
constexpr int roll() const
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
const unsigned short size() const
void checkTMBClasses()
makes new TMB classes, if needed
void add(const CSCStripDigi &, int layer)
void setL1A(unsigned l1a)
constexpr uint32_t rawId() const
get the raw id
unsigned sizeInWords() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
CSCAnodeData * alctData() const
user must check if nalct > 0
std::vector< CSCWireDigi > wireDigis(unsigned ilayer) const
CSCALCTHeader * alctHeader() const
user must check if nalct > 0
int nalct() const
the flag for existence of ALCT data
void addAnodeShower(const std::vector< CSCShowerDigi > &)
Add/pack anode CSCShower object (from OTMB header)
constexpr std::array< uint8_t, layerIndexSize > layer
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
static int sizeInWords()
in 16-bit frames
void addAnodeALCTShower(const std::vector< CSCShowerDigi > &)
Add/pack anode CSCShower objects (from ALCT board data)
bool isALCT(const uint16_t *buf)
if dealing with ALCT data
U second(std::pair< T, U > const &p)
CSCDMBHeader theDMBHeader
void digis(uint32_t idlayer, std::vector< CSCStripDigi > &result) const
faster way to get to digis
CSCALCTTrailer * alctTrailer() const
user must check if nalct > 0
void addShower(const std::vector< CSCShowerDigi > &)
Run3 CSC Shower HMT objects.
CSCALCTHeader * theALCTHeader
unsigned cfeb_starttimeout() const
std::vector< CSCStripDigi > stripDigis(const CSCDetId &idlayer) const
returns all the strip digis in the chamber, with the comparator information.
CSCTMBData * tmbData() const
user must check in nclct > 0
void add(const CSCWireDigi &wireDigi, int layer)
CSCDMBTrailer theDMBTrailer
CSCEventData operator=(const CSCEventData &data)
CSCALCTTrailer * theALCTTrailer
int getWireGroup() const
default
CSCComparatorData * comparatorData()
void copy(const CSCEventData &)
constexpr int layer() const
int getWireGroupBX() const
return BX assigned for the wire group (16 upper bits from the wire group number)
void add(const CSCComparatorDigi &digi, int layer)
TODO for packing. Doesn't do flipping yet.
std::vector< CSCWireDigi > wireDigis(int layer) const
input layer is from 1 to 6
bool isTMB(const uint16_t *buf)
if dealing with TMB data
unsigned sizeInWords() const
unsigned short size() const
size of the data buffer used, in bytes
bool cscPackerCompare(const T &t1, const T &t2)
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
CSCTMBHeader * tmbHeader()
CSCTMBHeader * tmbHeader() const
user must check if nclct > 0
const CSCCFEBData * cfebData(unsigned icfeb) const
unpacked in long mode: has overflow and error bits decoded
char data[epos_bytes_allocation]
static std::atomic< bool > debug
boost::dynamic_bitset ushortToBitset(const unsigned int numberOfBits, unsigned short *buf)
this method takes numberOfBits bits from unsigned short * array and returns them in the bitset obj...
boost::dynamic_bitset pack()
returns the packed event data.
void addCathodeShower(const std::vector< CSCShowerDigi > &)
Add/pack cathode CSCShower object (from OTMB header)
void setCRC(unsigned int crc)
CSCAnodeData * theAnodeData