MINT2
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
FromFileGenerator Class Reference

#include <FromFileGenerator.h>

Inheritance diagram for FromFileGenerator:
BaseGenerator MINT::IEventGenerator< IDalitzEvent > MINT::IEventGenerator< IDalitzEvent >

Public Member Functions

 FromFileGenerator (const std::string &fname="integrationEvents.root", const std::string &ntpName="DalitzEventList")
 
 FromFileGenerator (const std::string &fname, MINT::IEventGenerator< IDalitzEvent > *addThisWhenFileEmpty, const std::string &opt="", const std::string &ntpName="DalitzEventList")
 
virtual ~FromFileGenerator ()
 
virtual MINT::counted_ptr< IDalitzEventnewDalitzEvent ()
 
virtual MINT::counted_ptr< IDalitzEventnewEvent ()
 
virtual bool exhausted () const
 
virtual bool ensureFreshEvents ()
 
virtual bool saveFile ()
 
virtual bool closeFile ()
 
DiskResidentEventListgetEventList ()
 
const DiskResidentEventListgetEventList () const
 
- Public Member Functions inherited from BaseGenerator
 BaseGenerator (TRandom *rnd=gRandom)
 
 BaseGenerator (const BaseGenerator &other)
 
void setMothers3Momentum (MINT::counted_ptr< MINT::IReturnReal > p, MINT::counted_ptr< MINT::IReturnReal > cosTheta=(MINT::counted_ptr< MINT::IReturnReal >) 0, MINT::counted_ptr< MINT::IReturnReal > phi=(MINT::counted_ptr< MINT::IReturnReal >) 0)
 
void unsetMothers3Momentum ()
 
bool mothers3MomentumIsSet () const
 
void setSaveEvents (const std::string &fname="GeneratorEvents.root", const std::string &opt="RECREATE")
 
void dontSaveEvents ()
 
void setUnweighted (bool uw=true)
 
void setWeighted (bool w=true)
 
void FillEventList (DalitzEventList &evtList, int NEvents)
 
void FillEventList (DiskResidentEventList &evtList, int NEvents)
 
void noPrintout ()
 
virtual ~BaseGenerator ()
 
- Public Member Functions inherited from MINT::IEventGenerator< IDalitzEvent >
virtual ~IEventGenerator ()
 

Protected Member Functions

virtual MINT::counted_ptr< IDalitzEventnewEventFromGenerator ()
 
- Protected Member Functions inherited from BaseGenerator
bool saveEvents ()
 
TVector3 mothers3Momentum () const
 

Protected Attributes

std::string _opt
 
DiskResidentEventList _dL
 
bool _listExhausted
 
unsigned int _listIndex
 
MINT::IEventGenerator< IDalitzEvent > * _gen
 
MINT::NamedParameter< int > _doBootstrap
 
std::vector< int > _bootstrap_indices
 
- Protected Attributes inherited from BaseGenerator
std::string _fname
 
bool _unWeighted
 
MINT::counted_ptr< DiskResidentEventList_evtList
 
bool _noPrintout
 
TRandom * _rnd
 
MINT::counted_ptr< MINT::IReturnReal_mums_p
 
MINT::counted_ptr< MINT::IReturnReal_mums_cosTheta
 
MINT::counted_ptr< MINT::IReturnReal_mums_phi
 

Detailed Description

Definition at line 16 of file FromFileGenerator.h.

Constructor & Destructor Documentation

◆ FromFileGenerator() [1/2]

FromFileGenerator::FromFileGenerator ( const std::string &  fname = "integrationEvents.root",
const std::string &  ntpName = "DalitzEventList" 
)

Definition at line 8 of file FromFileGenerator.cpp.

10  : BaseGenerator()
11  , _opt("READ")
12  , _dL(fname,1,ntpName)
13  , _listExhausted(false)
14  , _listIndex(0)
15  , _gen(0)
16  , _doBootstrap("FromFileGenerator::doBootstrap",0)
17 {
18  cout << "FromFileGenerator::FromFileGenerator(" << fname << ")" << endl;
19  std::cout << "Got Intergrator events " << _dL.size() << std::endl;
20 
21  if(_doBootstrap){
22  while( _bootstrap_indices.size() < _dL.size() )_bootstrap_indices.push_back(TMath::Nint(gRandom->Uniform(0,_dL.size()-1)));
23  sort(_bootstrap_indices.begin(), _bootstrap_indices.end());
24  rotate(_bootstrap_indices.begin(),_bootstrap_indices.begin() + TMath::Nint(gRandom->Uniform(0,_dL.size()-1)), _bootstrap_indices.end());
25  }
26 
27 }
MINT::IEventGenerator< IDalitzEvent > * _gen
std::vector< int > _bootstrap_indices
unsigned int _listIndex
virtual unsigned int size() const
MINT::NamedParameter< int > _doBootstrap
BaseGenerator(TRandom *rnd=gRandom)
DiskResidentEventList _dL

◆ FromFileGenerator() [2/2]

FromFileGenerator::FromFileGenerator ( const std::string &  fname,
MINT::IEventGenerator< IDalitzEvent > *  addThisWhenFileEmpty,
const std::string &  opt = "",
const std::string &  ntpName = "DalitzEventList" 
)

Definition at line 28 of file FromFileGenerator.cpp.

34  : BaseGenerator()
35  , _opt( ("" != opt ? opt : ( 0 == addThisWhenFileEmpty ? "READ" : "UPDATE") ) )
36  , _dL(fname, 1, ntpName, _opt)
37  , _listExhausted(false)
38  , _listIndex(0)
39  , _gen(addThisWhenFileEmpty)
40  , _doBootstrap("FromFileGenerator::doBootstrap",0)
41 {
42  cout << " FromFileGenerator::FromFileGenerator(" << fname
43  << ", " << addThisWhenFileEmpty
44  << ", " << opt << ")" << endl;
45 
46  std::cout << "Got Intergrator events " << _dL.size() << std::endl;
47 
48  if(_doBootstrap){
49  while( _bootstrap_indices.size() < _dL.size() )_bootstrap_indices.push_back(TMath::Nint(gRandom->Uniform(0,_dL.size()-1)));
50  sort(_bootstrap_indices.begin(), _bootstrap_indices.end());
51  rotate(_bootstrap_indices.begin(),_bootstrap_indices.begin() + TMath::Nint(gRandom->Uniform(0,_dL.size()-1)), _bootstrap_indices.end());
52  }
53 }
MINT::IEventGenerator< IDalitzEvent > * _gen
std::vector< int > _bootstrap_indices
unsigned int _listIndex
virtual unsigned int size() const
MINT::NamedParameter< int > _doBootstrap
BaseGenerator(TRandom *rnd=gRandom)
DiskResidentEventList _dL

◆ ~FromFileGenerator()

virtual FromFileGenerator::~FromFileGenerator ( )
inlinevirtual

Definition at line 39 of file FromFileGenerator.h.

39 {}

Member Function Documentation

◆ closeFile()

bool FromFileGenerator::closeFile ( )
virtual

Definition at line 115 of file FromFileGenerator.cpp.

115  {
116  return _dL.Close();
117 }
DiskResidentEventList _dL

◆ ensureFreshEvents()

bool FromFileGenerator::ensureFreshEvents ( )
virtual

Reimplemented from BaseGenerator.

Definition at line 103 of file FromFileGenerator.cpp.

103  {
104  _listExhausted=true;
105  if(0 != _gen) _gen->ensureFreshEvents();
106  return true;
107 }
MINT::IEventGenerator< IDalitzEvent > * _gen
virtual bool ensureFreshEvents()=0

◆ exhausted()

bool FromFileGenerator::exhausted ( ) const
virtual

Reimplemented from BaseGenerator.

Definition at line 97 of file FromFileGenerator.cpp.

97  {
98  if(! _listExhausted) return false;
99  if(0 == _gen) return true;
100  return _gen->exhausted();
101 }
MINT::IEventGenerator< IDalitzEvent > * _gen
virtual bool exhausted() const =0

◆ getEventList() [1/2]

DiskResidentEventList & FromFileGenerator::getEventList ( )

Definition at line 119 of file FromFileGenerator.cpp.

119  {
120  return _dL;
121 }
DiskResidentEventList _dL

◆ getEventList() [2/2]

const DiskResidentEventList & FromFileGenerator::getEventList ( ) const

Definition at line 122 of file FromFileGenerator.cpp.

122  {
123  return _dL;
124 }
DiskResidentEventList _dL

◆ newDalitzEvent()

counted_ptr< IDalitzEvent > FromFileGenerator::newDalitzEvent ( )
virtual

Definition at line 78 of file FromFileGenerator.cpp.

78  {
80  if(_listIndex < _dL.size()){
81 
82  int index = _listIndex;
84 
86  if(mothers3MomentumIsSet() && 0 != evtPtr){
87  evtPtr->setMothers3Momentum(mothers3Momentum());
88  }
89  _listIndex++;
90  return evtPtr;
91  }else{
92  _listExhausted=true;
93  }
94  return newEventFromGenerator();
95 }
std::vector< int > _bootstrap_indices
bool mothers3MomentumIsSet() const
unsigned int _listIndex
virtual MINT::counted_ptr< IDalitzEvent > newEventFromGenerator()
virtual unsigned int size() const
MINT::NamedParameter< int > _doBootstrap
TVector3 mothers3Momentum() const
DalitzEvent getEvent(unsigned int i) const
DiskResidentEventList _dL

◆ newEvent()

counted_ptr< IDalitzEvent > FromFileGenerator::newEvent ( )
virtual

Implements BaseGenerator.

Definition at line 108 of file FromFileGenerator.cpp.

108  {
110 }
virtual MINT::counted_ptr< IDalitzEvent > newDalitzEvent()

◆ newEventFromGenerator()

counted_ptr< IDalitzEvent > FromFileGenerator::newEventFromGenerator ( )
protectedvirtual

Definition at line 55 of file FromFileGenerator.cpp.

55  {
56  bool dbThis=false;
57 
58  if(0 == _gen) return counted_ptr<IDalitzEvent>(0);
60 
61  if(0 == evtPtr) return evtPtr;
62 
64  evtPtr->setMothers3Momentum(mothers3Momentum());
65  }
66 
67  if(_opt != "READ"){
68  if(dbThis){
69  cout << "FromFileGenerator::newEventFromGenerator():"
70  << " saving event to list"
71  << " opt = " << _opt << endl;
72  }
73  _dL.Add(*evtPtr);
74  _listIndex++;
75  }
76  return evtPtr;
77 }
MINT::IEventGenerator< IDalitzEvent > * _gen
virtual bool Add(const DalitzEvent &evt)
bool mothers3MomentumIsSet() const
unsigned int _listIndex
virtual counted_ptr< RETURN_TYPE > newEvent()=0
TVector3 mothers3Momentum() const
DiskResidentEventList _dL

◆ saveFile()

bool FromFileGenerator::saveFile ( )
virtual

Definition at line 112 of file FromFileGenerator.cpp.

112  {
113  return _dL.save();
114 }
DiskResidentEventList _dL

Member Data Documentation

◆ _bootstrap_indices

std::vector<int> FromFileGenerator::_bootstrap_indices
protected

Definition at line 26 of file FromFileGenerator.h.

◆ _dL

DiskResidentEventList FromFileGenerator::_dL
protected

Definition at line 21 of file FromFileGenerator.h.

◆ _doBootstrap

MINT::NamedParameter<int> FromFileGenerator::_doBootstrap
protected

Definition at line 25 of file FromFileGenerator.h.

◆ _gen

MINT::IEventGenerator<IDalitzEvent>* FromFileGenerator::_gen
protected

Definition at line 24 of file FromFileGenerator.h.

◆ _listExhausted

bool FromFileGenerator::_listExhausted
protected

Definition at line 22 of file FromFileGenerator.h.

◆ _listIndex

unsigned int FromFileGenerator::_listIndex
protected

Definition at line 23 of file FromFileGenerator.h.

◆ _opt

std::string FromFileGenerator::_opt
protected

Definition at line 20 of file FromFileGenerator.h.


The documentation for this class was generated from the following files: