CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/DataFormats/LTCDigi/interface/LTCDigi.h

Go to the documentation of this file.
00001 #ifndef DataFormats_LTCDigi_h
00002 #define DataFormats_LTCDigi_h
00003 
00004 #include <vector>
00005 #include <ostream>
00006 #include <string>
00007 
00008 #include "FWCore/Utilities/interface/typedefs.h"
00009 
00017 class LTCDigi
00018 {
00019  public:
00020   // need a default constructor!
00021   LTCDigi() {}
00022   LTCDigi(const unsigned char* data);
00023   
00024   // STATIC functions
00025   // These are to allow the event builder to grab the run number 
00026   // from a butter it knows points at LTC data.
00027   static cms_uint32_t GetEventNumberFromBuffer(const unsigned char *databuffer);
00028   static cms_uint32_t  GetRunNumberFromBuffer(const unsigned char *databuffer);
00029   static std::string utcTime(cms_uint64_t t);
00030   static std::string locTime(cms_uint64_t t);
00031 
00032   // right now these are just silly but maybe if we pack the internals
00033   // then this won't seem as silly
00034   unsigned int eventNumber() const { return eventNumber_; };
00035   unsigned int eventID() const { return eventID_; };
00036   unsigned int runNumber() const   { return runNumber_;   };
00037 
00038   unsigned int bunchNumber() const { return bunchNumber_;};
00039   cms_uint32_t     orbitNumber() const { return orbitNumber_;};
00040 
00041   int version() const { return versionNumber_; } ;
00042   int sourceID() const { return sourceID_; };
00043 
00044   int daqPartition() const { return daqPartition_; };
00045 
00046   cms_uint32_t triggerInputStatus() const { return trigInputStat_; };
00047   cms_uint32_t triggerInhibitNumber() const { return trigInhibitNumber_; };
00048 
00049   cms_uint64_t bstGpsTime() const { return bstGpsTime_;};
00050 
00051   unsigned int bxMask() const { return ((triggerInputStatus()>>28)&0x1); } ;
00052   unsigned int vmeTrigger() const 
00053   { 
00054     return ((triggerInputStatus()>>27)&0x1); 
00055   } ;
00056   unsigned int ramTrigger() const 
00057   { 
00058     return ((triggerInputStatus()>>26)&0x1); 
00059   } ;
00060   unsigned char externTriggerMask() const // six bits
00061   { 
00062     return ((triggerInputStatus()>>20)&0x3FU); 
00063   } ;
00064   unsigned char cyclicTriggerMask() const // six bits
00065   { 
00066     return (triggerInputStatus()&0x3FU); 
00067   } ;
00068   
00069   
00070   
00071   bool HasTriggered( int i ) const {
00072     if ( i > 5 ) return false; // throw exception?
00073     return ((externTriggerMask()&(0x1U<<i))!=0);
00074   }
00075 
00076   
00077 
00078  private:
00079   // unpacked for now
00080   unsigned int trigType_; // 4 bits
00081 
00082   unsigned int eventID_; // 24 bits
00083   unsigned int runNumber_; // 32 bits
00084 
00085   unsigned int sourceID_;    // 12 bits - 0xCBB constant for LTC
00086 
00087   unsigned int bunchNumber_; // 12 bits
00088   cms_uint32_t     orbitNumber_; // 32 bits
00089 
00090   int          versionNumber_; // 8 bits - Slink data version number  
00091 
00092   int          daqPartition_;  // 4 bits
00093   
00094   cms_uint32_t     eventNumber_; // 32 bits
00095                                // same as event number up to resets
00096   cms_uint32_t     trigInputStat_; // 32 bits
00097   cms_uint32_t     trigInhibitNumber_; // 32 bits
00098   cms_uint64_t     bstGpsTime_; // 64 bits - is standard unix time in seconds
00099 
00100 
00101     
00102 };
00103 
00104 std::ostream & operator<<(std::ostream & stream, 
00105                           const LTCDigi & myDigi);
00106 
00107 typedef std::vector<LTCDigi> LTCDigiCollection;
00108 
00109 
00110 #endif  // DataFormats_LTCDigi_h