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

#include <DalitzBWBoxSet.h>

Inheritance diagram for DalitzBWBoxSet:
MINT::PolymorphVector< DalitzBWBox > MINT::IUnweightedEventGenerator< IDalitzEvent > MINT::IEventGenerator< IDalitzEvent >

Public Member Functions

 DalitzBWBoxSet (MINT::IReturnRealForEvent< IDalitzEvent > *amps=0, TRandom *r=gRandom)
 
 DalitzBWBoxSet (TRandom *r)
 
 DalitzBWBoxSet (const DalitzBWBoxSet &other)
 
virtual ~DalitzBWBoxSet ()
 
void add (DalitzBWBox &box)
 
void add (DalitzBWBoxSet &boxes)
 
void setPhaseSpaceFrac (double ps)
 
double phaseSpaceFrac () const
 
void setUnWeightPs (bool doSo=true)
 
virtual MINT::counted_ptr< DalitzEventmakeEventForOwner ()
 
virtual MINT::counted_ptr< DalitzEventmakeEventForOwner (int &nTries)
 
virtual MINT::counted_ptr< DalitzEventmakeWeightedEventForOwner ()
 
virtual MINT::counted_ptr< DalitzEventmakeWeightedEventForOwner (int &nTries)
 
virtual MINT::counted_ptr< DalitzEventtryEventForOwner ()
 
virtual MINT::counted_ptr< DalitzEventphaseSpaceEvent ()
 
virtual MINT::counted_ptr< IDalitzEventnewEvent ()
 
virtual MINT::counted_ptr< IDalitzEventnewUnweightedEvent ()
 
virtual bool exhausted () const
 
double phaseSpaceIntegral () const
 
double fullPdf (DalitzEvent &evt)
 
double genValueNoPs (const DalitzEvent &evt) const
 
double genValuePs (const DalitzEvent &evt) const
 
double genValueWithLoop (DalitzEvent &evt) const
 
double genValue (const DalitzEvent &evt) const
 
void print (std::ostream &os) const
 
bool ensureFreshEvents ()
 
bool setRnd (TRandom *rnd=gRandom)
 
bool am_I_generating_what_I_think_I_am_generating (int Nevents=1000000)
 
bool compareGenerationMethodsForFullPDF (int Nevents=1000000)
 
- Public Member Functions inherited from MINT::PolymorphVector< DalitzBWBox >
 PolymorphVector ()
 
 PolymorphVector (unsigned int N)
 
 PolymorphVector (unsigned int N, const DalitzBWBox &c)
 
 PolymorphVector (const PolymorphVector &other)
 
 PolymorphVector (const typename std::vector< DalitzBWBox > &other)
 
virtual ~PolymorphVector ()
 
std::vector< DalitzBWBox > & theVector ()
 
const std::vector< DalitzBWBox > & theVector () const
 
DalitzBWBoxoperator[] (unsigned int i)
 
const DalitzBWBoxoperator[] (unsigned int i) const
 
DalitzBWBoxat (unsigned int i)
 
const DalitzBWBoxat (unsigned int i) const
 
std::vector< DalitzBWBox >::iterator begin ()
 
std::vector< DalitzBWBox >::const_iterator begin () const
 
std::vector< DalitzBWBox >::iterator end ()
 
std::vector< DalitzBWBox >::const_iterator end () const
 
std::vector< DalitzBWBox >::iterator find (const DalitzBWBox &c)
 
std::vector< DalitzBWBox >::const_iterator find (const DalitzBWBox &c) const
 
DalitzBWBoxfront ()
 
const DalitzBWBoxfront () const
 
DalitzBWBoxback ()
 
const DalitzBWBoxback () const
 
unsigned int size () const
 
bool empty () const
 
void push_back (const DalitzBWBox &c)
 
void pop_back ()
 
void erase (typename std::vector< DalitzBWBox >::iterator pos)
 
void erase (typename std::vector< DalitzBWBox >::iterator first, typename std::vector< DalitzBWBox >::iterator last)
 
PolymorphVector< DalitzBWBox > & operator= (const PolymorphVector< DalitzBWBox > &other)
 
void clear ()
 
void resize (unsigned int N)
 
void resize (unsigned int N, const DalitzBWBox &c)
 
 operator const typename std::vector< DalitzBWBox > & () const
 
 operator typename std::vector< DalitzBWBox > & ()
 
bool operator== (const MINT::PolymorphVector< DalitzBWBox > &v2) const
 
bool operator!= (const MINT::PolymorphVector< DalitzBWBox > &v2) const
 
bool operator< (const MINT::PolymorphVector< DalitzBWBox > &v2) const
 
bool operator> (const MINT::PolymorphVector< DalitzBWBox > &v2) const
 
- Public Member Functions inherited from MINT::IUnweightedEventGenerator< IDalitzEvent >
virtual ~IUnweightedEventGenerator ()
 
- Public Member Functions inherited from MINT::IEventGenerator< IDalitzEvent >
virtual ~IEventGenerator ()
 

Protected Member Functions

void getReady ()
 
void findMax ()
 
int justThrowAwayData (double maxValue, MINT::IReturnRealForEvent< IDalitzEvent > *amps)
 
MINT::counted_ptr< DalitzEventpopEventFromList ()
 
void set_psbox_height_and_weight ()
 
void setup_psbox ()
 
double VolumeSum () const
 
double heightSum () const
 
void makeVolumeProbIntervals ()
 
int pickRandomVolume ()
 
double calc_pick_ps_prob () const
 
double pick_ps_prob ()
 
bool checkIntegration () const
 
bool ready () const
 
double findMaxInList (double &sampleMax)
 
virtual MINT::counted_ptr< DalitzEventmakeWeightedApproxEventForOwner ()
 
virtual MINT::counted_ptr< DalitzEventmakeWeightedApproxEventForOwner (int &nTries)
 

Protected Attributes

DalitzEventPtrList _eventPtrList
 
double _maxWeightEstimate
 
double _maxWeightInSample
 
MINT::IReturnRealForEvent< IDalitzEvent > * _ampSum
 
bool _ready
 
std::vector< double > _volumeProbs
 
TRandom * _rnd
 
double _phaseSpaceFrac
 
double _phaseSpaceIntegral
 
DalitzPhaseSpaceBox _psbox
 
double _pick_ps_prob
 
- Protected Attributes inherited from MINT::PolymorphVector< DalitzBWBox >
std::vector< DalitzBWBox_vec
 

Static Protected Attributes

static double __phaseSpaceFracDefaultValue =0.25
 

Detailed Description

Definition at line 23 of file DalitzBWBoxSet.h.

Constructor & Destructor Documentation

◆ DalitzBWBoxSet() [1/3]

DalitzBWBoxSet::DalitzBWBoxSet ( MINT::IReturnRealForEvent< IDalitzEvent > *  amps = 0,
TRandom *  r = gRandom 
)

Definition at line 23 of file DalitzBWBoxSet.cpp.

25  , _maxWeightEstimate(-9999.0)
26  , _maxWeightInSample(-9999.0)
27  , _ampSum(amps)
28  , _ready(false)
29  , _volumeProbs()
30  , _rnd(r)
32  , _phaseSpaceIntegral(-9999)
33  , _psbox()
34  , _pick_ps_prob(-9999)
35 {}
std::vector< double > _volumeProbs
double _phaseSpaceIntegral
TRandom * _rnd
double _maxWeightInSample
double _pick_ps_prob
DalitzPhaseSpaceBox _psbox
double _phaseSpaceFrac
static double __phaseSpaceFracDefaultValue
double _maxWeightEstimate
MINT::IReturnRealForEvent< IDalitzEvent > * _ampSum

◆ DalitzBWBoxSet() [2/3]

DalitzBWBoxSet::DalitzBWBoxSet ( TRandom *  r)

Definition at line 36 of file DalitzBWBoxSet.cpp.

38  , _maxWeightEstimate(-9999.0)
39  , _maxWeightInSample(-9999.0)
40  , _ampSum(0)
41  , _ready(false)
42  , _volumeProbs()
43  , _rnd(r)
45  , _phaseSpaceIntegral(-9999)
46  , _psbox()
47  , _pick_ps_prob(-9999)
48 {}
std::vector< double > _volumeProbs
double _phaseSpaceIntegral
TRandom * _rnd
double _maxWeightInSample
double _pick_ps_prob
DalitzPhaseSpaceBox _psbox
double _phaseSpaceFrac
static double __phaseSpaceFracDefaultValue
double _maxWeightEstimate
MINT::IReturnRealForEvent< IDalitzEvent > * _ampSum

◆ DalitzBWBoxSet() [3/3]

DalitzBWBoxSet::DalitzBWBoxSet ( const DalitzBWBoxSet other)

Definition at line 50 of file DalitzBWBoxSet.cpp.

57  , _ampSum(other._ampSum)
58  , _ready(other._ready)
59  , _volumeProbs(other._volumeProbs)
60  , _rnd(other._rnd)
63  , _psbox(other._psbox)
65 {}
std::vector< double > _volumeProbs
DalitzEventPtrList _eventPtrList
double _phaseSpaceIntegral
TRandom * _rnd
double _maxWeightInSample
double _pick_ps_prob
DalitzPhaseSpaceBox _psbox
double _phaseSpaceFrac
double _maxWeightEstimate
MINT::IReturnRealForEvent< IDalitzEvent > * _ampSum

◆ ~DalitzBWBoxSet()

virtual DalitzBWBoxSet::~DalitzBWBoxSet ( )
inlinevirtual

Definition at line 79 of file DalitzBWBoxSet.h.

79 {}

Member Function Documentation

◆ add() [1/2]

void DalitzBWBoxSet::add ( DalitzBWBox box)

Definition at line 77 of file DalitzBWBoxSet.cpp.

77  {
78  _ready = false;
79  box.setRnd(_rnd);
80  this->push_back(box);
81 }
void push_back(const DalitzBWBox &c)
TRandom * _rnd
bool setRnd(TRandom *rnd=gRandom)

◆ add() [2/2]

void DalitzBWBoxSet::add ( DalitzBWBoxSet boxes)

Definition at line 83 of file DalitzBWBoxSet.cpp.

83  {
84  _ready = false;
85  for(unsigned int i=0; i<boxes.size(); i++){
86  this->add(boxes[i]);
87  }
88 }
unsigned int size() const
void add(DalitzBWBox &box)

◆ am_I_generating_what_I_think_I_am_generating()

bool DalitzBWBoxSet::am_I_generating_what_I_think_I_am_generating ( int  Nevents = 1000000)
virtual

Reimplemented from MINT::IUnweightedEventGenerator< IDalitzEvent >.

Definition at line 119 of file DalitzBWBoxSet.cpp.

119  {
120  cout << "Hello from DalitzBWBoxSet::am_I_generating_what_I_think_I_am_generating"
121  << " with " << Nevents << " events to generate for each case" << endl;
122 
123  DiskResidentEventList generated_approxPDF_events("generated_approxPDF_events.root"
124  , "RECREATE");
125  DiskResidentEventList generatedFlat_weighted_approxPDF_events("generatedFlat_weighted_approxPDF_events.root"
126  , "RECREATE");
127 
128  int printEvery = min(Nevents/10, 10000);
129 
130  for(int i=0; i < Nevents; i++){
131  generated_approxPDF_events.Add(*makeWeightedApproxEventForOwner());
132  if(0 == i%printEvery) cout << "done event " << i << endl;
133  }
134  cout << "generated approxPDF_events"<< endl;
135 
136  generated_approxPDF_events.save();
137  DalitzHistoSet datGen= generated_approxPDF_events.weightedHistoSet();
138  datGen.save("generated_approxPDF_histos.root");
139  datGen.draw("generated_approxPDF_histos");
140 
141  int rwfactor=1;
142  for(int i=0; i < Nevents*rwfactor; i++){
144  evtPtr->setWeight(evtPtr->getWeight()*genValueNoPs(*evtPtr));
145  generatedFlat_weighted_approxPDF_events.Add(*evtPtr);
146  if(0 == i%(printEvery*rwfactor)) cout << "done event " << i << endl;
147  }
148  cout << "generated generatedFlat_weighted_approxPDF_events" << endl;
149  generatedFlat_weighted_approxPDF_events.save();;
150  DalitzHistoSet datWeight = generatedFlat_weighted_approxPDF_events.weightedHistoSet();
151  datWeight.save("generatedFlat_weighted_approxPDF_histos.root");
152  datWeight.draw("generatedFlat_weighted_approxPDF_histos");
153  datGen.drawWithFitNorm(datWeight, "genDotsWeightLine_", "eps", "E1 SAME");
154 
155  DalitzHistoSet ratio(datGen);
156  ratio /= datWeight;
157  ratio.save("ratio_full_by_weight.root");
158  ratio.draw("ratio_full_by_weight");
159 
160 
161  cout << "DalitzBWBoxSet::am_I_generating_what_I_think_I_am_generating:"
162  << " all done" << endl;
163 
164  return true;
165 }
bool drawWithFitNorm(const DalitzHistoSet &fit, const std::string &baseName="", const std::string &format="eps", const std::string &fitDrawOpt="HIST C SAME") const
virtual MINT::counted_ptr< DalitzEvent > phaseSpaceEvent()
bool draw(const std::string &baseName="", const std::string &drawOpt="", const std::string &format="eps") const
virtual MINT::counted_ptr< DalitzEvent > makeWeightedApproxEventForOwner()
double genValueNoPs(const DalitzEvent &evt) const
bool save(const std::string &filename="DalitzHistos.root") const

◆ calc_pick_ps_prob()

double DalitzBWBoxSet::calc_pick_ps_prob ( ) const
protected

Definition at line 237 of file DalitzBWBoxSet.cpp.

237  {
238  bool dbThis=false;
239  if(_phaseSpaceFrac <= 0) return 0;
240  double returnVal= _psbox.volume()/(_psbox.volume() + VolumeSum());
241  if(dbThis){
242  cout << "calc_pick_ps_prob() = "
243  << _psbox.volume() << " / " << "("
244  << _psbox.volume() << " + " << VolumeSum() << ")"
245  << " = " << returnVal << endl;
246  }
247  return returnVal;
248 }
double VolumeSum() const
DalitzPhaseSpaceBox _psbox
double _phaseSpaceFrac

◆ checkIntegration()

bool DalitzBWBoxSet::checkIntegration ( ) const
protected

Definition at line 103 of file DalitzBWBoxSet.cpp.

103  {
104  bool s=true;
105 
106  double prevV=0;
107  for(unsigned int i=0; i< this->size(); i++){
108  if(prevV == _volumeProbs[i]) continue;
109  prevV=_volumeProbs[i];
110  cout << "checking integration for box "
111  << (*this)[i].name() << endl;
112  s &= (*this)[i].checkIntegration();
113  cout << "============================="
114  << endl;
115  }
116  return s;
117 }
std::vector< double > _volumeProbs
static const double s

◆ compareGenerationMethodsForFullPDF()

bool DalitzBWBoxSet::compareGenerationMethodsForFullPDF ( int  Nevents = 1000000)
virtual

Reimplemented from MINT::IUnweightedEventGenerator< IDalitzEvent >.

Definition at line 166 of file DalitzBWBoxSet.cpp.

166  {
167  cout << "Hello from DalitzBWBoxSet::compareGenerationMethodsForFullPDF"
168  << " (with " << this->size() << " boxes)"
169  << " with " << Nevents << " events to generate for each case" << endl;
170 
171  DiskResidentEventList generated_fullPDF_efficient_weighted_events("generated_fullPDF_efficient_weighted_events.root"
172  , "RECREATE");
173  DiskResidentEventList generatedFlat_fullPDF_flat_weighted_events("generated_fullPDF_flat_weighted_events.root"
174  , "RECREATE");
175 
176  bool unweightFull = false;
177 
178  int printEvery = min(Nevents/10, 10000);
179 
180  for(int i=0; i < Nevents; i++){
181  if(unweightFull) {
182  generated_fullPDF_efficient_weighted_events.Add(*makeEventForOwner());
183  }else{
184  generated_fullPDF_efficient_weighted_events.Add(*makeWeightedEventForOwner());
185  }
186  if(0 == i%printEvery) cout << "done event " << i << endl;
187  }
188  cout << "generated approxPDF_events"<< endl;
189 
190  generated_fullPDF_efficient_weighted_events.save();
191  DalitzHistoSet datGen= generated_fullPDF_efficient_weighted_events.weightedHistoSet();
192  datGen.save("generated_fullPDF_efficient_weighted_histos.root");
193  datGen.draw("generated_fullPDF_efficient_weighted");
194 
195  int rwfactor=1;
196  for(int i=0; i < Nevents*rwfactor; i++){
198  evtPtr->setWeight(evtPtr->getWeight()*fullPdf(*evtPtr));
199  generatedFlat_fullPDF_flat_weighted_events.Add(*evtPtr);
200  if(0 == i%(printEvery*rwfactor)) cout << "done event " << i << endl;
201  }
202  cout << "generated generatedFlat_fullPDF_flat_weighted_events" << endl;
203  generatedFlat_fullPDF_flat_weighted_events.save();;
204  DalitzHistoSet datWeight = generatedFlat_fullPDF_flat_weighted_events.weightedHistoSet();
205  datWeight.save("generated_fullPDF_efficient_weighted_histos.root");
206  datWeight.draw("generated_fullPDF_efficient_weighted_events");
207  datGen.drawWithFitNorm(datWeight, "efficientBlue_FlatRed_", "eps", "E1 SAME");
208 
209  DalitzHistoSet ratio(datGen);
210  ratio /= datWeight;
211  ratio.save("ratio_full_by_weight.root");
212  ratio.draw("ratio_full_by_weight");
213 
214  cout << "DalitzBWBoxSet::compareGenerationMethodsForFullPDF:"
215  << " all done" << endl;
216 
217  return true;
218 }
double fullPdf(DalitzEvent &evt)
virtual MINT::counted_ptr< DalitzEvent > makeEventForOwner()
bool drawWithFitNorm(const DalitzHistoSet &fit, const std::string &baseName="", const std::string &format="eps", const std::string &fitDrawOpt="HIST C SAME") const
virtual MINT::counted_ptr< DalitzEvent > makeWeightedEventForOwner()
virtual MINT::counted_ptr< DalitzEvent > phaseSpaceEvent()
bool draw(const std::string &baseName="", const std::string &drawOpt="", const std::string &format="eps") const
bool save(const std::string &filename="DalitzHistos.root") const

◆ ensureFreshEvents()

bool DalitzBWBoxSet::ensureFreshEvents ( )
virtual

Implements MINT::IUnweightedEventGenerator< IDalitzEvent >.

Definition at line 98 of file DalitzBWBoxSet.cpp.

98  {
99  setRnd(_rnd); // safety paranoia - all boxes should be using this already
100  _rnd->SetSeed(time(0)*2);
101  return true;
102 }
TRandom * _rnd
bool setRnd(TRandom *rnd=gRandom)

◆ exhausted()

virtual bool DalitzBWBoxSet::exhausted ( ) const
inlinevirtual

Implements MINT::IEventGenerator< IDalitzEvent >.

Definition at line 100 of file DalitzBWBoxSet.h.

100 {return false;}

◆ findMax()

void DalitzBWBoxSet::findMax ( )
protected

Definition at line 291 of file DalitzBWBoxSet.cpp.

291  {
292  bool dbThis=false;
293 
294  time_t startTime = time(0);
295  // int maxEvents = 100000;
296  int maxEvents = 60000; // memory
297  int maxTries = 9;
298 
299  bool speedupabit=true;
300  if(speedupabit){
301  maxEvents=50000;
302  maxTries = 3;
303  }
304  bool speedupalot=false;
305  if(speedupalot){
306  maxEvents=30000;
307  maxTries = 2;
308  }
309  bool instant=false; // set true for very fast & very dirty testing jobs etc;
310  if(instant){
311  maxEvents=5000;
312  maxTries = 1;
313  }
314  //int maxEvents = 100000;
315  // maxEvents = 10000;
316 
317  cout << "DalitzBWBoxSet::findMax making starter set with "
318  << maxEvents << " events." << endl;
319 
320  int numTries=0;
321  _maxWeightEstimate=-9999; // estimated max from pareto
322 
323  while(_maxWeightEstimate < 0 ||
325  && numTries < maxTries
326  && _eventPtrList.size() < 1000000)
327  ){
328  numTries++;
329  cout << " DalitzBWBoxSet::findMax(): iteration number " << numTries
330  << " for estimated max of parent " << _maxWeightEstimate
331  << " and max of current sample: " << _maxWeightInSample
332  << endl;
333  for(int i=0; i < maxEvents; i++){
335 
336  unsigned int printEvery = 100000;
337  if(i <= 10) printEvery=10;
338  else if(i <= 100) printEvery=100;
339  else if(i <= 1000) printEvery=1000;
340  else if(i <= 100000) printEvery=10000;
341  else if(i <= 1000000) printEvery=500000;
342 
343  if(i < 1 || i%printEvery == 0){
344  cout << "DalitzBWBoxSet::findMax() "
345  << "made event number " << i
346  << "\t (" << difftime(time(0), startTime) << " sec)"
347  << endl;
348  }
349  if(dbThis && (0 != evt)) {
350  cout << "DalitzBWBoxSet::findMax(): made event with weight "
351  << evt->getWeight() << endl;
352  }
353  if(0 != evt) _eventPtrList.Add(evt);
354  }
355 
356  cout << "DalitzBWBoxSet::findMax() starter set took "
357  << difftime(time(0), startTime) << " s." << endl;
358 
360  // _maxWeightEstimate = 60; // debug only june 2011
361  // break; // debug only june 2011
362  }
363 
367  }
368  // _maxWeightEstimate = 60; // debug only june 2011
369 
370  if(dbThis){
371  cout << "DalitzBWBoxSet::findMax(): I have now "
372  << _eventPtrList.size()
373  << " events in the eventPtrList." << endl;
374  if( _eventPtrList.size() > 0){
375  cout << "The first one is: " << _eventPtrList.getEventRef(0) << endl;
376  }
377  }
378 
379  //if(dbThis)_eventPtrList.save("eventListBeforeUnweighting.root");
380 
381  ReturnWeight w;
383 
384  if(dbThis){
385  cout << "DalitzBWBoxSet::findMax(): AFTER unweighting I have "
386  << _eventPtrList.size()
387  << " events in the eventPtrList." << endl;
388  if( _eventPtrList.size() > 0){
389  cout << "The first unweighted event is: " << _eventPtrList.getEventRef(0) << endl;
390  }
391  }
392 
393 
394 
395  /*
396  _eventPtrList.findMaxAndThrowAwayData(_maxWeightEstimate, &w);
397  */
398 
399  // we've un-weighted them, need to set weight correctly...
400  for(unsigned int i=0; i < _eventPtrList.size(); i++){
402  }
403 
404  cout << "DalitzBWBoxSet::findMax() after throw away I have "
405  << _eventPtrList.size() << " events left. Maximum weight estimate is: "
406  << _maxWeightEstimate << endl;
407 
408  cout << "DalitzBWBoxSet::findMax() done after "
409  << difftime(time(0), startTime) << " s." << endl;
410  return;
411 }
virtual const EVENT_TYPE & getEventRef(unsigned int i) const
Definition: EventPtrList.h:49
virtual void setWeight(double w)
virtual bool Add(const EVENT_TYPE &evt)
Definition: EventPtrList.h:88
DalitzEventPtrList _eventPtrList
virtual MINT::counted_ptr< DalitzEvent > makeWeightedEventForOwner()
double findMaxInList(double &sampleMax)
double _maxWeightInSample
virtual unsigned int size() const
Definition: EventPtrList.h:76
int justThrowAwayData(double maxValue, MINT::IReturnRealForEvent< IDalitzEvent > *amps)
double _maxWeightEstimate

◆ findMaxInList()

double DalitzBWBoxSet::findMaxInList ( double &  sampleMax)
protected

Definition at line 413 of file DalitzBWBoxSet.cpp.

413  {
414  bool dbThis=false;
415 
416 
417  time_t startTime = time(0);
418  if(0 == _eventPtrList.size()) return -9999;
419 
420  std::vector<double> vals;
421  vals.resize(_eventPtrList.size());
422  sampleMax=-9999;
423  for(unsigned int i=0; i < _eventPtrList.size(); i++){
425 
426  double w = evt.getWeight();
427  double d=w;
428 
429  if(dbThis) cout << "w = " << w << endl;
430 
431  if(d > sampleMax || 0 == i) sampleMax=d;
432  vals[i] = d;
433 
434 
435  unsigned int printEvery = _eventPtrList.size()/10;
436  if(printEvery <=0) printEvery = 5;
437  if(i <= 2) printEvery=1;
438  else if(i <= 200) printEvery=100;
439 
440  if(i < 5 || 0 == i%(printEvery)){
441  std::cout << "DalitzBWBoxSet::findMaxInList() calculated "
442  << "_ampSum for event "
443  << i
444  << ", its value is " << d
445  << std::endl;
446  double deltaT = difftime(time(0), startTime);
447  std::cout << " DalitzBWBoxSet::findMaxInList()this took "
448  << deltaT << " s";
449  if(deltaT > 0){
450  std::cout << "; rate (before throwing away) = "
451  << i/deltaT
452  << " evts/s";
453  }
454  std::cout << std::endl;
455  }
456  };
457 
458 
459  double epsilon = 0.2;
460  // sampleMax = sampleMax + fabs(sampleMax * epsilon);
461 
462  double CL = 1.0 - 1./(_eventPtrList.size()*10000);
463  std::cout << "sampleMax = " << sampleMax << std::endl;
464 
465  double maxValue = generalisedPareto_estimateMaximum(vals, CL);
466  std::cout << " maxValue after " << maxValue << std::endl;
467  maxValue *= 1.0 + epsilon;
468  std::cout << "DalitzBWBoxSet::findMaxInList():: Now added "
469  << epsilon * 100 << "% for safety. Returning "
470  << maxValue << std::endl;
471 
472  return maxValue;
473 }
virtual const EVENT_TYPE & getEventRef(unsigned int i) const
Definition: EventPtrList.h:49
DalitzEventPtrList _eventPtrList
double generalisedPareto_estimateMaximum(const std::vector< double > &input, double CL=0.001)
virtual unsigned int size() const
Definition: EventPtrList.h:76
virtual double getWeight() const

◆ fullPdf()

double DalitzBWBoxSet::fullPdf ( DalitzEvent evt)

Definition at line 67 of file DalitzBWBoxSet.cpp.

67  { // (but w/o phase space factor)
68  bool dbThis=false;
69  if(dbThis) cout << "DalitzBWBoxSet::fullPdf called" << endl;
70  if(0 == _ampSum) return 0;
71  double returnVal = _ampSum->RealVal(evt);
72  if(dbThis) cout << "DalitzBWBoxSet::fullPdf result: "
73  << returnVal << endl;
74  return returnVal;
75 }
virtual double RealVal(EVENT_TYPE &evt)=0
MINT::IReturnRealForEvent< IDalitzEvent > * _ampSum

◆ genValue()

double DalitzBWBoxSet::genValue ( const DalitzEvent evt) const

Definition at line 900 of file DalitzBWBoxSet.cpp.

900  {
901  bool dbThis=false;
902  double sum=0;
903  sum = genValueNoPs(evt) * (1.0 - phaseSpaceFrac());
904 
905  if(dbThis) cout << "DalitzBWBoxSet::genValue sum before phase space "
906  << sum << endl;
907  double ps = phaseSpaceFrac()*genValuePs(evt);
908  if(dbThis) cout << "DalitzBWBoxSet::genValue adding ps = "
909  << ps << endl;
910  sum += ps;
911  if(dbThis) cout << "DalitzBWBoxSet::genValue sum after phase space "
912  << sum << endl;
913  return sum;
914 }
double genValuePs(const DalitzEvent &evt) const
double phaseSpaceFrac() const
double genValueNoPs(const DalitzEvent &evt) const

◆ genValueNoPs()

double DalitzBWBoxSet::genValueNoPs ( const DalitzEvent evt) const

Definition at line 856 of file DalitzBWBoxSet.cpp.

856  {
857  bool dbThis=false;
858  double sum=0;
859  if(dbThis){
860  cout << "DalitzBWBoxSet::genValueNoPs called with " << evt
861  << endl;
862  }
863 
864  if(this->empty()) return 0;
865 
866  for(unsigned int i=0; i<this->size(); i++){
867  double val = (*this)[i].genValue(evt);
868  if(dbThis){
869  cout << "DalitzBWBoxSet::genValueNoPs adding " << (*this)[i].name()
870  << " with " << val << endl;
871  }
872  sum += val;
873  }
874  if(phaseSpaceFrac() > 0)sum += _psbox.genValue();
875 
876  if(dbThis){
877  cout << "DalitzBWBoxSet::genValueNoPs returning " << sum << endl;
878  }
879  return sum;
880 }
DalitzPhaseSpaceBox _psbox
double phaseSpaceFrac() const

◆ genValuePs()

double DalitzBWBoxSet::genValuePs ( const DalitzEvent evt) const

Definition at line 881 of file DalitzBWBoxSet.cpp.

881  {
882  //bool dbThis=false;
883  return evt.phaseSpace()/phaseSpaceIntegral();
884 }
virtual double phaseSpace() const
double phaseSpaceIntegral() const

◆ genValueWithLoop()

double DalitzBWBoxSet::genValueWithLoop ( DalitzEvent evt) const

Definition at line 887 of file DalitzBWBoxSet.cpp.

887  {
888  // for debug only
889  //bool dbThis=false;
890  double sum=0;
891  for(int i=0; i < evt.numPermutations(); i++){
892  evt.setPermutationIndex(i);
893  sum += genValue(evt);
894  }
895  evt.setPermutationIndex(0);
896  sum /= ((double) evt.numPermutations());
897  return sum;
898 }
int numPermutations() const
double genValue(const DalitzEvent &evt) const
void setPermutationIndex(int i)

◆ getReady()

void DalitzBWBoxSet::getReady ( )
protected

Definition at line 271 of file DalitzBWBoxSet.cpp.

271  {
272  // checkIntegration();
273  bool dbThis=false;
274  if(this->empty()) return;
275  setup_psbox();
276 
279 
280  // checkIntegration(); // for debug only
281 
282  if(dbThis){
283  cout << "DalitzBWBoxSet::getReady() - got ready, result is this: "
284  << (*this) << "\n ======= OK, no? ====== " << endl;
285  }
286  _ready=true;
287  // am_I_generating_what_I_think_I_am_generating(1000000); // for debug only
288 
289 }
void makeVolumeProbIntervals()
DalitzEventPtrList _eventPtrList

◆ heightSum()

double DalitzBWBoxSet::heightSum ( ) const
protected

Definition at line 538 of file DalitzBWBoxSet.cpp.

538  {
539  bool dbThis=false;
540 
541  double sum = 0;
542  for(unsigned int i=0; i< this->size(); i++){
543  if(dbThis)cout << " height number " << i << ") "
544  << (*this)[i].height()
545  << endl;
546  sum += (*this)[i].height();
547  }
548 
549  if(dbThis)cout << " Volume sum: " << sum;
550  return sum;
551 }

◆ justThrowAwayData()

int DalitzBWBoxSet::justThrowAwayData ( double  maxValue,
MINT::IReturnRealForEvent< IDalitzEvent > *  amps 
)
protected

Definition at line 475 of file DalitzBWBoxSet.cpp.

477  {
478  // bool dbThis=true;
479  std::cout << "EventPtrList::justThrowAwayData:"
480  << " before throwing away data, my size is "
481  << _eventPtrList.size() << std::endl;
482 
483  time_t startTime = time(0);
484 
485  int rememberSize = _eventPtrList.size();
486  unsigned int counter=0;
487 
488  DalitzEventPtrList newList;
489 
490  for(unsigned int i=0; i < _eventPtrList.size(); i++){
491  double d=amps->RealVal(_eventPtrList.getEventRef(i));
492  if(_rnd->Rndm()*maxValue < d){
493  newList.Add( _eventPtrList.getEventRef(counter) );
494  }
495 
496  unsigned int printEvery = 10000; //size()/10;
497  //if(printEvery <=0) printEvery = 500;
498  // if(counter <= 2) printEvery=1;
499  //else if(counter <= 200) printEvery=10000;
500 
501  if(counter < 1 || 0 == counter%(printEvery)){
502  std::cout << " amps for event "
503  << counter
504  << ": " << d
505  << ". " << newList.size()
506  << " events passed ";
507  double deltaT = difftime(time(0), startTime);
508  std::cout << ". Took " << deltaT << " s";
509 
510  if(deltaT > 0){
511  std::cout << "; rate (before/after throwing away) = "
512  << counter/deltaT
513  << " / " << newList.size()/deltaT
514  << " evts/s";
515  }
516  std::cout << std::endl;
517  }
518  counter++;
519  };
520 
521  _eventPtrList = newList;
522  std::cout << "now my size has changed to " << _eventPtrList.size()
523  << std::endl;
524  std::cout << " So the waste factor is ";
525  if(size() > 0) std::cout << rememberSize/_eventPtrList.size();
526  else std::cout << " infinity! - that's big!";
527  std::cout << std::endl;
528 
529 
530  double deltaTFinal = difftime(time(0), startTime);
531  std::cout << " this took " << deltaTFinal/60.0 << " min" << std::endl;
532 
533  return _eventPtrList.size();
534 }
virtual const EVENT_TYPE & getEventRef(unsigned int i) const
Definition: EventPtrList.h:49
virtual bool Add(const EVENT_TYPE &evt)
Definition: EventPtrList.h:88
DalitzEventPtrList _eventPtrList
virtual double RealVal(EVENT_TYPE &evt)=0
TRandom * _rnd
virtual unsigned int size() const
Definition: EventPtrList.h:76

◆ makeEventForOwner() [1/2]

counted_ptr< DalitzEvent > DalitzBWBoxSet::makeEventForOwner ( )
virtual

Definition at line 670 of file DalitzBWBoxSet.cpp.

670  {
671  int NTries = 0;
672  return makeEventForOwner(NTries);
673 }
virtual MINT::counted_ptr< DalitzEvent > makeEventForOwner()

◆ makeEventForOwner() [2/2]

counted_ptr< DalitzEvent > DalitzBWBoxSet::makeEventForOwner ( int &  nTries)
virtual

Definition at line 674 of file DalitzBWBoxSet.cpp.

674  {
675 // bool dbThis=false;
676  static unsigned int Ncalls=0;
677  static unsigned int printEveryNthCall = 10000;
678 
679  Ncalls++;
680  bool printThis = Ncalls < 3 || (0 == Ncalls%printEveryNthCall);
681 
682  NTries = 0;
683  if(! _ready) getReady();
684  if(_maxWeightEstimate < 0) findMax();
685 // if(dbThis) cout << "makeEventForOwner found max" << endl;
686  if(_eventPtrList.size() > 0){
687 // if(dbThis) cout << "popping Event" << endl;
688  return popEventFromList();
689  }
690 // if(dbThis) cout << "making new event" << endl;
691  counted_ptr<DalitzEvent> evtPtr(0);
692 
693  int counter=0;
694  int maxCount = 1000000;
695  int countProblems = 0;
696  do{
697  int tempTries=0;
698  counter++;
699  if(counter > maxCount){
700  cout << "DalitzBWBoxSet::makeEventForOwner tried "
701  << counter << " times unsuccessfully. Giving up"
702  << endl;
703  return evtPtr;
704  }
705  evtPtr = makeWeightedEventForOwner(tempTries);
706  NTries += tempTries;
707  double w = -9999.0;
708  if(0 != evtPtr) w = evtPtr->getWeight();
710  if(w > _maxWeightEstimate){
711  countProblems++;
712  cout << "DalitzBWBoxSet::makeEventForOwner ERROR!!! "
713  << " for the " << countProblems << " th time. "
714  << "\n\t This event's weight > max Weight: "
715  << evtPtr->getWeight() << " > " << _maxWeightEstimate
716  << endl;
717  _maxWeightEstimate = evtPtr->getWeight()*1.3;
718  cout << "\n\t...increased _maxWeightEstimate to: "
720  << endl;
721  }
722  }while(0 == evtPtr || _rnd->Rndm()*_maxWeightEstimate > evtPtr->getWeight());
723 
724  if(printThis){
725  cout << "DalitzBWBoxSet::makeEventForOwner INFO after "
726  << Ncalls << " calls."
727  << " Estimate of max weight " << _maxWeightEstimate
728  << " max weight in sample so far " << _maxWeightInSample
729  << "." << endl;
730  }
731 
732  if(0 != evtPtr) evtPtr->setWeight(1);
733  return evtPtr;
734 }
DalitzEventPtrList _eventPtrList
virtual MINT::counted_ptr< DalitzEvent > makeWeightedEventForOwner()
TRandom * _rnd
double _maxWeightInSample
virtual unsigned int size() const
Definition: EventPtrList.h:76
MINT::counted_ptr< DalitzEvent > popEventFromList()
double _maxWeightEstimate

◆ makeVolumeProbIntervals()

void DalitzBWBoxSet::makeVolumeProbIntervals ( )
protected

Definition at line 573 of file DalitzBWBoxSet.cpp.

573  {
574  bool dbThis=false;
575 
576  if(this->empty()) return;
577  // intervals each with a length proportional
578  // to the volume of the corresponding box.
579  // All put together add up to one.
580  // For random number generation.
581 
582  _volumeProbs.clear();
583  _volumeProbs.resize(this->size());
584 
585  double totalVolume = VolumeSum();
586  double sum=0;
587  for(unsigned int i=0; i < this->size(); i++){
588  // (*this)[i].height() *= 1./totalVolume;
589  sum += (*this)[i].volume()/totalVolume;
590  if(dbThis){
591  // cout << " with height " << (*this)[i].height();
592  cout << " + " << (*this)[i].volume()/totalVolume;
593  cout << " = \t volume probs [" << i <<"] = " << sum << endl;
594  }
595  _volumeProbs[i] = sum;
596  }
597 }
double VolumeSum() const
std::vector< double > _volumeProbs

◆ makeWeightedApproxEventForOwner() [1/2]

counted_ptr< DalitzEvent > DalitzBWBoxSet::makeWeightedApproxEventForOwner ( )
protectedvirtual

Definition at line 785 of file DalitzBWBoxSet.cpp.

785  {
786  int NTries = 0;
787  return makeWeightedApproxEventForOwner(NTries);
788 }
virtual MINT::counted_ptr< DalitzEvent > makeWeightedApproxEventForOwner()

◆ makeWeightedApproxEventForOwner() [2/2]

counted_ptr< DalitzEvent > DalitzBWBoxSet::makeWeightedApproxEventForOwner ( int &  nTries)
protectedvirtual

Definition at line 789 of file DalitzBWBoxSet.cpp.

789  {
790  //bool dbThis=false;
792  int maxTries = 10000000;
793  NTries = 0;
794  while((! ptr) && NTries < maxTries){
795  ptr=tryEventForOwner();
796  NTries++;
797  }
798  if(! ptr){
799  cout << "ERROR in DalitzBWBoxSet::makeWeightedEventForOwner() "
800  << " failed to make event after " << maxTries
801  << " tries!"
802  << endl;
803  return ptr;
804  }
805  return ptr;
806 }
virtual MINT::counted_ptr< DalitzEvent > tryEventForOwner()

◆ makeWeightedEventForOwner() [1/2]

counted_ptr< DalitzEvent > DalitzBWBoxSet::makeWeightedEventForOwner ( )
virtual

Definition at line 760 of file DalitzBWBoxSet.cpp.

760  {
761  int NTries = 0;
762  return makeWeightedEventForOwner(NTries);
763 }
virtual MINT::counted_ptr< DalitzEvent > makeWeightedEventForOwner()

◆ makeWeightedEventForOwner() [2/2]

counted_ptr< DalitzEvent > DalitzBWBoxSet::makeWeightedEventForOwner ( int &  nTries)
virtual

Definition at line 764 of file DalitzBWBoxSet.cpp.

764  {
765 // bool dbThis=false;
767  if(! ptr) return ptr;
768  double w = ptr->getWeight();
769 // if(dbThis) cout << "phase space weight " << w << endl;
770 
771  double full = fullPdf(*ptr);
772  double gen = genValueNoPs(*ptr);
773 // if(dbThis) cout << ", full weight " << w
774 // << " * " << full << " / " << gen << " = ";
775 
776  w *= full/gen;
777 // if(dbThis) cout << w << endl;
778 
779  ptr->setWeight(w);
780  ptr->setGeneratorPdfRelativeToPhaseSpace(full);
781 
782  return ptr;
783 }
double fullPdf(DalitzEvent &evt)
virtual MINT::counted_ptr< DalitzEvent > makeWeightedApproxEventForOwner()
double genValueNoPs(const DalitzEvent &evt) const

◆ newEvent()

counted_ptr< IDalitzEvent > DalitzBWBoxSet::newEvent ( )
virtual

Implements MINT::IUnweightedEventGenerator< IDalitzEvent >.

Definition at line 736 of file DalitzBWBoxSet.cpp.

736  {
737  bool dbThis=false;
738  if(! dbThis){
740  return returnThis;
741  } else {
743  return returnThis;
744  }
745 }
virtual MINT::counted_ptr< DalitzEvent > makeWeightedEventForOwner()
virtual MINT::counted_ptr< DalitzEvent > tryEventForOwner()

◆ newUnweightedEvent()

counted_ptr< IDalitzEvent > DalitzBWBoxSet::newUnweightedEvent ( )
virtual

Implements MINT::IUnweightedEventGenerator< IDalitzEvent >.

Definition at line 746 of file DalitzBWBoxSet.cpp.

746  {
748  return returnThis;
749 }
virtual MINT::counted_ptr< DalitzEvent > makeEventForOwner()

◆ phaseSpaceEvent()

counted_ptr< DalitzEvent > DalitzBWBoxSet::phaseSpaceEvent ( )
virtual

Definition at line 620 of file DalitzBWBoxSet.cpp.

620  {
621  if(this->empty()) return counted_ptr<DalitzEvent>(0);
622  if(! ready()) getReady();
623  return _psbox.makeEventForOwner();
624 }
bool ready() const
MINT::counted_ptr< DalitzEvent > makeEventForOwner()
DalitzPhaseSpaceBox _psbox

◆ phaseSpaceFrac()

double DalitzBWBoxSet::phaseSpaceFrac ( ) const
inline

Definition at line 85 of file DalitzBWBoxSet.h.

85 {return _phaseSpaceFrac;}
double _phaseSpaceFrac

◆ phaseSpaceIntegral()

double DalitzBWBoxSet::phaseSpaceIntegral ( ) const

Definition at line 809 of file DalitzBWBoxSet.cpp.

809  {
810  // mainly for debug.
811  bool dbThis=false;
812 
814  if(this->empty())return -9999;
815 
816  if(dbThis) cout << " calculating phaseSpaceIntegral " << endl;
817  DalitzEventPattern pat = (*this)[0].pattern();
818  DalitzBWBox box(pat);
819 
821  cout << "compare to " << p4.getVal(pat) << endl;
822 
823  int maxEvents = 10000;
824  int maxTries = 10000 * maxEvents;
825  int nTries=0;
826  double sum=0, sumsq=0;
827  for(int i=0; i < maxEvents && nTries < maxTries; i++){
828  int triesForThisEvent=0;
829  counted_ptr<DalitzEvent> ptr(box.makeEventForOwner(triesForThisEvent));
830  nTries += triesForThisEvent;
831  if(! ptr) continue;
832  double val = ptr->phaseSpace();
833  sum += val;
834  sumsq += val*val;
835  if(dbThis && (0 == i%1000 || i < 100)){
836  cout << " i = " << i << ", nTries = " << nTries
837  << " val = " << val << " sum " << sum << endl;
838  }
839  }
840  double mean = sum/((double)nTries);
841  double meanOfSq = sumsq/((double)nTries);
842  double variance = meanOfSq - mean*mean;
843  double error = sqrt(variance)/sqrt((double)nTries);
844 
845  _phaseSpaceIntegral = sum/((double)nTries) * box.area().size();
846  // _phaseSpaceIntegral = sum/((double)maxEvents);// * box.volume();
847  // double psVolume = box.volume() * ((double)maxEvents)/((double)nTries);
848  //double psVolume = box.volume();
849  //_phaseSpaceIntegral = sum/((double)maxEvents);// * psVolume;
850  cout << "phaseSpaceIntegral: returning " << _phaseSpaceIntegral
851  << " relativeError: " << error/mean * 100 << "%" << endl;
852 
853  return _phaseSpaceIntegral;
854 }
double _phaseSpaceIntegral
double getVal(const DalitzEventPattern &_pat)

◆ pick_ps_prob()

double DalitzBWBoxSet::pick_ps_prob ( )
protected

Definition at line 249 of file DalitzBWBoxSet.cpp.

249  {
250  bool dbThis=false;
251  if(_phaseSpaceFrac <= 0) return 0;
252  if(_pick_ps_prob < 0){
254  if(dbThis){
255  cout << " DalitzBWBoxSet::pick_ps_prob() = " << _pick_ps_prob << endl;
256  }
257  }
258  return _pick_ps_prob;
259 }
double calc_pick_ps_prob() const
double _pick_ps_prob
double _phaseSpaceFrac

◆ pickRandomVolume()

int DalitzBWBoxSet::pickRandomVolume ( )
protected

Definition at line 599 of file DalitzBWBoxSet.cpp.

599  {
600  if(! ready()) getReady();
601 
602  if(_volumeProbs.size() != this->size()){
604  }
605 
606  double rndNumber = _rnd->Rndm();
607  for(unsigned int i=0; i< _volumeProbs.size(); i++){
608  if(_volumeProbs[i] > rndNumber) return i;
609  }
610  cout << "WARNING in DalitzBWBoxSet::pickRandomVolume():"
611  << " How odd - should never have gotten here."
612  << " rndNumber = " << rndNumber
613  << ", _volumeProbs[this->size()-1] = "
614  << _volumeProbs[this->size()-1]
615  << endl;
616  return this->size()-1;
617 }
void makeVolumeProbIntervals()
std::vector< double > _volumeProbs
bool ready() const
TRandom * _rnd

◆ popEventFromList()

counted_ptr< DalitzEvent > DalitzBWBoxSet::popEventFromList ( )
protected

Definition at line 751 of file DalitzBWBoxSet.cpp.

751  {
752  if(_eventPtrList.empty()){
753  return counted_ptr<DalitzEvent>(0);
754  }
755  // counted_ptr<DalitzEvent> evt(new DalitzEvent(_eventPtrList.getEventRef(_eventPtrList.size()-1]));
756  //_eventPtrList.resize(_eventPtrList.size()-1);
758 }
DalitzEventPtrList _eventPtrList
virtual MINT::counted_ptr< EVENT_TYPE > popLastEventPtr()
Definition: EventPtrList.h:80

◆ print()

void DalitzBWBoxSet::print ( std::ostream &  os) const

Definition at line 915 of file DalitzBWBoxSet.cpp.

915  {
916  for(unsigned int i=0; i < this->size(); i++){
917  os << " box " << i << " )" << (*this)[i] << "\n";
918  }
919  return;
920 }

◆ ready()

bool DalitzBWBoxSet::ready ( ) const
inlineprotected

Definition at line 66 of file DalitzBWBoxSet.h.

66 {return _ready;}

◆ set_psbox_height_and_weight()

void DalitzBWBoxSet::set_psbox_height_and_weight ( )
protected

Definition at line 220 of file DalitzBWBoxSet.cpp.

220  {
221  bool dbThis=false;
222  if(phaseSpaceFrac() <= 0) return;
223 
224  double rat = calc_pick_ps_prob()/phaseSpaceFrac();
225  double w=1;
226  if(rat > 0) w=rat;
227  _psbox.weight() *= w;
228  _psbox.height() /= w;
229 
230  if(dbThis){
231  cout << "h " << _psbox.height()
232  << ", w " << _psbox.weight()
233  << endl;
234  }
235 }
double calc_pick_ps_prob() const
DalitzPhaseSpaceBox _psbox
double phaseSpaceFrac() const

◆ setPhaseSpaceFrac()

void DalitzBWBoxSet::setPhaseSpaceFrac ( double  ps)
inline

Definition at line 84 of file DalitzBWBoxSet.h.

84 {_phaseSpaceFrac = ps; getReady();}
double _phaseSpaceFrac

◆ setRnd()

bool DalitzBWBoxSet::setRnd ( TRandom *  rnd = gRandom)
virtual

Implements MINT::IUnweightedEventGenerator< IDalitzEvent >.

Definition at line 89 of file DalitzBWBoxSet.cpp.

89  {
90  if(0 == rnd) _rnd = gRandom;
91  else _rnd = rnd; // this *should* do it, but for safety:
92  for(unsigned int i=0; i< this->size(); i++){
93  (*this)[i].setRnd(_rnd);
94  }
95  return true;
96 }
TRandom * _rnd

◆ setUnWeightPs()

void DalitzBWBoxSet::setUnWeightPs ( bool  doSo = true)

Definition at line 567 of file DalitzBWBoxSet.cpp.

567  {
568  for(unsigned int i=0; i< this->size(); i++){
569  (*this)[i].setUnWeightPs(doSo);
570  }
571 }

◆ setup_psbox()

void DalitzBWBoxSet::setup_psbox ( )
protected

Definition at line 261 of file DalitzBWBoxSet.cpp.

261  {
262  _psbox.setPattern(this->begin()->pattern());
263 
265  _psbox.weight()=1.0;
266  for(int i=0; i < 100; i++){
268  }
269 }
void setPattern(const DalitzEventPattern &pat)
void set_psbox_height_and_weight()
double heightSum() const
std::vector< DalitzBWBox >::iterator begin()
DalitzPhaseSpaceBox _psbox
double phaseSpaceFrac() const

◆ tryEventForOwner()

counted_ptr< DalitzEvent > DalitzBWBoxSet::tryEventForOwner ( )
virtual

Definition at line 626 of file DalitzBWBoxSet.cpp.

626  {
627 // bool dbThis=false;
628  if(this->empty()){
629  cout << "DalitzBWBoxSet::tryEventForOwner ERROR: "
630  << " you called me, but there are no boxes"
631  << "\n\t returning 0-ptr" << endl;
632  return counted_ptr<DalitzEvent>(0);
633  }
634  if(! ready()) getReady();
635 
636  counted_ptr<DalitzEvent> evtPtr(0);
637  if(_rnd->Rndm() < pick_ps_prob()){
638  evtPtr = phaseSpaceEvent();
639 /* if(dbThis){
640  cout << "picked phaseSpace " << endl;
641  }*/
642  }else{
643  int vol = pickRandomVolume();
644  evtPtr = ((*this)[vol].tryEventForOwner());
645 /* if(dbThis){
646  cout << "picked volume number: " << vol << endl;
647  }*/
648  }
649 /* if(dbThis && 0 != evtPtr){
650  cout << "weight in DalitzBWBoxSet::tryEventForOwner() "
651  << evtPtr->getWeight() << endl;
652  }*/
653  if(0 != evtPtr){
654 /* if(dbThis) {
655  cout << "DalitzBWBoxSet::tryEventForOwner() calling:"
656  << " setGeneratorPdfRelativeToPhaseSpace(genValueNoPs(*evtPtr))"
657  << endl;
658  }*/
659  evtPtr->setGeneratorPdfRelativeToPhaseSpace(genValueNoPs(*evtPtr));
660 // if(dbThis) cout << " .. done that." << endl;
661  }
662 /* if(dbThis){
663  cout << " DalitzBWBoxSet::tryEventForOwner(): Returning " << evtPtr << endl;
664  if(0 != evtPtr){
665  cout << " ... with weight " << evtPtr->getWeight() << endl;
666  }
667  }*/
668  return evtPtr;
669 }
bool ready() const
TRandom * _rnd
virtual MINT::counted_ptr< DalitzEvent > phaseSpaceEvent()
double genValueNoPs(const DalitzEvent &evt) const

◆ VolumeSum()

double DalitzBWBoxSet::VolumeSum ( ) const
protected

Definition at line 552 of file DalitzBWBoxSet.cpp.

552  {
553  bool dbThis=false;
554 
555  double sum = 0;
556  for(unsigned int i=0; i< this->size(); i++){
557  if(dbThis)cout << " volume number " << i << ") "
558  << (*this)[i].volume()
559  << endl;
560  sum += (*this)[i].volume();
561  }
562 
563  if(dbThis)cout << " Volume sum: " << sum;
564  return sum;
565 }

Member Data Documentation

◆ __phaseSpaceFracDefaultValue

double DalitzBWBoxSet::__phaseSpaceFracDefaultValue =0.25
staticprotected

Definition at line 26 of file DalitzBWBoxSet.h.

◆ _ampSum

MINT::IReturnRealForEvent<IDalitzEvent>* DalitzBWBoxSet::_ampSum
protected

Definition at line 34 of file DalitzBWBoxSet.h.

◆ _eventPtrList

DalitzEventPtrList DalitzBWBoxSet::_eventPtrList
protected

Definition at line 28 of file DalitzBWBoxSet.h.

◆ _maxWeightEstimate

double DalitzBWBoxSet::_maxWeightEstimate
protected

Definition at line 31 of file DalitzBWBoxSet.h.

◆ _maxWeightInSample

double DalitzBWBoxSet::_maxWeightInSample
protected

Definition at line 32 of file DalitzBWBoxSet.h.

◆ _phaseSpaceFrac

double DalitzBWBoxSet::_phaseSpaceFrac
protected

Definition at line 40 of file DalitzBWBoxSet.h.

◆ _phaseSpaceIntegral

double DalitzBWBoxSet::_phaseSpaceIntegral
mutableprotected

Definition at line 41 of file DalitzBWBoxSet.h.

◆ _pick_ps_prob

double DalitzBWBoxSet::_pick_ps_prob
protected

Definition at line 44 of file DalitzBWBoxSet.h.

◆ _psbox

DalitzPhaseSpaceBox DalitzBWBoxSet::_psbox
protected

Definition at line 43 of file DalitzBWBoxSet.h.

◆ _ready

bool DalitzBWBoxSet::_ready
protected

Definition at line 36 of file DalitzBWBoxSet.h.

◆ _rnd

TRandom* DalitzBWBoxSet::_rnd
protected

Definition at line 38 of file DalitzBWBoxSet.h.

◆ _volumeProbs

std::vector<double> DalitzBWBoxSet::_volumeProbs
protected

Definition at line 37 of file DalitzBWBoxSet.h.


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