CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/EventFilter/EcalTBRawToDigi/src/DCCDataMapper.h

Go to the documentation of this file.
00001 // Date   : 30/05/2005
00002 // Author : N.Almeida (LIP)
00003 
00004 #ifndef DCCTBDATAMAPPER_HH
00005 #define DCCTBDATAMAPPER_HH
00006 
00007 
00008 #include <string>                //STL
00009 #include <set>
00010 
00011 #include "DCCDataParser.h"
00012 
00013 
00014 /*----------------------------------------------------------*/
00015 /* DCC DATA FIELD                                           */
00016 /* define data fields from the ECAL raw data format         */
00017 /* a data field has a name, a word position, a bit position */
00018 /* and a mask (number of bits)                              */
00019 /* Note: this class is defined inline                       */
00020 /*----------------------------------------------------------*/
00021 class DCCTBDataField{
00022 public : 
00026   DCCTBDataField(std::string name, uint32_t wordPosition, uint32_t bitPosition, uint32_t mask){
00027     name_=name; wordPosition_ = wordPosition; bitPosition_= bitPosition; mask_= mask;
00028   }
00029                 
00033   void setName(std::string namestr)        { name_.clear(); name_ = namestr; }
00034   std::string name()                       { return name_;                   }
00035   void setWordPosition(uint32_t wordpos) { wordPosition_ = wordpos;        }
00036   uint32_t wordPosition()                { return wordPosition_;           }
00037   void setBitPosition(uint32_t bitpos)   { bitPosition_ = bitpos;          }
00038   uint32_t bitPosition()                 { return bitPosition_;            }
00039   void setMask(uint32_t maskvalue)       { mask_=maskvalue;                }
00040   uint32_t mask()                        { return mask_;                   }
00041 
00045   ~DCCTBDataField() { };
00046                 
00047 protected :
00048   std::string name_;
00049   uint32_t wordPosition_;
00050   uint32_t bitPosition_;
00051   uint32_t mask_;
00052 };
00053 
00054 
00055 
00056 /*----------------------------------------------------------*/
00057 /* DCC DATA FIELD COMPARATOR                                */
00058 /* compares data fields positions                           */
00059 /*----------------------------------------------------------*/
00060 class DCCTBDataFieldComparator{ 
00061  
00062 public : 
00063 
00067   bool operator()(DCCTBDataField *d1, DCCTBDataField * d2){
00068     bool value(false);
00069     
00070     if (d1->wordPosition() < d2->wordPosition()){ 
00071       value=true;
00072     }
00073     else if(d1->wordPosition() == d2->wordPosition()){ 
00074       if(d1->bitPosition() > d2->bitPosition()) {
00075         value=true;
00076       } 
00077     }
00078     
00079     return value;  
00080   } 
00081 }; 
00082 
00083 
00084 
00085 /*----------------------------------------------------------*/
00086 /* DCC DATA MAPPER                                          */
00087 /* maps the data according to ECAL raw data format specs.   */
00088 /*----------------------------------------------------------*/
00089 class DCCTBDataMapper{
00090 public: 
00091   
00092   DCCTBDataMapper(DCCTBDataParser * myParser );
00093   ~DCCTBDataMapper();
00094 
00098   void buildDCCFields();
00099   void buildTCCFields();
00100   void buildSRPFields();
00101   void buildTowerFields();
00102   void buildXtalFields();
00103   void buildTrailerFields();
00104   
00108   std::set<DCCTBDataField *, DCCTBDataFieldComparator> *dccFields()        { return dccFields_;        }
00109   std::set<DCCTBDataField *, DCCTBDataFieldComparator> *emptyEventFields() { return emptyEventFields_; }
00110   std::set<DCCTBDataField *, DCCTBDataFieldComparator> *tcc68Fields()      { return tcc68Fields_;      }
00111   std::set<DCCTBDataField *, DCCTBDataFieldComparator> *tcc32Fields()      { return tcc32Fields_;      }
00112   std::set<DCCTBDataField *, DCCTBDataFieldComparator> *tcc16Fields()      { return tcc16Fields_;      }
00113   std::set<DCCTBDataField *, DCCTBDataFieldComparator> *srp68Fields()      { return srp68Fields_;      }
00114   std::set<DCCTBDataField *, DCCTBDataFieldComparator> *srp32Fields()      { return srp32Fields_;      }
00115   std::set<DCCTBDataField *, DCCTBDataFieldComparator> *srp16Fields()      { return srp16Fields_;      }
00116   std::set<DCCTBDataField *, DCCTBDataFieldComparator> *towerFields()      { return towerFields_;      }
00117   std::set<DCCTBDataField *, DCCTBDataFieldComparator> *xtalFields()       { return xtalFields_;       }
00118   std::set<DCCTBDataField *, DCCTBDataFieldComparator> *trailerFields()    { return trailerFields_;    }
00119   
00120 protected:
00121   DCCTBDataParser * parser_;
00122   std::set<DCCTBDataField *, DCCTBDataFieldComparator> * dccFields_;
00123   std::set<DCCTBDataField *, DCCTBDataFieldComparator> * emptyEventFields_;
00124   std::set<DCCTBDataField *, DCCTBDataFieldComparator> * tcc68Fields_;
00125   std::set<DCCTBDataField *, DCCTBDataFieldComparator> * tcc32Fields_;
00126   std::set<DCCTBDataField *, DCCTBDataFieldComparator> * tcc16Fields_;
00127   
00128   std::set<DCCTBDataField *, DCCTBDataFieldComparator> * srp68Fields_;
00129   std::set<DCCTBDataField *, DCCTBDataFieldComparator> * srp32Fields_;
00130   std::set<DCCTBDataField *, DCCTBDataFieldComparator> * srp16Fields_;
00131   
00132   std::set<DCCTBDataField *, DCCTBDataFieldComparator> * towerFields_;
00133   std::set<DCCTBDataField *, DCCTBDataFieldComparator> * xtalFields_;
00134   std::set<DCCTBDataField *, DCCTBDataFieldComparator> * trailerFields_;
00135   
00136 public: 
00137 
00138   //HEADER data fields (each 32 bits is separated by a space in the enum)
00139   enum DCCFIELDS{
00140     H_WPOSITION                = 0, H_BPOSITION              =  3,    H_MASK              = 0x1,
00141     FOV_WPOSITION              = 0, FOV_BPOSITION            =  4,    FOV_MASK            = 0xF,
00142     DCCID_WPOSITION            = 0, DCCID_BPOSITION          =  8,    DCCID_MASK          = 0xFFF,
00143     DCCBX_WPOSITION            = 0, DCCBX_BPOSITION          = 20,    DCCBX_MASK          = 0xFFF,
00144 
00145     DCCL1_WPOSITION            = 1, DCCL1_BPOSITION          =  0,    DCCL1_MASK          = 0xFFFFFF,
00146     TRIGGERTYPE_WPOSITION      = 1, TRIGGERTYPE_BPOSITION    = 24,    TRIGGERTYPE_MASK    = 0xF,
00147     BOE_WPOSITION              = 1, BOE_BPOSITION            = 28,    BOE_MASK            = 0xF,
00148     
00149     EVENTLENGTH_WPOSITION      = 2, EVENTLENGTH_BPOSITION     =  0,    EVENTLENGTH_MASK    = 0xFFFFFF,
00150     DCCERRORS_WPOSITION        = 2, DCCERRORS_BPOSITION       = 24,    DCCERRORS_MASK      = 0xFF,
00151     
00152     RNUMB_WPOSITION            = 3, RNUMB_BPOSITION           =  0,    RNUMB_MASK          = 0xFFFFFF,
00153     HD_WPOSITION               = 3, HD_BPOSITION              = 24,    HD_MASK             = 0xFF,
00154     
00155     RUNTYPE_WPOSITION          = 4, RUNTYPE_BPOSITION         =  0,    RUNTYPE_MASK        = 0xFFFFFFFF,
00156     
00157     DETAILEDTT_WPOSITION       = 5, DETAILEDTT_BPOSITION      =  0,    DETAILEDTT_MASK     = 0xFFFF,
00158     
00159     ORBITCOUNTER_WPOSITION     = 6, ORBITCOUNTER_BPOSITION   =  0,    ORBITCOUNTER_MASK    = 0xFFFFFFFF,
00160                         
00161     SR_WPOSITION               = 7, SR_BPOSITION             =  0,    SR_MASK             = 0x1,
00162     ZS_WPOSITION               = 7, ZS_BPOSITION             =  1,    ZS_MASK             = 0x1,
00163     TZS_WPOSITION              = 7, TZS_BPOSITION            =  2,    TZS_MASK            = 0x1,
00164     SR_CHSTATUS_WPOSITION      = 7, SR_CHSTATUS_BPOSITION    =  4,    SR_CHSTATUS_MASK    = 0xF, 
00165     TCC_CHSTATUS_WPOSITION     = 7, TCC_CHSTATUS_BPOSITION   =  8,    TCC_CHSTATUS_MASK   = 0xF, 
00166     
00167     FE_CHSTATUS_WPOSITION      = 8, CHSTATUS_BPOSITION       =  0,    FE_CHSTATUS_MASK    = 0xF 
00168   };
00169 
00170 
00171   //TCC block data fields
00172   enum TCCFIELDS{
00173     TCCID_WPOSITION           =  0, TCCID_BPOSITION          =  0,    TCCID_MASK          = 0xFF,
00174     TCCBX_WPOSITION           =  0, TCCBX_BPOSITION          = 16,    TCCBX_MASK          = 0xFFF,
00175     TCCE0_WPOSITION           =  0, TCCE0_BPOSITION          = 28,    TCCE0_MASK          = 0x1,
00176     
00177     TCCL1_WPOSITION           =  1, TCCL1_BPOSITION          =  0,    TCCL1_MASK          = 0xFFF,
00178     TCCE1_WPOSITION           =  1, TCCE1_BPOSITION          = 12,    TCCE1_MASK          = 0x1,
00179     NTT_WPOSITION             =  1, NTT_BPOSITION            = 16,    NTT_MASK            = 0x7F,
00180     TCCTSAMP_WPOSITION        =  1, TCCTSAMP_BPOSITION       = 23,    TCCTSAMP_MASK       = 0xF,
00181     TCCLE0_WPOSITION          =  1, TCCLE0_BPOSITION         = 27,    TCCLE0_MASK         = 0x1,
00182     TCCLE1_WPOSITION          =  1, TCCLE1_BPOSITION         = 28,    TCCLE1_MASK         = 0x1,
00183                         
00184     TPG_WPOSITION             =  2,  TPG_BPOSITION           =  0,    TPG_MASK            = 0x1FF,
00185     TTF_WPOSITION             =  2,  TTF_BPOSITION           =  9,    TTF_MASK            = 0x7
00186   };
00187                 
00188   //SR block data fields
00189   enum SRPFIELDS{
00190     SRPID_WPOSITION           =  0, SRPID_BPOSITION          =  0,    SRPID_MASK          = 0xFF,
00191     SRPBX_WPOSITION           =  0, SRPBX_BPOSITION          = 16,    SRPBX_MASK          = 0xFFF,
00192     SRPE0_WPOSITION           =  0, SRPE0_BPOSITION          = 28,    SRPE0_MASK          = 0x1,
00193                                 
00194     SRPL1_WPOSITION           =  1, SRPL1_BPOSITION          =  0,    SRPL1_MASK          = 0xFFF,
00195     SRPE1_WPOSITION           =  1, SRPE1_BPOSITION          = 12,    SRPE1_MASK          = 0x1,
00196     NSRF_WPOSITION            =  1, NSRF_BPOSITION           = 16,    NSRF_MASK           = 0x7F,
00197     SRPLE0_WPOSITION          =  1, SRPLE0_BPOSITION         = 27,    SRPLE0_MASK         = 0x1,
00198     SRPLE1_WPOSITION          =  1, SRPLE1_BPOSITION         = 28,    SRPLE1_MASK         = 0x1,
00199 
00200     SRF_WPOSITION             =  2, SRF_BPOSITION            =  0,    SRF_MASK            = 0x3, 
00201     SRPBOFFSET                = 16 
00202   };
00203         
00204   //TOWER block data fields
00205   enum TOWERFIELDS{
00206     TOWERID_WPOSITION          = 0, TOWERID_BPOSITION          =   0,   TOWERID_MASK          = 0x7F, //FEID remask?? --> the 8th bit is in use 
00207     XSAMP_WPOSITION            = 0, XSAMP_BPOSITION            =   8,   XSAMP_MASK            = 0x7F,
00208     TOWERBX_WPOSITION          = 0, TOWERBX_BPOSITION          =  16,   TOWERBX_MASK          = 0xFFF,
00209     TOWERE0_WPOSITION          = 0, TOWERE0_BPOSITION          =  28,   TOWERE0_MASK          = 0x1,
00210     
00211     TOWERL1_WPOSITION          = 1, TOWERL1_BPOSITION          =  0,    TOWERL1_MASK         = 0xFFF,
00212     TOWERE1_WPOSITION          = 1, TOWERE1_BPOSITION          = 12,    TOWERE1_MASK         = 0x1,
00213     TOWERLENGTH_WPOSITION      = 1, TOWERLENGTH_BPOSITION      = 16,   TOWERLENGTH_MASK      = 0x1FF                    
00214   };
00215                 
00216   //CRYSTAL data fields
00217   enum XTALFIELDS{
00218     STRIPID_WPOSITION        = 0, STRIPID_BPOSITION        =  0, STRIPID_MASK         = 0x7,
00219     XTALID_WPOSITION         = 0, XTALID_BPOSITION         =  4, XTALID_MASK          = 0x7,
00220     M_WPOSITION              = 0, M_BPOSITION              =  8, M_MASK               = 0x1,
00221     SMF_WPOSITION            = 0, SMF_BPOSITION            =  9, SMF_MASK             = 0x1,
00222     GMF_WPOSITION            = 0, GMF_BPOSITION            = 10, GMF_MASK             = 0x1,  
00223     XTAL_TZS_WPOSITION       = 0, XTAL_TZS_BPOSITION       = 16, XTAL_TZS_MASK        = 0x1,  
00224     XTAL_GDECISION_WPOSITION = 0, XTAL_GDECISION_BPOSITION = 17, XTAL_GDECISION_MASK  = 0x1,    
00225     ADC_WPOSITION            = 0, ADC_BPOSITION            =  0, ADC_MASK             = 0x3FFF,
00226     ADCBOFFSET               = 16 
00227   };
00228         
00229   //TRAILER data fields
00230   enum TRAILERFIELDS{
00231     T_WPOSITION                = 0, T_BPOSITION                =   3,    T_MASK               = 0x1,
00232     ESTAT_WPOSITION            = 0, ESTAT_BPOSITION            =   8,    ESTAT_MASK           = 0xF,
00233                         
00234     TTS_WPOSITION              = 0, TTS_BPOSITION              =   4,     TTS_MASK             = 0xF,
00235     
00236     CRC_WPOSITION              = 0, CRC_BPOSITION              =  16,    CRC_MASK             = 0xFFFF,
00237     TLENGTH_WPOSITION          = 1, TLENGTH_BPOSITION          =   0,    TLENGTH_MASK         = 0xFFFFFF,
00238     EOE_WPOSITION              = 1, EOE_BPOSITION              =  28,    EOE_MASK             = 0xF
00239   };
00240                                 
00241 };
00242 
00243 #endif