CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LTCDigi.cc
Go to the documentation of this file.
1 // $Id: LTCDigi.cc,v 1.4 2011/08/25 20:18:06 wmtan Exp $
3 
4 
5 LTCDigi::LTCDigi(const unsigned char *data)
6 {
7  // six 64 bit words
8  cms_uint64_t *ld = (cms_uint64_t*)data;
9 
10  trigType_ = (ld[0]>>56)& 0xFULL; // 4 bits
11 
12  eventID_ = (ld[0]>>32)&0x00FFFFFFULL; // 24 bits
13  runNumber_ = (ld[2]>>32)&0xFFFFFFFFULL; // 32 bits
14  eventNumber_ = (ld[2]) &0xFFFFFFFFULL; // 32 bits
15 
16  sourceID_ = (ld[0]>> 8)&0x00000FFFULL; // 12 bits
17  // this should always be 815?
18  //assert(sourceID_ == 815);
19 
20  bunchNumber_ = (ld[0]>>20)& 0xFFFULL; // 12 bits
21  orbitNumber_ = (ld[1]>>32)&0xFFFFFFFFULL; // 32 bits
22 
23  versionNumber_ = (ld[1]>>24)&0xFFULL; // 8 bits
24 
25  daqPartition_ = (ld[1] )&0xFULL; // 4 bits
26 
27 
28  trigInputStat_ = (ld[3] )&0xFFFFFFFFULL; // 32 bits
29 
30  trigInhibitNumber_ = (ld[3]>>32)&0xFFFFFFFFULL; // 32 bits
31 
32  bstGpsTime_ = ld[4]; // 64 bits
33 
34 }
35 //static
37 {
38  // six 64 bit words
39  cms_uint64_t *ld = (cms_uint64_t*)data;
40  cms_uint32_t eventNumber = (ld[2]) &0xFFFFFFFFULL; // 32 bits
41  return eventNumber;
42 }
43 //static
45 {
46  // six 64 bit words
47  cms_uint64_t *ld = (cms_uint64_t*)data;
48  cms_uint32_t runNumber = (ld[2]>>32)&0xFFFFFFFFULL; // 32 bits
49  return runNumber;
50 }
51 
52 
53 std::ostream &
54 operator<<(std::ostream & stream, const LTCDigi & myDigi)
55 {
56  stream << "----------------------------------------"<< std::endl;
57  stream << "Dumping LTC digi. " << std::endl;
58  stream << "Source ID: " << myDigi.sourceID() << std::endl;
59  stream << "Run, event: " << myDigi.runNumber()
60  << ", " << myDigi.eventNumber () << std::endl;
61  stream << "N_Inhibit:" << myDigi.triggerInhibitNumber() << std::endl;
62  stream << LTCDigi::utcTime(myDigi.bstGpsTime()) << std::endl;
63  stream << LTCDigi::locTime(myDigi.bstGpsTime()) << std::endl;
65  stream << "Partition: " << myDigi.daqPartition() << std::endl;
66  stream << "Bunch #: " << myDigi.bunchNumber() << std::endl;
67  stream << "Orbit #: " << myDigi.orbitNumber() << std::endl;
68 
69  // Trigger information
70  stream << "Trigger Bits(0-5):" ;
71  for (int i = 0; i < 6; ++i ) {
72  if ( myDigi.HasTriggered(i) )
73  stream << "1";
74  else
75  stream << "0";
76  stream << " ";
77  }
78  stream << std::endl;
79 
80  //
81  stream << "Ram trigger: " << myDigi.ramTrigger() << std::endl;
82  stream << "VME trigger: " << myDigi.vmeTrigger() << std::endl;
83 
84  stream << "++++++++++++++++++++++++++++++++++++++++"<< std::endl;
85 
86  stream << "Raw Data" << std::endl;
87  stream << "Trigger Input status: 0x"
88  << std::hex << myDigi.triggerInputStatus() << std::endl;
89  stream << "GPS time: 0x"
90  << std::hex << myDigi.bstGpsTime() << std::endl;
91 
92  stream << "----------------------------------------"<< std::endl;
93  stream << std::dec << std::endl;
94 
95  return stream;
96 }
97 
98 
99 std::string LTCDigi::utcTime(cms_uint64_t t) //const
100 {
101  // note that gmtime isn't reentrant and we don't own the data
102  time_t tsmall = t/1000000;
103  tm *utct = gmtime(&tsmall);
104  std::string tstr("UTC: ");
105  tstr += asctime(utct);
106  tstr.replace(tstr.find("\n"),tstr.size(), "");
107  return tstr;
108 }
109 
110 std::string LTCDigi::locTime(cms_uint64_t t) //const
111 {
112  time_t tsmall = t/1000000;
113  std::string a("LOC: ");
114  a+= std::string(ctime(&tsmall));
115  a.replace(a.find("\n"),a.size(), "");
116  return a;
117 }
118 
119 
120 
121 
int daqPartition_
Definition: LTCDigi.h:92
int i
Definition: DBlmapReader.cc:9
unsigned int ramTrigger() const
Definition: LTCDigi.h:56
cms_uint64_t bstGpsTime() const
Definition: LTCDigi.h:49
int sourceID() const
Definition: LTCDigi.h:42
unsigned int bunchNumber_
Definition: LTCDigi.h:87
cms_uint32_t eventNumber_
Definition: LTCDigi.h:94
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
unsigned int runNumber_
Definition: LTCDigi.h:83
unsigned int trigType_
Definition: LTCDigi.h:80
unsigned int vmeTrigger() const
Definition: LTCDigi.h:52
cms_uint64_t bstGpsTime_
Definition: LTCDigi.h:98
bool HasTriggered(int i) const
Definition: LTCDigi.h:71
unsigned int sourceID_
Definition: LTCDigi.h:85
unsigned int bunchNumber() const
Definition: LTCDigi.h:38
cms_uint32_t trigInputStat_
Definition: LTCDigi.h:96
cms_uint32_t triggerInputStatus() const
Definition: LTCDigi.h:46
unsigned int cms_uint32_t
Definition: typedefs.h:15
static cms_uint32_t GetRunNumberFromBuffer(const unsigned char *databuffer)
Definition: LTCDigi.cc:44
int daqPartition() const
Definition: LTCDigi.h:44
unsigned int eventID_
Definition: LTCDigi.h:82
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
cms_uint32_t trigInhibitNumber_
Definition: LTCDigi.h:97
double a
Definition: hdecay.h:121
cms_uint32_t orbitNumber() const
Definition: LTCDigi.h:39
int versionNumber_
Definition: LTCDigi.h:90
cms_uint32_t triggerInhibitNumber() const
Definition: LTCDigi.h:47
unsigned long long cms_uint64_t
Definition: typedefs.h:17
LTCDigi()
Definition: LTCDigi.h:21
unsigned int runNumber() const
Definition: LTCDigi.h:36
unsigned int eventNumber() const
Definition: LTCDigi.h:34
static cms_uint32_t GetEventNumberFromBuffer(const unsigned char *databuffer)
Definition: LTCDigi.cc:36
cms_uint32_t orbitNumber_
Definition: LTCDigi.h:88
static std::string locTime(cms_uint64_t t)
Definition: LTCDigi.cc:110
static std::string utcTime(cms_uint64_t t)
Definition: LTCDigi.cc:99