Go to the documentation of this file.00001
00002 #include "DataFormats/LTCDigi/interface/LTCDigi.h"
00003
00004
00005 LTCDigi::LTCDigi(const unsigned char *data)
00006 {
00007
00008 uint64_t *ld = (uint64_t*)data;
00009
00010 trigType_ = (ld[0]>>56)& 0xFULL;
00011
00012 eventID_ = (ld[0]>>32)&0x00FFFFFFULL;
00013 runNumber_ = (ld[2]>>32)&0xFFFFFFFFULL;
00014 eventNumber_ = (ld[2]) &0xFFFFFFFFULL;
00015
00016 sourceID_ = (ld[0]>> 8)&0x00000FFFULL;
00017
00018
00019
00020 bunchNumber_ = (ld[0]>>20)& 0xFFFULL;
00021 orbitNumber_ = (ld[1]>>32)&0xFFFFFFFFULL;
00022
00023 versionNumber_ = (ld[1]>>24)&0xFFULL;
00024
00025 daqPartition_ = (ld[1] )&0xFULL;
00026
00027
00028 trigInputStat_ = (ld[3] )&0xFFFFFFFFULL;
00029
00030 trigInhibitNumber_ = (ld[3]>>32)&0xFFFFFFFFULL;
00031
00032 bstGpsTime_ = ld[4];
00033
00034 }
00035
00036 uint32_t LTCDigi::GetEventNumberFromBuffer(const unsigned char *data)
00037 {
00038
00039 uint64_t *ld = (uint64_t*)data;
00040 uint32_t eventNumber = (ld[2]) &0xFFFFFFFFULL;
00041 return eventNumber;
00042 }
00043
00044 uint32_t LTCDigi::GetRunNumberFromBuffer(const unsigned char *data)
00045 {
00046
00047 uint64_t *ld = (uint64_t*)data;
00048 uint32_t runNumber = (ld[2]>>32)&0xFFFFFFFFULL;
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
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(uint64_t t)
00100 {
00101
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(uint64_t t)
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