CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DataFormats/LTCDigi/src/LTCDigi.cc

Go to the documentation of this file.
00001 // $Id: LTCDigi.cc,v 1.4 2011/08/25 20:18:06 wmtan Exp $
00002 #include "DataFormats/LTCDigi/interface/LTCDigi.h"
00003 
00004 
00005 LTCDigi::LTCDigi(const unsigned char *data)
00006 {
00007   // six 64 bit words
00008   cms_uint64_t *ld = (cms_uint64_t*)data;
00009 
00010   trigType_   = (ld[0]>>56)&        0xFULL; // 4 bits
00011 
00012   eventID_     = (ld[0]>>32)&0x00FFFFFFULL; // 24 bits
00013   runNumber_   = (ld[2]>>32)&0xFFFFFFFFULL; // 32 bits
00014   eventNumber_ = (ld[2])    &0xFFFFFFFFULL; // 32 bits
00015   
00016   sourceID_      = (ld[0]>> 8)&0x00000FFFULL; // 12 bits
00017   // this should always be 815?
00018   //assert(sourceID_ == 815);
00019 
00020   bunchNumber_   = (ld[0]>>20)&     0xFFFULL; // 12 bits
00021   orbitNumber_   = (ld[1]>>32)&0xFFFFFFFFULL; // 32 bits
00022 
00023   versionNumber_ = (ld[1]>>24)&0xFFULL;       // 8 bits
00024   
00025   daqPartition_  = (ld[1]    )&0xFULL;        // 4 bits
00026 
00027 
00028   trigInputStat_ = (ld[3]    )&0xFFFFFFFFULL; // 32 bits
00029 
00030   trigInhibitNumber_ = (ld[3]>>32)&0xFFFFFFFFULL; // 32 bits
00031 
00032   bstGpsTime_    = ld[4]; // 64 bits
00033 
00034 }
00035 //static
00036 cms_uint32_t LTCDigi::GetEventNumberFromBuffer(const unsigned char *data) 
00037 {
00038   // six 64 bit words
00039   cms_uint64_t *ld = (cms_uint64_t*)data;
00040   cms_uint32_t eventNumber = (ld[2])    &0xFFFFFFFFULL; // 32 bits
00041   return eventNumber;
00042 }
00043 //static
00044 cms_uint32_t LTCDigi::GetRunNumberFromBuffer(const unsigned char *data) 
00045 {
00046   // six 64 bit words
00047   cms_uint64_t *ld = (cms_uint64_t*)data;
00048   cms_uint32_t runNumber   = (ld[2]>>32)&0xFFFFFFFFULL; // 32 bits
00049   return runNumber;
00050 }
00051 
00052 
00053 std::ostream & 
00054 operator<<(std::ostream & stream, const LTCDigi & myDigi)
00055 {
00056    stream << "----------------------------------------"<< std::endl;
00057    stream << "Dumping LTC digi. " << std::endl;
00058    stream << "Source ID: " << myDigi.sourceID() << std::endl;
00059    stream << "Run, event: " << myDigi.runNumber()
00060           << ", " << myDigi.eventNumber () << std::endl;
00061    stream << "N_Inhibit:" << myDigi.triggerInhibitNumber() << std::endl;
00062    stream << LTCDigi::utcTime(myDigi.bstGpsTime()) << std::endl;
00063    stream << LTCDigi::locTime(myDigi.bstGpsTime()) << std::endl;
00065    stream << "Partition: " << myDigi.daqPartition() << std::endl;
00066    stream << "Bunch #:   " << myDigi.bunchNumber()  << std::endl;
00067    stream << "Orbit #:   " << myDigi.orbitNumber()  << std::endl;
00068 
00069    // Trigger information
00070    stream << "Trigger Bits(0-5):" ;
00071    for (int i = 0; i < 6; ++i ) {
00072       if ( myDigi.HasTriggered(i) )
00073          stream << "1";
00074       else 
00075          stream << "0";
00076       stream << " ";
00077    }
00078    stream << std::endl;
00079 
00080    //
00081    stream << "Ram trigger: " << myDigi.ramTrigger() << std::endl;
00082    stream << "VME trigger: " << myDigi.vmeTrigger() << std::endl;
00083 
00084    stream << "++++++++++++++++++++++++++++++++++++++++"<< std::endl;
00085    
00086    stream << "Raw Data" << std::endl;
00087    stream << "Trigger Input status: 0x" 
00088           << std::hex << myDigi.triggerInputStatus() << std::endl;
00089    stream << "GPS time:             0x"
00090           << std::hex << myDigi.bstGpsTime() << std::endl;
00091 
00092    stream << "----------------------------------------"<< std::endl;
00093    stream << std::dec << std::endl;
00094 
00095    return stream;
00096 }
00097 
00098 
00099 std::string LTCDigi::utcTime(cms_uint64_t t) //const
00100 {
00101   // note that gmtime isn't reentrant and we don't own the data
00102   time_t tsmall = t/1000000;
00103   tm *utct = gmtime(&tsmall);
00104   std::string tstr("UTC: ");
00105   tstr += asctime(utct);
00106   tstr.replace(tstr.find("\n"),tstr.size(), "");
00107   return tstr;
00108 }
00109 
00110 std::string LTCDigi::locTime(cms_uint64_t t) //const
00111 {
00112   time_t tsmall = t/1000000;
00113   std::string a("LOC: ");
00114   a+= std::string(ctime(&tsmall));
00115   a.replace(a.find("\n"),a.size(), "");
00116   return a;
00117 }
00118 
00119 
00120 
00121