CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/EventFilter/DTRawToDigi/interface/DTDDUWords.h

Go to the documentation of this file.
00001 #ifndef DTRawToDigi_DTDDUWords_h
00002 #define DTRawToDigi_DTDDUWords_h
00003 
00010 #define WORDCONTROLMASK 0xE0000000
00011 #define WORDCONTROLSHIFT 29
00012 #define WORDTYPEMASK 0x1F000000
00013 #define WORDTYPESHIFT 24
00014 
00016 #define ERRORMASK 0x8000
00017 #define ERRORSHIFT 15
00018 
00019 #define DEBUG_TYPE_MASK 0xE00000
00020 #define DEBUG_TYPE_SHIFT 21
00021 #define DEBUG_MESSAGE_MASK 0x7FFF
00022 #define CEROS_ID_CEROS_STATUS_MASK 0x1F0000
00023 #define CEROS_ID_CEROS_STATUS_SHIFT 16
00024 #define EV_ID_CEROS_STATUS_MASK 0xFC0
00025 #define EV_ID_CEROS_STATUS_SHIFT 6
00026 #define DONTREAD_CEROS_STATUS_MASK 0x3F
00027 #define CEROS_ID_ROS_STATUS_MASK 0x3F
00028 
00029 
00030 #define TTC_EVENT_COUNTER_MASK 0xFFFFFF
00031 
00032 #define TFF_MASK 0x800000
00033 #define TFF_SHIFT 23
00034 #define TPX_MASK 0x400000
00035 #define TPX_SHIFT 22
00036 #define L1A_FIFO_OCC_MASK 0x3F0000
00037 #define L1A_FIFO_OCC_SHIFT 16
00038 #define EVENT_WORD_COUNT_MASK 0xFFFF
00039 
00040 #define ERROR_TYPE_MASK 0xE00000
00041 #define ERROR_TYPE_SHIFT 21
00042 #define ERROR_ROB_ID_MASK 0x1F0000
00043 #define ERROR_ROB_ID_SHIFT 16
00044 #define ERROR_CEROS_ID_MASK 0x3F
00045 
00046 #define ROB_ID_MASK 0x1F000000 
00047 #define EVENT_ID_MASK 0xFFF000
00048 #define EVENT_ID_SHIFT 12
00049 #define BUNCH_ID_MASK 0xFFF
00050 #define WORD_COUNT_MASK 0xFFF
00051 
00052 #define PC_MASK 0x8000000
00053 #define PC_SHIFT 27
00054 #define PAF_MASK 0x4000000
00055 #define PAF_SHIFT 26
00056 #define TDC_ID_MASK 0x3000000
00057 #define TDC_ID_SHIFT 24
00058 
00059 #define TDC_CHANNEL_MASK 0xF80000
00060 #define TDC_CHANNEL_SHIFT 19
00061 #define TDC_TIME_MASK 0x7FFFC // First two bits are excluded
00062 #define TDC_TIME_SHIFT 2
00063 
00064 #define TDC_ERROR_MASK 0x7FFF
00065 
00066 #define SCFO_MASK 0xFF
00067 
00068 #define TRIGGER_WORD_COUNT_MASK 0xFFFF
00069 
00070 #define TRIGGER_DATA_MASK 0xFFFF
00071 
00072 
00073 #define SC_LAT_SHIFT 8
00074 #define SC_LAT_MASK 0x7F
00075 
00076 #define SC_NW_MASK 0xFF
00077 
00078 #define SC_TRIGGERDLY_MASK 0x7
00079 #define SC_TRIGGERDLY_SHIFT 12
00080 #define SC_BXC_MASK 0xFFF
00081 
00082 
00083 
00084 #include <boost/cstdint.hpp>
00085 #include <iostream>
00086 
00087 
00088 
00096 class DTROSWordType {
00097 
00098 public:
00099   
00101   DTROSWordType(const uint32_t index) {
00102     word_ = index;
00103   }
00104   
00105   DTROSWordType(const DTROSWordType& obj) {
00106     *this = obj;
00107   }
00108 
00110   virtual ~DTROSWordType() {};
00111 
00113   enum wordTypes {
00114     ROSHeader = 1,
00115     ROSTrailer = 2,
00116     ROSError = 3,
00117     GroupHeader = 4,
00118     GroupTrailer = 5,
00119     TDCHeader = 6,
00120     TDCTrailer = 7,
00121     TDCMeasurement = 8,
00122     TDCError = 9,
00123     SCHeader = 10,
00124     SCTrailer = 11,
00125     SCData = 12,
00126     ROSDebug = 13,
00127     TDCDebug = 14,
00128     Control = 15
00129   };
00130 
00131 
00133   enum wordTypes type() {
00134     
00135     enum wordTypes wordType = Control;
00136     
00137     // ROS/ROB/SC Headers
00138     if ( ((word_ & WORDCONTROLMASK) >> WORDCONTROLSHIFT) == headerControlWord ) {
00139       if ( ((word_ & WORDTYPEMASK) >> WORDTYPESHIFT) == rosTypeWord ) wordType = ROSHeader;
00140       if ( ((word_ & WORDTYPEMASK) >> WORDTYPESHIFT) == scTypeWord ) wordType = SCHeader;
00141       if ( ((word_ & WORDTYPEMASK) >> WORDTYPESHIFT) < scTypeWord ) wordType = GroupHeader;
00142     }
00143 
00144     // ROS/ROB/SC Trailers
00145     if ( ((word_ & WORDCONTROLMASK) >> WORDCONTROLSHIFT) == trailerControlWord ) {
00146       if ( ((word_ & WORDTYPEMASK) >> WORDTYPESHIFT) == rosTypeWord ) wordType = ROSTrailer;
00147       if ( ((word_ & WORDTYPEMASK) >> WORDTYPESHIFT) == scTypeWord ) wordType = SCTrailer;
00148       if ( ((word_ & WORDTYPEMASK) >> WORDTYPESHIFT) < scTypeWord ) wordType = GroupTrailer;
00149     }
00150 
00151     // TDC Header
00152     if ( ((word_ & WORDCONTROLMASK) >> WORDCONTROLSHIFT) == tdcHeaderControlWord ) 
00153       wordType = TDCHeader;
00154 
00155     // TDC Trailer
00156     if ( ((word_ & WORDCONTROLMASK) >> WORDCONTROLSHIFT) == tdcTrailerControlWord ) 
00157       wordType = TDCTrailer;
00158 
00159     // TDC/SC Data
00160     if ( ((word_ & WORDCONTROLMASK) >> WORDCONTROLSHIFT) == tdcDataControlWord ) {
00161       if ( ((word_ & WORDTYPEMASK) >> WORDTYPESHIFT) == scTypeWord ) wordType = SCData;
00162       else wordType = TDCMeasurement;
00163     }
00164 
00165     // Errors
00166     if ( ((word_ & WORDCONTROLMASK) >> WORDCONTROLSHIFT) == errorControlWord ) {
00167       if ( ((word_ & WORDTYPEMASK) >> WORDTYPESHIFT) == rosTypeWord ) wordType = ROSError;
00168       if ( ((word_ & WORDTYPEMASK) >> WORDTYPESHIFT) < scTypeWord ) wordType = TDCError;
00169     }
00170 
00171     // ROS Debug
00172     if ( ((word_ & WORDCONTROLMASK) >> WORDCONTROLSHIFT) == debugControlWord ) {
00173       if ( ((word_ & WORDTYPEMASK) >> WORDTYPESHIFT) == rosTypeWord ) wordType = ROSDebug;
00174       if ( ((word_ & WORDTYPEMASK) >> WORDTYPESHIFT) < scTypeWord ) wordType = TDCDebug;
00175     }
00176 
00177 
00178     return wordType;
00179   }
00180 
00181 
00183   static const uint32_t headerControlWord = 0;
00184   static const uint32_t trailerControlWord = 1;
00185   static const uint32_t tdcHeaderControlWord = 2;
00186   static const uint32_t tdcTrailerControlWord = 3;
00187   static const uint32_t tdcDataControlWord = 4;
00188   static const uint32_t errorControlWord = 6;
00189   static const uint32_t debugControlWord = 7;
00190 
00192   static const uint32_t rosTypeWord = 31;
00193   static const uint32_t scTypeWord = 25;
00194 
00195 
00196 private:
00197 
00198    uint32_t word_;
00199   
00200 };
00201 
00202 
00203 
00212 class DTROSHeaderWord {
00213 
00214 public:
00215 
00217   DTROSHeaderWord() {}
00218 
00219   DTROSHeaderWord(const DTROSHeaderWord& obj) { *this = obj; }
00220 
00221   DTROSHeaderWord(const uint32_t index) : 
00222     word_(index) {} 
00223 
00225   virtual ~DTROSHeaderWord() {}
00226 
00227   int TTCEventCounter() const { return  word_ & TTC_EVENT_COUNTER_MASK; }
00228 
00229   static void set(uint32_t &word,
00230                   int ttc_event_counter) {
00231     
00232     word = 
00233       DTROSWordType::headerControlWord << WORDCONTROLSHIFT |
00234       DTROSWordType::rosTypeWord << WORDTYPESHIFT |
00235       ttc_event_counter;
00236   }
00237 
00238 
00239 private:
00240 
00241   uint32_t word_;
00242 
00243 };
00244 
00245 
00258 class DTROSTrailerWord {
00259 
00260 public:
00261   
00263   DTROSTrailerWord() {}
00264 
00265   DTROSTrailerWord(const DTROSTrailerWord& obj) { *this = obj; }
00266 
00267   DTROSTrailerWord(const uint32_t index) : 
00268     word_(index) {} 
00269 
00271   virtual ~DTROSTrailerWord() {}
00272 
00273   int TFF() const { return (word_ & TFF_MASK) >> TFF_SHIFT; }
00274   int TPX() const { return (word_ & TPX_MASK) >> TPX_SHIFT; }
00275   int l1AFifoOccupancy() const { return (word_ & L1A_FIFO_OCC_MASK) >> L1A_FIFO_OCC_SHIFT; }
00276   int EventWordCount() const { return word_ & EVENT_WORD_COUNT_MASK; }
00277 
00278   static void set(uint32_t &word,
00279                   int tff,
00280                   int tpx,
00281                   int l1a_fifo_occ,
00282                   int event_word_count) {
00283     
00284     word = 
00285       DTROSWordType::trailerControlWord << WORDCONTROLSHIFT |
00286       DTROSWordType::rosTypeWord << WORDTYPESHIFT |
00287       tff << TFF_SHIFT |
00288       tpx << TPX_SHIFT |
00289       l1a_fifo_occ << L1A_FIFO_OCC_SHIFT |
00290       event_word_count;
00291   }
00292 
00293 
00294 private:
00295 
00296   uint32_t word_;
00297 
00298 };
00299 
00300 
00309 class DTROSErrorWord {
00310 
00311 public:
00312 
00314   DTROSErrorWord() {}
00315 
00316   DTROSErrorWord(const DTROSErrorWord& obj) { *this = obj; }
00317 
00318   DTROSErrorWord(const uint32_t index) : 
00319     word_(index) {}
00320 
00322   virtual ~DTROSErrorWord() {}
00323 
00324   int errorType() const { return (word_ & ERROR_TYPE_MASK) >> ERROR_TYPE_SHIFT;} 
00325   int robID() const { return (word_ & ERROR_ROB_ID_MASK) >> ERROR_ROB_ID_SHIFT;}
00326   int cerosID() const {return errorType()==4 ? (word_ & ERROR_CEROS_ID_MASK) : 0;}
00327 
00328   static void set(uint32_t &word,
00329                   int error_type,
00330                   int rob_id) {
00331     
00332     word = 
00333       DTROSWordType::errorControlWord << WORDCONTROLSHIFT |
00334       DTROSWordType::rosTypeWord << WORDTYPESHIFT |
00335       error_type << ERROR_TYPE_SHIFT |
00336       rob_id << ERROR_ROB_ID_SHIFT |
00337       1 << ERRORSHIFT;
00338   }
00339 
00340 private:
00341 
00342   uint32_t word_;
00343 
00344 };
00345 
00346 
00356 class DTROSDebugWord {
00357 
00358 public:
00359 
00361   DTROSDebugWord() {}
00362 
00363   DTROSDebugWord(const DTROSDebugWord& obj) { *this = obj; }
00364 
00365   DTROSDebugWord(const uint32_t index) : 
00366     word_(index) {}
00367 
00369   virtual ~DTROSDebugWord() {}
00370 
00371   int debugType() const { return (word_ & DEBUG_TYPE_MASK) >> DEBUG_TYPE_SHIFT;} 
00372   int debugMessage() const { return (word_ & DEBUG_MESSAGE_MASK) ;} 
00373   int cerosIdCerosStatus() const { return debugType()==3 ? (word_ & CEROS_ID_CEROS_STATUS_MASK) >> CEROS_ID_CEROS_STATUS_SHIFT : 0;} 
00374   int evIdMis() const { return debugType()==3 ? (word_ & EV_ID_CEROS_STATUS_MASK) >> EV_ID_CEROS_STATUS_SHIFT : 0;} 
00375   int dontRead() const { return debugType()==3 ? (word_ & DONTREAD_CEROS_STATUS_MASK) : 0;} 
00376   int cerosIdRosStatus() const { return debugType()==4 ? (word_ & CEROS_ID_ROS_STATUS_MASK) : 0;} 
00377 
00378   static void set(uint32_t &word,                                 //CB FIXME do we need setters for DEBUG Types 3 and 4? 
00379                   int debug_type) {
00380     
00381     word = 
00382       DTROSWordType::debugControlWord << WORDCONTROLSHIFT |
00383       DTROSWordType::rosTypeWord << WORDTYPESHIFT |
00384       debug_type << DEBUG_TYPE_SHIFT |
00385       504 << 15; // TEMPORARY
00386   }
00387 
00388   static void set(uint32_t &word,                                 
00389                   int debug_type,
00390                   int ceros_id) {
00391     
00392     word = 
00393       DTROSWordType::debugControlWord << WORDCONTROLSHIFT |
00394       DTROSWordType::rosTypeWord << WORDTYPESHIFT |
00395       debug_type << DEBUG_TYPE_SHIFT |
00396       ceros_id << CEROS_ID_CEROS_STATUS_SHIFT |
00397       1 << 15;
00398   }
00399 
00400 private:
00401 
00402   uint32_t word_;
00403 
00404 };
00405 
00406 
00416 class DTROBHeaderWord {
00417 
00418 public:
00419 
00421   DTROBHeaderWord() {}
00422 
00423   DTROBHeaderWord(const DTROBHeaderWord& obj) { *this = obj; }
00424 
00425   DTROBHeaderWord(const uint32_t index) : 
00426     word_(index) {}
00427 
00429   virtual ~DTROBHeaderWord() {}
00430 
00431   int robID() const { return (word_ & ROB_ID_MASK) >> WORDTYPESHIFT;} 
00432   int eventID() const { return (word_ & EVENT_ID_MASK) >> EVENT_ID_SHIFT;} 
00433   int bunchID() const { return (word_ & BUNCH_ID_MASK);} 
00434 
00435 
00436   static void set(uint32_t &word,
00437                   int rob_id,
00438                   int event_id,
00439                   int bunch_id) {
00440     
00441     word = 
00442       DTROSWordType::headerControlWord << WORDCONTROLSHIFT |
00443       rob_id << WORDTYPESHIFT |
00444       event_id << EVENT_ID_SHIFT |
00445       bunch_id;
00446   }
00447   
00448 
00449 private:
00450 
00451   uint32_t word_;
00452 
00453 };
00454 
00455 
00465 class DTROBTrailerWord {
00466 
00467 public:
00468 
00470   DTROBTrailerWord() {}
00471 
00472   DTROBTrailerWord(const DTROBTrailerWord& obj) { *this = obj; }
00473 
00474   DTROBTrailerWord(const uint32_t index) : 
00475     word_(index) {}
00476 
00478   virtual ~DTROBTrailerWord() {}
00479 
00480   int robID() const { return (word_ & ROB_ID_MASK) >> WORDTYPESHIFT;} 
00481   int eventID() const { return (word_ & EVENT_ID_MASK) >> EVENT_ID_SHIFT;} 
00482   int wordCount() const { return (word_ & WORD_COUNT_MASK);} 
00483 
00484   static void set(uint32_t &word,
00485                   int rob_id,
00486                   int event_id,
00487                   int word_count) {
00488     
00489     word = 
00490       DTROSWordType::trailerControlWord << WORDCONTROLSHIFT |
00491       rob_id << WORDTYPESHIFT |
00492       event_id << EVENT_ID_SHIFT |
00493       word_count;
00494   }
00495   
00496 
00497 private:
00498 
00499   uint32_t word_;
00500 };
00501 
00502 
00503 
00504 
00514 class DTTDCHeaderWord {
00515 
00516 public:
00517 
00519   DTTDCHeaderWord() {}
00520 
00521   DTTDCHeaderWord(const DTTDCHeaderWord& obj) { *this = obj; }
00522 
00523   DTTDCHeaderWord(const uint32_t index) : 
00524     word_(index) {}
00525 
00527   virtual ~DTTDCHeaderWord() {}
00528 
00529   int PC() const { return (word_ & PC_MASK) >> PC_SHIFT;} 
00530   int PAF() const { return (word_ & PAF_MASK) >> PAF_SHIFT;} 
00531   int HU() const { return (word_ & PAF_MASK) >> PAF_SHIFT;} 
00532   int tdcID() const { return (word_ & TDC_ID_MASK) >> TDC_ID_SHIFT;} 
00533   int eventID() const { return (word_ & EVENT_ID_MASK) >> EVENT_ID_SHIFT;} 
00534   int bunchID() const { return (word_ & BUNCH_ID_MASK);} 
00535 
00536   static void set(uint32_t &word,
00537                   int pc,
00538                   int paf,
00539                   int hu,
00540                   int tdc_id,
00541                   int event_id,
00542                   int bunch_id) {
00543     
00544     word = 
00545       DTROSWordType::tdcHeaderControlWord << WORDCONTROLSHIFT |
00546       pc << PC_SHIFT |
00547       paf << PAF_SHIFT |
00548       hu << PAF_SHIFT |
00549       tdc_id << TDC_ID_SHIFT |
00550       event_id << EVENT_ID_SHIFT |
00551       bunch_id;
00552   }
00553 
00554 
00555 private:
00556 
00557   uint32_t word_;
00558 };
00559 
00560 
00570 class DTTDCTrailerWord {
00571 
00572 public:
00573 
00575   DTTDCTrailerWord() {}
00576 
00577   DTTDCTrailerWord(const DTTDCTrailerWord& obj) { *this = obj; }
00578 
00579   DTTDCTrailerWord(const uint32_t index) : 
00580     word_(index) {}
00581 
00583   virtual ~DTTDCTrailerWord() {}
00584 
00585   int PC() const { return (word_ & PC_MASK) >> PC_SHIFT;} 
00586   int PAF() const { return (word_ & PAF_MASK) >> PAF_SHIFT;} 
00587   int HU() const { return (word_ & PAF_MASK) >> PAF_SHIFT;} 
00588   int tdcID() const { return (word_ & TDC_ID_MASK) >> TDC_ID_SHIFT;} 
00589   int eventID() const { return (word_ & EVENT_ID_MASK) >> EVENT_ID_SHIFT;} 
00590   int wordCount() const { return (word_ & WORD_COUNT_MASK);} 
00591 
00592   static void set(uint32_t &word,
00593                   int pc,
00594                   int paf,
00595                   int hu,
00596                   int tdc_id,
00597                   int event_id,
00598                   int word_count) {
00599     
00600     word = 
00601       DTROSWordType::tdcTrailerControlWord << WORDCONTROLSHIFT |
00602       pc << PC_SHIFT |
00603       paf << PAF_SHIFT |
00604       hu << PAF_SHIFT |
00605       tdc_id << TDC_ID_SHIFT |
00606       event_id << EVENT_ID_SHIFT |
00607       word_count;
00608   }
00609 
00610 private:
00611 
00612   uint32_t word_;
00613 };
00614 
00615 
00625 class DTTDCMeasurementWord {
00626 
00627 public:
00628 
00630   DTTDCMeasurementWord() {}
00631   
00632   DTTDCMeasurementWord(const DTTDCMeasurementWord& obj) { *this = obj; }
00633 
00634   DTTDCMeasurementWord(const uint32_t index) : 
00635     word_(index) {}
00636 
00638   virtual ~DTTDCMeasurementWord() {}
00639 
00640   int PC() const { return (word_ & PC_MASK) >> PC_SHIFT;} 
00641   int PAF() const { return (word_ & PAF_MASK) >> PAF_SHIFT;} 
00642   int HU() const { return (word_ & PAF_MASK) >> PAF_SHIFT;} 
00643   int tdcID() const { return (word_ & TDC_ID_MASK) >> TDC_ID_SHIFT;} 
00644   int tdcChannel() const { return (word_ & TDC_CHANNEL_MASK) >> TDC_CHANNEL_SHIFT;} 
00645   int tdcTime() const { return (word_ & TDC_TIME_MASK) >> TDC_TIME_SHIFT;} 
00646 
00647 
00648   static void set(uint32_t &word,
00649                   int pc,
00650                   int paf,
00651                   int hu,
00652                   int tdc_id,
00653                   int tdc_channel,
00654                   int tdc_time) {
00655     
00656     word = 
00657       DTROSWordType::tdcDataControlWord << WORDCONTROLSHIFT |
00658       pc << PC_SHIFT |
00659       paf << PAF_SHIFT |
00660       hu << PAF_SHIFT |
00661       tdc_id << TDC_ID_SHIFT |
00662       tdc_channel << TDC_CHANNEL_SHIFT |
00663       tdc_time;
00664   }
00665 
00666 
00667 
00668 private:
00669 
00670   uint32_t word_;
00671 };
00672 
00673 
00683 class DTTDCErrorWord {
00684 
00685 public:
00686 
00688   DTTDCErrorWord() {}
00689   
00690   DTTDCErrorWord(const DTTDCErrorWord& obj) { *this = obj; }
00691 
00692   DTTDCErrorWord(const uint32_t index) : 
00693     word_(index) {}
00694 
00696   virtual ~DTTDCErrorWord() {}
00697 
00698   int PC() const { return (word_ & PC_MASK) >> PC_SHIFT;} 
00699   int PAF() const { return (word_ & PAF_MASK) >> PAF_SHIFT;} 
00700   int HU() const { return (word_ & PAF_MASK) >> PAF_SHIFT;} 
00701   int tdcID() const { return (word_ & TDC_ID_MASK) >> TDC_ID_SHIFT;} 
00702   int tdcError() const { return (word_ & TDC_ERROR_MASK);} 
00703 
00704   static void set(uint32_t &word,
00705                   int pc,
00706                   int paf,
00707                   int hu,
00708                   int tdc_id,
00709                   int tdc_error) {
00710     
00711     word = 
00712       DTROSWordType::errorControlWord << WORDCONTROLSHIFT |
00713       pc << PC_SHIFT |
00714       paf << PAF_SHIFT |
00715       hu << PAF_SHIFT |
00716       tdc_id << TDC_ID_SHIFT |
00717       0 << ERRORSHIFT |
00718       tdc_error;
00719   }
00720 
00721 private:
00722 
00723   uint32_t word_;
00724 };
00725 
00726 
00735 class DTLocalTriggerHeaderWord {
00736 
00737 public:
00738 
00740   DTLocalTriggerHeaderWord() {}
00741   
00742   DTLocalTriggerHeaderWord(const DTLocalTriggerHeaderWord& obj) { *this = obj; }
00743 
00744   DTLocalTriggerHeaderWord(const uint32_t index) : 
00745     word_(index) {}
00746 
00748   virtual ~DTLocalTriggerHeaderWord() {}
00749 
00750   int eventID() const { return (word_ & EVENT_ID_MASK) >> EVENT_ID_SHIFT;}
00751   int SCFO() const { return (word_ & SCFO_MASK);}
00752 
00753   
00754   static void set(uint32_t &word,
00755                   int event_id,
00756                   int scfo) {
00757     
00758     word = 
00759       DTROSWordType::headerControlWord << WORDCONTROLSHIFT |
00760       DTROSWordType::scTypeWord << WORDTYPESHIFT |
00761       event_id << EVENT_ID_SHIFT |
00762       scfo; 
00763   }
00764 
00765 private:
00766 
00767   uint32_t word_;
00768 };
00769 
00770 
00779 class DTLocalTriggerTrailerWord {
00780 
00781 public:
00782 
00784   DTLocalTriggerTrailerWord() {}
00785   
00786   DTLocalTriggerTrailerWord(const DTLocalTriggerTrailerWord& obj) { *this = obj; }
00787 
00788   DTLocalTriggerTrailerWord(const uint32_t index) : 
00789     word_(index) {}
00790 
00792   virtual ~DTLocalTriggerTrailerWord() {}
00793 
00794   int wordCount() const { return (word_ & TRIGGER_WORD_COUNT_MASK);}
00795 
00796   static void set(uint32_t &word,
00797                   int word_count) {
00798     
00799     word = 
00800       DTROSWordType::trailerControlWord << WORDCONTROLSHIFT |
00801       DTROSWordType::scTypeWord << WORDTYPESHIFT |
00802       word_count; 
00803   }
00804 
00805 
00806 private:
00807 
00808   uint32_t word_;
00809 };
00810 
00811 
00820 class DTLocalTriggerDataWord {
00821 
00822 public:
00823 
00825   DTLocalTriggerDataWord() {}
00826   
00827   DTLocalTriggerDataWord(const DTLocalTriggerDataWord& obj) { *this = obj; }
00828  
00829   DTLocalTriggerDataWord(const uint32_t index) : 
00830     word_(index) {}
00831 
00833   virtual ~DTLocalTriggerDataWord() {}
00834 
00835   int SCData() const { return (word_ & TRIGGER_DATA_MASK);}
00836 
00837   int getBits(int first) const { 
00838     return first==1 ? ((word_ & TRIGGER_DATA_MASK) >> 8) : ((word_ & TRIGGER_DATA_MASK)&0xFF);  
00839   }
00840 
00841   //int hasTrigger(int first) const { return (getBits(first) & 0x40) >> 6; }
00842   int hasTrigger(int first) const { return (trackQuality(first) != 7? 1 : 0);}
00843   int trackQuality(int first) const { return (getBits(first) & 0xE) >> 1; }
00844  
00845 
00846   static void set(uint32_t &word,
00847                   int sc_data) {
00848     
00849     word = 
00850       DTROSWordType::tdcDataControlWord << WORDCONTROLSHIFT |
00851       DTROSWordType::scTypeWord << WORDTYPESHIFT |
00852       sc_data; 
00853   }
00854 
00855 
00856 private:
00857 
00858   uint32_t word_;
00859 };
00860 
00861 
00870 class DTDDUFirstStatusWord {
00871 
00872 public:
00873 
00875   DTDDUFirstStatusWord() {}
00876 
00877   DTDDUFirstStatusWord(const DTDDUFirstStatusWord& obj) { *this = obj; }
00878 
00879   DTDDUFirstStatusWord(const unsigned char index) : 
00880     word_(index) {}
00881 
00883   virtual ~DTDDUFirstStatusWord() {}
00884 
00885   int channelEnabled() const { return (word_ & 0x1);}
00886   int timeout() const { return (word_ & 0x2) >> 1;}
00887   int eventTrailerLost() const { return (word_ & 0x4) >> 2;}
00888   int opticalFiberSignalLost() const { return (word_ & 0x8) >> 3;}
00889   int tlkPropagationError() const { return (word_ & 0x10) >> 4;}
00890   int tlkPatternError() const { return (word_ & 0x20) >> 5;}
00891   int tlkSignalLost() const { return (word_ & 0x40) >> 6;}
00892   int errorFromROS() const { return (word_ & 0x80) >> 7;}
00893 
00894 
00895 private:
00896 
00897   unsigned char word_;
00898 };
00899 
00900 
00910 class DTDDUSecondStatusWord {
00911   
00912 public:
00913   
00915   DTDDUSecondStatusWord() {}
00916 
00917   DTDDUSecondStatusWord(const DTDDUSecondStatusWord& obj) { *this = obj; }
00918 
00919   DTDDUSecondStatusWord(const uint32_t index) : 
00920     word_(index) {}
00921   
00923   virtual ~DTDDUSecondStatusWord() {}
00924   
00925   int l1AIDError() const { return (word_ & 0x1); }
00926   int bxIDError() const { return (word_ & 0x2) >> 1; }
00927   int fifoFull() const { return (word_ & 0x1C ) >> 2; }
00928   int inputFifoFull() const { return (word_ & 0xE0) >> 5; }
00929   int fifoAlmostFull() const { return (word_ & 0x700) >> 8; }
00930   int inputFifoAlmostFull() const { return (word_ & 0x3800) >> 11; }
00931   int outputFifoFull() const { return (word_ & 0x4000) >> 14; }
00932   int outputFifoAlmostFull() const { return (word_ & 0x8000) >> 15; }
00933   int rosList() const {return (word_ & 0xFFF0000) >> 16; }
00934   int warningROSPAF() const {return (word_ & 0x10000000) >> 28; }
00935   int busyROSPAF() const {return (word_ & 0x20000000) >> 29; }
00936   int outOfSynchROSError() const {return (word_ & 0x40000000) >> 30; }
00937   
00938 
00939 //   int fifoAlmostEmpty() const { return (word_ & 0x1C000) >> 14; }
00940 //   int inputFifoAlmostEmpty() const { return (word_ & 0xE0000) >> 17; }
00941 //   int outputFifoFull() const { return (word_ & 0x100000) >> 20; }
00942 //   int outputFifoAlmostFull() const { return (word_ & 0x200000) >> 21; }
00943 //   int outputFifoAlmostEmpty() const { return (word_ & 0x400000) >> 22; }
00944 
00945 private:
00946   
00947   uint32_t word_;
00948 };
00949 
00950 
00960 class DTLocalTriggerSectorCollectorHeaderWord {
00961 
00962 public:
00963 
00965   DTLocalTriggerSectorCollectorHeaderWord() {}
00966   
00967   DTLocalTriggerSectorCollectorHeaderWord(const DTLocalTriggerSectorCollectorHeaderWord& obj) { *this = obj; }
00968 
00969   DTLocalTriggerSectorCollectorHeaderWord(const uint32_t index) : 
00970     word_(index) {}
00971 
00973   virtual ~DTLocalTriggerSectorCollectorHeaderWord() {}
00974 
00975   int Latency() const { return ((word_  >> SC_LAT_SHIFT) &  SC_LAT_MASK);}
00976   int NumberOf16bitWords() const { return (word_ & SC_NW_MASK);}
00977 
00978   
00979   static void set(uint32_t &word,
00980                   int lat,
00981                   int nw) {
00982     
00983     word = 
00984       DTROSWordType::headerControlWord << WORDCONTROLSHIFT |
00985       DTROSWordType::scTypeWord << WORDTYPESHIFT |
00986       (lat & SC_LAT_MASK) << SC_LAT_SHIFT |
00987       (nw & SC_NW_MASK) ; 
00988   }
00989 
00990 private:
00991 
00992   uint32_t word_;
00993 };
00994 
00995 
01005 class DTLocalTriggerSectorCollectorSubHeaderWord {
01006 
01007 public:
01008 
01010   DTLocalTriggerSectorCollectorSubHeaderWord() {}
01011   
01012   DTLocalTriggerSectorCollectorSubHeaderWord(const DTLocalTriggerSectorCollectorSubHeaderWord& obj) { *this = obj; }
01013 
01014   DTLocalTriggerSectorCollectorSubHeaderWord(const uint32_t index) : 
01015     word_(index) {}
01016 
01018   virtual ~DTLocalTriggerSectorCollectorSubHeaderWord() {}
01019 
01020   int TriggerDelay() const { return ((word_  >>SC_TRIGGERDLY_SHIFT ) & SC_TRIGGERDLY_MASK);}
01021   int LocalBunchCounter() const { return (word_ & SC_BXC_MASK );}
01022 
01023   
01024   static void set(uint32_t &word,
01025                   int trigdly,
01026                   int bxcount) {
01027     
01028     word = 
01029       DTROSWordType::headerControlWord << WORDCONTROLSHIFT |
01030       DTROSWordType::scTypeWord << WORDTYPESHIFT |
01031       (trigdly &  SC_TRIGGERDLY_MASK) << SC_TRIGGERDLY_SHIFT |
01032       (bxcount & SC_BXC_MASK) ; 
01033   }
01034 
01035 private:
01036 
01037   uint32_t word_;
01038 };
01039 
01040 
01041 #endif