Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:10:27

0001 /** File contains simple tools to dump Init and Event 
0002     Messages on screen.
0003 */
0004 
0005 #include "IOPool/Streamer/interface/DumpTools.h"
0006 #include "FWCore/Utilities/interface/Digest.h"
0007 #include "FWCore/Utilities/interface/Algorithms.h"
0008 #include <iostream>
0009 #include <iterator>
0010 #include "DataFormats/Streamer/interface/StreamedProducts.h"
0011 #include "IOPool/Streamer/interface/ClassFiller.h"
0012 
0013 #include "TBufferFile.h"
0014 
0015 #include <memory>
0016 
0017 using namespace edm;
0018 
0019 void dumpInitHeader(const InitMsgView* view) {
0020   std::cout << "code = " << view->code() << ", "
0021             << "size = " << view->size() << "\n"
0022             << "run = " << view->run() << ", "
0023             << "proto = " << view->protocolVersion() << "\n"
0024             << "release = " << view->releaseTag() << "\n"
0025             << "processName = " << view->processName() << "\n";
0026   if (view->protocolVersion() >= 5) {
0027     std::cout << "outModuleLabel = " << view->outputModuleLabel() << "\n";
0028   }
0029   if (view->protocolVersion() >= 6) {
0030     std::cout << "outputModuleId=0x" << std::hex << view->outputModuleId() << std::dec << std::endl;
0031   }
0032   if (view->protocolVersion() >= 8) {
0033     std::cout << "Checksum for Registry data = " << view->adler32_chksum() << " Hostname = " << view->hostName()
0034               << std::endl;
0035   }
0036 
0037   //PSet 16 byte non-printable representation, stored in message.
0038   uint8 vpset[16];
0039   view->pset(vpset);
0040 
0041   //Lets convert it to printable hex form
0042   std::string pset_str(vpset, vpset + sizeof(vpset));
0043   pset_str += '\0';
0044   cms::Digest dig(pset_str);
0045   cms::MD5Result r1 = dig.digest();
0046   std::string hexy = r1.toString();
0047   std::cout << "PSetID= " << hexy << std::endl;
0048 
0049   Strings vhltnames, vhltselections, vl1names;
0050   view->hltTriggerNames(vhltnames);
0051   if (view->protocolVersion() >= 5) {
0052     view->hltTriggerSelections(vhltselections);
0053   }
0054   view->l1TriggerNames(vl1names);
0055 
0056   std::cout << "HLT names :- \n ";
0057   edm::copy_all(vhltnames, std::ostream_iterator<std::string>(std::cout, "\n"));
0058 
0059   if (view->protocolVersion() >= 5) {
0060     std::cout << "HLT selections :- \n ";
0061     edm::copy_all(vhltselections, std::ostream_iterator<std::string>(std::cout, "\n"));
0062   }
0063 
0064   std::cout << "L1 names :- \n ";
0065   edm::copy_all(vl1names, std::ostream_iterator<std::string>(std::cout, "\n"));
0066   std::cout << "\n";
0067   std::cout.flush();
0068 }
0069 
0070 void dumpInitView(const InitMsgView* view) {
0071   dumpInitHeader(view);
0072   std::cout << "desc len = " << view->descLength() << "\n";
0073   //const uint8* pos = view->descData();
0074   //std::copy(pos,pos+view->descLength(),std::ostream_iterator<uint8>(std::cout,""));
0075   //std::cout << "\n";
0076   std::cout.flush();
0077 }
0078 
0079 void dumpStartMsg(const InitMsgView* view) {
0080   dumpInitHeader(view);
0081   std::cout.flush();
0082 }
0083 
0084 void dumpInitVerbose(const InitMsgView* view) {
0085   std::cout << ">>>>> INIT Message Dump (begin) >>>>>" << std::endl;
0086   dumpInitHeader(view);
0087 
0088   TClass* desc = getTClass(typeid(SendJobHeader));
0089   TBufferFile xbuf(TBuffer::kRead, view->descLength(), (char*)view->descData(), kFALSE);
0090   std::unique_ptr<SendJobHeader> sd((SendJobHeader*)xbuf.ReadObjectAny(desc));
0091 
0092   if (sd.get() == nullptr) {
0093     std::cout << "Unable to determine the product registry - "
0094               << "Registry deserialization error." << std::endl;
0095   } else {
0096     std::cout << "Branch Descriptions:" << std::endl;
0097     SendDescs const& descs = sd->descs();
0098     SendDescs::const_iterator iDesc(descs.begin()), eDesc(descs.end());
0099     while (iDesc != eDesc) {
0100       BranchDescription branchDesc = *iDesc;
0101       branchDesc.init();
0102       //branchDesc.write(std::cout);
0103       std::cout << branchDesc.branchName() << std::endl;
0104       iDesc++;
0105     }
0106   }
0107 
0108   std::cout << "<<<<< INIT Message Dump (end) <<<<<" << std::endl;
0109   std::cout.flush();
0110 }
0111 
0112 void dumpInit(uint8* buf) {
0113   InitMsgView view(buf);
0114   dumpInitHeader(&view);
0115 
0116   std::cout << "desc len = " << view.descLength() << "\n";
0117   //const uint8* pos = view.descData();
0118   //std::copy(pos,pos+view.descLength(),std::ostream_iterator<uint8>(std::cout,""));
0119   //std::cout << "\n";
0120   std::cout.flush();
0121 }
0122 
0123 void printBits(unsigned char c) {
0124   for (int i = 7; i >= 0; --i) {
0125     int bit = ((c >> i) & 1);
0126     std::cout << " " << bit;
0127   }
0128 }
0129 
0130 void dumpEventHeader(const EventMsgView* eview) {
0131   std::cout << "code=" << eview->code() << "\n"
0132             << "size=" << eview->size() << "\n"
0133             << "protocolVersion=" << eview->protocolVersion() << "\n"
0134             << "run=" << eview->run() << "\n"
0135             << "event=" << eview->event() << "\n"
0136             << "lumi=" << eview->lumi() << "\n"
0137             << "origDataSize=" << eview->origDataSize() << "\n"
0138             << "outModId=0x" << std::hex << eview->outModId() << std::dec << "\n"
0139             << "adler32 chksum= " << eview->adler32_chksum() << "\n"
0140             << "host name= " << eview->hostName() << "\n"
0141             << "event length=" << eview->eventLength() << "\n"
0142             << "droppedEventsCount=" << eview->droppedEventsCount() << "\n";
0143 
0144   std::vector<bool> l1_out;
0145   eview->l1TriggerBits(l1_out);
0146 
0147   std::cout << "\nl1 size= " << l1_out.size() << "\n l1 bits=\n";
0148   edm::copy_all(l1_out, std::ostream_iterator<bool>(std::cout, " "));
0149 
0150   std::vector<unsigned char> hlt_out;
0151   if (eview->hltCount() > 0) {
0152     hlt_out.resize(1 + (eview->hltCount() - 1) / 4);
0153   }
0154   eview->hltTriggerBits(&hlt_out[0]);
0155 
0156   std::cout << "\nhlt Count:" << eview->hltCount();
0157   std::cout << "\nhlt bits=\n(";
0158   for (int i = (hlt_out.size() - 1); i != -1; --i)
0159     printBits(hlt_out[i]);
0160   std::cout << ")\n";
0161   std::cout.flush();
0162 }
0163 
0164 void dumpEventView(const EventMsgView* eview) {
0165   dumpEventHeader(eview);
0166   //const uint8* edata = eview->eventData();
0167   //std::cout << "\nevent data=\n(";
0168   //std::copy(&edata[0],&edata[0]+eview->eventLength(),
0169   //     std::ostream_iterator<char>(std::cout,""));
0170   //std::cout << ")\n";
0171   std::cout.flush();
0172 }
0173 
0174 void dumpEventIndex(const EventMsgView* eview) {
0175   dumpEventHeader(eview);
0176   std::cout.flush();
0177 }
0178 
0179 void dumpEvent(uint8* buf) {
0180   EventMsgView eview(buf);
0181 
0182   dumpEventHeader(&eview);
0183 
0184   //const uint8* edata = eview.eventData();
0185   //std::cout << "\nevent data=\n(";
0186   //std::copy(&edata[0],&edata[0]+eview.eventLength(),
0187   //     std::ostream_iterator<char>(std::cout,""));
0188   //std::cout << ")\n";
0189   std::cout.flush();
0190 }
0191 
0192 void dumpFRDEventView(const FRDEventMsgView* fview) {
0193   std::cout << "\n>>>>> FRDEvent Message Dump (begin) >>>>>" << std::endl;
0194   std::cout.flush();
0195 
0196   std::cout << "size = " << fview->size() << "\n"
0197             << "version = " << fview->version() << "\n"
0198             << "run = " << fview->run() << "\n"
0199             << "lumi = " << fview->lumi() << "\n"
0200             << "event = " << fview->event() << "\n";
0201   std::cout.flush();
0202 
0203   std::cout << ">>>>> FRDEvent Message Dump (end) >>>>>" << std::endl;
0204   std::cout.flush();
0205 }