Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:14:44

0001 #include <cstring>  // memcpy, bzero
0002 #include "EventFilter/CSCTFRawToDigi/src/CSCSPRecord.h"
0003 #include "EventFilter/CSCTFRawToDigi/src/CSCSPHeader.h"
0004 
0005 bool CSCSPRecord::unpack(const unsigned short*& buf,
0006                          unsigned int nonmasked_data_blocks,
0007                          bool empty_blocks_suppressed,
0008                          unsigned int tbin) throw() {
0009   memcpy((void*)this, buf, 8 * sizeof(short));
0010   buf += 8;
0011 
0012   bool unpackError = check();
0013 
0014   bzero(me, 15 * sizeof(CSCSP_MEblock));
0015   bzero(mb, 2 * sizeof(CSCSP_MBblock));
0016   bzero(me, 3 * sizeof(CSCSP_SPblock));
0017 
0018   bzero(meFilled, sizeof(meFilled));
0019   bzero(mbFilled, sizeof(mbFilled));
0020   bzero(spFilled, sizeof(spFilled));
0021 
0022   const CSCSPHeader::ACTIVE id[] = {CSCSPHeader::F1,
0023                                     CSCSPHeader::F1,
0024                                     CSCSPHeader::F1,
0025                                     CSCSPHeader::F2,
0026                                     CSCSPHeader::F2,
0027                                     CSCSPHeader::F2,
0028                                     CSCSPHeader::F3,
0029                                     CSCSPHeader::F3,
0030                                     CSCSPHeader::F3,
0031                                     CSCSPHeader::F4,
0032                                     CSCSPHeader::F4,
0033                                     CSCSPHeader::F4,
0034                                     CSCSPHeader::F5,
0035                                     CSCSPHeader::F5,
0036                                     CSCSPHeader::F5};
0037 
0038   // 15 ME data blocks
0039   for (unsigned int block = 0; block < 15; block++)
0040     if (nonmasked_data_blocks & id[block] && (!empty_blocks_suppressed || vp_bits & (1 << block))) {
0041       unsigned int mpc = block / 3, link = block % 3;
0042       unpackError |= me[mpc][link].unpack(buf);
0043       me[mpc][link].tbin_ = tbin;
0044       me[mpc][link].valid_pattern = vp_bits & (1 << block);
0045       me[mpc][link].sync_error = se_bits & (1 << block);
0046       me[mpc][link].sync_modified = sm_bits & (1 << block);
0047       me[mpc][link].alignment_fifo = af_bits & (1 << block);
0048       me[mpc][link].bxBit = bx_bits & (1 << block);
0049       me[mpc][link].spInput_ = block + 1;
0050       meFilled[mpc][link] = true;
0051     }
0052   // 2 MB data blocks
0053   for (unsigned int block = 0; block < 2; block++)
0054     if (nonmasked_data_blocks & CSCSPHeader::DT && (!empty_blocks_suppressed || (block ? vq_b : vq_a))) {
0055       unpackError |= mb[block].unpack(buf);
0056       mb[block].tbin_ = tbin;
0057       mb[block].valid_quality = (block ? vq_b : vq_a);
0058       mb[block].alignment_fifo = (block ? af_barrel_2 : af_barrel_1);
0059       mb[block].bxBit = (block ? bx_barrel_2 : bx_barrel_1);
0060       mb[block].id_ = block + 1;
0061       mbFilled[block] = true;
0062     }
0063 
0064   // 3 SP data blocks
0065   for (unsigned int block = 0; block < 3; block++)
0066     if (nonmasked_data_blocks & CSCSPHeader::SP &&
0067         (!empty_blocks_suppressed || (block == 0 ? mode1 : (block == 1 ? mode2 : mode3)))) {
0068       unpackError |= sp[block].unpack(buf);
0069       sp[block].tbin_ = tbin;
0070       sp[block].mode_ = (block == 0 ? mode1 : (block == 1 ? mode2 : mode3));
0071       sp[block].id_ = block + 1;
0072       spFilled[block] = true;
0073     }
0074 
0075   return unpackError;
0076 }
0077 
0078 std::vector<CSCSP_MEblock> CSCSPRecord::LCTs(void) const throw() {
0079   std::vector<CSCSP_MEblock> result;
0080   for (int mpc = 0; mpc < 5; mpc++)
0081     for (int link = 0; link < 3; link++)
0082       if (meFilled[mpc][link])
0083         result.push_back(me[mpc][link]);
0084   return result;
0085 }
0086 
0087 std::vector<CSCSP_MEblock> CSCSPRecord::LCTs(unsigned int mpc) const throw() {
0088   std::vector<CSCSP_MEblock> result;
0089   if (mpc < 5)
0090     for (int link = 0; link < 3; link++)
0091       if (meFilled[mpc][link])
0092         result.push_back(me[mpc][link]);
0093   return result;
0094 }
0095 
0096 std::vector<CSCSP_MEblock> CSCSPRecord::LCT(unsigned int mpc, unsigned int link) const throw() {
0097   std::vector<CSCSP_MEblock> result;
0098   if (mpc < 5 && link < 3)
0099     if (meFilled[mpc][link])
0100       result.push_back(me[mpc][link]);
0101   return result;
0102 }
0103 
0104 std::vector<CSCSP_SPblock> CSCSPRecord::tracks(void) const throw() {
0105   std::vector<CSCSP_SPblock> result;
0106   if (spFilled[0])
0107     result.push_back(sp[0]);
0108   if (spFilled[1])
0109     result.push_back(sp[1]);
0110   if (spFilled[2])
0111     result.push_back(sp[2]);
0112   return result;
0113 }
0114 
0115 std::vector<CSCSP_MBblock> CSCSPRecord::mbStubs(void) const throw() {
0116   std::vector<CSCSP_MBblock> result;
0117   if (mbFilled[0])
0118     result.push_back(mb[0]);
0119   if (mbFilled[1])
0120     result.push_back(mb[1]);
0121   return result;
0122 }