File indexing completed on 2021-02-14 14:21:21
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include <iostream>
0018 #include "IOPool/Streamer/interface/MsgTools.h"
0019 #include "IOPool/Streamer/interface/EventMsgBuilder.h"
0020 #include "IOPool/Streamer/interface/InitMsgBuilder.h"
0021 #include "IOPool/Streamer/interface/InitMessage.h"
0022
0023 #include "FWCore/Utilities/interface/Adler32Calculator.h"
0024 #include "FWCore/Utilities/interface/Exception.h"
0025 #include "IOPool/Streamer/interface/StreamerOutputFile.h"
0026
0027 #include "zlib.h"
0028
0029 #define NO_OF_EVENTS 10
0030
0031 int main() try {
0032 typedef std::vector<uint8> Buffer;
0033 Buffer buf(1024);
0034 Buffer buf2(11024);
0035
0036
0037
0038 char psetid[] = "1234567890123456";
0039 char test_value[] = "This is a test, This is a";
0040 char test_value_event[] = "This is a test Event, This is a";
0041 Strings hlt_names;
0042 Strings l1_names;
0043
0044 hlt_names.push_back("a");
0045 hlt_names.push_back("b");
0046 hlt_names.push_back("c");
0047 hlt_names.push_back("d");
0048 hlt_names.push_back("e");
0049 hlt_names.push_back("f");
0050 hlt_names.push_back("g");
0051 hlt_names.push_back("h");
0052 hlt_names.push_back("i");
0053
0054 l1_names.push_back("t10");
0055 l1_names.push_back("t11");
0056 l1_names.push_back("t12");
0057 l1_names.push_back("t13");
0058 l1_names.push_back("t14");
0059 l1_names.push_back("t15");
0060 l1_names.push_back("t16");
0061 l1_names.push_back("t17");
0062 l1_names.push_back("t18");
0063 l1_names.push_back("t19");
0064 l1_names.push_back("t20");
0065
0066 char reltag[] = "CMSSW_0_8_0_pre7";
0067 std::string processName = "HLT";
0068 std::string outputModuleLabel = "HLTOutput";
0069
0070 uLong crc = crc32(0L, Z_NULL, 0);
0071 Bytef* crcbuf = (Bytef*)outputModuleLabel.data();
0072 crc = crc32(crc, crcbuf, outputModuleLabel.length());
0073
0074 uint32 adler32_chksum = (uint32)cms::Adler32((char*)&test_value[0], sizeof(test_value));
0075
0076 InitMsgBuilder init(&buf[0],
0077 buf.size(),
0078 12,
0079 Version((const uint8*)psetid),
0080 (const char*)reltag,
0081 processName.c_str(),
0082 outputModuleLabel.c_str(),
0083 crc,
0084 hlt_names,
0085 hlt_names,
0086 l1_names,
0087 adler32_chksum);
0088
0089 init.setDataLength(sizeof(test_value));
0090 std::copy(&test_value[0], &test_value[0] + sizeof(test_value), init.dataAddress());
0091
0092
0093
0094
0095 std::cout << "Trying to Write a Streamer file" << std::endl;
0096 std::string initfilename = "teststreamfile.dat";
0097 StreamerOutputFile stream_writer(initfilename);
0098
0099 std::cout << "Trying to Write Out The Init message into Streamer File: " << initfilename << std::endl;
0100 stream_writer.write(init);
0101
0102
0103
0104 std::vector<bool> l1bit(11);
0105 uint8 hltbits[] = "4567";
0106 const int hltsize = 9;
0107
0108 l1bit[0] = true;
0109 l1bit[4] = true;
0110 l1bit[8] = false;
0111 l1bit[1] = true;
0112 l1bit[5] = false;
0113 l1bit[9] = false;
0114 l1bit[2] = false;
0115 l1bit[6] = true;
0116 l1bit[10] = true;
0117 l1bit[3] = false;
0118 l1bit[7] = false;
0119
0120
0121
0122
0123 adler32_chksum = (uint32)cms::Adler32((char*)&test_value_event[0], sizeof(test_value_event));
0124 std::string host_name = "mytestnode.cms";
0125
0126 for (uint32 eventId = 2000; eventId != 2000 + NO_OF_EVENTS; ++eventId) {
0127 EventMsgBuilder emb(
0128 &buf2[0], buf2.size(), 45, eventId, 2, 0xdeadbeef, 3, l1bit, hltbits, hltsize, adler32_chksum, host_name.c_str());
0129 emb.setOrigDataSize(78);
0130 emb.setEventLength(sizeof(test_value_event));
0131 std::copy(&test_value_event[0], &test_value_event[0] + sizeof(test_value_event), emb.eventAddr());
0132
0133
0134 std::cout << "Writing Event# : " << eventId << " To Streamer file" << std::endl;
0135 stream_writer.write(emb);
0136 }
0137
0138 return 0;
0139 } catch (cms::Exception const& e) {
0140 std::cerr << e.explainSelf() << std::endl;
0141 return 1;
0142 }