CMS 3D CMS Logo

Functions

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/EventFilter/ShmBuffer/bin/FUShmClient_t.cc File Reference

#include "EventFilter/ShmBuffer/interface/FUShmBuffer.h"
#include "EventFilter/ShmBuffer/bin/FUShmClient.h"
#include <iostream>
#include <iomanip>
#include <sstream>
#include <unistd.h>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
void print_fed (unsigned int iFed, const vector< unsigned char > &fedData)

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 29 of file FUShmClient_t.cc.

References OfflineClient_cff::client, gather_cfg::cout, i, print_fed(), evf::FUShmClient::readNext(), evf::FUShmClient::setCrashPrb(), and evf::FUShmClient::setSleep().

{
  // set parameters
  bool   waitForKey(false);if (argc>1) {stringstream ss;ss<<argv[1];ss>>waitForKey;}
  double crashPrb(0.0);    if (argc>2) {stringstream ss;ss<<argv[2];ss>>crashPrb;  }
  int    sleepTime(0);     if (argc>3) {stringstream ss;ss<<argv[3];ss>>sleepTime; }

  // get shared memory buffer and instantiate client
  FUShmBuffer* buffer=FUShmBuffer::getShmBuffer(); if (0==buffer) return 1;
  FUShmClient* client=new FUShmClient(buffer);
  client->setCrashPrb(crashPrb);
  client->setSleep(sleepTime);
  
  // the structure to hold the read fed data
  vector<vector<unsigned char> > fedData;
  
  // client loop
  while(1) {
    
    // wait for the user to press a key
    if (waitForKey) {
      cout<<"press key+<RETURN> to read next: "<<flush; char val; cin>>val;
      cout<<endl;
    }
    
    // read next event
    unsigned int iCell=client->readNext(fedData);
    cout<<"READ at index "<<iCell<<endl;

    // print content
    for(unsigned int i=0;i<4 /*fedData.size()*/;i++) print_fed(i,fedData[i]);
    cout<<endl;
    
  }
  
  return 0;
}
void print_fed ( unsigned int  iFed,
const vector< unsigned char > &  fedData 
)

Definition at line 69 of file FUShmClient_t.cc.

References gather_cfg::cout.

Referenced by main().

{
  cout<<"fed "<<iFed<<": "<<flush;
  vector<unsigned char>::const_iterator it;
  cout.fill('0');
  for (it=fedData.begin();it!=fedData.end();++it)
    cout<<setiosflags(ios::right)<<setw(2)<<hex<<(int)(*it)<<dec<<" ";
  cout<<endl;
}