MINT2
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BaseGenerator Class Referenceabstract

#include <BaseGenerator.h>

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

Public Member Functions

 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)
 
virtual MINT::counted_ptr< IDalitzEventnewEvent ()=0
 
virtual bool exhausted () const
 
virtual bool ensureFreshEvents ()
 
void noPrintout ()
 
virtual ~BaseGenerator ()
 
- Public Member Functions inherited from MINT::IEventGenerator< IDalitzEvent >
virtual ~IEventGenerator ()
 

Protected Member Functions

bool saveEvents ()
 
TVector3 mothers3Momentum () const
 

Protected Attributes

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 27 of file BaseGenerator.h.

Constructor & Destructor Documentation

◆ BaseGenerator() [1/2]

BaseGenerator::BaseGenerator ( TRandom *  rnd = gRandom)

Definition at line 12 of file BaseGenerator.cpp.

13  : _unWeighted(true)
14  , _evtList(0)
15  , _noPrintout(false)
16  , _rnd(rnd)
17  , _mums_p(0)
18  , _mums_cosTheta(0)
19  , _mums_phi(0)
20 {
21 
22 }
MINT::counted_ptr< MINT::IReturnReal > _mums_p
Definition: BaseGenerator.h:39
MINT::counted_ptr< DiskResidentEventList > _evtList
Definition: BaseGenerator.h:31
MINT::counted_ptr< MINT::IReturnReal > _mums_cosTheta
Definition: BaseGenerator.h:40
TRandom * _rnd
Definition: BaseGenerator.h:37
MINT::counted_ptr< MINT::IReturnReal > _mums_phi
Definition: BaseGenerator.h:41

◆ BaseGenerator() [2/2]

BaseGenerator::BaseGenerator ( const BaseGenerator other)

Definition at line 23 of file BaseGenerator.cpp.

25  , _unWeighted(other._unWeighted)
26  , _evtList(other._evtList)
27  , _noPrintout(other._noPrintout)
28  , _rnd(other._rnd)
29  , _mums_p(other._mums_p)
31  , _mums_phi(other._mums_phi)
32 {
33 }
MINT::counted_ptr< MINT::IReturnReal > _mums_p
Definition: BaseGenerator.h:39
MINT::counted_ptr< DiskResidentEventList > _evtList
Definition: BaseGenerator.h:31
MINT::counted_ptr< MINT::IReturnReal > _mums_cosTheta
Definition: BaseGenerator.h:40
TRandom * _rnd
Definition: BaseGenerator.h:37
MINT::counted_ptr< MINT::IReturnReal > _mums_phi
Definition: BaseGenerator.h:41

◆ ~BaseGenerator()

BaseGenerator::~BaseGenerator ( )
virtual

Definition at line 157 of file BaseGenerator.cpp.

157  {
158 
159 }

Member Function Documentation

◆ dontSaveEvents()

void BaseGenerator::dontSaveEvents ( )

Definition at line 80 of file BaseGenerator.cpp.

80  {
81  _evtList =
83 }
MINT::counted_ptr< DiskResidentEventList > _evtList
Definition: BaseGenerator.h:31

◆ ensureFreshEvents()

bool BaseGenerator::ensureFreshEvents ( )
virtual

Implements MINT::IEventGenerator< IDalitzEvent >.

Reimplemented in SignalGenerator, FromFileGenerator, and FoamDalitzMC.

Definition at line 152 of file BaseGenerator.cpp.

152  {
153  if(0 == _rnd) _rnd = gRandom;
154  _rnd->SetSeed(time(0)*3);
155  return true;
156 }
TRandom * _rnd
Definition: BaseGenerator.h:37

◆ exhausted()

virtual bool BaseGenerator::exhausted ( ) const
inlinevirtual

Implements MINT::IEventGenerator< IDalitzEvent >.

Reimplemented in SignalGenerator, FromFileGenerator, and FoamDalitzMC.

Definition at line 70 of file BaseGenerator.h.

70 {return false;}

◆ FillEventList() [1/2]

void BaseGenerator::FillEventList ( DalitzEventList evtList,
int  NEvents 
)

Definition at line 116 of file BaseGenerator.cpp.

116  {
117  bool dbThis=false;
118  if(dbThis) cout << "BaseGenerator::FillEventList (mr) called" << endl;
119 
120  time_t t0 = time(0);
121  for(int i=0; i < NEvents; i++){
122  if(!_noPrintout){
123  int printEvery = 10000;
124  //if(i < 1000) printEvery=100;
125  bool printout = ( i%printEvery == 0 || i < 1);
126  if(dbThis || printout){
127  cout << "BaseGenerator::FillEventList (memory resident)" << endl;
128  cout << " about to make event number " << i << endl;
129  cout << " current list size " << evtList.size() << endl;
130  double dt = difftime(time(0), t0);
131  cout << " this took " << dt << "s" << endl;
132  if(dt > 0) cout << " or " << evtList.size()/dt << "evt/s" << endl;
133  }
134  }
135  // counted_ptr<IDalitzEvent> evt = newEvent();
136  if(dbThis) cout << " got new event, now adding it" << endl;
137  // evtList.Add(counted_ptr<DalitzEvent>(new DalitzEvent(evt.get()))); // this is a bit silly - will fix later
139  DalitzEvent evt(evtPtr.get());
140  evtList.Add(evt);
141  if(dbThis){
142  cout << "BaseGenerator::FillEventList (memory resident)" <<endl;
143  cout << "After adding this event to the event list:\n " << evt << endl;
144  cout << ".... the last event in the list is:\n "
145  << evtList[evtList.size()-1] << endl;
146  cout << "are they the same?" << endl;
147  }
148 
149  }
150 }
virtual bool Add(const EVENT_TYPE &evt)
Definition: EventList.h:63
virtual unsigned int size() const
Definition: EventList.h:59
virtual MINT::counted_ptr< IDalitzEvent > newEvent()=0

◆ FillEventList() [2/2]

void BaseGenerator::FillEventList ( DiskResidentEventList evtList,
int  NEvents 
)

Definition at line 85 of file BaseGenerator.cpp.

85  {
86  bool dbThis=false;
87  if(dbThis) cout << "BaseGenerator::FillEventList (dr) called" << endl;
88  time_t t0 = time(0);
89  for(int i=0; i < NEvents; i++){
90  if(!_noPrintout){
91  int printEvery = 10000;
92  //if(i < 1000) printEvery=100;
93  bool printout = ( i%printEvery == 0 || i < 1);
94  if(dbThis || printout){
95  cout << "BaseGenerator::FillEventList (disk resident)" << endl;
96  cout << " about to make event number " << i << endl;
97  cout << " current list size " << evtList.size() << endl;
98  double dt = difftime(time(0), t0);
99  cout << " this took " << dt << "s" << endl;
100  if(dt > 0) cout << " or " << evtList.size()/dt << "evt/s" << endl;
101  }
102  }
104  DalitzEvent evt(evtPtr.get());
105  evtList.Add(evt);
106  if(dbThis){
107  cout << "BaseGenerator::FillEventList (disk resident)" <<endl;
108  cout << "After adding this event to the event list:\n " << evt << endl;
109  cout << ".... the last event in the list is:\n "
110  << evtList.getEvent(evtList.size()-1) << endl;
111  cout << "are they the same?" << endl;
112  }
113  }
114 }
virtual bool Add(const DalitzEvent &evt)
virtual unsigned int size() const
DalitzEvent getEvent(unsigned int i) const
virtual MINT::counted_ptr< IDalitzEvent > newEvent()=0

◆ mothers3Momentum()

TVector3 BaseGenerator::mothers3Momentum ( ) const
protected

Definition at line 51 of file BaseGenerator.cpp.

51  {
53  double p, cT, phi;
54  if(0 != _mums_p) p = _mums_p->RealVal();
55  else p=0;
56  if(0 != _mums_cosTheta) cT = _mums_cosTheta->RealVal();
57  else cT = _rnd->Rndm()*2.0 - 1.0;
58  if(0 != _mums_phi) phi = _mums_phi->RealVal();
59  else phi = _rnd->Rndm()*2.0*pi;
60 
61  double sT2 = 1.0 - cT*cT;
62  double sT;
63  if(sT2 < 0) sT=0;
64  else sT = sqrt(sT2);
65 
66  TVector3 v(p*cos(phi)*sT, p*sin(phi)*sT, p*cT);
67 
68  return v;
69  }else{
70  TVector3 v(0,0,0);
71  return v;
72  }
73 }
MINT::counted_ptr< MINT::IReturnReal > _mums_p
Definition: BaseGenerator.h:39
MINT::counted_ptr< MINT::IReturnReal > _mums_cosTheta
Definition: BaseGenerator.h:40
TRandom * _rnd
Definition: BaseGenerator.h:37
static const double pi
bool mothers3MomentumIsSet() const
MINT::counted_ptr< MINT::IReturnReal > _mums_phi
Definition: BaseGenerator.h:41
virtual double RealVal()=0

◆ mothers3MomentumIsSet()

bool BaseGenerator::mothers3MomentumIsSet ( ) const

Definition at line 47 of file BaseGenerator.cpp.

47  {
48  return (0 != _mums_p);
49 }
MINT::counted_ptr< MINT::IReturnReal > _mums_p
Definition: BaseGenerator.h:39

◆ newEvent()

virtual MINT::counted_ptr<IDalitzEvent> BaseGenerator::newEvent ( )
pure virtual

◆ noPrintout()

void BaseGenerator::noPrintout ( )
inline

Definition at line 73 of file BaseGenerator.h.

73 {_noPrintout=true;}

◆ saveEvents()

bool BaseGenerator::saveEvents ( )
inlineprotected

Definition at line 34 of file BaseGenerator.h.

34 {return 0 != _evtList;}
MINT::counted_ptr< DiskResidentEventList > _evtList
Definition: BaseGenerator.h:31

◆ setMothers3Momentum()

Definition at line 35 of file BaseGenerator.cpp.

38  {
39  _mums_p = p;
40  _mums_cosTheta = cosTheta;
41  _mums_phi = phi;
42 }
MINT::counted_ptr< MINT::IReturnReal > _mums_p
Definition: BaseGenerator.h:39
MINT::counted_ptr< MINT::IReturnReal > _mums_cosTheta
Definition: BaseGenerator.h:40
MINT::counted_ptr< MINT::IReturnReal > _mums_phi
Definition: BaseGenerator.h:41

◆ setSaveEvents()

void BaseGenerator::setSaveEvents ( const std::string &  fname = "GeneratorEvents.root",
const std::string &  opt = "RECREATE" 
)

Definition at line 75 of file BaseGenerator.cpp.

◆ setUnweighted()

void BaseGenerator::setUnweighted ( bool  uw = true)
inline

Definition at line 61 of file BaseGenerator.h.

61 {_unWeighted = uw;}

◆ setWeighted()

void BaseGenerator::setWeighted ( bool  w = true)
inline

Definition at line 62 of file BaseGenerator.h.

62 {_unWeighted = ! w;}

◆ unsetMothers3Momentum()

void BaseGenerator::unsetMothers3Momentum ( )

Definition at line 43 of file BaseGenerator.cpp.

43  {
45 }
MINT::counted_ptr< MINT::IReturnReal > _mums_p
Definition: BaseGenerator.h:39
MINT::counted_ptr< MINT::IReturnReal > _mums_cosTheta
Definition: BaseGenerator.h:40
MINT::counted_ptr< MINT::IReturnReal > _mums_phi
Definition: BaseGenerator.h:41

Member Data Documentation

◆ _evtList

MINT::counted_ptr<DiskResidentEventList> BaseGenerator::_evtList
protected

Definition at line 31 of file BaseGenerator.h.

◆ _fname

std::string BaseGenerator::_fname
protected

Definition at line 29 of file BaseGenerator.h.

◆ _mums_cosTheta

MINT::counted_ptr<MINT::IReturnReal> BaseGenerator::_mums_cosTheta
protected

Definition at line 40 of file BaseGenerator.h.

◆ _mums_p

MINT::counted_ptr<MINT::IReturnReal> BaseGenerator::_mums_p
protected

Definition at line 39 of file BaseGenerator.h.

◆ _mums_phi

MINT::counted_ptr<MINT::IReturnReal> BaseGenerator::_mums_phi
protected

Definition at line 41 of file BaseGenerator.h.

◆ _noPrintout

bool BaseGenerator::_noPrintout
protected

Definition at line 32 of file BaseGenerator.h.

◆ _rnd

TRandom* BaseGenerator::_rnd
protected

Definition at line 37 of file BaseGenerator.h.

◆ _unWeighted

bool BaseGenerator::_unWeighted
protected

Definition at line 30 of file BaseGenerator.h.


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