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

#include <CoherenceFactorCalculator.h>

Public Member Functions

 CoherenceFactorCalculator (FitAmpSum &A, FitAmpSum &Abar, double CSAbs=1, double CSPhase=0.0, MINT::IReturnRealForEvent< IDalitzEvent > *eff=0, double prec=1.e-3, const std::string &name="coherenceFactorC")
 
void printResult (std::ostream &os=std::cout) const
 
std::complex< double > evaluate ()
 
void setPrecision (double prec)
 
double estimatedPrecision () const
 
double effA () const
 
double effAbar () const
 
double effAVar () const
 
double effAbarVar () const
 
double effASigma () const
 
double effAbarSigma () const
 

Private Member Functions

MINT::counted_ptr< MINT::IEventGenerator< IDalitzEvent > > getGenerator ()
 
MINT::counted_ptr< IDalitzEventnewEvent ()
 

Private Attributes

FitAmpSum _A_plus_Abar
 
MINT::counted_ptr< MINT::IEventGenerator< IDalitzEvent > > _myOwnGenAplusAbar
 
double _precision
 
std::string _name
 
std::vector< MINT::counted_ptr< CoherenceFactorStoreAndEvaluate > > _cfList
 

Detailed Description

Definition at line 27 of file CoherenceFactorCalculator.h.

Constructor & Destructor Documentation

◆ CoherenceFactorCalculator()

CoherenceFactorCalculator::CoherenceFactorCalculator ( FitAmpSum A,
FitAmpSum Abar,
double  CSAbs = 1,
double  CSPhase = 0.0,
MINT::IReturnRealForEvent< IDalitzEvent > *  eff = 0,
double  prec = 1.e-3,
const std::string &  name = "coherenceFactorC" 
)

Definition at line 21 of file CoherenceFactorCalculator.cpp.

28  : _A_plus_Abar(A+Abar)
30  , _precision(prec)
31  , _name(name)
32 {
34  ptr_flat(new CoherenceFactorStoreAndEvaluate(A, Abar
35  , CSAbs, CSPhase
36  , 0, prec));
37  _cfList.push_back(ptr_flat);
38 
40  ptr_eff(new CoherenceFactorStoreAndEvaluate(A, Abar
41  , CSAbs, CSPhase
42  , eff, prec));
43  _cfList.push_back(ptr_eff);
44 
45 }
MINT::counted_ptr< MINT::IEventGenerator< IDalitzEvent > > _myOwnGenAplusAbar
std::vector< MINT::counted_ptr< CoherenceFactorStoreAndEvaluate > > _cfList

Member Function Documentation

◆ effA()

double CoherenceFactorCalculator::effA ( ) const

Definition at line 66 of file CoherenceFactorCalculator.cpp.

66  {
67  if(_cfList.size() < 2) return 1;
68  double d = _cfList[0]->integASq();
69  if(d <=0){
70  return -1;
71  }else{
72  return _cfList[1]->integASq()/d;
73  }
74 }
std::vector< MINT::counted_ptr< CoherenceFactorStoreAndEvaluate > > _cfList

◆ effAbar()

double CoherenceFactorCalculator::effAbar ( ) const

Definition at line 75 of file CoherenceFactorCalculator.cpp.

75  {
76  if(_cfList.size() < 2) return 1;
77  double d = _cfList[0]->integAbarSq();
78  if(d <=0){
79  return -1;
80  }else{
81  return _cfList[1]->integAbarSq()/d;
82  }
83 }
std::vector< MINT::counted_ptr< CoherenceFactorStoreAndEvaluate > > _cfList

◆ effAbarSigma()

double CoherenceFactorCalculator::effAbarSigma ( ) const

Definition at line 110 of file CoherenceFactorCalculator.cpp.

110  {
111  double v = effAbarVar();
112  if(v < 0) return -1;
113  return sqrt(v);
114 }

◆ effAbarVar()

double CoherenceFactorCalculator::effAbarVar ( ) const

Definition at line 95 of file CoherenceFactorCalculator.cpp.

95  {
96  double d = _cfList[0]->integAbarSq();
97  if(d <=0){
98  return -1;
99  }else{
100  double vn = _cfList[1]->varAbarSq();
101  double vd = _cfList[0]->varAbarSq();
102  return vn/(d*d) + effAbar()*effAbar()*vd/(d*d);
103  }
104 }
std::vector< MINT::counted_ptr< CoherenceFactorStoreAndEvaluate > > _cfList

◆ effASigma()

double CoherenceFactorCalculator::effASigma ( ) const

Definition at line 105 of file CoherenceFactorCalculator.cpp.

105  {
106  double v = effAVar();
107  if(v < 0) return -1;
108  return sqrt(v);
109 }

◆ effAVar()

double CoherenceFactorCalculator::effAVar ( ) const

Definition at line 85 of file CoherenceFactorCalculator.cpp.

85  {
86  double d = _cfList[0]->integASq();
87  if(d <=0){
88  return -1;
89  }else{
90  double vn = _cfList[1]->varASq();
91  double vd = _cfList[0]->varASq();
92  return vn/(d*d) + effA()*effA()*vd/(d*d);
93  }
94 }
std::vector< MINT::counted_ptr< CoherenceFactorStoreAndEvaluate > > _cfList

◆ estimatedPrecision()

double CoherenceFactorCalculator::estimatedPrecision ( ) const

Definition at line 214 of file CoherenceFactorCalculator.cpp.

214  {
215  double prec = -9999;
216  for(unsigned int i=0; i < _cfList.size(); i++){
217  double tp = _cfList[i]->estimatedPrecision();
218  if(tp > prec) prec = tp;
219  }
220  return prec;
221 }
std::vector< MINT::counted_ptr< CoherenceFactorStoreAndEvaluate > > _cfList

◆ evaluate()

complex< double > CoherenceFactorCalculator::evaluate ( )

Definition at line 150 of file CoherenceFactorCalculator.cpp.

150  {
151  bool dbThis=false;
152  if(dbThis) cout << "Hello from CoherenceFactorCalculator::evaluate()" << endl;
153 
154  long int rediculousNumber = 1000000000;
155  int tries=0;
156  int printEvery = 10000;
157  int makeHistosEvery = 100000;
158  while(estimatedPrecision() > _precision && tries < rediculousNumber){
159  for(int i=0; i < 1000; i++){
160  tries++;
161  bool printout = tries < 10 || (0 == tries%printEvery);
162  bool makeHistos = (0 == tries%makeHistosEvery);
164  if(0 == evtPtr){
165  if(dbThis) cout << "WARNING in CoherenceFactor::getR()"
166  << " got evtPtr = " << evtPtr << endl;
167  continue;
168  }
169 
170  for(unsigned int i=0; i < _cfList.size(); i++){
171  _cfList[i]->addEvent(evtPtr);
172  }
173 
174  if(printout){
175  cout << " DalitzEvent::EventCounter() "
177  << endl;
178  cout << "INFO from CoherenceFactor::getR()"
179  << "\n\t tries: " << tries
180  << endl;
181  // << "\n\t c_a, c_abar: " << c_a << ", " << c_abar
182  // << "\n\t value: " << Rval()
183  // << " = " << abs(Rval()) << " * exp( i * " << arg(Rval()) << " )"
184  // << " +/- " << estimatedPrecision()
185  // << endl;
186  printResult();
187  cout << " --------------------------------- " << endl;
188  }
189  if(makeHistos){
190  /*
191  for(unsigned int i=0; i < _cfList.size(); i++){
192  char fname[1000];
193  sprintf(fname, "%s_%d", _name.c_str(), i);
194  _cfList[i]->saveHistos(fname);
195  _cfList[i]->drawHistos(fname);
196  }
197  */
198  if(_cfList.size() >=2){
199  _cfList[1]->drawHistosWith(*_cfList[0], _name + "AmpCompare", effA());
200  _cfList[1]->drawHistoRatios(*_cfList[0], _name + "Eff");
201  }
202  }
203  }
204  }
205  return _cfList[1]->Rval();
206 }
MINT::counted_ptr< IDalitzEvent > newEvent()
std::vector< MINT::counted_ptr< CoherenceFactorStoreAndEvaluate > > _cfList
static long int eventCounter()
Definition: DalitzEvent.h:125
void printResult(std::ostream &os=std::cout) const

◆ getGenerator()

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

Definition at line 48 of file CoherenceFactorCalculator.cpp.

48  {
49  bool dbThis=false;
50  if(0 == _myOwnGenAplusAbar){
51  if(dbThis) cout << "CoherenceFactorCalculator::getGenerator(): "
52  << "making generator" << endl;
53  if(_A_plus_Abar.size() <= 0) return 0;
56  ptr( new DalitzBWBoxSet(_A_plus_Abar.makeBWBoxes(pat)));
57  if(dbThis) cout << "made generator." << endl;
58  _myOwnGenAplusAbar = ptr;
59  }
60  return _myOwnGenAplusAbar;
61 }
MINT::counted_ptr< MINT::IEventGenerator< IDalitzEvent > > _myOwnGenAplusAbar
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
virtual unsigned int size() const

◆ newEvent()

counted_ptr< IDalitzEvent > CoherenceFactorCalculator::newEvent ( )
private

Definition at line 62 of file CoherenceFactorCalculator.cpp.

62  {
63  return getGenerator()->newEvent();
64 }
virtual counted_ptr< RETURN_TYPE > newEvent()=0
MINT::counted_ptr< MINT::IEventGenerator< IDalitzEvent > > getGenerator()

◆ printResult()

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

Definition at line 115 of file CoherenceFactorCalculator.cpp.

115  {
116  double R0 = -9999;
117  if(_cfList.size() >=2){
118  R0 = _cfList[0]->absR();
119  os << "Efficiencies from CoherenceFactorCalculater\n";
120  os << " A: " << effA() << " +/- " << effASigma();
121  os << ", Abar: " << effAbar() << " +/- " << effAbarSigma();
122  }
123  os << "\n Coherence Factors";
124  for(unsigned int i=0; i < _cfList.size(); i++){
125  if(0 == i){
126  os << "\n * No efficiency effects "
127  << " - 100% efficient detector\n";
128  }else{
129  os << "\n * Including efficiency effects\n";
130  }
131  _cfList[i]->print(os, "\t" + anythingToString((int) i) + ")");
132  if(i > 0){
133  os << "\n ....difference..relative..to..no..efficiency..effects:....";
134  os << "\n diff R= " << _cfList[i]->absR() - R0
135  << " +/- " << sqrt(_cfList[i]->varAbs() + _cfList[0]->varAbs());
136  if(R0 > 0){
137  os << "\n relative diff R= "
138  << ((_cfList[i]->absR() - _cfList[0]->absR())/R0)
139  << " +/- " << (sqrt(_cfList[i]->varAbs() + _cfList[0]->varAbs())/R0);
140  os << "\n diff phase= "
141  << _cfList[i]->phaseRdeg() - _cfList[0]->phaseRdeg()
142  << " +/- " << sqrt(_cfList[i]->varAngleDeg() + _cfList[0]->varAngleDeg())
143  << "\n";
144  }
145  }
146  }
147  os << endl;
148 }
std::vector< MINT::counted_ptr< CoherenceFactorStoreAndEvaluate > > _cfList
std::string anythingToString(const T &anything)
Definition: Utils.h:62

◆ setPrecision()

void CoherenceFactorCalculator::setPrecision ( double  prec)

Definition at line 208 of file CoherenceFactorCalculator.cpp.

208  {
209  _precision = prec;
210  for(unsigned int i=0; i < _cfList.size(); i++){
211  _cfList[i]->setPrecision(prec);
212  }
213 }
std::vector< MINT::counted_ptr< CoherenceFactorStoreAndEvaluate > > _cfList

Member Data Documentation

◆ _A_plus_Abar

FitAmpSum CoherenceFactorCalculator::_A_plus_Abar
private

Definition at line 31 of file CoherenceFactorCalculator.h.

◆ _cfList

std::vector< MINT::counted_ptr< CoherenceFactorStoreAndEvaluate> > CoherenceFactorCalculator::_cfList
private

Definition at line 40 of file CoherenceFactorCalculator.h.

◆ _myOwnGenAplusAbar

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

Definition at line 32 of file CoherenceFactorCalculator.h.

◆ _name

std::string CoherenceFactorCalculator::_name
private

Definition at line 34 of file CoherenceFactorCalculator.h.

◆ _precision

double CoherenceFactorCalculator::_precision
private

Definition at line 33 of file CoherenceFactorCalculator.h.


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