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

#include <CoherenceFactor.h>

Public Member Functions

 CoherenceFactor (FitAmpSum &A, FitAmpSum &Abar, double CSAbs=1, double CSPhase=0.0, MINT::IReturnRealForEvent< IDalitzEvent > *eff=0, double prec=1.e-3)
 
std::complex< double > var () const
 
std::complex< double > sigma () const
 
double varAbs () const
 
double sigmaAbs () const
 
double varAngle () const
 
double sigmaAngle () const
 
void printResult (std::ostream &os=std::cout) const
 
void setPrecision (double prec)
 
double estimatedPrecision () const
 
std::complex< double > getCVal ()
 

Private Member Functions

MINT::IReturnComplexForEvent< IDalitzEvent > * A ()
 
MINT::IReturnComplexForEvent< IDalitzEvent > * Abar ()
 
std::complex< double > A_Value (IDalitzEvent &evt)
 
std::complex< double > Abar_Value (IDalitzEvent &evt)
 
MINT::counted_ptr< MINT::IEventGenerator< IDalitzEvent > > getGenerator ()
 
MINT::counted_ptr< IDalitzEventnewEvent ()
 
std::complex< double > integAxAbarStar () const
 
double integA () const
 
double integAbar () const
 
double integASq () const
 
double integAbarSq () const
 
std::complex< double > complexVar (std::complex< double > s, std::complex< double > s_sq) const
 
double realAorAbarVar (double s, double sq) const
 
std::complex< double > cvarAxAbarStar () const
 
double varA () const
 
double varAbar () const
 
std::complex< double > Rval () const
 
double getEff (IDalitzEvent &evt)
 
double getEff (MINT::counted_ptr< IDalitzEvent > evtPtr)
 

Private Attributes

FitAmpSum_A
 
FitAmpSum_Abar
 
double _CSAbs
 
double _CSPhase
 
FitAmpSum _A_plus_Abar
 
MINT::counted_ptr< MINT::IEventGenerator< IDalitzEvent > > _myOwnGenAplusAbar
 
MINT::IReturnRealForEvent< IDalitzEvent > * _eff
 
double _precision
 
double _sumASq
 
double _sumASqSquared
 
double _sumAbarSq
 
double _sumAbarSqSquared
 
std::complex< double > _sumAxAbarStar
 
std::complex< double > _sumAxAbarStarSquared
 
long int _Nevents
 

Detailed Description

Definition at line 25 of file CoherenceFactor.h.

Constructor & Destructor Documentation

◆ CoherenceFactor()

CoherenceFactor::CoherenceFactor ( FitAmpSum A,
FitAmpSum Abar,
double  CSAbs = 1,
double  CSPhase = 0.0,
MINT::IReturnRealForEvent< IDalitzEvent > *  eff = 0,
double  prec = 1.e-3 
)

Definition at line 17 of file CoherenceFactor.cpp.

23  : _A(&A)
24  , _Abar(&Abar)
25  , _CSAbs(CSAbs)
26  , _CSPhase(CSPhase)
29  , _eff(eff)
30  , _precision(prec)
31  , _sumASq(0), _sumASqSquared(0)
34  , _Nevents(0)
35 {
36 }
MINT::IReturnComplexForEvent< IDalitzEvent > * Abar()
std::complex< double > _sumAxAbarStarSquared
std::complex< double > _sumAxAbarStar
FitAmpSum * _A
MINT::IReturnRealForEvent< IDalitzEvent > * _eff
MINT::IReturnComplexForEvent< IDalitzEvent > * A()
MINT::counted_ptr< MINT::IEventGenerator< IDalitzEvent > > _myOwnGenAplusAbar
double _sumAbarSqSquared
FitAmpSum _A_plus_Abar
FitAmpSum * _Abar

Member Function Documentation

◆ A()

MINT::IReturnComplexForEvent<IDalitzEvent>* CoherenceFactor::A ( )
inlineprivate

◆ A_Value()

complex< double > CoherenceFactor::A_Value ( IDalitzEvent evt)
private

Definition at line 205 of file CoherenceFactor.cpp.

205  {
206  // bool dbThis=false;
207  return A()->ComplexVal(evt);
208 }
MINT::IReturnComplexForEvent< IDalitzEvent > * A()
virtual std::complex< double > ComplexVal(EVENT_TYPE &evt)=0

◆ Abar()

MINT::IReturnComplexForEvent<IDalitzEvent>* CoherenceFactor::Abar ( )
inlineprivate

◆ Abar_Value()

complex< double > CoherenceFactor::Abar_Value ( IDalitzEvent evt)
private

Definition at line 209 of file CoherenceFactor.cpp.

209  {
210  bool dbThis=false;
211  if(dbThis) cout << "CoherenceFactor::Abar_Value" << endl;
212  complex<double> val = Abar()->ComplexVal(evt);
213  if(dbThis) cout << "got value: " << val << endl;
214  return val;
215 }
MINT::IReturnComplexForEvent< IDalitzEvent > * Abar()
virtual std::complex< double > ComplexVal(EVENT_TYPE &evt)=0

◆ complexVar()

complex< double > CoherenceFactor::complexVar ( std::complex< double >  s,
std::complex< double >  s_sq 
) const
private

Definition at line 110 of file CoherenceFactor.cpp.

112  {
113  if(_Nevents <=0) return 0;
114  complex<double> m = s / ((double) _Nevents);
115  complex<double> mos = s_sq / ((double) _Nevents);
116  complex<double> som(m.real()*m.real(), m.imag()*m.imag());
117  return (mos - som)/((double)_Nevents);
118 }
static const double s
static const double m

◆ cvarAxAbarStar()

complex< double > CoherenceFactor::cvarAxAbarStar ( ) const
private

Definition at line 91 of file CoherenceFactor.cpp.

91  {
93 }
std::complex< double > _sumAxAbarStarSquared
std::complex< double > _sumAxAbarStar
std::complex< double > complexVar(std::complex< double > s, std::complex< double > s_sq) const

◆ estimatedPrecision()

double CoherenceFactor::estimatedPrecision ( ) const

Definition at line 61 of file CoherenceFactor.cpp.

61  {
62  if(_Nevents <= 0) return 9999;
63  double s = sigmaAbs();
64  if(s < 0) s *=-1;
65  return s;
66 }
static const double s
double sigmaAbs() const

◆ getCVal()

complex< double > CoherenceFactor::getCVal ( )

Definition at line 217 of file CoherenceFactor.cpp.

217  {
218  bool dbThis=false;
219  if(dbThis) cout << "Hello from CoherenceFactor::getCVal()" << endl;
220  long int rediculousNumber = 1000000000;
221  long int tries=0;
222 
223  int printEvery = 10000;
224 
225  while(estimatedPrecision() > _precision && tries < rediculousNumber){
226  for(int i=0; i < 1000; i++){
227  tries++;
228  bool printout = tries < 10 || (0 == tries%printEvery);
229 
231 
232  if(0 == evtPtr){
233  if(dbThis) cout << "WARNING in CoherenceFactor::getR()"
234  << " got evtPtr = " << evtPtr << endl;
235  continue;
236  }
237  //cout << "evtPtr->phaseSpace() " << evtPtr->phaseSpace() << endl;
238 
239  double w = evtPtr->getWeight()
240  /evtPtr->getGeneratorPdfRelativeToPhaseSpace();
241 
242  w*= getEff(*evtPtr);
243 
244  w = sqrt(w); // since we apply the weight to the amplitudes,
245  // while the integrals (as one might expect) all
246  // contain terms |A|^2, |Abar|^2, or |A*Abar|.
247 
248  complex<double> c_a=
249  A_Value(*evtPtr) * w;
250 
251  complex<double> c_abar=
252  Abar_Value(*evtPtr) *w*polar(_CSAbs, _CSPhase);
253 
254  double d_a = norm(c_a);
255  double d_abar = norm(c_abar);
256 
257  _sumASq += d_a;
258  _sumASqSquared += d_a*d_a;
259 
260  _sumAbarSq += d_abar;
261  _sumAbarSqSquared += d_abar*d_abar;
262 
263  complex<double> c_prod = c_a * conj(c_abar);
264  _sumAxAbarStar += c_prod;
265  complex<double> c_prodSquared(c_prod.real() * c_prod.real()
266  , c_prod.imag() * c_prod.imag()
267  );
268  _sumAxAbarStarSquared += c_prodSquared;
269 
270  _Nevents++;
271 
272  if(printout){
273  cout << " DalitzEvent::EventCounter() "
275  << endl;
276  cout << "INFO from CoherenceFactor::getR()"
277  << "\n\t tries: " << tries << ", for " << _Nevents << " events."
278  << endl;
279  // << "\n\t c_a, c_abar: " << c_a << ", " << c_abar
280  // << "\n\t value: " << Rval()
281  // << " = " << abs(Rval()) << " * exp( i * " << arg(Rval()) << " )"
282  // << " +/- " << estimatedPrecision()
283  // << endl;
284  printResult();
285  cout << " --------------------------------- " << endl;
286  }
287  }
288  }
289  return Rval();
290 }
std::complex< double > _sumAxAbarStarSquared
void printResult(std::ostream &os=std::cout) const
std::complex< double > _sumAxAbarStar
static long int eventCounter()
Definition: DalitzEvent.h:125
MINT::counted_ptr< IDalitzEvent > newEvent()
std::complex< double > Rval() const
double estimatedPrecision() const
std::complex< double > Abar_Value(IDalitzEvent &evt)
double _sumAbarSqSquared
double getEff(IDalitzEvent &evt)
std::complex< double > A_Value(IDalitzEvent &evt)

◆ getEff() [1/2]

double CoherenceFactor::getEff ( IDalitzEvent evt)
private

Definition at line 57 of file CoherenceFactor.cpp.

57  {
58  if(0 == _eff) return 1.0;
59  return _eff->RealVal(evt);
60 }
virtual double RealVal(EVENT_TYPE &evt)=0
MINT::IReturnRealForEvent< IDalitzEvent > * _eff

◆ getEff() [2/2]

double CoherenceFactor::getEff ( MINT::counted_ptr< IDalitzEvent evtPtr)
inlineprivate

Definition at line 75 of file CoherenceFactor.h.

75  {
76  if(0 == evtPtr) return 0;
77  return getEff(*evtPtr);// just for backward compatibility.
78  }
double getEff(IDalitzEvent &evt)

◆ getGenerator()

counted_ptr< IEventGenerator< IDalitzEvent > > CoherenceFactor::getGenerator ( )
private

Definition at line 39 of file CoherenceFactor.cpp.

39  {
40  bool dbThis=false;
41  if(0 == _myOwnGenAplusAbar){
42  if(dbThis) cout << "CoherenceFactor::getGenerator(): "
43  << "making generator" << endl;
44  if(_A_plus_Abar.size() <= 0) return 0;
47  ptr( new DalitzBWBoxSet(_A_plus_Abar.makeBWBoxes(pat)));
48  if(dbThis) cout << "made generator." << endl;
49  _myOwnGenAplusAbar = ptr;
50  }
51  return _myOwnGenAplusAbar;
52 }
DalitzEventPattern getTreePattern() const
Definition: FitAmplitude.h:169
virtual FitAmplitude * getAmpPtr(unsigned int i)
virtual DalitzBWBoxSet makeBWBoxes(const DalitzEventPattern &pat, TRandom *rnd=gRandom)
Definition: FitAmpSum.h:81
MINT::counted_ptr< MINT::IEventGenerator< IDalitzEvent > > _myOwnGenAplusAbar
virtual unsigned int size() const
FitAmpSum _A_plus_Abar

◆ integA()

double CoherenceFactor::integA ( ) const
private

Definition at line 72 of file CoherenceFactor.cpp.

72  {
73  if(_Nevents <=0) return 0;
74  if(_sumASq <=0) return -9999;
75  return sqrt(_sumASq / ((double) _Nevents));
76 }

◆ integAbar()

double CoherenceFactor::integAbar ( ) const
private

Definition at line 77 of file CoherenceFactor.cpp.

77  {
78  if(_Nevents <=0) return 0;
79  if(_sumAbarSq <=0) return -9999;
80  return sqrt(_sumAbarSq / ((double) _Nevents));
81 }

◆ integAbarSq()

double CoherenceFactor::integAbarSq ( ) const
private

Definition at line 86 of file CoherenceFactor.cpp.

86  {
87  if(_Nevents <=0) return 0;
88  return _sumAbarSq / ((double) _Nevents);
89 }

◆ integASq()

double CoherenceFactor::integASq ( ) const
private

Definition at line 82 of file CoherenceFactor.cpp.

82  {
83  if(_Nevents <=0) return 0;
84  return _sumASq / ((double) _Nevents);
85 }

◆ integAxAbarStar()

complex< double > CoherenceFactor::integAxAbarStar ( ) const
private

Definition at line 68 of file CoherenceFactor.cpp.

68  {
69  if(_Nevents <=0) return 0;
70  return _sumAxAbarStar / ((double) _Nevents);
71 }
std::complex< double > _sumAxAbarStar

◆ newEvent()

counted_ptr< IDalitzEvent > CoherenceFactor::newEvent ( )
private

Definition at line 53 of file CoherenceFactor.cpp.

53  {
54  return getGenerator()->newEvent();
55 }
MINT::counted_ptr< MINT::IEventGenerator< IDalitzEvent > > getGenerator()
virtual counted_ptr< RETURN_TYPE > newEvent()=0

◆ printResult()

void CoherenceFactor::printResult ( std::ostream &  os = std::cout) const

Definition at line 175 of file CoherenceFactor.cpp.

175  {
176  os << "Integrals from CoherenceFactor\n"
177  << "\t int |A|^2: " << integASq()
178  << ", int |Abar|^2 " << integAbarSq();
179  double rBSq = _CSAbs*_CSAbs;
180  if(rBSq > 0){
181  os << "\n\t int |Abar|^2/rB^2 " << integAbarSq()/rBSq;
182  }
183  if(integAbarSq() > 0){
184  os << "\n ratio int |A|^2 / int |Abar|^2 = " << integASq()/integAbarSq()
185  << ", ratio * rB^2 = " << rBSq*integASq()/integAbarSq();
186  }
187  os << "\n\n Coherence factor result (same result, different formats):"
188  << "\n\tR exp(i xi) = " << Rval() << " +/- " << sigma()
189  << "\n\tR exp(i xi) = " << abs(Rval())
190  << " * exp( i * " << arg(Rval()) << " )"
191  << "\n\t sig(R) = " << sigmaAbs()
192  << " sig(xi) = " << sigmaAngle()
193  << "\n\tR exp(i xi) = " << abs(Rval())
194  << " * exp( i * " << arg(Rval())*180.0/pi << " deg )"
195  << "\n\t sig(R) = " << sigmaAbs()
196  << " sig(xi) = " << sigmaAngle()*180.0/pi << " deg";
197  if(arg(Rval()) < 0){
198  cout << "\n\tR exp(i xi) = " << abs(Rval())
199  << " * exp( i * " << arg(Rval())*180.0/pi + 360. << " deg )"
200  << "\n\t sig(R) = " << sigmaAbs()
201  << " sig(xi) = " << sigmaAngle()*180.0/pi << " deg";
202  }
203  cout << endl;
204 }
double sigmaAngle() const
static const double pi
std::complex< double > sigma() const
std::complex< double > Rval() const
double sigmaAbs() const
double integAbarSq() const
double integASq() const

◆ realAorAbarVar()

double CoherenceFactor::realAorAbarVar ( double  s,
double  sq 
) const
private

Definition at line 94 of file CoherenceFactor.cpp.

94  {
95  if(_Nevents <=0 ) return 0;
96  if(s == 0) return -9999;
97  double m = s/((double) _Nevents);
98  double msq = sq/((double) _Nevents);
99  double varAsq = (msq - m*m)/((double) _Nevents);
100 
101  return 0.5 * varAsq / fabs(s);
102 }
static const double s
static const double m

◆ Rval()

complex< double > CoherenceFactor::Rval ( ) const
private

Definition at line 170 of file CoherenceFactor.cpp.

170  {
171  if(_Nevents <= 0 || integA() <= 0 || integAbar() <= 0) return -9999;
172  return integAxAbarStar() / (integA() * integAbar());
173 }
double integA() const
std::complex< double > integAxAbarStar() const
double integAbar() const

◆ setPrecision()

void CoherenceFactor::setPrecision ( double  prec)
inline

Definition at line 95 of file CoherenceFactor.h.

95 {_precision = prec;}

◆ sigma()

complex< double > CoherenceFactor::sigma ( ) const

Definition at line 144 of file CoherenceFactor.cpp.

144  {
145  return complex<double>(sqrt(fabs(var().real())), sqrt(fabs(var().imag())));
146 }
std::complex< double > var() const

◆ sigmaAbs()

double CoherenceFactor::sigmaAbs ( ) const

Definition at line 152 of file CoherenceFactor.cpp.

152  {
153  double va = varAbs();
154  if(va < 0) return -9999;
155  return sqrt(va);
156 }
double varAbs() const

◆ sigmaAngle()

double CoherenceFactor::sigmaAngle ( ) const

Definition at line 165 of file CoherenceFactor.cpp.

165  {
166  double va = varAngle();
167  if(va < 0) return -9999;
168  return sqrt(va);
169 }
double varAngle() const

◆ var()

complex< double > CoherenceFactor::var ( ) const

Definition at line 121 of file CoherenceFactor.cpp.

121  {
122  bool dbThis=false;
123 
124  complex<double> m = Rval();
125  complex<double> som(m.real()*m.real(), m.imag()*m.imag());
126 
127  double den = integA()*integA() * integAbar()*integAbar();
128  if(den <= 0) return complex<double>(-9999,-9999);
129 
130  double ar = cvarAxAbarStar().real() / den;
131  double ai = cvarAxAbarStar().imag() / den;
132  complex<double> a(ar, ai);
133  complex<double> b = varA()/(integA()*integA()) * som;
134  complex<double> c = varAbar()/(integAbar()*integAbar()) * som;
135 
136  if(dbThis){
137  cout << " cvarAxAbarStar() << " << cvarAxAbarStar() << endl;
138  cout << "var() = " << a << " + " << b << " + " << c
139  << " = " << a + b + c << endl;
140  }
141  return a + b + c;
142 }
std::complex< double > cvarAxAbarStar() const
std::complex< double > Rval() const
double integA() const
static const double m
double varAbar() const
double integAbar() const
double varA() const

◆ varA()

double CoherenceFactor::varA ( ) const
private

Definition at line 103 of file CoherenceFactor.cpp.

103  {
105 }
double realAorAbarVar(double s, double sq) const

◆ varAbar()

double CoherenceFactor::varAbar ( ) const
private

Definition at line 106 of file CoherenceFactor.cpp.

106  {
108 }
double realAorAbarVar(double s, double sq) const
double _sumAbarSqSquared

◆ varAbs()

double CoherenceFactor::varAbs ( ) const

Definition at line 147 of file CoherenceFactor.cpp.

147  {
148  double a = var().real() * 2*fabs(Rval().real()/norm(Rval()));
149  double b = var().imag() * 2*fabs(Rval().imag()/norm(Rval()));
150  return a+b;
151 }
std::complex< double > var() const
std::complex< double > Rval() const

◆ varAngle()

double CoherenceFactor::varAngle ( ) const

Definition at line 157 of file CoherenceFactor.cpp.

157  {
158  double a= fabs(Rval().real());
159  double b= fabs(Rval().imag());
160  double den = a*a + b*b;
161  if(den <= 0)return -9999;
162 
163  return var().real()*b/den + var().imag()*a/den;
164 }
std::complex< double > var() const
std::complex< double > Rval() const

Member Data Documentation

◆ _A

FitAmpSum* CoherenceFactor::_A
private

Definition at line 29 of file CoherenceFactor.h.

◆ _A_plus_Abar

FitAmpSum CoherenceFactor::_A_plus_Abar
private

Definition at line 33 of file CoherenceFactor.h.

◆ _Abar

FitAmpSum * CoherenceFactor::_Abar
private

Definition at line 29 of file CoherenceFactor.h.

◆ _CSAbs

double CoherenceFactor::_CSAbs
private

Definition at line 30 of file CoherenceFactor.h.

◆ _CSPhase

double CoherenceFactor::_CSPhase
private

Definition at line 31 of file CoherenceFactor.h.

◆ _eff

MINT::IReturnRealForEvent<IDalitzEvent>* CoherenceFactor::_eff
private

Definition at line 35 of file CoherenceFactor.h.

◆ _myOwnGenAplusAbar

MINT::counted_ptr< MINT::IEventGenerator<IDalitzEvent> > CoherenceFactor::_myOwnGenAplusAbar
private

Definition at line 34 of file CoherenceFactor.h.

◆ _Nevents

long int CoherenceFactor::_Nevents
private

Definition at line 42 of file CoherenceFactor.h.

◆ _precision

double CoherenceFactor::_precision
private

Definition at line 36 of file CoherenceFactor.h.

◆ _sumAbarSq

double CoherenceFactor::_sumAbarSq
private

Definition at line 39 of file CoherenceFactor.h.

◆ _sumAbarSqSquared

double CoherenceFactor::_sumAbarSqSquared
private

Definition at line 39 of file CoherenceFactor.h.

◆ _sumASq

double CoherenceFactor::_sumASq
private

Definition at line 38 of file CoherenceFactor.h.

◆ _sumASqSquared

double CoherenceFactor::_sumASqSquared
private

Definition at line 38 of file CoherenceFactor.h.

◆ _sumAxAbarStar

std::complex<double> CoherenceFactor::_sumAxAbarStar
private

Definition at line 40 of file CoherenceFactor.h.

◆ _sumAxAbarStarSquared

std::complex<double> CoherenceFactor::_sumAxAbarStarSquared
private

Definition at line 40 of file CoherenceFactor.h.


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