CMS 3D CMS Logo

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 GenMuonPlsPt100GeV_cfg::cout, lat::endl(), flush(), i, print_fed(), evf::FUShmClient::readNext(), evf::FUShmClient::setCrashPrb(), evf::FUShmClient::setSleep(), and ss.

00030 {
00031   // set parameters
00032   bool   waitForKey(false);if (argc>1) {stringstream ss;ss<<argv[1];ss>>waitForKey;}
00033   double crashPrb(0.0);    if (argc>2) {stringstream ss;ss<<argv[2];ss>>crashPrb;  }
00034   int    sleepTime(0);     if (argc>3) {stringstream ss;ss<<argv[3];ss>>sleepTime; }
00035 
00036   // get shared memory buffer and instantiate client
00037   FUShmBuffer* buffer=FUShmBuffer::getShmBuffer(); if (0==buffer) return 1;
00038   FUShmClient* client=new FUShmClient(buffer);
00039   client->setCrashPrb(crashPrb);
00040   client->setSleep(sleepTime);
00041   
00042   // the structure to hold the read fed data
00043   vector<vector<unsigned char> > fedData;
00044   
00045   // client loop
00046   while(1) {
00047     
00048     // wait for the user to press a key
00049     if (waitForKey) {
00050       cout<<"press key+<RETURN> to read next: "<<flush; char val; cin>>val;
00051       cout<<endl;
00052     }
00053     
00054     // read next event
00055     unsigned int iCell=client->readNext(fedData);
00056     cout<<"READ at index "<<iCell<<endl;
00057 
00058     // print content
00059     for(unsigned int i=0;i<4 /*fedData.size()*/;i++) print_fed(i,fedData[i]);
00060     cout<<endl;
00061     
00062   }
00063   
00064   return 0;
00065 }

void print_fed ( unsigned int  iFed,
const vector< unsigned char > &  fedData 
)

Definition at line 69 of file FUShmClient_t.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), flush(), int, and it.

Referenced by main().

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


Generated on Tue Jun 9 17:52:52 2009 for CMSSW by  doxygen 1.5.4