00001 #include "IOPool/Streamer/interface/EventMessage.h" 00002 #include "FWCore/Utilities/interface/Exception.h" 00003 00004 00005 EventMsgView::EventMsgView(void* buf): 00006 buf_((uint8*)buf),head_(buf), 00007 v2Detected_(false) 00008 { 00009 // 29-Jan-2008, KAB - adding an explicit version number. 00010 // We'll start with 5 to match the new version of the INIT message. 00011 // We support earlier versions of the full protocol, of course, but since 00012 // we didn't have an explicit version number in the Event Message before 00013 // now, we have to limit what we can handle to versions that have the 00014 // version number included (>= 5). 00015 00016 // 18-Jul-2008, wmtan - payload changed for version 7. 00017 // So we no longer support previous formats. 00018 if (protocolVersion() != 7) { 00019 throw cms::Exception("EventMsgView", "Invalid Message Version:") 00020 << "Only message version 7 is currently supported \n" 00021 << "(invalid value = " << protocolVersion() << ").\n" 00022 << "We support only reading and converting streamer files\n" 00023 << "using the same version of CMSSW used to created the\n" 00024 << "streamer file. This is because the streamer format is\n" 00025 << "only a temporary format, as such we do not support\n" 00026 << "backwards compatibility. If you really need a streamer\n" 00027 << "file for some reason, the work around is that you convert\n" 00028 << "the streamer file to a Root file using the CMSSW version\n" 00029 << "that created the streamer file, then convert the Root file\n" 00030 << "to a streamer file using a newer release that will produce\n" 00031 << "the version of streamer file that you desire.\n"; 00032 } 00033 00034 uint8* l1_bit_size_ptr = buf_ + sizeof(EventHeader); //Just after Header 00035 l1_bits_count_ = convert32(l1_bit_size_ptr); 00036 uint32 l1_sz = l1_bits_count_; 00037 //Lets detect if thats V2 message 00038 if (l1_bits_count_ == 11) { 00039 l1_sz = 1; 00040 v2Detected_=true; 00041 } 00042 00043 l1_bits_start_ = buf_ + sizeof(EventHeader) + sizeof(uint32); 00044 00045 if (v2Detected_ == false) { 00046 if (l1_sz != 0) l1_sz = 1 + ((l1_sz-1)/8); 00047 } 00048 uint8* hlt_bit_size_ptr = l1_bits_start_ + l1_sz; 00049 hlt_bits_count_ = convert32(hlt_bit_size_ptr); 00050 hlt_bits_start_ = hlt_bit_size_ptr + sizeof(uint32); 00051 uint32 hlt_sz = hlt_bits_count_; 00052 if (hlt_sz != 0) hlt_sz = 1+ ((hlt_sz-1)/4); 00053 00054 if(v2Detected_) hlt_sz=2; 00055 event_start_ = hlt_bits_start_ + hlt_sz; 00056 event_len_ = convert32(event_start_); 00057 event_start_ += sizeof(char_uint32); 00058 } 00059 00060 uint32 EventMsgView::protocolVersion() const 00061 { 00062 EventHeader* h = (EventHeader*)buf_; 00063 return h->protocolVersion_; 00064 } 00065 00066 uint32 EventMsgView::run() const 00067 { 00068 EventHeader* h = (EventHeader*)buf_; 00069 return convert32(h->run_); 00070 } 00071 00072 uint32 EventMsgView::event() const 00073 { 00074 EventHeader* h = (EventHeader*)buf_; 00075 return convert32(h->event_); 00076 } 00077 00078 uint32 EventMsgView::lumi() const 00079 { 00080 EventHeader* h = (EventHeader*)buf_; 00081 return convert32(h->lumi_); 00082 } 00083 00084 uint32 EventMsgView::origDataSize() const 00085 { 00086 EventHeader* h = (EventHeader*)buf_; 00087 return convert32(h->origDataSize_); 00088 } 00089 00090 uint32 EventMsgView::outModId() const 00091 { 00092 EventHeader* h = (EventHeader*)buf_; 00093 return convert32(h->outModId_); 00094 } 00095 00096 void EventMsgView::l1TriggerBits(std::vector<bool>& put_here) const 00097 { 00098 put_here.clear(); 00099 put_here.resize(l1_bits_count_); 00100 00101 for(std::vector<bool>::size_type i = 0; i < l1_bits_count_; ++i) 00102 put_here[i] = (bool)(l1_bits_start_[i/8] & (1<<((i&0x07)))); 00103 } 00104 00105 void EventMsgView::hltTriggerBits(uint8* put_here) const 00106 { 00107 uint32 hlt_sz = hlt_bits_count_; 00108 if (hlt_sz != 0) hlt_sz = 1 + ((hlt_sz-1)/4); 00109 00110 if(v2Detected_) hlt_sz=2; 00111 00112 std::copy(hlt_bits_start_,hlt_bits_start_ + hlt_sz, 00113 put_here); 00114 } 00115 00116