CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/IOPool/Streamer/src/DumpTools.cc

Go to the documentation of this file.
00001 
00005 #include "IOPool/Streamer/interface/DumpTools.h"
00006 #include "FWCore/Utilities/interface/Digest.h"
00007 #include "FWCore/Utilities/interface/Algorithms.h"
00008 #include <iostream>
00009 #include <iterator>
00010 #include "DataFormats/Streamer/interface/StreamedProducts.h"
00011 #include "IOPool/Streamer/interface/ClassFiller.h"
00012 
00013 #include "TBufferFile.h"
00014 
00015 using namespace edm;
00016 
00017 void dumpInitHeader(const InitMsgView* view)
00018 {
00019   std::cout
00020     << "code = " << view->code() << ", "
00021     << "size = " << view->size() << "\n"
00022     << "run = " << view->run() << ", "
00023     << "proto = " << view->protocolVersion() << "\n"
00024     << "release = " << view->releaseTag() << "\n"
00025     << "processName = " << view->processName() << "\n";
00026   if (view->protocolVersion() >= 5) {
00027     std::cout << "outModuleLabel = " << view->outputModuleLabel() << "\n";
00028   }
00029   if (view->protocolVersion() >= 6) {
00030     std::cout << "outputModuleId=0x" << std::hex << view->outputModuleId()
00031               << std::dec << std::endl;
00032   }
00033   if (view->protocolVersion() >= 8) {
00034     std::cout << "Checksum for Registry data = " << view->adler32_chksum()
00035               << " Hostname = " << view->hostName() << std::endl;
00036   }
00037 
00038   //PSet 16 byte non-printable representation, stored in message.
00039   uint8 vpset[16];
00040   view->pset(vpset); 
00041 
00042   //Lets convert it to printable hex form
00043   std::string pset_str(vpset, vpset+sizeof(vpset));
00044   pset_str += '\0';
00045   cms::Digest dig(pset_str);
00046   cms::MD5Result r1 = dig.digest();
00047   std::string hexy = r1.toString();
00048   std::cout << "PSetID= " << hexy << std::endl;
00049 
00050   Strings vhltnames,vhltselections,vl1names;
00051   view->hltTriggerNames(vhltnames);
00052   if (view->protocolVersion() >= 5) {
00053     view->hltTriggerSelections(vhltselections);
00054   }
00055   view->l1TriggerNames(vl1names);
00056 
00057   std::cout << "HLT names :- \n ";
00058   edm::copy_all(vhltnames,std::ostream_iterator<std::string>(std::cout,"\n"));
00059 
00060   if (view->protocolVersion() >= 5) {
00061     std::cout << "HLT selections :- \n ";
00062     edm::copy_all(vhltselections,std::ostream_iterator<std::string>(std::cout,"\n"));
00063   }
00064 
00065   std::cout << "L1 names :- \n ";
00066   edm::copy_all(vl1names,std::ostream_iterator<std::string>(std::cout,"\n"));
00067   std::cout << "\n";
00068   std::cout.flush();
00069 
00070 }
00071 
00072 void dumpInitView(const InitMsgView* view)
00073 {
00074 
00075 
00076   dumpInitHeader(view);
00077   std::cout << "desc len = " << view->descLength() << "\n";
00078   //const uint8* pos = view->descData();
00079   //std::copy(pos,pos+view->descLength(),std::ostream_iterator<uint8>(std::cout,""));
00080   //std::cout << "\n";
00081   std::cout.flush();
00082 
00083 }
00084 
00085 void dumpStartMsg(const InitMsgView* view)
00086 {
00087   dumpInitHeader(view);
00088   std::cout.flush();
00089 }
00090 
00091 void dumpInitVerbose(const InitMsgView* view)
00092 {
00093   std::cout << ">>>>> INIT Message Dump (begin) >>>>>" << std::endl;
00094   dumpInitHeader(view);
00095 
00096   TClass* desc = getTClass(typeid(SendJobHeader));
00097   TBufferFile xbuf(TBuffer::kRead, view->descLength(),
00098                (char*)view->descData(), kFALSE);
00099   std::auto_ptr<SendJobHeader> sd((SendJobHeader*)xbuf.ReadObjectAny(desc));
00100 
00101   if (sd.get() == 0) {
00102     std::cout << "Unable to determine the product registry - "
00103               << "Registry deserialization error." << std::endl;
00104   }
00105   else {
00106     std::cout << "Branch Descriptions:" << std::endl;
00107     SendDescs const& descs = sd->descs();
00108     SendDescs::const_iterator iDesc(descs.begin()), eDesc(descs.end());
00109     while (iDesc != eDesc) {
00110       BranchDescription branchDesc = *iDesc;
00111       branchDesc.init();
00112       //branchDesc.write(std::cout);
00113       std::cout << branchDesc.branchName() << std::endl;
00114       iDesc++;
00115     }
00116   }
00117 
00118   std::cout << "<<<<< INIT Message Dump (end) <<<<<" << std::endl;
00119   std::cout.flush();
00120 }
00121 
00122 void dumpInit(uint8* buf)
00123 {
00124   InitMsgView view(buf);
00125   dumpInitHeader(&view);
00126   
00127   std::cout << "desc len = " << view.descLength() << "\n";
00128   //const uint8* pos = view.descData();
00129   //std::copy(pos,pos+view.descLength(),std::ostream_iterator<uint8>(std::cout,""));
00130   //std::cout << "\n";
00131   std::cout.flush();
00132 }
00133 
00134 void printBits(unsigned char c){
00135 
00136         for (int i = 7; i >= 0; --i) {
00137             int bit = ((c >> i) & 1);
00138             std::cout << " "<<bit;
00139         }
00140 }
00141 
00142 void dumpEventHeader(const EventMsgView* eview)
00143 {
00144   std::cout << "code=" << eview->code() << "\n"
00145        << "size=" << eview->size() << "\n"
00146        << "protocolVersion=" << eview->protocolVersion() << "\n"
00147        << "run=" << eview->run() << "\n"
00148        << "event=" << eview->event() << "\n"
00149        << "lumi=" << eview->lumi() << "\n"
00150        << "origDataSize=" << eview->origDataSize() << "\n"
00151        << "outModId=0x" << std::hex << eview->outModId() << std::dec << "\n"
00152        << "adler32 chksum= " << eview->adler32_chksum() << "\n"
00153        << "host name= " << eview->hostName() << "\n"
00154        << "event length=" << eview->eventLength() << "\n"
00155        << "droppedEventsCount=" << eview->droppedEventsCount() << "\n";
00156 
00157   std::vector<bool> l1_out;
00158   eview->l1TriggerBits(l1_out);
00159 
00160   std::cout << "\nl1 size= " << l1_out.size() << "\n l1 bits=\n";
00161   edm::copy_all(l1_out,std::ostream_iterator<bool>(std::cout," "));
00162 
00163   std::vector<unsigned char> hlt_out;
00164   if (eview->hltCount() > 0) {hlt_out.resize(1 + (eview->hltCount()-1)/4);}
00165   eview->hltTriggerBits(&hlt_out[0]);
00166 
00167   std::cout << "\nhlt Count:" << eview->hltCount();
00168   std::cout << "\nhlt bits=\n(";
00169   for(int i=(hlt_out.size()-1); i != -1 ; --i)
00170     printBits(hlt_out[i]);
00171   std::cout << ")\n";
00172   std::cout.flush();
00173 }
00174 
00175 void dumpEventView(const EventMsgView* eview)
00176   {
00177   dumpEventHeader(eview);
00178   //const uint8* edata = eview->eventData();
00179   //std::cout << "\nevent data=\n(";
00180   //std::copy(&edata[0],&edata[0]+eview->eventLength(),
00181   //     std::ostream_iterator<char>(std::cout,""));
00182   //std::cout << ")\n";
00183   std::cout.flush();
00184 
00185 }
00186 
00187 void dumpEventIndex(const EventMsgView* eview)
00188 {
00189   dumpEventHeader(eview);
00190   std::cout.flush();
00191 }
00192 
00193 void dumpEvent(uint8* buf)
00194 {
00195   EventMsgView eview(buf);
00196 
00197   dumpEventHeader(&eview);
00198 
00199   //const uint8* edata = eview.eventData();
00200   //std::cout << "\nevent data=\n(";
00201   //std::copy(&edata[0],&edata[0]+eview.eventLength(),
00202   //     std::ostream_iterator<char>(std::cout,""));
00203   //std::cout << ")\n";
00204   std::cout.flush();
00205 
00206 }
00207 
00208 void dumpDQMEventHeader(const DQMEventMsgView* dview)
00209 {
00210   std::cout << "code = " << dview->code() << "\n"
00211        << "size = " << dview->size() << "\n"
00212        << "protocolVersion = " << dview->protocolVersion() << "\n"
00213        << "run = " << dview->runNumber() << "\n"
00214        << "event = " << dview->eventNumberAtUpdate() << "\n"
00215        << "lumi = " << dview->lumiSection() << "\n"
00216        << "update = " << dview->updateNumber() << "\n"
00217        << "checksum = " << dview->adler32_chksum() << "\n"
00218        << "host name= " << dview->hostName() << "\n"
00219        << "compressionFlag = " << dview->compressionFlag() << "\n"
00220        << "fuProcessId = " << dview->fuProcessId() << "\n"
00221        << "fuGuid = 0x" << std::hex << dview->fuGuid() << std::dec << "\n"
00222        << "mergeCount = " << dview->mergeCount() << "\n"
00223        << "release = " << dview->releaseTag() << "\n"
00224        << "topFolder = " << dview->topFolderName() << "\n"
00225        << "event length = " << dview->eventLength() << "\n";
00226   std::cout.flush();
00227  }
00228 
00229 void dumpDQMEventView(const DQMEventMsgView* dview)
00230 {
00231   std::cout << "\n>>>>> DQMEvent Message Dump (begin) >>>>>" << std::endl;
00232   dumpDQMEventHeader(dview);
00233 
00234   boost::shared_ptr< std::vector<std::string> > subFolders =
00235     dview->subFolderNames();
00236   for (uint32 idx = 0; idx < subFolders->size(); idx++) {
00237     std::string name = subFolders->at(idx);
00238     uint32 count = dview->meCount(name);
00239     std::cout << "Subfolder " << name << " has " << count
00240               << " monitor elements." << std::endl;
00241   }
00242 
00243   std::cout << ">>>>> DQMEvent Message Dump (end) >>>>>" << std::endl;
00244   std::cout.flush();
00245 }
00246 
00247 void dumpFRDEventView(const FRDEventMsgView* fview)
00248 {
00249   std::cout << "\n>>>>> FRDEvent Message Dump (begin) >>>>>" << std::endl;
00250   std::cout.flush();
00251 
00252   std::cout << "size = " << fview->size() << "\n"
00253             << "version = " << fview->version() << "\n"
00254             << "run = " << fview->run() << "\n"
00255             << "lumi = " << fview->lumi() << "\n"
00256             << "event = " << fview->event() << "\n";
00257   std::cout.flush();
00258 
00259   std::cout << ">>>>> FRDEvent Message Dump (end) >>>>>" << std::endl;
00260   std::cout.flush();
00261 }