Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:00

0001 #ifndef DataFormats_LTCDigi_h
0002 #define DataFormats_LTCDigi_h
0003 
0004 #include <vector>
0005 #include <ostream>
0006 #include <string>
0007 
0008 #include "FWCore/Utilities/interface/typedefs.h"
0009 
0010 /** \class LTCDigi
0011  *  Data from the Local Trigger Controller (LTC)
0012  *
0013  */
0014 
0015 class LTCDigi {
0016 public:
0017   // need a default constructor!
0018   LTCDigi() {}
0019   LTCDigi(const unsigned char *data);
0020 
0021   // STATIC functions
0022   // These are to allow the event builder to grab the run number
0023   // from a butter it knows points at LTC data.
0024   static cms_uint32_t GetEventNumberFromBuffer(const unsigned char *databuffer);
0025   static cms_uint32_t GetRunNumberFromBuffer(const unsigned char *databuffer);
0026   static std::string utcTime(cms_uint64_t t);
0027   static std::string locTime(cms_uint64_t t);
0028 
0029   // right now these are just silly but maybe if we pack the internals
0030   // then this won't seem as silly
0031   unsigned int eventNumber() const { return eventNumber_; };
0032   unsigned int eventID() const { return eventID_; };
0033   unsigned int runNumber() const { return runNumber_; };
0034 
0035   unsigned int bunchNumber() const { return bunchNumber_; };
0036   cms_uint32_t orbitNumber() const { return orbitNumber_; };
0037 
0038   int version() const { return versionNumber_; };
0039   int sourceID() const { return sourceID_; };
0040 
0041   int daqPartition() const { return daqPartition_; };
0042 
0043   cms_uint32_t triggerInputStatus() const { return trigInputStat_; };
0044   cms_uint32_t triggerInhibitNumber() const { return trigInhibitNumber_; };
0045 
0046   cms_uint64_t bstGpsTime() const { return bstGpsTime_; };
0047 
0048   unsigned int bxMask() const { return ((triggerInputStatus() >> 28) & 0x1); };
0049   unsigned int vmeTrigger() const { return ((triggerInputStatus() >> 27) & 0x1); };
0050   unsigned int ramTrigger() const { return ((triggerInputStatus() >> 26) & 0x1); };
0051   unsigned char externTriggerMask() const  // six bits
0052   {
0053     return ((triggerInputStatus() >> 20) & 0x3FU);
0054   };
0055   unsigned char cyclicTriggerMask() const  // six bits
0056   {
0057     return (triggerInputStatus() & 0x3FU);
0058   };
0059 
0060   bool HasTriggered(int i) const {
0061     if (i > 5)
0062       return false;  // throw exception?
0063     return ((externTriggerMask() & (0x1U << i)) != 0);
0064   }
0065 
0066 private:
0067   // unpacked for now
0068   unsigned int trigType_;  // 4 bits
0069 
0070   unsigned int eventID_;    // 24 bits
0071   unsigned int runNumber_;  // 32 bits
0072 
0073   unsigned int sourceID_;  // 12 bits - 0xCBB constant for LTC
0074 
0075   unsigned int bunchNumber_;  // 12 bits
0076   cms_uint32_t orbitNumber_;  // 32 bits
0077 
0078   int versionNumber_;  // 8 bits - Slink data version number
0079 
0080   int daqPartition_;  // 4 bits
0081 
0082   cms_uint32_t eventNumber_;        // 32 bits
0083                                     // same as event number up to resets
0084   cms_uint32_t trigInputStat_;      // 32 bits
0085   cms_uint32_t trigInhibitNumber_;  // 32 bits
0086   cms_uint64_t bstGpsTime_;         // 64 bits - is standard unix time in seconds
0087 };
0088 
0089 std::ostream &operator<<(std::ostream &stream, const LTCDigi &myDigi);
0090 
0091 typedef std::vector<LTCDigi> LTCDigiCollection;
0092 
0093 #endif  // DataFormats_LTCDigi_h