CMS 3D CMS Logo

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