CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MCFileSource.cc
Go to the documentation of this file.
1 // $Id: MCFileSource.cc,v 1.9.2.1 2009/01/09 10:34:32 saout Exp $
2 
13 #include <iostream>
14 #include <string>
15 
16 
23 
24 
25 using namespace edm;
26 using namespace std;
27 
28 
29 //-------------------------------------------------------------------------
31  ExternalInputSource(pset, desc),
32  reader_(HepMCFileReader::instance()), evt_(0)
33 {
34  edm::LogInfo("MCFileSource") << "Reading HepMC file:" << fileNames()[0];
35  string fileName = fileNames()[0];
36  // strip the file:
37  if (fileName.find("file:") == 0){
38  fileName.erase(0,5);
39  }
40 
41  reader_->initialize(fileName);
42  produces<HepMCProduct>();
43 }
44 
45 
46 //-------------------------------------------------------------------------
48 }
49 
50 
51 //-------------------------------------------------------------------------
53  // Read one HepMC event and store it in the Event.
54 
55  auto_ptr<HepMCProduct> bare_product(new HepMCProduct());
56 
57  edm::LogInfo("MCFileSource") << "Start Reading";
59  if (evt_ == 0) return false;
60 
61  bare_product->addHepMCData(evt_);
62  e.put(bare_product);
63 
64  return true;
65 }
MCFileSource(const ParameterSet &pset, const InputSourceDescription &desc)
Definition: MCFileSource.cc:30
virtual void initialize(const std::string &filename)
virtual bool produce(Event &e)
Definition: MCFileSource.cc:52
virtual ~MCFileSource()
Definition: MCFileSource.cc:47
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
HepMCFileReader * reader_
Definition: MCFileSource.h:32
HepMC::GenEvent * evt_
Definition: MCFileSource.h:33
HepMC::GenEvent * fillCurrentEventData()
std::vector< std::string > const & fileNames() const