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

#include <DalitzPdfNormChecker.h>

Public Member Functions

 DalitzPdfNormChecker (IDalitzPdf *pdf, const DalitzEventPattern &pat, double prec=1.0e-2, TRandom *rnd=gRandom)
 
double checkNorm ()
 
double result () const
 
double resultError () const
 
void print (std::ostream &os=std::cout) const
 

Private Member Functions

void makeMiMa ()
 
MINT::counted_ptr< DalitzEventmakeEventForOwner (double scale0, double scale1, double scale2, double scale3, double scale4) const
 
MINT::counted_ptr< DalitzEventmake3Event () const
 
MINT::counted_ptr< DalitzEventmake4Event () const
 
MINT::counted_ptr< DalitzEventmakeEventForOwner () const
 
double currentAbsolutePrecision () const
 
double currentRelativePrecision () const
 
double boxSize () const
 
bool sufficientPrecision () const
 

Private Attributes

IDalitzPdf_pdf
 
TRandom * _rnd
 
DalitzEventPattern _pat
 
DalitzCoordinate _t01
 
DalitzCoordinate _s12
 
DalitzCoordinate _s23
 
DalitzCoordinate _s34
 
DalitzCoordinate _t40
 
double _askingPrecision
 
double _sum
 
double _sumsq
 
int _NInside
 
double _sumPhaseSpace
 
double _sumPhaseSpaceSq
 
long unsigned int _Nevents
 

Detailed Description

Definition at line 17 of file DalitzPdfNormChecker.h.

Constructor & Destructor Documentation

◆ DalitzPdfNormChecker()

DalitzPdfNormChecker::DalitzPdfNormChecker ( IDalitzPdf pdf,
const DalitzEventPattern pat,
double  prec = 1.0e-2,
TRandom *  rnd = gRandom 
)

Definition at line 11 of file DalitzPdfNormChecker.cpp.

15  : _pdf(pdf)
16  , _rnd(rnd)
17  , _pat(pat)
18  , _t01(2,3,4)
19  , _s12(1,2)
20  , _s23(2,3)
21  , _s34(3,4)
22  , _t40(1,2,3)
23  , _askingPrecision(prec)
24  , _sum(0.0)
25  , _sumsq(0.0)
26  , _NInside(0)
27  , _sumPhaseSpace(0.0)
28  , _sumPhaseSpaceSq(0.0)
29  , _Nevents(0)
30 {
31  makeMiMa();
32 }
long unsigned int _Nevents
DalitzEventPattern _pat

Member Function Documentation

◆ boxSize()

double DalitzPdfNormChecker::boxSize ( ) const
private

Definition at line 231 of file DalitzPdfNormChecker.cpp.

231  {
232  // return 1;
233  double dt01 = (_t01.max() - _t01.min());
234  double ds12 = (_s12.max() - _s12.min());
235  double ds23 = (_s23.max() - _s23.min());
236  double ds34 = (_s34.max() - _s34.min());
237  double dt40 = (_t40.max() - _t40.min());
238 
239  if(_pat.numDaughters() == 3){
240  return ds12*ds23;
241  }else if(_pat.numDaughters() == 4){
242  return dt01*ds12*ds23*ds34*dt40;
243  }else{
244  cout << "ERROR in DalitzPdfNormChecker::boxSize()"
245  << " don't know how to handle "
246  << _pat.numDaughters()
247  << " final state particles. Will return -9999"
248  << endl;
249  return -9999.;
250  }
251 }
double min() const
double max() const
DalitzEventPattern _pat

◆ checkNorm()

double DalitzPdfNormChecker::checkNorm ( )

Definition at line 173 of file DalitzPdfNormChecker.cpp.

173  {
174 
175  long unsigned int stupidNumber = 2000000000;
176 
177  int printEvery=50000;
178  for(long unsigned int i=0;
179  ( i < stupidNumber && (! sufficientPrecision()));
180  i++
181  ){
183  if(0 == i%printEvery){
184  print();
185  cout << endl;
186  cout << " current ptr " << evtPtr.get() << endl;
187  if(0 != evtPtr){
188  cout << " phase space = " << evtPtr->phaseSpace() << endl;
189  }
190  }
191  _Nevents++;
192  if(0 == evtPtr) continue;
193  if(evtPtr->phaseSpace() <= 0) continue;
194  double val = _pdf->getVal_withPs(*evtPtr);
195  if(_Nevents < 20 || 0 == i%printEvery){
196  cout << " for _Nevents = " << _Nevents << ", current val = " << val << endl;
197  cout << "event: " << *evtPtr << endl;
198  cout << " ------------------ " << endl;
199  }
200 
201  _sum += val;
202  _sumsq += val*val;
203 
204  double ps = evtPtr->phaseSpace();
205  _NInside++;
206  _sumPhaseSpace += ps;
207  _sumPhaseSpaceSq += ps*ps;
208  }
209  if(_Nevents <=0) return -9999;
210 
211  cout << "DalitzPdfNormChecker::checkNorm(): "
212  << "\n\t result: ";
213  print();
214  cout << endl;
215 
216  return result();
217 }
long unsigned int _Nevents
void print(std::ostream &os=std::cout) const
MINT::counted_ptr< DalitzEvent > makeEventForOwner() const
virtual double getVal_withPs(IDalitzEvent &evt)=0

◆ currentAbsolutePrecision()

double DalitzPdfNormChecker::currentAbsolutePrecision ( ) const
private

Definition at line 145 of file DalitzPdfNormChecker.cpp.

145  {
146  if(_Nevents <= 0) return 9999;
147  double dN = (double) _Nevents;
148  double mean = _sum/dN;
149  double meansq = _sumsq/dN;
150  double var = meansq - mean*mean;
151  if(var < 0){
152  cout << "ERROR ind DalitzPdfNormChecker::currentPrecision()"
153  << ". Variance = " << var
154  << ". We have a problem."
155  << endl;
156  return 9999;
157  }
158  return sqrt(var/dN)*boxSize(); // sigma on mean.
159 }
long unsigned int _Nevents

◆ currentRelativePrecision()

double DalitzPdfNormChecker::currentRelativePrecision ( ) const
private

Definition at line 160 of file DalitzPdfNormChecker.cpp.

160  {
161  if(_Nevents <= 0) return 9999;
162  if(result() == 0.0) return 9999;
163  return currentAbsolutePrecision()/result();
164 }
long unsigned int _Nevents
double currentAbsolutePrecision() const

◆ make3Event()

counted_ptr< DalitzEvent > DalitzPdfNormChecker::make3Event ( ) const
private

Definition at line 110 of file DalitzPdfNormChecker.cpp.

110  {
111 
112  cout << " ERROR DalitzPdfNormChecker::make3Event(): I don't work, yet. "
113  << "\n Please improve me. Sorry, will have to crash, now"
114  << endl;
115  throw "no making 3 body events in DalitzPdfNormChecker, yet";
116 
117  /*
118  double s12 = _s12.min() + _rnd->Rndm()*(_s12.max() - _s12.min());
119  double s23 = _s23.min() + _rnd->Rndm()*(_s23.max() - _s23.min());
120 
121  _evt = new DalitzEvent(_pat, s12, s23);
122  if(_evt->phaseSpace() <= 0){
123  deleteEvent();
124  return 0;
125  }
126 
127  return _evt;
128  */
129  return counted_ptr<DalitzEvent>(0);
130 }

◆ make4Event()

counted_ptr< DalitzEvent > DalitzPdfNormChecker::make4Event ( ) const
private

Definition at line 131 of file DalitzPdfNormChecker.cpp.

131  {
132  //counted_ptr<DalitzEvent> evtttt(new DalitzEvent(_pat, _rnd));
133  //evtttt->setGeneratorPdfRelativeToPhaseSpace(evtttt->phaseSpace());
134  //return evtttt;
135 
136  return makeEventForOwner( _rnd->Rndm()
137  , _rnd->Rndm()
138  , _rnd->Rndm()
139  , _rnd->Rndm()
140  , _rnd->Rndm()
141  );
142 }
MINT::counted_ptr< DalitzEvent > makeEventForOwner() const

◆ makeEventForOwner() [1/2]

counted_ptr< DalitzEvent > DalitzPdfNormChecker::makeEventForOwner ( double  scale0,
double  scale1,
double  scale2,
double  scale3,
double  scale4 
) const
private

Definition at line 52 of file DalitzPdfNormChecker.cpp.

57  {
58  bool dbThis=false;
59 
60  double t01 = _t01.min() + scale0*(_t01.max() - _t01.min());
61  double s12 = _s12.min() + scale1*(_s12.max() - _s12.min());
62  double s23 = _s23.min() + scale2*(_s23.max() - _s23.min());
63  double s34 = _s34.min() + scale3*(_s34.max() - _s34.min());
64  double t40 = _t40.min() + scale4*(_t40.max() - _t40.min());
65 
66  Calculate4BodyProps c4b(t01, s12
67  , s23, s34
68  , t40
69  , _pat[0].mass()
70  , _pat[1].mass(), _pat[2].mass()
71  , _pat[3].mass(), _pat[4].mass()
72  );
73  if(c4b.phaseSpaceFactor() <=0){
74  if(dbThis){
75  cout << " for \n "
76  << t01 << "( " << _t01 << "), \n "
77  << s12 << "( " << _s12 << "), \n "
78  << s23 << "( " << _s23 << "), \n "
79  << s34 << "( " << _s34 << "), \n "
80  << t40 << "( " << _t40 << "), \n "
81  << " outside phase space!! "
82  << endl;
83  }
84  return counted_ptr<DalitzEvent>(0);
85  }
86  counted_ptr<DalitzEvent> evt(new DalitzEvent(_pat, t01, s12, s23, s34, t40));
87  if(0 == evt){
88  cout << "WARNING DalitzPdfNormChecker::make4Event()"
89  << " making the event failed at 'new DalitzEvent(...)'"
90  << " this shouldn't really happen."
91  << endl;
92  return evt;
93  }
94  if(evt->phaseSpace() <= 0){
95  return counted_ptr<DalitzEvent>(0);
96  }
97 
98  return evt;
99 }
double min() const
double max() const
DalitzEventPattern _pat

◆ makeEventForOwner() [2/2]

counted_ptr< DalitzEvent > DalitzPdfNormChecker::makeEventForOwner ( ) const
private

Definition at line 101 of file DalitzPdfNormChecker.cpp.

101  {
102  if(_pat.numDaughters() == 3) return make3Event();
103  if(_pat.numDaughters() == 4) return make4Event();
104  cout << "ERROR in DalitzPdfNormChecker::makeEvent() can only make events"
105  << " with 3 or 4 daughters. You want : " << _pat
106  << endl;
107  return counted_ptr<DalitzEvent>(0);
108 }
MINT::counted_ptr< DalitzEvent > make3Event() const
MINT::counted_ptr< DalitzEvent > make4Event() const
DalitzEventPattern _pat

◆ makeMiMa()

void DalitzPdfNormChecker::makeMiMa ( )
private

Definition at line 34 of file DalitzPdfNormChecker.cpp.

34  {
35  double safetyFactor=1.001;
36 
37  _s12.setMinMax( _pat.sijMin(1,2)/safetyFactor
38  , _pat.sijMax(1,2)*safetyFactor);
39  _s23.setMinMax( _pat.sijMin(2,3)/safetyFactor
40  , _pat.sijMax(2,3)*safetyFactor);
41  if(_pat.numDaughters() >= 4){
42  _t01.setMinMax( _pat.sijMin(2,3,4)/safetyFactor
43  , _pat.sijMax(2,3,4)*safetyFactor);
44  _s34.setMinMax( _pat.sijMin(3,4)/safetyFactor
45  , _pat.sijMax(3,4)*safetyFactor);
46  _t40.setMinMax( _pat.sijMin(1,2,3)/safetyFactor
47  , _pat.sijMax(1,2,3)*safetyFactor);
48  }
49 
50 }
double sijMax(const MINT::PolymorphVector< int > &indices) const
double sijMin(const MINT::PolymorphVector< int > &indices) const
DalitzEventPattern _pat
void setMinMax(double min, double max)

◆ print()

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

Definition at line 219 of file DalitzPdfNormChecker.cpp.

219  {
220  os << " DalitzPdfNormChecker after " << _Nevents << " events: ";
221  if(_Nevents <= 0) return;
222  os << "\n\t result: " << result() << " +/- " << resultError();
223  double dN = (double) _Nevents;
224  // double shouldBe = dInside/(dN);
225  double shouldBe = _sumPhaseSpace/dN * boxSize();
226  //shouldBe *= _sumPhaseSpace/dN;
227  //shouldBe = boxSize();
228  os << "\n this should be " << shouldBe;
229 }
long unsigned int _Nevents

◆ result()

double DalitzPdfNormChecker::result ( ) const

Definition at line 253 of file DalitzPdfNormChecker.cpp.

253  {
254  if(_Nevents <=0 )return -9999;
255  return _sum/((double)_Nevents) * boxSize();
256 }
long unsigned int _Nevents

◆ resultError()

double DalitzPdfNormChecker::resultError ( ) const

Definition at line 166 of file DalitzPdfNormChecker.cpp.

166  {
167  return currentAbsolutePrecision();
168 }
double currentAbsolutePrecision() const

◆ sufficientPrecision()

bool DalitzPdfNormChecker::sufficientPrecision ( ) const
private

Definition at line 170 of file DalitzPdfNormChecker.cpp.

170  {
172 }
long unsigned int _Nevents
double currentRelativePrecision() const

Member Data Documentation

◆ _askingPrecision

double DalitzPdfNormChecker::_askingPrecision
private

Definition at line 23 of file DalitzPdfNormChecker.h.

◆ _Nevents

long unsigned int DalitzPdfNormChecker::_Nevents
private

Definition at line 27 of file DalitzPdfNormChecker.h.

◆ _NInside

int DalitzPdfNormChecker::_NInside
private

Definition at line 25 of file DalitzPdfNormChecker.h.

◆ _pat

DalitzEventPattern DalitzPdfNormChecker::_pat
private

Definition at line 20 of file DalitzPdfNormChecker.h.

◆ _pdf

IDalitzPdf* DalitzPdfNormChecker::_pdf
private

Definition at line 18 of file DalitzPdfNormChecker.h.

◆ _rnd

TRandom* DalitzPdfNormChecker::_rnd
private

Definition at line 19 of file DalitzPdfNormChecker.h.

◆ _s12

DalitzCoordinate DalitzPdfNormChecker::_s12
private

Definition at line 21 of file DalitzPdfNormChecker.h.

◆ _s23

DalitzCoordinate DalitzPdfNormChecker::_s23
private

Definition at line 21 of file DalitzPdfNormChecker.h.

◆ _s34

DalitzCoordinate DalitzPdfNormChecker::_s34
private

Definition at line 21 of file DalitzPdfNormChecker.h.

◆ _sum

double DalitzPdfNormChecker::_sum
private

Definition at line 24 of file DalitzPdfNormChecker.h.

◆ _sumPhaseSpace

double DalitzPdfNormChecker::_sumPhaseSpace
private

Definition at line 26 of file DalitzPdfNormChecker.h.

◆ _sumPhaseSpaceSq

double DalitzPdfNormChecker::_sumPhaseSpaceSq
private

Definition at line 26 of file DalitzPdfNormChecker.h.

◆ _sumsq

double DalitzPdfNormChecker::_sumsq
private

Definition at line 24 of file DalitzPdfNormChecker.h.

◆ _t01

DalitzCoordinate DalitzPdfNormChecker::_t01
private

Definition at line 21 of file DalitzPdfNormChecker.h.

◆ _t40

DalitzCoordinate DalitzPdfNormChecker::_t40
private

Definition at line 21 of file DalitzPdfNormChecker.h.


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