MINT2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
DalitzBox Class Reference

#include <DalitzBox.h>

Public Member Functions

void getReady ()
 
void setFlatPhaseSpace (bool flat=true)
 
double amps (IDalitzEvent &ep)
 
double phaseSpace (IDalitzEvent &ep)
 
double ampsWithPhaseSpace (IDalitzEvent &ep)
 
 DalitzBox ()
 
 DalitzBox (const DalitzEventPattern &pat, MINT::IReturnRealForEvent< IDalitzEvent > *amps=0, TRandom *rnd=gRandom)
 
 DalitzBox (const DalitzEventPattern &pat, const DalitzCoordinate &limit, MINT::IReturnRealForEvent< IDalitzEvent > *amps=0, TRandom *rnd=gRandom)
 
 DalitzBox (const DalitzEventPattern &pat, const std::vector< DalitzCoordinate > &limits, MINT::IReturnRealForEvent< IDalitzEvent > *amps=0, TRandom *rnd=gRandom)
 
 DalitzBox (const DalitzBox &other)
 
 ~DalitzBox ()
 
void setNumber (int num)
 
int number () const
 
void setName (const std::string &name)
 
const std::string & name () const
 
void setGuessedHeight (double h)
 
double guessedHeight () const
 
const MappedDalitzAreaarea () const
 
MappedDalitzAreaarea ()
 
double height () const
 
double setHeight (double h)
 
DalitzEventListeventList ()
 
const DalitzEventListeventList () const
 
double volume () const
 
void setDaddy (const DalitzBox *daddy)
 
bool setAmps (MINT::IReturnRealForEvent< IDalitzEvent > *amps)
 
bool insideArea (const DalitzEvent &evt) const
 
bool insideDaddysArea (const DalitzEvent &evt) const
 
bool insideMyOrDaddysArea (const DalitzEvent &evt) const
 
MINT::counted_ptr< DalitzEventtryEventForOwner ()
 
MINT::counted_ptr< DalitzEventtryWeightedEventForOwner ()
 
void encloseInPhaseSpaceArea ()
 
std::vector< DalitzBoxsplit (unsigned int nWays) const
 
std::vector< DalitzBoxsplitIfWiderThan (double maxWidth) const
 
bool setRnd (TRandom *rnd=gRandom)
 
void print (std::ostream &os=std::cout) const
 

Private Member Functions

int makeFlatEventsKeepAll (int N)
 
bool estimateHeight (std::vector< double > &vals)
 
bool estimateHeight_old (std::vector< double > &vals)
 
bool estimateHeightMinuit ()
 
bool makeStarterSet ()
 
int throwAwayData (const std::vector< double > &vals)
 
MINT::counted_ptr< DalitzEventtryNewEvent ()
 
MINT::counted_ptr< DalitzEventtryEventFromList ()
 
MINT::counted_ptr< DalitzEventpopEventFromList ()
 
double getEventsPdf (DalitzEvent &evt)
 

Private Attributes

double _max_s0
 
double _max_s1
 
double _max_s2
 
double _max_s3
 
double _max_s4
 
double _maxPhaseSpace
 
int _number
 
std::string _name
 
bool _ready
 
MappedDalitzArea _area
 
DalitzEventPattern _pat
 
MINT::IReturnRealForEvent< IDalitzEvent > * _amps
 
TRandom * _rnd
 
double _height
 
DalitzEventList _eventList
 
int _nTries
 
int _nEventsForTries
 
const DalitzBox_daddy
 
double _guessedHeight
 
unsigned int _heightProblems
 
bool _flatPhaseSpace
 

Detailed Description

Definition at line 22 of file DalitzBox.h.

Constructor & Destructor Documentation

◆ DalitzBox() [1/5]

DalitzBox::DalitzBox ( )

Definition at line 76 of file DalitzBox.cpp.

77  : _max_s0(-1), _max_s1(-1), _max_s2(-1), _max_s3(-1), _max_s4(-1)
78  , _maxPhaseSpace(-9999)
79  , _number(-1)
80  , _name("noName")
81  , _ready(false)
82  , _area()
83  , _pat()
84  , _amps(0)
85  , _rnd(0)
86  , _height(-9999)
87  , _eventList()
88  , _nTries(0)
89  , _nEventsForTries(0)
90  , _daddy(0)
91  , _guessedHeight(-9999)
92  , _heightProblems(0)
93  , _flatPhaseSpace(0)
94 {}
double _max_s4
Definition: DalitzBox.h:23
MappedDalitzArea _area
Definition: DalitzBox.h:31
bool _flatPhaseSpace
Definition: DalitzBox.h:47
const DalitzBox * _daddy
Definition: DalitzBox.h:42
DalitzEventList _eventList
Definition: DalitzBox.h:38
double _max_s3
Definition: DalitzBox.h:23
int _number
Definition: DalitzBox.h:26
double _max_s2
Definition: DalitzBox.h:23
double _maxPhaseSpace
Definition: DalitzBox.h:24
MINT::IReturnRealForEvent< IDalitzEvent > * _amps
Definition: DalitzBox.h:34
double _height
Definition: DalitzBox.h:37
int _nTries
Definition: DalitzBox.h:40
double _max_s0
Definition: DalitzBox.h:23
double _max_s1
Definition: DalitzBox.h:23
TRandom * _rnd
Definition: DalitzBox.h:36
std::string _name
Definition: DalitzBox.h:27
int _nEventsForTries
Definition: DalitzBox.h:41
bool _ready
Definition: DalitzBox.h:29
unsigned int _heightProblems
Definition: DalitzBox.h:45
double _guessedHeight
Definition: DalitzBox.h:44
DalitzEventPattern _pat
Definition: DalitzBox.h:33

◆ DalitzBox() [2/5]

DalitzBox::DalitzBox ( const DalitzEventPattern pat,
MINT::IReturnRealForEvent< IDalitzEvent > *  amps = 0,
TRandom *  rnd = gRandom 
)

Definition at line 97 of file DalitzBox.cpp.

100  : _max_s0(-1), _max_s1(-1), _max_s2(-1), _max_s3(-1), _max_s4(-1)
101  , _maxPhaseSpace(-9999)
102  , _number(-1)
103  , _name("noName")
104  , _ready(false)
105  , _area(pat, rnd)
106  , _pat(pat)
107  , _amps(0)
108  , _rnd(rnd)
109  , _height(-9999)
110  , _eventList()
111  , _nTries(0)
112  , _nEventsForTries(0)
113  , _daddy(0)
114  , _guessedHeight(-9999)
115  , _heightProblems(0)
116  , _flatPhaseSpace(0)
117 {
118  setAmps(amps);
119 }
double amps(IDalitzEvent &ep)
Definition: DalitzBox.cpp:268
double _max_s4
Definition: DalitzBox.h:23
MappedDalitzArea _area
Definition: DalitzBox.h:31
bool _flatPhaseSpace
Definition: DalitzBox.h:47
const DalitzBox * _daddy
Definition: DalitzBox.h:42
DalitzEventList _eventList
Definition: DalitzBox.h:38
double _max_s3
Definition: DalitzBox.h:23
int _number
Definition: DalitzBox.h:26
double _max_s2
Definition: DalitzBox.h:23
double _maxPhaseSpace
Definition: DalitzBox.h:24
MINT::IReturnRealForEvent< IDalitzEvent > * _amps
Definition: DalitzBox.h:34
double _height
Definition: DalitzBox.h:37
int _nTries
Definition: DalitzBox.h:40
double _max_s0
Definition: DalitzBox.h:23
double _max_s1
Definition: DalitzBox.h:23
TRandom * _rnd
Definition: DalitzBox.h:36
std::string _name
Definition: DalitzBox.h:27
int _nEventsForTries
Definition: DalitzBox.h:41
bool _ready
Definition: DalitzBox.h:29
unsigned int _heightProblems
Definition: DalitzBox.h:45
bool setAmps(MINT::IReturnRealForEvent< IDalitzEvent > *amps)
Definition: DalitzBox.cpp:198
double _guessedHeight
Definition: DalitzBox.h:44
DalitzEventPattern _pat
Definition: DalitzBox.h:33

◆ DalitzBox() [3/5]

DalitzBox::DalitzBox ( const DalitzEventPattern pat,
const DalitzCoordinate limit,
MINT::IReturnRealForEvent< IDalitzEvent > *  amps = 0,
TRandom *  rnd = gRandom 
)

Definition at line 121 of file DalitzBox.cpp.

125  : _max_s0(-1), _max_s1(-1), _max_s2(-1), _max_s3(-1), _max_s4(-1)
126  , _maxPhaseSpace(-9999)
127  , _number(-1)
128  , _name("noName")
129  , _ready(false)
130  , _area(pat, limit, rnd)
131  , _pat(pat)
132  , _amps(0)
133  , _rnd(rnd)
134  , _height(-9999)
135  , _eventList()
136  , _nTries(0)
137  , _nEventsForTries(0)
138  , _daddy(0)
139  , _guessedHeight(-9999)
140  , _heightProblems(0)
141  , _flatPhaseSpace(0)
142 {
143  setAmps(amps);
144 }
double amps(IDalitzEvent &ep)
Definition: DalitzBox.cpp:268
double _max_s4
Definition: DalitzBox.h:23
MappedDalitzArea _area
Definition: DalitzBox.h:31
bool _flatPhaseSpace
Definition: DalitzBox.h:47
const DalitzBox * _daddy
Definition: DalitzBox.h:42
DalitzEventList _eventList
Definition: DalitzBox.h:38
double _max_s3
Definition: DalitzBox.h:23
int _number
Definition: DalitzBox.h:26
double _max_s2
Definition: DalitzBox.h:23
double _maxPhaseSpace
Definition: DalitzBox.h:24
MINT::IReturnRealForEvent< IDalitzEvent > * _amps
Definition: DalitzBox.h:34
double _height
Definition: DalitzBox.h:37
int _nTries
Definition: DalitzBox.h:40
double _max_s0
Definition: DalitzBox.h:23
double _max_s1
Definition: DalitzBox.h:23
TRandom * _rnd
Definition: DalitzBox.h:36
std::string _name
Definition: DalitzBox.h:27
int _nEventsForTries
Definition: DalitzBox.h:41
bool _ready
Definition: DalitzBox.h:29
unsigned int _heightProblems
Definition: DalitzBox.h:45
bool setAmps(MINT::IReturnRealForEvent< IDalitzEvent > *amps)
Definition: DalitzBox.cpp:198
double _guessedHeight
Definition: DalitzBox.h:44
DalitzEventPattern _pat
Definition: DalitzBox.h:33

◆ DalitzBox() [4/5]

DalitzBox::DalitzBox ( const DalitzEventPattern pat,
const std::vector< DalitzCoordinate > &  limits,
MINT::IReturnRealForEvent< IDalitzEvent > *  amps = 0,
TRandom *  rnd = gRandom 
)

Definition at line 146 of file DalitzBox.cpp.

150  : _max_s0(-1), _max_s1(-1), _max_s2(-1), _max_s3(-1), _max_s4(-1)
151  , _maxPhaseSpace(-9999)
152  , _number(-1)
153  , _name("noName")
154  , _ready(false)
155  , _area(pat, limits, rnd)
156  , _pat(pat)
157  , _amps(0)
158  , _rnd(rnd)
159  , _height(-9999)
160  , _eventList()
161  , _nTries(0)
162  , _nEventsForTries(0)
163  , _daddy(0)
164  , _guessedHeight(-9999)
165  , _heightProblems(0)
166  , _flatPhaseSpace(0)
167 {
168  setAmps(amps);
169 }
double amps(IDalitzEvent &ep)
Definition: DalitzBox.cpp:268
double _max_s4
Definition: DalitzBox.h:23
MappedDalitzArea _area
Definition: DalitzBox.h:31
bool _flatPhaseSpace
Definition: DalitzBox.h:47
const DalitzBox * _daddy
Definition: DalitzBox.h:42
DalitzEventList _eventList
Definition: DalitzBox.h:38
double _max_s3
Definition: DalitzBox.h:23
int _number
Definition: DalitzBox.h:26
double _max_s2
Definition: DalitzBox.h:23
double _maxPhaseSpace
Definition: DalitzBox.h:24
MINT::IReturnRealForEvent< IDalitzEvent > * _amps
Definition: DalitzBox.h:34
double _height
Definition: DalitzBox.h:37
int _nTries
Definition: DalitzBox.h:40
double _max_s0
Definition: DalitzBox.h:23
double _max_s1
Definition: DalitzBox.h:23
TRandom * _rnd
Definition: DalitzBox.h:36
std::string _name
Definition: DalitzBox.h:27
int _nEventsForTries
Definition: DalitzBox.h:41
bool _ready
Definition: DalitzBox.h:29
unsigned int _heightProblems
Definition: DalitzBox.h:45
bool setAmps(MINT::IReturnRealForEvent< IDalitzEvent > *amps)
Definition: DalitzBox.cpp:198
double _guessedHeight
Definition: DalitzBox.h:44
DalitzEventPattern _pat
Definition: DalitzBox.h:33

◆ DalitzBox() [5/5]

DalitzBox::DalitzBox ( const DalitzBox other)

Definition at line 171 of file DalitzBox.cpp.

172  : _max_s0(other._max_s0)
173  , _max_s1(other._max_s1)
174  , _max_s2(other._max_s2)
175  , _max_s3(other._max_s3)
176  , _max_s4(other._max_s4)
178  , _number(other._number)
179  , _name(other._name)
180  , _ready(other._ready)
181  , _area(other._area)
182  , _pat(other._pat)
183  , _amps(other._amps)
184  , _rnd(other._rnd)
185  , _height(other._height)
186  , _eventList(other._eventList) // expensive!
187  , _nTries(other._nTries)
189  , _daddy(other._daddy)
193 {
194  // _ready = false;
195  // cout << "copying box" << endl;
196 }
double _max_s4
Definition: DalitzBox.h:23
MappedDalitzArea _area
Definition: DalitzBox.h:31
bool _flatPhaseSpace
Definition: DalitzBox.h:47
const DalitzBox * _daddy
Definition: DalitzBox.h:42
DalitzEventList _eventList
Definition: DalitzBox.h:38
double _max_s3
Definition: DalitzBox.h:23
int _number
Definition: DalitzBox.h:26
double _max_s2
Definition: DalitzBox.h:23
double _maxPhaseSpace
Definition: DalitzBox.h:24
MINT::IReturnRealForEvent< IDalitzEvent > * _amps
Definition: DalitzBox.h:34
double _height
Definition: DalitzBox.h:37
int _nTries
Definition: DalitzBox.h:40
double _max_s0
Definition: DalitzBox.h:23
double _max_s1
Definition: DalitzBox.h:23
TRandom * _rnd
Definition: DalitzBox.h:36
std::string _name
Definition: DalitzBox.h:27
int _nEventsForTries
Definition: DalitzBox.h:41
bool _ready
Definition: DalitzBox.h:29
unsigned int _heightProblems
Definition: DalitzBox.h:45
double _guessedHeight
Definition: DalitzBox.h:44
DalitzEventPattern _pat
Definition: DalitzBox.h:33

◆ ~DalitzBox()

DalitzBox::~DalitzBox ( )

Definition at line 206 of file DalitzBox.cpp.

206  {
207 }

Member Function Documentation

◆ amps()

double DalitzBox::amps ( IDalitzEvent ep)

Definition at line 268 of file DalitzBox.cpp.

268  {
269  bool dbThis=false;
270 
271  if(0 == _amps) return 1;
272  if(dbThis) cout << " the event: " << endl;
273  if(dbThis) evt.print();
274  if(dbThis) cout << " ... now getting RealVal() " << endl;
275  double val = _amps->RealVal(evt);
276  if(dbThis) cout << " all done, returning " << val << endl;
277  return val;
278 }
virtual double RealVal(EVENT_TYPE &evt)=0
MINT::IReturnRealForEvent< IDalitzEvent > * _amps
Definition: DalitzBox.h:34

◆ ampsWithPhaseSpace()

double DalitzBox::ampsWithPhaseSpace ( IDalitzEvent ep)

Definition at line 285 of file DalitzBox.cpp.

285  {
286  bool dbThis=false;
287 
288  double a = amps(evt_in);
289  if(dbThis) cout << "amps " << a << endl;
290  double ps = phaseSpace(evt_in);
291  if(dbThis) cout << "ps " << ps << endl;
292 
293  return a*ps;
294 }
double amps(IDalitzEvent &ep)
Definition: DalitzBox.cpp:268
double phaseSpace(IDalitzEvent &ep)
Definition: DalitzBox.cpp:280

◆ area() [1/2]

const MappedDalitzArea& DalitzBox::area ( ) const
inline

Definition at line 103 of file DalitzBox.h.

103 {return _area;}
MappedDalitzArea _area
Definition: DalitzBox.h:31

◆ area() [2/2]

MappedDalitzArea& DalitzBox::area ( )
inline

Definition at line 104 of file DalitzBox.h.

104 {return _area;}
MappedDalitzArea _area
Definition: DalitzBox.h:31

◆ encloseInPhaseSpaceArea()

void DalitzBox::encloseInPhaseSpaceArea ( )
inline

Definition at line 128 of file DalitzBox.h.

128  {
130  }
const MappedDalitzArea & area() const
Definition: DalitzBox.h:103
void encloseInPhaseSpaceArea()

◆ estimateHeight()

bool DalitzBox::estimateHeight ( std::vector< double > &  vals)
private

Definition at line 406 of file DalitzBox.cpp.

407  {
408  bool dbThis=false;
409  int maxEvents = 100000;
410  int maxTries = 10000000;
411  double meanPhaseSpaceSum = 0;
412  if(fastTest){
413  maxEvents = 10000;
414  maxTries = 1000000;
415  }
416  if(veryFastTest || ultraFast){
417  maxEvents = 1000;
418  maxTries = 1000000;
419  }
420 
421  if(guessedHeight() > 0){
423  return 0;
424  }
425 
426  // double saveFactor = 2.0;
427 
428  cout << "DalitzBox::estimateHeight" << endl;
429  //time_t startTime = time(0);
430 
431  double max = -9999;
432 
433  int numEvents=0, counter=0;
434  while(numEvents < maxEvents && counter < maxTries){
435  counter++;
436  double tmp_s0 = _rnd->Rndm();
437  double tmp_s1 = _rnd->Rndm();
438  double tmp_s2 = _rnd->Rndm();
439  double tmp_s3 = _rnd->Rndm();
440  double tmp_s4 = _rnd->Rndm();
441  counted_ptr<DalitzEvent> tmpEvtPtr(area().makeEventForOwner(tmp_s0, tmp_s1, tmp_s2, tmp_s3, tmp_s4));
442  if(0 == tmpEvtPtr) continue;
443  if(dbThis) cout << "estimate height got event "
444  << " printing it: " << endl;
445  if(dbThis) cout << *tmpEvtPtr << endl;
446 
447  //cout << " found a non-zero event!!!" << endl;
448  if(this->insideDaddysArea(*tmpEvtPtr)) continue;
449 
450  numEvents++;
451 
452 
453  DalitzEvent tmpEvt(*tmpEvtPtr);
454  double val = ampsWithPhaseSpace(tmpEvt);
455  vals.push_back(val);
456  if(val > max){
457  max=val;
458  _max_s0 = tmp_s0;
459  _max_s1 = tmp_s1;
460  _max_s2 = tmp_s2;
461  _max_s3 = tmp_s3;
462  _max_s4 = tmp_s4;
463  }
464  double p = phaseSpace(tmpEvt);
465 
466  meanPhaseSpaceSum += p;
467  if(p > _maxPhaseSpace){
468  _maxPhaseSpace = p;
469  }
470  };
471 
472  double meanPhaseSpace = meanPhaseSpaceSum/((double)numEvents);
473  cout << "mean phase space " << meanPhaseSpace
474  << ", max: " << _maxPhaseSpace << endl;
475 
476  //double epsilon = 0.25;
477 
478  double CL = 1.0 - 1.e-7;
479  std::cout << "actual max = " << max << std::endl;
480 
481  if(numEvents < 50){
482  cout << " no Paret of only " << _eventList.size()
483  << " events. Taking 5*max = 5*" << max
484  << " = " << 5*max
485  << " and return false." << endl;
486  _height = 5.0 * max;
487  return false;
488  }
489 
490  double actualMax=-1, paretoMax=-1;
491 
493  , CL
494  , actualMax
495  , paretoMax
496  );
497 
498  std::cout << " Pareto max " << paretoMax << std::endl;
499  /*
500  max *= 1.0 + epsilon;
501  std::cout << "Now added " << epsilon * 100 << "% for safety "
502  << max << std::endl;
503 
504  max *= saveFactor;
505 
506  std::cout << "and multiplied by safety factor "
507  << saveFactor
508  << " giving " << max
509  << endl;
510  */
511  cout << "compare to guessed height: "
512  << guessedHeight()*_maxPhaseSpace << endl;
513  _height = max;
514 
515  if(fabs( (paretoMax - actualMax)/actualMax) > 0.3 ){
516  return false;
517  }
518 
519  return true;
520 }
bool veryFastTest
Definition: DalitzBox.cpp:20
double _max_s4
Definition: DalitzBox.h:23
double ampsWithPhaseSpace(IDalitzEvent &ep)
Definition: DalitzBox.cpp:285
double generalisedPareto_estimateMaximum(const std::vector< double > &input, double CL=0.001)
DalitzEventList _eventList
Definition: DalitzBox.h:38
double phaseSpace(IDalitzEvent &ep)
Definition: DalitzBox.cpp:280
double _max_s3
Definition: DalitzBox.h:23
double guessedHeight() const
Definition: DalitzBox.h:101
bool fastTest
Definition: DalitzBox.cpp:19
bool ultraFast
Definition: DalitzBox.cpp:21
double _max_s2
Definition: DalitzBox.h:23
double _maxPhaseSpace
Definition: DalitzBox.h:24
const MappedDalitzArea & area() const
Definition: DalitzBox.h:103
double _height
Definition: DalitzBox.h:37
double _max_s0
Definition: DalitzBox.h:23
double _max_s1
Definition: DalitzBox.h:23
TRandom * _rnd
Definition: DalitzBox.h:36
virtual unsigned int size() const
Definition: EventList.h:59
bool insideDaddysArea(const DalitzEvent &evt) const
Definition: DalitzBox.cpp:232

◆ estimateHeight_old()

bool DalitzBox::estimateHeight_old ( std::vector< double > &  vals)
private

Definition at line 522 of file DalitzBox.cpp.

523  {
524  double saveFactor = 2.0;
525 
526  cout << "DalitzBox::estimateHeight" << endl;
527  if(false && bigDebug){
528  vals.resize(_eventList.size(), 1);
529  _height=1;
530  return true;
531  }
532  if(_eventList.empty()){
533  _height = 0;
534  return false;
535  }
536  time_t startTime = time(0);
537 
538  unsigned int counter=0;
539 
540  vals.clear();
541 
542  vals.resize(_eventList.size());
543 
544  double max = -9999;
545 
546  double maxPhaseSpace = -9999;
547 
548  for(unsigned int i=0; i < _eventList.size(); i++){
549  IDalitzEvent& evt = _eventList[i];
550  double p = evt.phaseSpace();
551  if(p > maxPhaseSpace || 0 == counter){
552  maxPhaseSpace = p;
553  }
554  double d=ampsWithPhaseSpace(evt);
555 
556  if(d > max || 0 == counter){
557  max=d;
558  // _maxEvent = *(_eventList.getEvent());
559  }
560  vals[i] = d;
561  if(i < 5 || 0 == i%(_eventList.size()/20 + 1)){
562  std::cout << " calculated amps for event "
563  << i
564  << ", its value is " << d
565  << std::endl;
566  double deltaT = difftime(time(0), startTime);
567  std::cout << " this took " << deltaT << " s";
568  if(deltaT > 0.5){
569  std::cout << "; rate (before throwing away) = "
570  << i/deltaT
571  << " evts/s";
572  }
573  std::cout << std::endl;
574  }
575  };
576 
577  cout << " max phase space: " << maxPhaseSpace << endl;
578 
579  double epsilon = 0.25;
580 
581  double CL = 1.0 - 1./_eventList.size();
582  std::cout << "actual max = " << max << std::endl;
583 
584  if(_eventList.size() < 50){
585  cout << " no Paret of only " << _eventList.size()
586  << " events. Taking 5*max = 5*" << max
587  << " = " << 5*max
588  << " and return false." << endl;
589  _height = 5.0 * max;
590  return false;
591  }
592 
593  double actualMax=-1, paretoMax=-1;
594 
596  , CL
597  , actualMax
598  , paretoMax
599  );
600 
601  std::cout << " Pareto max " << paretoMax << std::endl;
602  max *= 1.0 + epsilon;
603  std::cout << "Now added " << epsilon * 100 << "% for safety "
604  << max << std::endl;
605 
606  max *= saveFactor;
607 
608  std::cout << "and multiplied by safety factor "
609  << saveFactor
610  << " giving " << max
611  << endl;
612  cout << "compare to guessed height: "
613  << guessedHeight()*maxPhaseSpace << endl;
614  _height = max;
615 
616  if(fabs( (paretoMax - actualMax)/actualMax) > 0.3 ){
617  return false;
618  }
619 
620  return true;
621 }
bool bigDebug
Definition: DalitzBox.cpp:18
double ampsWithPhaseSpace(IDalitzEvent &ep)
Definition: DalitzBox.cpp:285
virtual double phaseSpace() const =0
double generalisedPareto_estimateMaximum(const std::vector< double > &input, double CL=0.001)
DalitzEventList _eventList
Definition: DalitzBox.h:38
double guessedHeight() const
Definition: DalitzBox.h:101
double _height
Definition: DalitzBox.h:37
virtual unsigned int size() const
Definition: EventList.h:59

◆ estimateHeightMinuit()

bool DalitzBox::estimateHeightMinuit ( )
private

Definition at line 296 of file DalitzBox.cpp.

296  {
297  MinuitParameterSet parset;
298 
299  /*
300  // step 1: Find starting values:
301  int minEvents= 10000000;
302  int maxEvents= 10000001;
303  int counter = 0;
304  double max = -1;
305  double s0=0.5, s1=0.5, s2=0.5, s3=0.5, s4=0.5;
306  bool foundOne=false;
307  cout << " starting loop" << endl;
308  while((! (foundOne && counter > minEvents)) && counter < maxEvents){
309  counter++;
310  // cout << " counter " << counter << endl;
311  double tmp_s0 = _rnd->Rndm();
312  double tmp_s1 = _rnd->Rndm();
313  double tmp_s2 = _rnd->Rndm();
314  double tmp_s3 = _rnd->Rndm();
315  double tmp_s4 = _rnd->Rndm();
316  counted_ptr<DalitzEvent> tmpEvtPtr(area().makeEventForOwner(tmp_s0, tmp_s1, tmp_s2, tmp_s3, tmp_s4));
317  if(0 == tmpEvtPtr) continue;
318  //cout << " found a non-zero event!!!" << endl;
319  if(this->insideDaddysArea(*tmpEvtPtr)) return 0;
320 
321  foundOne=true;
322  _amps->setEvent(&(*tmpEvtPtr));
323  double val = _amps->RealVal();
324  _amps->resetEventRecord();
325  if(val > max){
326  max=val;
327  s0 = tmp_s0; s1=tmp_s1, s2=tmp_s2, s3=tmp_s3, s4=tmp_s4;
328  }
329  }
330 
331  if(max < 0){
332  cout << " didn't find starting point "
333  << " giving up; "
334  << endl;
335  _height = -1;
336  return true;
337  }
338 
339  cout << " max = " << max << " at "
340  << s0 << ", " << s1 << ", " << s2 << ", " << s3 << ", " << s4 << endl;
341 
342  */
343  FitParameter fit_scale0("scale0"
344  , 0
345  , _max_s0
346  , 0.2
347  , -0.05
348  , 1.05
349  , &parset
350  );
351  FitParameter fit_scale1("scale1"
352  , 0
353  , _max_s1
354  , 0.2
355  , -0.05
356  , 1.05
357  , &parset
358  );
359  FitParameter fit_scale2("scale2"
360  , 0
361  , _max_s2
362  , 0.2
363  , -0.05
364  , 1.05
365  , &parset
366  );
367  FitParameter fit_scale3("scale3"
368  , 0
369  , _max_s3
370  , 0.2
371  , -0.05
372  , 1.05
373  , &parset
374  );
375  FitParameter fit_scale4("scale4"
376  , 0
377  , _max_s4
378  , 0.2
379  , -0.05
380  , 1.05
381  , &parset
382  );
383 
384  FindMaxFCN fcn(fit_scale0
385  , fit_scale1
386  , fit_scale2
387  , fit_scale3
388  , fit_scale4
389  , this, &parset);
390 
391  Minimiser mini(&fcn);
392  // mini.Command("Set Strategy 2");
393  mini.prepFit();
394  mini.Command("Simplex 10000000");
395  mini.Command("MIGRAD");
396 
397  double safetyMargin = 0;
398 
399  _height = -(mini.getFCNVal() * (1.0 + safetyMargin));
400 
401  if(_height <= 0.0) _height = -1.0;
402  cout << " setting height to " << _height << endl;
403  return true;
404 }
double _max_s4
Definition: DalitzBox.h:23
double _max_s3
Definition: DalitzBox.h:23
double _max_s2
Definition: DalitzBox.h:23
double _height
Definition: DalitzBox.h:37
double _max_s0
Definition: DalitzBox.h:23
double _max_s1
Definition: DalitzBox.h:23

◆ eventList() [1/2]

DalitzEventList& DalitzBox::eventList ( )
inline

Definition at line 112 of file DalitzBox.h.

112 { return _eventList;}
DalitzEventList _eventList
Definition: DalitzBox.h:38

◆ eventList() [2/2]

const DalitzEventList& DalitzBox::eventList ( ) const
inline

Definition at line 113 of file DalitzBox.h.

113 { return _eventList;}
DalitzEventList _eventList
Definition: DalitzBox.h:38

◆ getEventsPdf()

double DalitzBox::getEventsPdf ( DalitzEvent evt)
private

Definition at line 830 of file DalitzBox.cpp.

830  {
831 
832  if(0 == _amps || bigDebug) return evt.phaseSpace();
833 
834  double val = _amps->RealVal(evt) * evt.phaseSpace();
835 
836  return val;
837 }
bool bigDebug
Definition: DalitzBox.cpp:18
virtual double phaseSpace() const
virtual double RealVal(EVENT_TYPE &evt)=0
MINT::IReturnRealForEvent< IDalitzEvent > * _amps
Definition: DalitzBox.h:34

◆ getReady()

void DalitzBox::getReady ( )

Definition at line 796 of file DalitzBox.cpp.

796  {
797  time_t startTime = time(0);
798 
799  cout << " DalitzBox::getReady() " << *this << endl;
800 
801  _nTries = 0;
803  _eventList.clear();
804 
805  makeStarterSet();
807 
808  double deltaT = difftime(time(0), startTime);
809  cout << " DalitzBox::getRead(): am ready. This took "
810  << deltaT/60 << " min" << endl;
811 
812  if(no_reuse) _eventList.clear();
813 
814  _ready = true;
815 }
DalitzEventList _eventList
Definition: DalitzBox.h:38
bool makeStarterSet()
Definition: DalitzBox.cpp:623
int _nTries
Definition: DalitzBox.h:40
virtual unsigned int size() const
Definition: EventList.h:59
int _nEventsForTries
Definition: DalitzBox.h:41
bool _ready
Definition: DalitzBox.h:29
bool no_reuse
Definition: DalitzBox.cpp:23

◆ guessedHeight()

double DalitzBox::guessedHeight ( ) const
inline

Definition at line 101 of file DalitzBox.h.

101 {return _guessedHeight;}
double _guessedHeight
Definition: DalitzBox.h:44

◆ height()

double DalitzBox::height ( ) const
inline

Definition at line 106 of file DalitzBox.h.

106  {
107  return _height;
108  }
double _height
Definition: DalitzBox.h:37

◆ insideArea()

bool DalitzBox::insideArea ( const DalitzEvent evt) const

Definition at line 214 of file DalitzBox.cpp.

214  {
215  /*
216  cout << "Hello from DalitzBox::insideArea()" << endl;
217  cout << " my area is " << _area << endl;
218  cout << ", or the same with (): " << area() << endl;
219  cout << " and the event: " << evt << endl;
220  cout << " Let's check if the event is inside the area: " << endl;
221  */
222  bool inside = area().isInside(evt);
223 
224  /*
225  cout << "Goodbye from DalitzBox::insideArea(); returning "
226  << inside << endl;
227  */
228 
229  return inside;
230 }
const MappedDalitzArea & area() const
Definition: DalitzBox.h:103
bool isInside(const DalitzEvent &evt) const

◆ insideDaddysArea()

bool DalitzBox::insideDaddysArea ( const DalitzEvent evt) const

Definition at line 232 of file DalitzBox.cpp.

232  {
233  if(0 == _daddy) return false;
234  return _daddy->insideMyOrDaddysArea(evt);
235 }
const DalitzBox * _daddy
Definition: DalitzBox.h:42
bool insideMyOrDaddysArea(const DalitzEvent &evt) const
Definition: DalitzBox.cpp:237

◆ insideMyOrDaddysArea()

bool DalitzBox::insideMyOrDaddysArea ( const DalitzEvent evt) const

Definition at line 237 of file DalitzBox.cpp.

237  {
238  return insideArea(evt) || insideDaddysArea(evt);
239 }
bool insideArea(const DalitzEvent &evt) const
Definition: DalitzBox.cpp:214
bool insideDaddysArea(const DalitzEvent &evt) const
Definition: DalitzBox.cpp:232

◆ makeFlatEventsKeepAll()

int DalitzBox::makeFlatEventsKeepAll ( int  N)
private

Definition at line 241 of file DalitzBox.cpp.

241  {
242  cout << "making " << N << " flat event" << endl;
243  int counter = 0;
244  int guessedWasteFactor = 110*5;
245  if(fastTest) guessedWasteFactor = 150;
246 
247  for(int i=0; i< N*guessedWasteFactor; i++){
248  _nTries ++;
249  bool printdbg = (_nTries < 5 || 0 == _nTries%100000);
250  if(printdbg) cout << " nTries " << _nTries << endl;
251 
252  counted_ptr<DalitzEvent> evt(area().makeEventForOwner());
253  if(printdbg) cout << " made event" << endl;
254 
255  if(0 != evt && (! insideDaddysArea(*evt))){ // this should work
256  if(printdbg)cout << " area OK " << endl;
257  _eventList.Add(*evt);
258  if(printdbg)cout << " added event" << endl;
259 
260  if(++counter >= N) break;
261  }
262  }
263 
264  cout << " got " << _eventList.size() << endl;
265  return _nTries;
266 }
virtual bool Add(const EVENT_TYPE &evt)
Definition: EventList.h:63
DalitzEventList _eventList
Definition: DalitzBox.h:38
bool fastTest
Definition: DalitzBox.cpp:19
const MappedDalitzArea & area() const
Definition: DalitzBox.h:103
int _nTries
Definition: DalitzBox.h:40
virtual unsigned int size() const
Definition: EventList.h:59
bool insideDaddysArea(const DalitzEvent &evt) const
Definition: DalitzBox.cpp:232

◆ makeStarterSet()

bool DalitzBox::makeStarterSet ( )
private

Definition at line 623 of file DalitzBox.cpp.

623  {
624  double safetyFactor = 2.5;
625 
626  time_t startTime = time(0);
627  cout << "making starter set" << endl;
628  // unsigned int maxEvents = 400000;
629  int NperLoop = 20000;
630  // int maxTries = maxEvents * 110;
631  int maxLoop = 5;
632  if(fastTest){
633  NperLoop = 10000;
634  maxLoop = 3;
635  }
636  if(veryFastTest){
637  NperLoop = 1000;
638  maxLoop = 1;
639  }
640 
641  bool successfulHeightEstimate = false;
642  std::vector<double> vals;
643 
644  int counter = 0;
645  double prevHeight = -0.1;
646  double heightErrorEstimate = 0.1;
647 
648  bool doOldHeight=(guessedHeight() < 10);
649  bool doMinuitHeight=false;
650  if(doOldHeight){
651  do{
652  // makeFlatEventsKeepAll(NperLoop);
653  successfulHeightEstimate = estimateHeight(vals);
654  heightErrorEstimate
655  = fabs(prevHeight - _height)/( 0.5*(fabs(prevHeight) + fabs(_height) ));
656 
657  /*
658  successfulHeightEstimate |= heightErrorEstimate < 0.25;
659  // the above line means: I believe it if pareto and actual
660  // are close - or if at least pareto is consistent.
661  */
662 
663  successfulHeightEstimate &= heightErrorEstimate < 0.25;
664  // the above line means: I believe it if pareto and actual
665  // are close AND if Pareto is consistent.
666  counter++;
667  double deltaT = difftime(time(0), startTime);
668  cout << " making " << counter
669  << " " << NperLoop << "-events starter set(s)"
670  << " took " << deltaT/60 << " min" << endl;
671  cout << " current heightErrorEstimate: " << heightErrorEstimate << endl;
672  prevHeight = _height;
673  // no event inside box - box must have 0 volume
674  // (most likely overlap 100% with other volume)
675  }while(counter < maxLoop
676  && (! successfulHeightEstimate)
677  );
678 
679  cout << " DONE \"old\" height guess, now MINUIT " << endl;
680  }
681  double search_height = _height;
682  double minuit_height = -1;
683  if(doMinuitHeight){
684  successfulHeightEstimate |= estimateHeightMinuit();
685  minuit_height = _height;
686  }
687 
688 
689  _height = ( search_height > minuit_height ? search_height : minuit_height);
691 
692  cout << "Different Heights:"
693  << "\n\t search_height " << search_height
694  << "\n\t minuit_height " << minuit_height
695  << "\n\t guessed height " << guessedHeight()
696  << "\n\t chosen height " << _height
697  << endl;
698 
699  if(! successfulHeightEstimate){
700  cout << "DalitzBox::makeStarterSet "
701  << "WARNING - no reliable estimate of box-height"
702  << endl;
703  cout << " I'll multiply it by " << 1.0 + 2*heightErrorEstimate
704  << ", and continue..." << endl;
705  // _height *= 1.0 + 2.0*heightErrorEstimate;
706  }else{
707  cout << "DalitzBox::makeStarterSet "
708  << "I think I found a reliable Height Estimate of "
709  << _height
710  << endl;
711  /* _height *= 1.0 + 2.0*heightErrorEstimate;
712  cout << "For safety, I'll add 2* the Error estimate of "
713  << heightErrorEstimate << " which gives a final height of "
714  << _height
715  << endl;
716  */
717  }
718  cout << " appliying safety factor of " << safetyFactor << endl;
719  _height *= safetyFactor;
720  cout << "final height " << _height << endl;
721 
722  //throwAwayData(vals);
723 
724  return true;
725 }
bool veryFastTest
Definition: DalitzBox.cpp:20
bool estimateHeight(std::vector< double > &vals)
Definition: DalitzBox.cpp:406
double guessedHeight() const
Definition: DalitzBox.h:101
bool fastTest
Definition: DalitzBox.cpp:19
double _height
Definition: DalitzBox.h:37
bool estimateHeightMinuit()
Definition: DalitzBox.cpp:296

◆ name()

const std::string& DalitzBox::name ( ) const
inline

Definition at line 98 of file DalitzBox.h.

98 {return _name;}
std::string _name
Definition: DalitzBox.h:27

◆ number()

int DalitzBox::number ( ) const
inline

Definition at line 95 of file DalitzBox.h.

95 {return _number;}
int _number
Definition: DalitzBox.h:26

◆ phaseSpace()

double DalitzBox::phaseSpace ( IDalitzEvent ep)

Definition at line 280 of file DalitzBox.cpp.

280  {
281  if(_flatPhaseSpace) return 1;
282  return evt_in.phaseSpace();
283 }
bool _flatPhaseSpace
Definition: DalitzBox.h:47

◆ popEventFromList()

counted_ptr< DalitzEvent > DalitzBox::popEventFromList ( )
private

Definition at line 908 of file DalitzBox.cpp.

908  {
909  if(_eventList.empty()){
910  return counted_ptr<DalitzEvent>(0);
911  }
914  return evt;
915 }
void resize(unsigned int N)
DalitzEventList _eventList
Definition: DalitzBox.h:38
virtual unsigned int size() const
Definition: EventList.h:59

◆ print()

void DalitzBox::print ( std::ostream &  os = std::cout) const

Definition at line 961 of file DalitzBox.cpp.

961  {
962  os << "DalitzBox: " << name() << " number " << number()
963  << "\n area " << area()
964  << "\n guessed height " << guessedHeight()
965  << "\n height " << height()
966  << "\n daddy: ";
967  if(0 == _daddy){
968  os << " none";
969  }else{
970  os << " number " << _daddy->number();
971  }
972 }
int number() const
Definition: DalitzBox.h:95
const DalitzBox * _daddy
Definition: DalitzBox.h:42
double height() const
Definition: DalitzBox.h:106
double guessedHeight() const
Definition: DalitzBox.h:101
const std::string & name() const
Definition: DalitzBox.h:98
const MappedDalitzArea & area() const
Definition: DalitzBox.h:103

◆ setAmps()

bool DalitzBox::setAmps ( MINT::IReturnRealForEvent< IDalitzEvent > *  amps)

Definition at line 198 of file DalitzBox.cpp.

198  {
199  _ready = false;
200  _amps = amps;
201  _eventList.clear();
202  if(0 == _amps) return false;
203  return true;
204 }
double amps(IDalitzEvent &ep)
Definition: DalitzBox.cpp:268
DalitzEventList _eventList
Definition: DalitzBox.h:38
MINT::IReturnRealForEvent< IDalitzEvent > * _amps
Definition: DalitzBox.h:34
bool _ready
Definition: DalitzBox.h:29

◆ setDaddy()

void DalitzBox::setDaddy ( const DalitzBox daddy)

Definition at line 209 of file DalitzBox.cpp.

209  {
210  _ready = false;
211  _daddy = daddy;
212 }
const DalitzBox * _daddy
Definition: DalitzBox.h:42
bool _ready
Definition: DalitzBox.h:29

◆ setFlatPhaseSpace()

void DalitzBox::setFlatPhaseSpace ( bool  flat = true)
inline

Definition at line 68 of file DalitzBox.h.

68  {
69  _flatPhaseSpace = flat;
70  }
bool _flatPhaseSpace
Definition: DalitzBox.h:47

◆ setGuessedHeight()

void DalitzBox::setGuessedHeight ( double  h)
inline

Definition at line 100 of file DalitzBox.h.

100 {_guessedHeight = h;}
double _guessedHeight
Definition: DalitzBox.h:44

◆ setHeight()

double DalitzBox::setHeight ( double  h)
inline

Definition at line 109 of file DalitzBox.h.

109  {
110  return _height = h;
111  }
double _height
Definition: DalitzBox.h:37

◆ setName()

void DalitzBox::setName ( const std::string &  name)
inline

Definition at line 97 of file DalitzBox.h.

97 { _name = name;}
const std::string & name() const
Definition: DalitzBox.h:98
std::string _name
Definition: DalitzBox.h:27

◆ setNumber()

void DalitzBox::setNumber ( int  num)
inline

Definition at line 94 of file DalitzBox.h.

94 {_number = num;}
int _number
Definition: DalitzBox.h:26

◆ setRnd()

bool DalitzBox::setRnd ( TRandom *  rnd = gRandom)

Definition at line 974 of file DalitzBox.cpp.

974  {
975  _rnd = rnd;
976  area().setRnd(rnd);
977  return true;
978 }
const MappedDalitzArea & area() const
Definition: DalitzBox.h:103
TRandom * _rnd
Definition: DalitzBox.h:36
bool setRnd(TRandom *rnd=gRandom)

◆ split()

std::vector< DalitzBox > DalitzBox::split ( unsigned int  nWays) const

Definition at line 917 of file DalitzBox.cpp.

918  {
919  std::vector<MappedDalitzArea> areaList(_area.split(nWays));
920 
921  std::vector<DalitzBox> newSet;
922  if(areaList.empty()) return newSet;
923  bool foundCtr=false;
924  for(unsigned int i=0; i < areaList.size(); i++){
925  DalitzBox newBox(*this);
926  newBox.area() = areaList[i];
927  if( ! (newBox.area().isInside((this->area().centre())))){
928  // newBox.setGuessedHeight(0.6*guessedHeight());
929  newBox.setGuessedHeight(-1);
930  }else{
931  foundCtr=true;
932  }
933  newSet.push_back(newBox);
934  }
935  if(false && (! foundCtr)){
936  cout << "ERROR split box " << *this << " " << nWays << " ways,"
937  << " but center: is gone." << endl;
938  cout << "newSet\n: " << newSet << endl;
939  }
940  return newSet;
941 }
MappedDalitzArea _area
Definition: DalitzBox.h:31
std::vector< MappedDalitzArea > split(unsigned int nWays) const
const MappedDalitzArea & area() const
Definition: DalitzBox.h:103

◆ splitIfWiderThan()

std::vector< DalitzBox > DalitzBox::splitIfWiderThan ( double  maxWidth) const

Definition at line 943 of file DalitzBox.cpp.

944  {
945  std::vector<MappedDalitzArea> areaList(_area.splitIfWiderThan(maxWidth));
946 
947  std::vector<DalitzBox> newSet;
948  if(areaList.empty()) return newSet;
949  for(unsigned int i=0; i < areaList.size(); i++){
950  DalitzBox newBox(*this);
951  newBox.area() = areaList[i];
952  if( ! (newBox.area().isInside((this->area().centre())))){
953  // newBox.setGuessedHeight(0.6*guessedHeight());
954  newBox.setGuessedHeight(-1);
955  }
956  newSet.push_back(newBox);
957  }
958  return newSet;
959 }
MappedDalitzArea _area
Definition: DalitzBox.h:31
std::vector< MappedDalitzArea > splitIfWiderThan(double maxWidth) const
const MappedDalitzArea & area() const
Definition: DalitzBox.h:103

◆ throwAwayData()

int DalitzBox::throwAwayData ( const std::vector< double > &  vals)
private

Definition at line 727 of file DalitzBox.cpp.

727  {
728  if(false && bigDebug) return 0;
729  time_t startTime = time(0);
730 
731  if(vals.size() != _eventList.size()){
732  cout << " ERROR in DalitzBox::throwAwayData: "
733  << " vals.size()=" << vals.size()
734  << ", but _eventList.size()="
735  << _eventList.size()
736  << endl;
737  throw "this is bad.";
738  }
739 
740  DalitzEventList newList;
741 
742  int rememberSize = _eventList.size();
743 
744  unsigned int counter=0;
745 
746  for(unsigned int i=0; i < _eventList.size(); i++){
747  IDalitzEvent& evt(_eventList[i]);
748 
749  double d=ampsWithPhaseSpace(evt);
750  // double d = vals[counter];
751 
752  if(_rnd->Rndm()*_height < d){
753  newList.Add( _eventList[i] );
754  }
755  if(counter < 10 || 0 == counter%(_eventList.size()/20 + 1)){
756  std::cout << " remembering amps for event "
757  << counter
758  << ", its value is " << d
759  << std::endl;
760  }
761  counter++;
762  }
763 
764  _eventList = newList;
765  std::cout << "now my size has changed to " << _eventList.size()
766  << std::endl;
767  std::cout << " So the waste factor for \n" << this->name() << " is ";
768  if(_eventList.size() > 0) std::cout << rememberSize/_eventList.size();
769  else std::cout << " infinity! - that's big!";
770  std::cout << std::endl;
771 
772 
773  double deltaTFinal = difftime(time(0), startTime);
774  std::cout << " this took " << deltaTFinal/60.0 << " min";
775  if(deltaTFinal > 0){
776  std::cout << " rate = " << (_eventList.size()/deltaTFinal) << " evts/s"
777  << " or " << (_eventList.size()/deltaTFinal) *60 << " evts/m"
778  << " or " << (_eventList.size()/deltaTFinal) *60.*60./1000.
779  << "k evts/h";
780  }
781  std::cout << std::endl;
782 
783  std::cout << " ---------------\n " << std::endl;
784 
785  return _eventList.size();
786 }
virtual bool Add(const EVENT_TYPE &evt)
Definition: EventList.h:63
bool bigDebug
Definition: DalitzBox.cpp:18
double ampsWithPhaseSpace(IDalitzEvent &ep)
Definition: DalitzBox.cpp:285
DalitzEventList _eventList
Definition: DalitzBox.h:38
const std::string & name() const
Definition: DalitzBox.h:98
double _height
Definition: DalitzBox.h:37
TRandom * _rnd
Definition: DalitzBox.h:36
virtual unsigned int size() const
Definition: EventList.h:59

◆ tryEventForOwner()

counted_ptr< DalitzEvent > DalitzBox::tryEventForOwner ( )

Definition at line 817 of file DalitzBox.cpp.

817  {
818  if(! _ready) getReady();
819 
821 
822  if(_eventList.empty()){
823  evt = tryNewEvent();
824  }else{
825  evt = tryEventFromList();
826  }
827  return evt;
828 }
DalitzEventList _eventList
Definition: DalitzBox.h:38
MINT::counted_ptr< DalitzEvent > tryNewEvent()
Definition: DalitzBox.cpp:839
void getReady()
Definition: DalitzBox.cpp:796
bool _ready
Definition: DalitzBox.h:29
MINT::counted_ptr< DalitzEvent > tryEventFromList()
Definition: DalitzBox.cpp:894

◆ tryEventFromList()

counted_ptr< DalitzEvent > DalitzBox::tryEventFromList ( )
private

Definition at line 894 of file DalitzBox.cpp.

894  {
895  // the list has already been subjected to
896  // data throwing away.
897  // _nTries were made, and _nEventsForTries are
898  // left over. So each event in the list represents
899  // on average _nTries/_nEventsForTries tries;
900 
901  double rndNumber = _rnd->Rndm()*_nTries;
902  if(rndNumber > (double) _nEventsForTries){
903  return counted_ptr<DalitzEvent>(0);
904  }
905  return popEventFromList();
906 }
int _nTries
Definition: DalitzBox.h:40
TRandom * _rnd
Definition: DalitzBox.h:36
int _nEventsForTries
Definition: DalitzBox.h:41
MINT::counted_ptr< DalitzEvent > popEventFromList()
Definition: DalitzBox.cpp:908

◆ tryNewEvent()

counted_ptr< DalitzEvent > DalitzBox::tryNewEvent ( )
private

Definition at line 839 of file DalitzBox.cpp.

839  {
840 
841  counted_ptr<DalitzEvent> evt( area().makeEventForOwner() );
842 
843  if( 0 == evt){ // bad ptr
844  return counted_ptr<DalitzEvent>(0);
845  }
846  if(insideDaddysArea(*evt)){ // out of area
847  return counted_ptr<DalitzEvent>(0);
848  }
849 
850  double val = getEventsPdf(*evt);
851  if(val > _height){
852  _heightProblems++;
853  cout << "ERROR in DalitzBox::tryNewEvent()\n" << (*this)
854  << "\n val > _height: " << val << " > " << _height
855  << "\n (for phase space = " << evt->phaseSpace() << ")."
856  << "\n if _height had been correctly estimated,"
857  << " this should not be possible." << endl;
858  cout << " This has happened " << _heightProblems
859  << " times in this box " << endl;
860  }
861  if(_rnd->Rndm()*_height > val){ // then we don't take it.
862  evt = counted_ptr<DalitzEvent>(0);
863  }
864  return evt;
865 }
const MappedDalitzArea & area() const
Definition: DalitzBox.h:103
double getEventsPdf(DalitzEvent &evt)
Definition: DalitzBox.cpp:830
double _height
Definition: DalitzBox.h:37
TRandom * _rnd
Definition: DalitzBox.h:36
unsigned int _heightProblems
Definition: DalitzBox.h:45
bool insideDaddysArea(const DalitzEvent &evt) const
Definition: DalitzBox.cpp:232

◆ tryWeightedEventForOwner()

counted_ptr< DalitzEvent > DalitzBox::tryWeightedEventForOwner ( )

Definition at line 867 of file DalitzBox.cpp.

867  {
868  bool dbThis=false;
869  counted_ptr<DalitzEvent> evt( area().makeEventForOwner() );
870 
871  if( 0 == evt){ // bad ptr
872  return counted_ptr<DalitzEvent>(0);
873  }
874  if(insideDaddysArea(*evt)){ // out of area
875  return counted_ptr<DalitzEvent>(0);
876  }
877 
878  if(dbThis)cout << " DalitzBox::tryWeightedEventForOwner() "
879  << " got event with ptr "
880  << evt
881  << ", setting val: " << endl;
882  if(dbThis)cout << " now printing event: "
883  << *evt
884  << endl;
885  double val = ampsWithPhaseSpace(*evt);
886  if(dbThis)cout << " val = " << val << ", now setting weight " << endl;
887  evt->setWeight(val/_height);
888  if(dbThis)cout << " done weight, now generator..." << endl;
889  evt->setGeneratorPdfRelativeToPhaseSpace(amps(*evt));
890  if(dbThis)cout << " all OK, returning " << evt << endl;
891  return evt;
892 }
double amps(IDalitzEvent &ep)
Definition: DalitzBox.cpp:268
double ampsWithPhaseSpace(IDalitzEvent &ep)
Definition: DalitzBox.cpp:285
const MappedDalitzArea & area() const
Definition: DalitzBox.h:103
double _height
Definition: DalitzBox.h:37
bool insideDaddysArea(const DalitzEvent &evt) const
Definition: DalitzBox.cpp:232

◆ volume()

double DalitzBox::volume ( ) const

Definition at line 788 of file DalitzBox.cpp.

788  {
789  double a = area().size();
790  cout << " volume: returning area " << a
791  << " times height " << _height
792  << " = " << a*_height
793  << endl;
794  return a * _height;
795 }
const MappedDalitzArea & area() const
Definition: DalitzBox.h:103
double _height
Definition: DalitzBox.h:37
double size() const

Member Data Documentation

◆ _amps

MINT::IReturnRealForEvent<IDalitzEvent>* DalitzBox::_amps
private

Definition at line 34 of file DalitzBox.h.

◆ _area

MappedDalitzArea DalitzBox::_area
private

Definition at line 31 of file DalitzBox.h.

◆ _daddy

const DalitzBox* DalitzBox::_daddy
private

Definition at line 42 of file DalitzBox.h.

◆ _eventList

DalitzEventList DalitzBox::_eventList
private

Definition at line 38 of file DalitzBox.h.

◆ _flatPhaseSpace

bool DalitzBox::_flatPhaseSpace
private

Definition at line 47 of file DalitzBox.h.

◆ _guessedHeight

double DalitzBox::_guessedHeight
private

Definition at line 44 of file DalitzBox.h.

◆ _height

double DalitzBox::_height
private

Definition at line 37 of file DalitzBox.h.

◆ _heightProblems

unsigned int DalitzBox::_heightProblems
private

Definition at line 45 of file DalitzBox.h.

◆ _max_s0

double DalitzBox::_max_s0
private

Definition at line 23 of file DalitzBox.h.

◆ _max_s1

double DalitzBox::_max_s1
private

Definition at line 23 of file DalitzBox.h.

◆ _max_s2

double DalitzBox::_max_s2
private

Definition at line 23 of file DalitzBox.h.

◆ _max_s3

double DalitzBox::_max_s3
private

Definition at line 23 of file DalitzBox.h.

◆ _max_s4

double DalitzBox::_max_s4
private

Definition at line 23 of file DalitzBox.h.

◆ _maxPhaseSpace

double DalitzBox::_maxPhaseSpace
private

Definition at line 24 of file DalitzBox.h.

◆ _name

std::string DalitzBox::_name
private

Definition at line 27 of file DalitzBox.h.

◆ _nEventsForTries

int DalitzBox::_nEventsForTries
private

Definition at line 41 of file DalitzBox.h.

◆ _nTries

int DalitzBox::_nTries
private

Definition at line 40 of file DalitzBox.h.

◆ _number

int DalitzBox::_number
private

Definition at line 26 of file DalitzBox.h.

◆ _pat

DalitzEventPattern DalitzBox::_pat
private

Definition at line 33 of file DalitzBox.h.

◆ _ready

bool DalitzBox::_ready
private

Definition at line 29 of file DalitzBox.h.

◆ _rnd

TRandom* DalitzBox::_rnd
private

Definition at line 36 of file DalitzBox.h.


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