CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
edmtestp::TestFileReader Class Reference

#include <TestFileReader.h>

Public Member Functions

void join ()
 
void start ()
 
 TestFileReader (std::string const &filename, edm::EventBuffer &to, edm::ProductRegistry &prods)
 
virtual ~TestFileReader ()
 

Private Member Functions

void readEvents ()
 

Static Private Member Functions

static void run (TestFileReader *)
 

Private Attributes

std::string filename_
 
boost::shared_ptr< boost::thread > me_
 
boost::shared_ptr
< edm::StreamerInputFile
streamReader_
 
edm::EventBufferto_
 

Detailed Description

Definition at line 17 of file TestFileReader.h.

Constructor & Destructor Documentation

edmtestp::TestFileReader::TestFileReader ( std::string const &  filename,
edm::EventBuffer to,
edm::ProductRegistry prods 
)
if(!ist_)
  {
throw edm::Exception(errors::Configuration,"TestFileReader")
  << "cannot open file " << filename_;
  }

std::auto_ptr<SendJobHeader> p = readHeaderFromStream(ist_);

just get rid of the header

Definition at line 41 of file TestFileReader.cc.

References b, buf_, edm::EventBuffer::OperateBuffer< T >::buffer(), InitMsgView::code(), edm::EventBuffer::OperateBuffer< T >::commit(), edm::errors::Configuration, edm::hlt::Exception, filename_, init, InitMsgView::outputModuleId(), L1TEmulatorMonitor_cff::p, edm::registryIsSubset(), InitMsgView::run(), InitMsgView::size(), InitMsgView::startAddress(), streamReader_, and to_.

43  :
45  //ist_(filename_.c_str(),ios_base::binary | ios_base::in),
46  //reader_(ist_),
48  to_(to) {
49 
50  const InitMsgView* init = streamReader_->startMessage();
51  std::auto_ptr<edm::SendJobHeader> p = StreamerInputSource::deserializeRegistry(*init);
64  if(edm::registryIsSubset(*p, prods) == false) {
65  throw edm::Exception(errors::Configuration,"TestFileReader")
66  << "the header record in file " << filename_
67  << "is not consistent with the one for the program \n";
68  }
69 
70  // 13-Oct-2008, KAB - Added the following code to put the
71  // INIT message on the input queue.
73  int len = init->size();
74  char* buf_ = new char[len];
75  memcpy(buf_, init->startAddress(), len);
76  new (b.buffer()) stor::FragEntry(buf_, buf_, len, 1, 1,
77  init->code(), init->run(),
78  0, init->outputModuleId(),
79  getpid(), 0);
80  b.commit(sizeof(stor::FragEntry));
81  }
boost::shared_array< char > buf_
int init
Definition: HydjetWrapper.h:63
boost::shared_ptr< edm::StreamerInputFile > streamReader_
uint8 * startAddress() const
Definition: InitMessage.h:67
bool registryIsSubset(SendJobHeader const &, ProductRegistry const &reg)
Definition: Utilities.cc:85
double b
Definition: hdecay.h:120
edm::EventBuffer & to_
uint32 outputModuleId() const
Definition: InitMessage.h:75
uint32 code() const
Definition: InitMessage.h:65
tuple filename
Definition: lut2db_cfg.py:20
uint32 run() const
Definition: InitMessage.cc:80
uint32 size() const
Definition: InitMessage.h:66
edmtestp::TestFileReader::~TestFileReader ( )
virtual

Definition at line 83 of file TestFileReader.cc.

83  {
84  }

Member Function Documentation

void edmtestp::TestFileReader::join ( )

Definition at line 90 of file TestFileReader.cc.

References me_.

90  {
91  me_->join();
92  }
boost::shared_ptr< boost::thread > me_
void edmtestp::TestFileReader::readEvents ( )
private

Definition at line 98 of file TestFileReader.cc.

References b, buf_, edm::EventBuffer::OperateBuffer< T >::buffer(), EventMsgView::code(), edm::EventBuffer::OperateBuffer< T >::commit(), EventMsgView::event(), EventMsgView::outModId(), EventMsgView::run(), EventMsgView::size(), EventMsgView::startAddress(), streamReader_, and to_.

Referenced by run().

98  {
99 
100  while(streamReader_->next()) {
102  const EventMsgView* eview = streamReader_->currentRecord();
103 
104  // 13-Oct-2008, KAB - we need to make a copy of the event message
105  // for two reasons: 1) the processing of the events is often done
106  // asynchronously in the code that uses this reader, so we can't
107  // keep re-using the same buffer from the stream_reader, and
108  // 2) the code that uses this reader often uses deleters to
109  // free up the memory used by the FragEntry, so we want the
110  // first argument to the FragEntry to be something that can
111  // be deleted successfully.
112  int len = eview->size();
113  char* buf_ = new char[len];
114  memcpy(buf_, eview->startAddress(), len);
115 
116  //stor::FragEntry* msg =
117  // new (b.buffer()) stor::FragEntry(eview->startAddress(),
118  // eview->startAddress(),
119  // the first arg should be startAddress() right?
120  //new (b.buffer()) stor::FragEntry((void*)eview->eventData(),
121  new (b.buffer()) stor::FragEntry(buf_, buf_, len, 1, 1,
122  eview->code(), eview->run(),
123  eview->event(), eview->outModId(),
124  getpid(), 0);
125  b.commit(sizeof(stor::FragEntry));
126  }
127 
128  /***
129  while(1)
130  {
131  int len=0;
132  ist_.read((char*)&len,sizeof(int));
133 
134  if(!ist_ || len==0 || ist_.eof()) break;
135 
136  EventBuffer::ProducerBuffer b(to_);
137  // Pay attention here.
138  // This is a bit of a mess.
139  // Here we allocate an array (on the heap), fill it with data
140  // from the file, then pass the bare pointer off onto the queue.
141  // The ownership is to be picked up by the code that pulls it
142  // off the queue. The current implementation of the queue
143  // is primitive - it knows nothing about the types of things
144  // that are on the queue.
145 
146  BufHelper data(len);
147  //std::cout << "allocated frag " << len << std::endl;
148  ist_.read((char*)data.get(),len);
149  //std::cout << "read frag to " << (void*)data.get() << std::endl;
150  if(!ist_ || ist_.eof()) std::cerr << "got end!!!!" << std::endl;
151  //HEREHERE need a real event number here for id
152  stor::FragEntry* msg =
153  new (b.buffer()) stor::FragEntry(data.get(),data.get(),len,1,1,Header::EVENT,0,1,0);
154  assert(msg); // Suppresses compiler warning about unused variable
155  //new (b.buffer()) stor::FragEntry(0,0,len);
156  //std::cout << "make entry for frag " << (void*)msg << " " << msg->buffer_address_ << std::endl;
157  data.release();
158  //std::cout << "release frag" << std::endl;
159  b.commit(sizeof(stor::FragEntry));
160  //std::cout << "commit frag " << sizeof(stor::FragEntry) << std::endl;
161  //sleep(2);
162  } **/
163  }
uint8 * startAddress() const
Definition: EventMessage.h:79
boost::shared_array< char > buf_
boost::shared_ptr< edm::StreamerInputFile > streamReader_
uint32 outModId() const
Definition: EventMessage.cc:97
uint32 run() const
Definition: EventMessage.cc:73
uint32 code() const
Definition: EventMessage.h:75
uint32 event() const
Definition: EventMessage.cc:79
uint32 size() const
Definition: EventMessage.h:76
double b
Definition: hdecay.h:120
edm::EventBuffer & to_
void edmtestp::TestFileReader::run ( TestFileReader t)
staticprivate

Definition at line 94 of file TestFileReader.cc.

References readEvents().

Referenced by start().

94  {
95  t->readEvents();
96  }
void edmtestp::TestFileReader::start ( void  )

Definition at line 86 of file TestFileReader.cc.

References me_, and run().

86  {
87  me_.reset(new boost::thread(boost::bind(TestFileReader::run,this)));
88  }
boost::shared_ptr< boost::thread > me_
static void run(TestFileReader *)

Member Data Documentation

std::string edmtestp::TestFileReader::filename_
private

Definition at line 30 of file TestFileReader.h.

Referenced by TestFileReader().

boost::shared_ptr<boost::thread> edmtestp::TestFileReader::me_
private

Definition at line 35 of file TestFileReader.h.

Referenced by join(), and start().

boost::shared_ptr<edm::StreamerInputFile> edmtestp::TestFileReader::streamReader_
private

Definition at line 31 of file TestFileReader.h.

Referenced by readEvents(), and TestFileReader().

edm::EventBuffer& edmtestp::TestFileReader::to_
private

Definition at line 34 of file TestFileReader.h.

Referenced by readEvents(), and TestFileReader().