CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
H2RootNtplSource.cc
Go to the documentation of this file.
1 /* \author: Joanna Weng
2 * $Date: 1/2006
3 */
4 
11 #include <iostream>
12 
13 
14 using namespace edm;
15 using namespace std;
16 
17 //used for defaults
18 
20 ExternalInputSource(pset, desc),
21 evt(0), firstEvent_ (pset.getUntrackedParameter<unsigned int>("firstEvent",0)),
22 reader_( Ntuple2HepMCFiller::instance() ){
23 
24 
25  cout << "H2RootNtplSource: Reading HepMC file: " << fileNames()[0] << endl;
26  string fileName = fileNames()[0];
27  // strip the file:
28  if ( ! fileName.find("file:")){
29  fileName.erase(0,5);
30  }
31  //Max number of events processed
32  cout << "H2RootNtplSource: Number of events to be processed = " << maxEvents() << endl;
33 
34  //First event
35  firstEvent_ = pset.getUntrackedParameter<unsigned int>("firstEvent",0);
36  cout << "H2RootNtplSource: Number of first event = " << firstEvent_ << endl;
37 
38  reader_->initialize(fileName,101);
40  produces<HepMCProduct>();
41 
42 }
43 
44 
46  clear();
47 }
48 
50 }
51 
53 
54 
55  // no need to clean up GenEvent memory - now done in HepMCProduct
56  //if ( evt != NULL ) delete evt ;
57 
58 
59  auto_ptr<HepMCProduct> bare_product(new HepMCProduct());
60  cout << "H2RootNtplSource: Start Reading " << endl;
62  if(evt) {
63  bare_product->addHepMCData(evt );
64  e.put(bare_product);
65  return true;
66  }
67  else return false;
68 
69 
70 }
71 
HepMC::GenEvent * fillCurrentEventData()
T getUntrackedParameter(std::string const &, T const &) const
static PFTauRenderPlugin instance
virtual bool produce(Event &e)
int maxEvents() const
Definition: InputSource.h:166
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
H2RootNtplSource(const ParameterSet &, const InputSourceDescription &)
virtual bool setEvent(unsigned int event)
tuple cout
Definition: gather_cfg.py:121
std::vector< std::string > const & fileNames() const
HepMC::GenEvent * evt
Ntuple2HepMCFiller * reader_
virtual void initialize(const std::string &filename, int id)