Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef CSCSP_SPblock_h
0002 #define CSCSP_SPblock_h
0003 #include <vector>
0004 #include <cstring>
0005 #include "EventFilter/CSCTFRawToDigi/src/CSCSP_MEblock.h"
0006 #include "EventFilter/CSCTFRawToDigi/src/CSCSP_MBblock.h"
0007 
0008 class CSCSP_SPblock {
0009 private:
0010   /////// word 1 ///////
0011   unsigned phi_ : 5;        // azimuth coordinate
0012   unsigned sign_ : 1;       // deltaPhi sign bit, part of the PT LUT address
0013   unsigned front_rear : 1;  // front/rear bit
0014   unsigned charge_ : 1;     // muon charge bit
0015   unsigned eta_ : 5;        // pseudo rapidity, eta[4:1] is a part of the PT LUT address
0016   unsigned halo_ : 1;       // halo bit
0017   // synchronization error: OR of 15 SM bits for all LCTs and similar bits for 2 MB Stubs, passed to the MS
0018   unsigned se : 1;
0019   unsigned zero_1 : 1;  // format specific
0020   /////// word 2 ///////
0021   unsigned deltaPhi12_ : 8;  // difference in phi between station 1 and 2, part of the PT LUT address
0022   unsigned deltaPhi23_ : 4;  // difference in phi between station 2 and 3, part of the PT LUT address
0023   unsigned zero_2 : 1;       // format specific
0024   unsigned bxn0_ : 1;        // OR of BX0 signals received with ME LCTs and MB stubs, passed to the MS
0025   unsigned bc0_ : 1;         // OR of BC0 signals received with ME LCTs and MB stubs, passed to the MS
0026   unsigned zero_3 : 1;       // format specific
0027   /////// word 3 ///////
0028   unsigned me1_id : 3;  // track stubs used to build up the track
0029   unsigned me2_id : 2;  // ...
0030   unsigned me3_id : 2;  // ...
0031   unsigned me4_id : 2;  // ...
0032   unsigned mb_id : 3;   // ...
0033   unsigned ms_id : 3;   // Muon Sorter Winner bit positional code
0034   unsigned zero_4 : 1;  // format specific
0035   /////// word 4 ///////
0036   unsigned me1_tbin : 3;  // time bins of the above track stubs used to build up a track
0037   unsigned me2_tbin : 3;  // ...
0038   unsigned me3_tbin : 3;  // ...
0039   unsigned me4_tbin : 3;  // ...
0040   unsigned mb_tbin : 3;   //
0041   unsigned zero_5 : 1;    // format specific
0042 
0043   // LCTs and MB stub, that formed this track should be easily accessible through the track interface
0044   //  Hence we keep copies of the data here and let top-level unpacking set these data
0045   friend class CSCSPEvent;
0046   CSCSP_MEblock lct_[4];  // LCTs from four stations
0047   CSCSP_MBblock dt_;      // MB stub
0048   // LCTs and stub were used (=true) in this record
0049   bool lctFilled[4], dtFilled;
0050 
0051   // Other data members logically belong to SP Block record,
0052   //  but physically are located in Data Block Header, which implementation is:
0053   friend class CSCSPRecord;
0054   friend class CSCTFPacker;
0055   unsigned int tbin_;  // time bin, that this SP block belongs to
0056   unsigned int mode_;  // stations, that this track crossed (they gave LCTs to build it)
0057   unsigned int id_;    // track number (1, 2, or 3)
0058 
0059 public:
0060   bool check(void) const throw() { return zero_1 != 0 || zero_2 != 0 || zero_3 != 0 || zero_4 != 0 || zero_5 != 0; }
0061 
0062   unsigned int phi(void) const throw() { return phi_; }
0063   unsigned int sign(void) const throw() { return sign_; }
0064   unsigned int f_r(void) const throw() { return front_rear; };
0065   unsigned int charge(void) const throw() { return charge_; }
0066   unsigned int eta(void) const throw() { return eta_; }
0067   unsigned int halo(void) const throw() { return halo_; }
0068   unsigned int syncErr(void) const throw() { return se; }
0069 
0070   unsigned int deltaPhi12(void) const throw() { return deltaPhi12_; }
0071   unsigned int deltaPhi23(void) const throw() { return deltaPhi23_; }
0072   unsigned int bx0(void) const throw() { return bxn0_; }
0073   unsigned int bc0(void) const throw() { return bc0_; }
0074 
0075   unsigned int ME1_id(void) const throw() { return me1_id; }
0076   unsigned int ME2_id(void) const throw() { return me2_id; }
0077   unsigned int ME3_id(void) const throw() { return me3_id; }
0078   unsigned int ME4_id(void) const throw() { return me4_id; }
0079   unsigned int MB_id(void) const throw() { return mb_id; }
0080   unsigned int MS_id(void) const throw() { return ms_id; }
0081 
0082   unsigned int ME1_tbin(void) const throw() { return me1_tbin; }
0083   unsigned int ME2_tbin(void) const throw() { return me2_tbin; }
0084   unsigned int ME3_tbin(void) const throw() { return me3_tbin; }
0085   unsigned int ME4_tbin(void) const throw() { return me4_tbin; }
0086   unsigned int MB_tbin(void) const throw() { return mb_tbin; }
0087 
0088   unsigned int tbin(void) const throw() { return tbin_; }
0089   unsigned int id(void) const throw() { return id_; }
0090 
0091   // vector may have up to 4 elements (one per station)
0092   std::vector<CSCSP_MEblock> LCTs(void) const throw() {
0093     std::vector<CSCSP_MEblock> result;
0094     for (int station = 0; station < 4; station++)
0095       if (lctFilled[station])
0096         result.push_back(lct_[station]);
0097     return result;
0098   }
0099 
0100   // vector either empty or has one element
0101   std::vector<CSCSP_MBblock> dtStub(void) const throw() {
0102     std::vector<CSCSP_MBblock> result;
0103     if (dtFilled)
0104       result.push_back(dt_);
0105     return result;
0106   }
0107 
0108   unsigned int ptLUTaddress(void) const throw() {
0109     return (sign_ << 20) | (mode_ << 16) | ((eta_ & 0x1E) << 11) | (deltaPhi23_ << 8) | deltaPhi12_;
0110   }
0111   unsigned int mode(void) const throw() { return mode_; }
0112 
0113   bool unpack(const unsigned short *&buf) throw() {
0114     std::memcpy((void *)this, buf, 4 * sizeof(short));
0115     buf += 4;
0116     return check();
0117   }
0118 
0119   CSCSP_SPblock(void) {}
0120 };
0121 
0122 #endif