CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EventMessage.cc
Go to the documentation of this file.
3 
4 EventMsgView::EventMsgView(void* buf) : buf_((uint8*)buf), head_(buf), v2Detected_(false) {
5  // 29-Jan-2008, KAB - adding an explicit version number.
6  // We'll start with 5 to match the new version of the INIT message.
7  // We support earlier versions of the full protocol, of course, but since
8  // we didn't have an explicit version number in the Event Message before
9  // now, we have to limit what we can handle to versions that have the
10  // version number included (>= 5).
11 
12  // 18-Jul-2008, wmtan - payload changed for version 7.
13  // So we no longer support previous formats.
14  if (protocolVersion() != 11) {
15  throw cms::Exception("EventMsgView", "Invalid Message Version:")
16  << "Only message version 10 is currently supported \n"
17  << "(invalid value = " << protocolVersion() << ").\n"
18  << "We support only reading and converting streamer files\n"
19  << "using the same version of CMSSW used to created the\n"
20  << "streamer file. This is because the streamer format is\n"
21  << "only a temporary format, as such we do not support\n"
22  << "backwards compatibility. If you really need a streamer\n"
23  << "file for some reason, the work around is that you convert\n"
24  << "the streamer file to a Root file using the CMSSW version\n"
25  << "that created the streamer file, then convert the Root file\n"
26  << "to a streamer file using a newer release that will produce\n"
27  << "the version of streamer file that you desire.\n";
28  }
29 
30  uint8* l1_bit_size_ptr = buf_ + sizeof(EventHeader); //Just after Header
31  l1_bits_count_ = convert32(l1_bit_size_ptr);
32  uint32 l1_sz = l1_bits_count_;
33  // No point! Not supporting older versions and causes problems in unit
34  // tests that uses l1_bits_count_ == 11, and could cause problems later if using 11
35  //Lets detect if thats V2 message
36  //if (l1_bits_count_ == 11) {
37  // l1_sz = 1;
38  // v2Detected_=true;
39  //}
40 
41  l1_bits_start_ = buf_ + sizeof(EventHeader) + sizeof(uint32);
42 
43  if (v2Detected_ == false) {
44  if (l1_sz != 0)
45  l1_sz = 1 + ((l1_sz - 1) / 8);
46  }
47  uint8* hlt_bit_size_ptr = l1_bits_start_ + l1_sz;
48  hlt_bits_count_ = convert32(hlt_bit_size_ptr);
49  hlt_bits_start_ = hlt_bit_size_ptr + sizeof(uint32);
50  uint32 hlt_sz = hlt_bits_count_;
51  if (hlt_sz != 0)
52  hlt_sz = 1 + ((hlt_sz - 1) / 4);
53 
54  if (v2Detected_)
55  hlt_sz = 2;
56  uint8* adler32_start = hlt_bits_start_ + hlt_sz;
57  adler32_chksum_ = convert32(adler32_start);
58  host_name_start_ = adler32_start + sizeof(uint32);
60  host_name_start_ += sizeof(uint8);
63  event_start_ += sizeof(char_uint32);
64 }
65 
68  return h->protocolVersion_;
69 }
70 
73  return convert32(h->run_);
74 }
75 
78  return convert64(h->event_);
79 }
80 
83  return convert32(h->lumi_);
84 }
85 
88  return convert32(h->origDataSize_);
89 }
90 
93  return convert32(h->outModId_);
94 }
95 
98  return convert32(h->droppedEventsCount_);
99  return 0;
100 }
101 
102 void EventMsgView::l1TriggerBits(std::vector<bool>& put_here) const {
103  put_here.clear();
104  put_here.resize(l1_bits_count_);
105 
107  put_here[i] = (bool)(l1_bits_start_[i / 8] & (1 << ((i & 0x07))));
108 }
109 
110 void EventMsgView::hltTriggerBits(uint8* put_here) const {
111  uint32 hlt_sz = hlt_bits_count_;
112  if (hlt_sz != 0)
113  hlt_sz = 1 + ((hlt_sz - 1) / 4);
114 
115  if (v2Detected_)
116  hlt_sz = 2;
117 
118  std::copy(hlt_bits_start_, hlt_bits_start_ + hlt_sz, put_here);
119 }
120 
122  //return std::string(reinterpret_cast<char *>(host_name_start_),host_name_len_);
123  std::string host_name(reinterpret_cast<char*>(host_name_start_), host_name_len_);
124  size_t found = host_name.find('\0');
125  if (found != std::string::npos) {
126  return std::string(host_name, 0, found);
127  } else {
128  return host_name;
129  }
130 }
uint32 lumi() const
Definition: EventMessage.cc:81
uint64 convert64(char_uint64 v)
Definition: MsgTools.h:20
uint8 * l1_bits_start_
Definition: EventMessage.h:106
void hltTriggerBits(uint8 *put_here) const
std::string hostName() const
char_uint32 lumi_
Definition: EventMessage.h:66
char_uint32 origDataSize_
Definition: EventMessage.h:67
uint32 outModId() const
Definition: EventMessage.cc:91
uint16_t size_type
EventMsgView(void *buf)
Definition: EventMessage.cc:4
uint32 run() const
Definition: EventMessage.cc:71
uint8 * event_start_
Definition: EventMessage.h:108
uint32 hlt_bits_count_
Definition: EventMessage.h:105
uint32 l1_bits_count_
Definition: EventMessage.h:107
uint8 protocolVersion_
Definition: EventMessage.h:63
char_uint32 droppedEventsCount_
Definition: EventMessage.h:69
uint8 * host_name_start_
Definition: EventMessage.h:111
unsigned int uint32
Definition: MsgTools.h:13
unsigned char char_uint32[sizeof(uint32)]
Definition: MsgTools.h:16
char_uint32 run_
Definition: EventMessage.h:64
uint32 adler32_chksum_
Definition: EventMessage.h:110
char_uint64 event_
Definition: EventMessage.h:65
unsigned long long uint64
Definition: MsgTools.h:14
uint8 * hlt_bits_start_
Definition: EventMessage.h:104
uint32 droppedEventsCount() const
Definition: EventMessage.cc:96
uint32 origDataSize() const
Definition: EventMessage.cc:86
char_uint32 outModId_
Definition: EventMessage.h:68
uint32 convert32(char_uint32 v)
Definition: MsgTools.h:28
unsigned char uint8
Definition: MsgTools.h:11
uint32 host_name_len_
Definition: EventMessage.h:112
uint8 * buf_
Definition: EventMessage.h:101
uint32 event_len_
Definition: EventMessage.h:109
uint64 event() const
Definition: EventMessage.cc:76
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void l1TriggerBits(std::vector< bool > &put_here) const
uint32 protocolVersion() const
Definition: EventMessage.cc:66