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

#include <FitAmpPairList.h>

Inheritance diagram for FitAmpPairList:
MINT::PolymorphVector< FitAmpPair > IIntegrationCalculator

Public Member Functions

 FitAmpPairList ()
 
 FitAmpPairList (const FitAmpPairList &other)
 
virtual ~FitAmpPairList ()
 
MINT::counted_ptr< IIntegrationCalculatorclone_IIntegrationCalculator () const
 
virtual void addAmps (FitAmplitude *a1, FitAmplitude *a2)
 
virtual void addAmps (FitAmplitude &a1, FitAmplitude &a2)
 
virtual void addEvent (IDalitzEvent *evtPtr, double weight=1)
 
virtual void addEvent (IDalitzEvent &evt, double weight=1)
 
virtual void addEvent (MINT::counted_ptr< IDalitzEvent > evtPtr, double weight=1)
 
virtual void reAddEvent (IDalitzEvent &evt, double weight=1)
 
bool isCompatibleWith (const FitAmpPairList &other) const
 
virtual bool add (const FitAmpPairList &otherList)
 
virtual bool add (const FitAmpPairList *otherListPtr)
 
virtual bool add (MINT::const_counted_ptr< FitAmpPairList > otherListPtr)
 
virtual bool append (const FitAmpPairList &otherListPtr)
 
virtual bool append (const FitAmpPairList *otherListPtr)
 
virtual bool append (MINT::const_counted_ptr< FitAmpPairList > otherListPtr)
 
virtual int numEvents () const
 
virtual double integral () const
 
std::complex< double > ComplexIntegralForTags (int tag1, int tag2) const
 
double integralForMatchingPatterns (bool match, int pattern_sign) const
 
std::complex< double > ComplexSumForMatchingPatterns (bool match) const
 
virtual double variance () const
 
virtual double sumOfVariances () const
 
virtual std::complex< double > ComplexSum () const
 
virtual void Gradient (MINT::MinuitParameterSet *mps, std::vector< double > &grad)
 
virtual void GradientForLasso (MINT::MinuitParameterSet *mps, std::vector< double > &grad)
 
double sumOfSqrtFitFractions ()
 
double absSumOfInterferenceFractions ()
 
double absSumOfSqrtInterferenceFractions ()
 
double sumOfFitFractions ()
 
int numberOfFitFractionsLargerThanThreshold (double threshold)
 
FitFractionList getFractions () const
 
FitFractionList getInterferenceTerms () const
 
bool doFractions ()
 
void setEfficiency (MINT::counted_ptr< MINT::IReturnRealForEvent< IDalitzEvent > > eff)
 
void unsetEfficiency ()
 
double efficiency (IDalitzEvent *evtPtr)
 
bool haveEfficiency () const
 
virtual bool makeAndStoreFractions (MINT::Minimiser *mini=0)
 
virtual bool makeAndStoreFractions (const std::string &fname, const std::string &fnameROOT, MINT::Minimiser *min=0)
 
virtual double getFractionChi2 () const
 
virtual DalitzHistoSet histoSet () const
 
virtual DalitzHistoSet un_normalised_histoSetRe () const
 
virtual DalitzHistoSet un_normalised_histoSetIm () const
 
void saveEachAmpsHistograms (const std::string &prefix) const
 
std::vector< DalitzHistoSetGetEachAmpsHistograms ()
 
DalitzHistoSet interferenceHistoSet () const
 
void saveInterferenceHistograms (const std::string &prefix) const
 
std::vector< DalitzHistoSetGetInterferenceHistograms ()
 
virtual void doFinalStats (MINT::Minimiser *min=0)
 
virtual void doFinalStatsAndSave (MINT::Minimiser *min=0, const std::string &fname="FitAmpResults.txt", const std::string &fnameROOT="fitFractions.root")
 
virtual bool save (const std::string &asSubdirOf=".") const
 
virtual bool retrieve (const std::string &asSubdirOf=".")
 
virtual void print (std::ostream &os=std::cout) const
 
bool needToReIntegrate () const
 
void startIntegration ()
 
void startReIntegration ()
 
void startForcedReIntegration ()
 
void endIntegration ()
 
void setSlow ()
 
void setFast ()
 
bool slow () const
 
bool fast () const
 
FitAmpPairListoperator+= (const FitAmpPairList &other)
 
FitAmpPairList operator+ (const FitAmpPairList &other) const
 
- Public Member Functions inherited from MINT::PolymorphVector< FitAmpPair >
 PolymorphVector ()
 
 PolymorphVector (unsigned int N)
 
 PolymorphVector (unsigned int N, const FitAmpPair &c)
 
 PolymorphVector (const PolymorphVector &other)
 
 PolymorphVector (const typename std::vector< FitAmpPair > &other)
 
virtual ~PolymorphVector ()
 
std::vector< FitAmpPair > & theVector ()
 
const std::vector< FitAmpPair > & theVector () const
 
FitAmpPairoperator[] (unsigned int i)
 
const FitAmpPairoperator[] (unsigned int i) const
 
FitAmpPairat (unsigned int i)
 
const FitAmpPairat (unsigned int i) const
 
std::vector< FitAmpPair >::iterator begin ()
 
std::vector< FitAmpPair >::const_iterator begin () const
 
std::vector< FitAmpPair >::iterator end ()
 
std::vector< FitAmpPair >::const_iterator end () const
 
std::vector< FitAmpPair >::iterator find (const FitAmpPair &c)
 
std::vector< FitAmpPair >::const_iterator find (const FitAmpPair &c) const
 
FitAmpPairfront ()
 
const FitAmpPairfront () const
 
FitAmpPairback ()
 
const FitAmpPairback () const
 
unsigned int size () const
 
bool empty () const
 
void push_back (const FitAmpPair &c)
 
void pop_back ()
 
void erase (typename std::vector< FitAmpPair >::iterator pos)
 
void erase (typename std::vector< FitAmpPair >::iterator first, typename std::vector< FitAmpPair >::iterator last)
 
PolymorphVector< FitAmpPair > & operator= (const PolymorphVector< FitAmpPair > &other)
 
void clear ()
 
void resize (unsigned int N)
 
void resize (unsigned int N, const FitAmpPair &c)
 
 operator const typename std::vector< FitAmpPair > & () const
 
 operator typename std::vector< FitAmpPair > & ()
 
bool operator== (const MINT::PolymorphVector< FitAmpPair > &v2) const
 
bool operator!= (const MINT::PolymorphVector< FitAmpPair > &v2) const
 
bool operator< (const MINT::PolymorphVector< FitAmpPair > &v2) const
 
bool operator> (const MINT::PolymorphVector< FitAmpPair > &v2) const
 
- Public Member Functions inherited from IIntegrationCalculator
virtual ~IIntegrationCalculator ()
 

Private Member Functions

void applyHistoOption ()
 
double phaseSpaceIntegral () const
 
std::string dirName () const
 
bool makeDirectory (const std::string &asSubdirOf=".") const
 
virtual double oldVariance () const
 
bool reset ()
 

Private Attributes

MINT::NamedParameter< std::string > HistoOption
 
int _Nevents
 
double _sum
 
double _sumsq
 
double _psSum
 
double _psSumSq
 
bool _slow
 
FitAmpPairCovariance _cov
 
MINT::counted_ptr< MINT::IReturnRealForEvent< IDalitzEvent > > _efficiency
 
FitFractionList _singleAmpFractions
 
FitFractionList _interferenceFractions
 

Additional Inherited Members

- Protected Attributes inherited from MINT::PolymorphVector< FitAmpPair >
std::vector< FitAmpPair_vec
 

Detailed Description

Definition at line 27 of file FitAmpPairList.h.

Constructor & Destructor Documentation

◆ FitAmpPairList() [1/2]

FitAmpPairList::FitAmpPairList ( )

Definition at line 50 of file FitAmpPairList.cpp.

52  , _Nevents(0)
53  , _sum(0)
54  , _sumsq(0)
55  , _psSum(0)
56  , _psSumSq(0)
57  , _slow(true)
58  , _cov(this)
59  , _efficiency(0)
60  , HistoOption("FitAmpPairList::HistoOption", (std::string) "default")
61 {
63 }
MINT::NamedParameter< std::string > HistoOption
FitAmpPairCovariance _cov
MINT::counted_ptr< MINT::IReturnRealForEvent< IDalitzEvent > > _efficiency

◆ FitAmpPairList() [2/2]

FitAmpPairList::FitAmpPairList ( const FitAmpPairList other)

Definition at line 64 of file FitAmpPairList.cpp.

67  , _Nevents(other._Nevents)
68  , _sum(other._sum)
69  , _sumsq(other._sumsq)
70  , _psSum(other._psSum)
71  , _psSumSq(other._psSumSq)
72  , _slow(other._slow)
73  , _cov(other._cov, this)
74  , _efficiency(other._efficiency)
75  , HistoOption("FitAmpPairList::HistoOption", (std::string) "default")
76 {
78 }
MINT::NamedParameter< std::string > HistoOption
FitAmpPairCovariance _cov
MINT::counted_ptr< MINT::IReturnRealForEvent< IDalitzEvent > > _efficiency

◆ ~FitAmpPairList()

virtual FitAmpPairList::~FitAmpPairList ( )
inlinevirtual

Definition at line 60 of file FitAmpPairList.h.

60 {}

Member Function Documentation

◆ absSumOfInterferenceFractions()

double FitAmpPairList::absSumOfInterferenceFractions ( )

Definition at line 430 of file FitAmpPairList.cpp.

430  {
431  double sum = 0;
432  for(unsigned int i=0; i< this->size(); i++){
433  if(!this->at(i).isSingleAmp())sum += abs(this->at(i).integral());
434  }
435  return sum/integral();
436 }
double integral() const
Definition: FitAmpPair.cpp:476
FitAmpPair & at(unsigned int i)
virtual double integral() const
bool isSingleAmp() const
Definition: FitAmpPair.cpp:590

◆ absSumOfSqrtInterferenceFractions()

double FitAmpPairList::absSumOfSqrtInterferenceFractions ( )

Definition at line 422 of file FitAmpPairList.cpp.

422  {
423  double sum = 0;
424  for(unsigned int i=0; i< this->size(); i++){
425  if(!this->at(i).isSingleAmp())sum += sqrt(abs(this->at(i).integral()));
426  }
427  return sum;
428 }
FitAmpPair & at(unsigned int i)
virtual double integral() const
bool isSingleAmp() const
Definition: FitAmpPair.cpp:590

◆ add() [1/3]

bool FitAmpPairList::add ( const FitAmpPairList otherList)
virtual

Definition at line 177 of file FitAmpPairList.cpp.

177  {
178  if(! isCompatibleWith(otherList)){
179  cout << "ERROR in FitAmpPairList::add "
180  << "trying to add incompatible lists"
181  << endl;
182  return false;
183  }
184 
185  _Nevents += otherList._Nevents;
186  _sum += otherList._sum;
187  _sumsq += otherList._sumsq;
188  _psSum += otherList._psSum;
189  _psSumSq += otherList._psSumSq;
190 
191  _cov += otherList._cov;
192 
193  for(unsigned int i=0; i< this->size(); i++){
194  this->at(i) += otherList[i];
195  }
196 
197  return true;
198 
199 }
FitAmpPairCovariance _cov
bool isCompatibleWith(const FitAmpPairList &other) const
FitAmpPair & at(unsigned int i)

◆ add() [2/3]

bool FitAmpPairList::add ( const FitAmpPairList otherListPtr)
virtual

Definition at line 165 of file FitAmpPairList.cpp.

165  {
166  if(0 != otherListPtr){
167  return add(*otherListPtr);
168  }
169  return true;
170 }
virtual bool add(const FitAmpPairList &otherList)

◆ add() [3/3]

bool FitAmpPairList::add ( MINT::const_counted_ptr< FitAmpPairList otherListPtr)
virtual

Definition at line 171 of file FitAmpPairList.cpp.

171  {
172  if(0 != otherListPtr){
173  return add(*otherListPtr);
174  }
175  return true;
176 }
virtual bool add(const FitAmpPairList &otherList)

◆ addAmps() [1/2]

void FitAmpPairList::addAmps ( FitAmplitude a1,
FitAmplitude a2 
)
virtual

Definition at line 85 of file FitAmpPairList.cpp.

85  {
86  if(0 == a1 || 0 == a2){
87  cout << "Error in FitAmpPairList::addAmps: " << a1 << ", " << a2 << endl;
88  throw "zero pointer";
89  }
90  FitAmpPair amps(*a1, *a2);
91  this->push_back(amps);
92 }
void push_back(const FitAmpPair &c)

◆ addAmps() [2/2]

void FitAmpPairList::addAmps ( FitAmplitude a1,
FitAmplitude a2 
)
virtual

Definition at line 93 of file FitAmpPairList.cpp.

93  {
94  FitAmpPair amps(a1, a2);
95  this->push_back(amps);
96 }
void push_back(const FitAmpPair &c)

◆ addEvent() [1/3]

void FitAmpPairList::addEvent ( IDalitzEvent evtPtr,
double  weight = 1 
)
virtual

Implements IIntegrationCalculator.

Definition at line 98 of file FitAmpPairList.cpp.

98  {
99  if(0 == evtPtr) return;
100  addEvent(*evtPtr, weight);
101 }
virtual void addEvent(IDalitzEvent *evtPtr, double weight=1)

◆ addEvent() [2/3]

void FitAmpPairList::addEvent ( IDalitzEvent evt,
double  weight = 1 
)
virtual

Definition at line 103 of file FitAmpPairList.cpp.

103  {
104  bool dbThis=false;
105  static unsigned int nZeroPs=0;
106  _Nevents++;
107  double x=0;
108  double ps = evt.phaseSpace();
109  if(ps <= 0.0){
110  if (!(nZeroPs%1000))
111  {
112  cout << "WARNING in FitAmpPairList::addToHistograms"
113  << " " << ++nZeroPs << " th"
114  << " event with phase space = " << ps << endl;
115  return; // should not happen.
116  }
117  }
118 
119  for(unsigned int i=0; i< this->size(); i++){
120  // x += this->at(i).add(evtPtr, weight*efficiency(evtPtr));
121  x += this->at(i).add(evt, weight, efficiency(&evt));
122  }
123  if(dbThis) cout << "FitAmpPairList::addEvent(): adding event" << endl;
124  //if(_cov.isValid())
126 
127  _sum += x;
128  _sumsq += x*x;
129 
130  //if(0 == evtPtr) return;
131  //double ps = evtPtr->phaseSpace();
132  _psSum += ps;
133  _psSumSq += ps*ps;
134 
135  return;
136 }
virtual double phaseSpace() const =0
bool add(const FitAmpPair &other)
Definition: FitAmpPair.cpp:110
FitAmpPairCovariance _cov
FitAmpPair & at(unsigned int i)
double efficiency(IDalitzEvent *evtPtr)

◆ addEvent() [3/3]

void FitAmpPairList::addEvent ( MINT::counted_ptr< IDalitzEvent evtPtr,
double  weight = 1 
)
virtual

Implements IIntegrationCalculator.

Definition at line 137 of file FitAmpPairList.cpp.

137  {
138  return addEvent(evtPtr.get(), weight);
139 }
virtual void addEvent(IDalitzEvent *evtPtr, double weight=1)
X * get() const
Definition: counted_ptr.h:123

◆ append() [1/3]

bool FitAmpPairList::append ( const FitAmpPairList otherListPtr)
virtual

Definition at line 207 of file FitAmpPairList.cpp.

207  {
208  // WARNING: this will reset everything to zero.
209 
210  for(unsigned int i=0; i< otherList.size(); i++){
211  this->push_back(otherList[i]);
212  }
213  this->reset();
214 
215  return true;
216 
217 }
void push_back(const FitAmpPair &c)

◆ append() [2/3]

bool FitAmpPairList::append ( const FitAmpPairList otherListPtr)
virtual

Definition at line 204 of file FitAmpPairList.cpp.

204  {
205  return append(*otherListPtr);
206 }
virtual bool append(const FitAmpPairList &otherListPtr)

◆ append() [3/3]

bool FitAmpPairList::append ( MINT::const_counted_ptr< FitAmpPairList otherListPtr)
virtual

Definition at line 201 of file FitAmpPairList.cpp.

201  {
202  return append(*otherListPtr);
203 }
virtual bool append(const FitAmpPairList &otherListPtr)

◆ applyHistoOption()

void FitAmpPairList::applyHistoOption ( )
private

Definition at line 45 of file FitAmpPairList.cpp.

45  {
46  if((string)HistoOption == (string)"fast") setFast();
47  if((string)HistoOption == (string)"slow") setSlow();
48 }
MINT::NamedParameter< std::string > HistoOption

◆ clone_IIntegrationCalculator()

counted_ptr< IIntegrationCalculator > FitAmpPairList::clone_IIntegrationCalculator ( ) const
virtual

Implements IIntegrationCalculator.

Definition at line 80 of file FitAmpPairList.cpp.

◆ ComplexIntegralForTags()

std::complex< double > FitAmpPairList::ComplexIntegralForTags ( int  tag1,
int  tag2 
) const

Definition at line 242 of file FitAmpPairList.cpp.

242  {
243  std::complex<double> sum = 0;
244 
245  for(unsigned int i=0; i< this->size(); i++){
246  if((this->at(i).fitAmp1().getTag() == tag1) && ( this->at(i).fitAmp2().getTag() == tag2)){
247  sum += conj(this->at(i).complexVal());
248  }
249  else if((this->at(i).fitAmp1().getTag() == tag2) && ( this->at(i).fitAmp2().getTag() == tag1)){
250  sum += this->at(i).complexVal();
251  }
252  }
253  return sum;
254 }
std::complex< double > complexVal() const
Definition: FitAmpPair.h:126
FitAmplitude & fitAmp2()
Definition: FitAmpPair.h:160
FitAmpPair & at(unsigned int i)
double getTag() const
Definition: FitAmplitude.h:132

◆ ComplexSum()

std::complex< double > FitAmpPairList::ComplexSum ( ) const
virtual

Definition at line 281 of file FitAmpPairList.cpp.

281  { //laurenPsuedo
282  bool dbThis = false;
283  std::complex<double> sum = 0;
284  for(unsigned int i=0; i< this->size(); i++){
285  sum += this->at(i).complexVal();
286  }
287  return sum;
288  (void)dbThis;
289 }
std::complex< double > complexVal() const
Definition: FitAmpPair.h:126
FitAmpPair & at(unsigned int i)

◆ ComplexSumForMatchingPatterns()

std::complex< double > FitAmpPairList::ComplexSumForMatchingPatterns ( bool  match) const

Definition at line 269 of file FitAmpPairList.cpp.

269  {
270  std::complex<double> sum = 0;
271  for(unsigned int i=0; i< this->size(); i++){
272  if(this->at(i).hasMatchingPattern()==match){
273  std::complex<double> val = this->at(i).complexVal();
274  if(this->at(i).fitAmp1().theBareDecay().getVal() > this->at(i).fitAmp2().theBareDecay().getVal() ) val = conj(val);
275  sum += val;
276  }
277  }
278  return sum;
279 }
std::complex< double > complexVal() const
Definition: FitAmpPair.h:126
bool hasMatchingPattern() const
Definition: FitAmpPair.cpp:594
FitAmpPair & at(unsigned int i)

◆ dirName()

std::string FitAmpPairList::dirName ( ) const
private

Definition at line 1099 of file FitAmpPairList.cpp.

1099  {
1100  return "FitAmpPairList";
1101 }

◆ doFinalStats()

void FitAmpPairList::doFinalStats ( MINT::Minimiser min = 0)
virtual

Implements IIntegrationCalculator.

Definition at line 653 of file FitAmpPairList.cpp.

653  {
654  bool dbThis=true;
655  if(dbThis) cout << "FitAmpPairList::doFinalStats() called" << endl;
656  makeAndStoreFractions(mini);
657 }
virtual bool makeAndStoreFractions(MINT::Minimiser *mini=0)

◆ doFinalStatsAndSave()

virtual void FitAmpPairList::doFinalStatsAndSave ( MINT::Minimiser min = 0,
const std::string &  fname = "FitAmpResults.txt",
const std::string &  fnameROOT = "fitFractions.root" 
)
inlinevirtual

Definition at line 129 of file FitAmpPairList.h.

129  {
130  makeAndStoreFractions(fname,fnameROOT,min);
131  }
virtual bool makeAndStoreFractions(MINT::Minimiser *mini=0)

◆ doFractions()

bool FitAmpPairList::doFractions ( )

Definition at line 660 of file FitAmpPairList.cpp.

660  {
661 
662  if(this->empty()) return 0;
663 
666 
667  cout << "\n============================================"
668  << "============================================"
669  << "\n Amplitude Fractions";
670 
671  double norm = integral();
672 
673  if(norm <= 0){
674  cout << "ERROR in FitAmpPairList::makeAndStoreFractions()"
675  << " integral = " << integral()
676  << " won't do fractions."
677  << endl;
678  return false;
679  }
680 
681  for(unsigned int i=0; i < this->size(); i++){
682  double frac = this->at(i).integral()/norm;
683  string name;
684  if(this->at(i).isSingleAmp()){
685  name = this->at(i).fitAmp1().name();
686  }else{
687 // name = this->at(i).name();
688  name = this->at(i).fitAmp1().name() + "_x_" + this->at(i).fitAmp2().name();
689  }
690  FitFraction f(name, frac);
691 
692  if(this->at(i).isSingleAmp()){
693  this->at(i).fitAmp1().setFraction(frac);
695  }else{
697  }
698  }
699 
700  cout << "filled FitFractionLists" << endl;
701  FitFractionList interferenceFractionsSorted(_interferenceFractions);
702  interferenceFractionsSorted.sortByMagnitudeDecending();
703 
704  cout << "================================================="
705  << "\n================================================="
706  << "\n FRACTIONS:"
707  << "\n ^^^^^^^^^^" << endl;
708  cout << _singleAmpFractions << endl;
709  cout << "================================================="
710  << "\n================================================="
711  << "\n Interference terms (sorted by size)"
712  << "\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << endl;
713  cout << interferenceFractionsSorted << endl;
714  cout << "================================================="
715  << "\n=================================================" << endl;
716 
717  cout << "\n\n\t X-check: total sum of all terms"
718  << " (amplitude fractions + interference terms): "
721 
722  return true;
723 }
FitFractionList _singleAmpFractions
std::string name() const
Definition: FitAmplitude.h:213
double integral() const
Definition: FitAmpPair.cpp:476
FitAmplitude & fitAmp2()
Definition: FitAmpPair.h:160
FitAmplitude & fitAmp1()
Definition: FitAmpPair.h:153
void add(const FitFraction &f)
double & frac()
Definition: FitFraction.h:21
void setFraction(double fr)
Definition: FitAmplitude.h:121
FitAmpPair & at(unsigned int i)
virtual double integral() const
const FitFraction & sum() const
FitFractionList _interferenceFractions

◆ efficiency()

double FitAmpPairList::efficiency ( IDalitzEvent evtPtr)

Definition at line 529 of file FitAmpPairList.cpp.

529  {
530  if(0 == _efficiency) return 1;
531  if(0 == evtPtr) return 0;
532  return _efficiency->RealVal(*evtPtr);
533 }
virtual double RealVal(EVENT_TYPE &evt)=0
MINT::counted_ptr< MINT::IReturnRealForEvent< IDalitzEvent > > _efficiency

◆ endIntegration()

void FitAmpPairList::endIntegration ( )

Definition at line 1218 of file FitAmpPairList.cpp.

1218  {
1219  for(unsigned int i=0; i < this->size(); i++){
1220  this->at(i).endIntegration();
1221  }
1222 }
FitAmpPair & at(unsigned int i)
void endIntegration()
Definition: FitAmpPair.cpp:515

◆ fast()

bool FitAmpPairList::fast ( ) const
inline

Definition at line 150 of file FitAmpPairList.h.

150 {return !_slow;}

◆ GetEachAmpsHistograms()

std::vector< DalitzHistoSet > FitAmpPairList::GetEachAmpsHistograms ( )

Definition at line 576 of file FitAmpPairList.cpp.

576  {
577  std::vector<DalitzHistoSet> HistoSet;
578  DalitzHistoSet sum;
579  int counter=0;
580  for(unsigned int i=0; i< this->size(); i++){
581  if(this->at(i).isSingleAmp()){
582  counter++;
583  std::string name = anythingToString(counter) + ".root";
584  double frac = this->at(i).integral()/integral();
585  DalitzHistoSet hs(this->at(i).histoSet());
586  std::string title = this->at(i).fitAmp1().name();
587  hs.setTitle(title);
588  cout << "FitAmpPairList::saveEachAmpsHistograms: "
589  << "saving " << title << " as " << name << endl;
590  hs.scale(frac/hs.integral());
591  HistoSet.push_back(hs);
592  }
593  }
594  return HistoSet;
595 }
std::string name() const
Definition: FitAmplitude.h:213
double integral() const
Definition: FitAmpPair.cpp:476
FitAmplitude & fitAmp1()
Definition: FitAmpPair.h:153
FitAmpPair & at(unsigned int i)
virtual double integral() const
std::string anythingToString(const T &anything)
Definition: Utils.h:62
bool isSingleAmp() const
Definition: FitAmpPair.cpp:590
virtual DalitzHistoSet histoSet() const

◆ getFractionChi2()

double FitAmpPairList::getFractionChi2 ( ) const
virtual

Implements IIntegrationCalculator.

Definition at line 1067 of file FitAmpPairList.cpp.

1067  {
1068  bool ErrorProportionalToSqrtTarget = true;
1069  double norm = integral();
1070  if(norm <= 0){
1071  cout << "ERROR in FitAmpPairList::getFractionChi2()"
1072  << " integral = " << integral()
1073  << " won't do fractions. Returning " << 9999.0e30
1074  << endl;
1075  return 9999.0e30;
1076  }
1077 
1078  double canonicalError=0.001;
1079 
1080  int counter=0;
1081  double sum=0;
1082  for(unsigned int i=0; i < this->size(); i++){
1083  if(this->at(i).isSingleAmp()){
1084  counter++;
1085  double frac = this->at(i).integral()/norm;
1086  double target_f = this->at(i).fitAmp1().getFraction();
1087  //if(i < 10){
1088  //cout << "(" << frac << " - " << target_f << ")" << endl;
1089  //}
1090  double dfs=(frac - target_f)/canonicalError;
1091  if(ErrorProportionalToSqrtTarget && target_f > 0) dfs /= sqrt(0.01*target_f);
1092  sum += dfs*dfs;
1093  }
1094  }
1095  return sum;
1096 }
double integral() const
Definition: FitAmpPair.cpp:476
FitAmplitude & fitAmp1()
Definition: FitAmpPair.h:153
double getFraction() const
Definition: FitAmplitude.h:124
FitAmpPair & at(unsigned int i)
virtual double integral() const
bool isSingleAmp() const
Definition: FitAmpPair.cpp:590

◆ getFractions()

FitFractionList FitAmpPairList::getFractions ( ) const
inlinevirtual

Implements IIntegrationCalculator.

Definition at line 104 of file FitAmpPairList.h.

104 {return _singleAmpFractions;}
FitFractionList _singleAmpFractions

◆ GetInterferenceHistograms()

std::vector< DalitzHistoSet > FitAmpPairList::GetInterferenceHistograms ( )

Definition at line 627 of file FitAmpPairList.cpp.

627  {
628  std::vector<DalitzHistoSet> HistoSet;
629  DalitzHistoSet sum;
630  int counter=0;
631  for(unsigned int i=0; i< this->size(); i++){
632  if(!this->at(i).isSingleAmp()){
633  counter++;
634  std::string name = anythingToString(counter) + ".root";
635  double frac = this->at(i).integral()/integral();
636  DalitzHistoSet hs(this->at(i).histoSet());
637  std::string title = this->at(i).name();
638  hs.setTitle(title);
639  cout << "FitAmpPairList::saveEachAmpsHistograms: "
640  << "saving " << title << " as " << name << endl;
641  hs.scale(frac/hs.integral());
642  HistoSet.push_back(hs);
643  }
644  }
645  return HistoSet;
646 }
double integral() const
Definition: FitAmpPair.cpp:476
FitAmpPair & at(unsigned int i)
virtual double integral() const
std::string anythingToString(const T &anything)
Definition: Utils.h:62
bool isSingleAmp() const
Definition: FitAmpPair.cpp:590
virtual DalitzHistoSet histoSet() const
const std::string & name() const
Definition: FitAmpPair.cpp:605

◆ getInterferenceTerms()

FitFractionList FitAmpPairList::getInterferenceTerms ( ) const
inline

Definition at line 105 of file FitAmpPairList.h.

105 {return _interferenceFractions;}
FitFractionList _interferenceFractions

◆ Gradient()

void FitAmpPairList::Gradient ( MINT::MinuitParameterSet mps,
std::vector< double > &  grad 
)
virtual

Definition at line 291 of file FitAmpPairList.cpp.

291  {
292 
293  for (unsigned int i=0; i<mps->size(); i++) {
294  if(mps->getParPtr(i)->hidden())continue;
295 
296  if(i+1 >= grad.size()){
297  cout << "WARNING in FitAmpPairList::Gradient:"
298  << " have to increase size of grad to avoid memory issues" << endl;
299  grad.resize(i+2);
300  }
301 
302  grad.at(i)=0; grad.at(i+1)=0;
303 
304  string name_i= mps->getParPtr(i)->name();
305  if(name_i.find("_Re")!=std::string::npos){
306  if(mps->getParPtr(i)->iFixInit() && mps->getParPtr(i+1)->iFixInit()){
307  i++;
308  continue;
309  }
310  name_i.replace(name_i.find("_Re"),3,"");
311  complex<double> sum(0);
312  for(unsigned int j=0; j< this->size(); j++){
313  if(!A_is_in_B(name_i,this->at(j).name())) continue;
314  if(A_is_in_B("Inco", name_i) != A_is_in_B("Inco",this->at(j).name()) ) continue;
315  double singleAmpCorrection= 1.;
316  if(this->at(j).isSingleAmp()) singleAmpCorrection = 2.;
317  // 2 a_j^* A_i A_j^*
318  if(A_is_in_B(name_i,this->at(j).fitAmp1().name())){
319  sum += singleAmpCorrection* this->at(j).valNoFitPars()* conj(this->at(j).fitAmp2().AmpPhase());
320  }
321  else {
322  sum += singleAmpCorrection* conj( this->at(j).valNoFitPars()* this->at(j).fitAmp1().AmpPhase() );
323  }
324 
325  }
326  grad.at(i)= sum.real();
327  grad.at(i+1)= -sum.imag();
328  i++;
329  }
330  // Doesn't work. Don't use!
331  /*
332  else if(name_i.find("_Amp")!=std::string::npos){
333  name_i.replace(name_i.find("_Amp"),4,"");
334  complex<double> sumAmp(0);
335  complex<double> sumPhase(0);
336 
337  for(unsigned int j=0; j< this->size(); j++){
338  if(!A_is_in_B(name_i,this->at(j).name())) continue;
339  double singleAmpCorrection= 1.;
340  if(this->at(j).isSingleAmp()) singleAmpCorrection = 2.;
341  // 2 a_j^* A_i A_j^*
342  if(A_is_in_B(name_i,this->at(j).fitAmp1().name())){
343  sumAmp += singleAmpCorrection*this->at(j).complexVal()/std::abs(this->at(j).fitAmp1().AmpPhase());
344  if(!this->at(j).isSingleAmp())sumPhase += this->at(j).complexVal()*std::arg(this->at(j).fitAmp1().AmpPhase());
345  }
346  else {
347  sumAmp += singleAmpCorrection*conj(this->at(j).complexVal())/std::abs(this->at(j).fitAmp2().AmpPhase());
348  if(!this->at(j).isSingleAmp())sumPhase += conj(this->at(j).complexVal())*std::arg(this->at(j).fitAmp2().AmpPhase());
349  }
350 
351  }
352  grad[i]= sumAmp.real();
353  grad[i+1]= -sumPhase.imag();
354  i++;
355  }
356  */
357  else if(mps->getParPtr(i)->iFixInit())continue;
358  else {
359  std::cout << "FitAmpPairList::Gradient() called. Sorry, I don't know how to calculate the derivative with respect to the fit parameter " << mps->getParPtr(i)->name() << " ! Please implement me or set useAnalytic Gradient to 0 in your options file. I'll crash now. " << std::endl;
360  throw "crash";
361  }
362  }
363 
364 }
virtual int iFixInit() const =0
IMinuitParameter * getParPtr(unsigned int i)
unsigned int size() const
virtual const std::string & name() const =0
bool A_is_in_B(const std::string &a, const std::string &b)
Definition: Utils.cpp:34
FitAmpPair & at(unsigned int i)
virtual bool hidden() const =0
bool isSingleAmp() const
Definition: FitAmpPair.cpp:590
std::complex< double > valNoFitPars() const
Definition: FitAmpPair.cpp:447

◆ GradientForLasso()

void FitAmpPairList::GradientForLasso ( MINT::MinuitParameterSet mps,
std::vector< double > &  grad 
)
virtual

Definition at line 366 of file FitAmpPairList.cpp.

367  {
368 
369  for (unsigned int i=0; i<mps->size(); i++) {
370  if(mps->getParPtr(i)->hidden())continue;
371 
372  grad[i]=0; grad[i+1]=0;
373  string name_i= mps->getParPtr(i)->name();
374  if(name_i.find("_Re")!=std::string::npos){
375  if(mps->getParPtr(i)->iFixInit() && mps->getParPtr(i+1)->iFixInit())continue;
376  name_i.replace(name_i.find("_Re"),3,"");
377  for(unsigned int j=0; j< this->size(); j++){
378  if(!A_is_in_B(name_i,this->at(j).name())) continue;
379  if(A_is_in_B("Inco", name_i) != A_is_in_B("Inco",this->at(j).name()) ) continue;
380  if(!this->at(j).isSingleAmp()) continue;
381 
382  if(i+1 >= grad.size()){
383  cout << "WARNING in FitAmpPairList::GradientForLasso:"
384  << " have to increase size of grad to avoid memory issues" << endl;
385  grad.resize(i+2);
386  }
387 
388  double integral = this->at(j).valNoFitPars().real()/sqrt(this->at(j).integral());
389  // Re(a_j) A_j A_j^* dphi
390  grad[i]= integral * this->at(j).fitAmp1().AmpPhase().real();
391  // Im(a_j) A_j A_j^* dphi
392  grad[i+1]= integral * this->at(j).fitAmp1().AmpPhase().imag();
393  i++;
394  break;
395  }
396  }
397  else if(mps->getParPtr(i)->iFixInit())continue;
398  else {
399  std::cout << "Sorry, I don't know how to calculate the derivative with respect to the fit parameter " << mps->getParPtr(i)->name() << " ! Please implement me or set useAnalytic Gradient to 0 in your options file. I'll crash now. " << std::endl;
400  throw "crash";
401  }
402  }
403 
404 }
std::complex< double > AmpPhase() const
Definition: FitAmplitude.h:153
virtual int iFixInit() const =0
IMinuitParameter * getParPtr(unsigned int i)
unsigned int size() const
virtual const std::string & name() const =0
FitAmplitude & fitAmp1()
Definition: FitAmpPair.h:153
bool A_is_in_B(const std::string &a, const std::string &b)
Definition: Utils.cpp:34
FitAmpPair & at(unsigned int i)
virtual double integral() const
virtual bool hidden() const =0
bool isSingleAmp() const
Definition: FitAmpPair.cpp:590
std::complex< double > valNoFitPars() const
Definition: FitAmpPair.cpp:447

◆ haveEfficiency()

bool FitAmpPairList::haveEfficiency ( ) const
inline

Definition at line 111 of file FitAmpPairList.h.

111 {return 0 != _efficiency;}
MINT::counted_ptr< MINT::IReturnRealForEvent< IDalitzEvent > > _efficiency

◆ histoSet()

DalitzHistoSet FitAmpPairList::histoSet ( ) const
virtual

Implements IIntegrationCalculator.

Definition at line 540 of file FitAmpPairList.cpp.

540  {
542 }
virtual double integral() const
virtual DalitzHistoSet un_normalised_histoSetRe() const

◆ integral()

double FitAmpPairList::integral ( ) const
virtual

Implements IIntegrationCalculator.

Definition at line 234 of file FitAmpPairList.cpp.

234  {
235  double sum = 0;
236  for(unsigned int i=0; i< this->size(); i++){
237  sum += this->at(i).integral();
238  }
239  return sum;
240 }
double integral() const
Definition: FitAmpPair.cpp:476
FitAmpPair & at(unsigned int i)

◆ integralForMatchingPatterns()

double FitAmpPairList::integralForMatchingPatterns ( bool  match,
int  pattern_sign 
) const

Definition at line 256 of file FitAmpPairList.cpp.

256  {
257  double sum = 0;
258  for(unsigned int i=0; i< this->size(); i++){
259  if(this->at(i).hasMatchingPattern()==match){
260  if(match){
261  if(static_cast<double>(pattern_sign) * this->at(i).fitAmp1().theBareDecay().getVal() < 0 ) continue;
262  }
263  sum += this->at(i).integral();
264  }
265  }
266  return sum;
267 }
double integral() const
Definition: FitAmpPair.cpp:476
DecayTree theBareDecay() const
Definition: FitAmplitude.h:166
const ValueType & getVal() const
Definition: DDTree.h:102
FitAmplitude & fitAmp1()
Definition: FitAmpPair.h:153
bool hasMatchingPattern() const
Definition: FitAmpPair.cpp:594
FitAmpPair & at(unsigned int i)

◆ interferenceHistoSet()

DalitzHistoSet FitAmpPairList::interferenceHistoSet ( ) const

Definition at line 597 of file FitAmpPairList.cpp.

597  {
598  DalitzHistoSet sum;
599  for(unsigned int i=0; i< this->size(); i++){
600  if(!this->at(i).isSingleAmp())sum += this->at(i).histoSet();
601  }
602  sum /= integral();
603  // if(_Nevents > 0) sum /= (double) _Nevents;
604  // above two lines normalise this to 1.
605 
606  return sum;
607 }
DalitzHistoSet histoSet() const
Definition: FitAmpPair.h:151
FitAmpPair & at(unsigned int i)
virtual double integral() const
bool isSingleAmp() const
Definition: FitAmpPair.cpp:590

◆ isCompatibleWith()

bool FitAmpPairList::isCompatibleWith ( const FitAmpPairList other) const

Definition at line 158 of file FitAmpPairList.cpp.

158  {
159  if(this->size() != otherList.size()) return false;
160  for(unsigned int i=0; i < this->size(); i++){
161  if(this->at(i).name() != otherList[i].name()) return false;
162  }
163  return true;
164 }
FitAmpPair & at(unsigned int i)
const std::string & name() const
Definition: FitAmpPair.cpp:605

◆ makeAndStoreFractions() [1/2]

virtual bool FitAmpPairList::makeAndStoreFractions ( MINT::Minimiser mini = 0)
inlinevirtual

Implements IIntegrationCalculator.

Definition at line 113 of file FitAmpPairList.h.

113  {
114  return makeAndStoreFractions("FitAmpResults.txt","fitFractions.root",mini);}
virtual bool makeAndStoreFractions(MINT::Minimiser *mini=0)

◆ makeAndStoreFractions() [2/2]

bool FitAmpPairList::makeAndStoreFractions ( const std::string &  fname,
const std::string &  fnameROOT,
MINT::Minimiser min = 0 
)
virtual

latex table

Definition at line 726 of file FitAmpPairList.cpp.

729  {
730  bool dbThis=true;
731 
734 
735  if(this->empty()) return 0;
737  if(0 != mini){
738  if(mini->parSet() != this->at(0).fitAmp1().FitAmpPhase().p1().parSet()){
739  cout << "ERROR in FitAmpPairList::makeAndStoreFractions"
740  << "\n Minuit parameter set and fit parameters incompatible"
741  << endl;
742  }else{
743  cout << "getting minuitCov" << endl;
744  TMatrixTSym<double> minuitCov(mini->covMatrixFull());
745  cout << "got minuitCov" << endl;
747  fc(new FitAmpPairFitCovariance(this, minuitCov));
748  fcov = fc;
749  cout << "got fcov" << endl;
750  }
751  }
752 
753  bool printFitErrors = (fcov != 0 && fcov->isValid());
754 
755  cout << "\n============================================"
756  << "============================================"
757  << "\n Amplitude Fractions";
758  if(0 != fcov) cout << " +/- fit error ";
759  cout << " +/- integration error "
760  << endl;
761  double norm = integral();
762  if(norm <= 0){
763  cout << "ERROR in FitAmpPairList::makeAndStoreFractions()"
764  << " integral = " << integral()
765  << " won't do fractions."
766  << endl;
767  return false;
768  }
769 
770  for(unsigned int i=0; i < this->size(); i++){
771  double frac = this->at(i).integral()/norm;
772  string name;
773  if(this->at(i).isSingleAmp()){
774  name = this->at(i).fitAmp1().name();
775  }else{
776  name = this->at(i).name();
777  }
778  FitFraction f(name, frac);
779  if(printFitErrors){
780  f.sigmaFit() = fcov->getFractionError(i);
781  }
782  if(_cov.isValid()){
783  f.sigmaInteg() = _cov.getFractionError(i);
784  }
785 
786  if(this->at(i).isSingleAmp()){
787  this->at(i).fitAmp1().setFraction(frac);
789  }else{
791  }
792  }
793 
794  if(dbThis)cout << "filled FitFractionLists" << endl;
795  if(printFitErrors){
796  _singleAmpFractions.setSumFitError(fcov->getFractionSumError());
797  _interferenceFractions.setSumFitError(fcov->getInterferenceFracSumError());
798  }
799  if(_cov.isValid()){
801  }
802 
803  if(dbThis) cout << "... now including errors" << endl;
804  if(dbThis)cout << " sorting" << endl;
806  if(dbThis)cout << "sorted" << endl;
807 
808  cout << "================================================="
809  << "\n================================================="
810  << "\n FRACTIONS:"
811  << "\n ^^^^^^^^^^" << endl;
812  cout << _singleAmpFractions << endl;
813  cout << "================================================="
814  << "\n================================================="
815  << "\n Interference terms (sorted by size)"
816  << "\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << endl;
817  cout << _interferenceFractions << endl;
818  cout << "================================================="
819  << "\n=================================================" << endl;
820 
821  cout << "\n\n\t X-check: total sum of all terms"
822  << " (amplitude fractions + interference terms): "
825  cout << endl;
826  ofstream os(fname.c_str(),std::ofstream::trunc);
827 // if(os){
828 // os << _singleAmpFractions << endl;
829 // os << _interferenceFractions << endl;
830 // os.close();
831 // }
833  if(!os)return true;
834  os << "\\begin{tabular}{l r}" << "\n";
835  os << "\\hline" << "\n";
836  os << "\\hline" << "\n";
837  os << "Decay channel & Fraction [$\\%$] \\\\" << "\n";
838  os << "\\hline" << "\n";
839 
840  for(unsigned int i=0; i < this->size(); i++){
841  double frac = this->at(i).integral()/norm;
842  TString name;
843  if(this->at(i).isSingleAmp()) name = this->at(i).fitAmp1().name();
844  else continue;
845  FitFraction f((string)name, frac);
846  double frac_err = fcov->getFractionError(i);
847 
848  name.ReplaceAll("->"," \\to ");
849  name.ReplaceAll("Bs0","B_s");
850  name.ReplaceAll("Ds","D_s");
851  name.ReplaceAll("pi","\\pi");
852  name.ReplaceAll("rho","\\rho");
853  name.ReplaceAll("sigma10","\\sigma");
854  name.ReplaceAll("GS","");
855  name.ReplaceAll("SBW","");
856  name.ReplaceAll("RhoOmega","");
857  name.ReplaceAll("GLass","");
858  name.ReplaceAll("Lass","");
859  name.ReplaceAll("Bugg","");
860  name.ReplaceAll("Flatte","");
861  name.ReplaceAll("+","^+");
862  name.ReplaceAll("-","^-");
863  name.ReplaceAll("*","^*");
864  name.ReplaceAll(")0",")^0");
865  name.ReplaceAll(","," \\, ");
866  name.ReplaceAll("NonResS0( \\to D_s^- \\, \\pi^+)","( D_s^- \\, \\pi^+)_{S}");
867  name.ReplaceAll("NonResV0( \\to D_s^- \\, \\pi^+)","( D_s^- \\, \\pi^+)_{P}");
868  name.ReplaceAll("NonResS0( \\to D_s^- \\, K^+)","( D_s^- \\, K^+)_{S}");
869  name.ReplaceAll("NonResV0( \\to D_s^- \\, K^+)","( D_s^- \\, K^+)_{P}");
870 
871  os << std::fixed << std::setprecision(2) << "$" << name << "$ & " << frac * 100. << " $\\pm$ " << frac_err * 100. << " \\\\" << "\n";
872  }
873  os << " \\hline" << "\n";
874  os << " Sum & " << std::fixed << std::setprecision(2) << _singleAmpFractions.sum().frac() * 100. << " $\\pm$ " << fcov->getFractionSumError() * 100. << " \\\\" << "\n";
875  os << "\\hline" << "\n";
876  os << "\\hline" << "\n";
877  os << "\\end{tabular}" << "\n";
878  os.close();
879 
880  TFile* paraFile = new TFile((fnameROOT).c_str(), "RECREATE");
881  TTree* tree = new TTree("fractions","fractions");
882 
883  for(unsigned int i=0; i < this->size(); i++){
884  double frac = this->at(i).integral()/norm;
885  TString name;
886  if(this->at(i).isSingleAmp())name = TString(this->at(i).fitAmp1().name());
887  else name = TString(this->at(i).name());
888  FitFraction f((string)name, frac);
889 
890  name.ReplaceAll("A(","");
891  name.ReplaceAll("fit","");
892  name.ReplaceAll("[","_");
893  name.ReplaceAll("]","_");
894  name.ReplaceAll("(","_");
895  name.ReplaceAll(")","_");
896  name.ReplaceAll("->","_");
897  name.ReplaceAll("+","p");
898  name.ReplaceAll("-","m");
899  name.ReplaceAll("*","s");
900  name.ReplaceAll(",","");
901  name.ReplaceAll("GS","");
902  name.ReplaceAll("GLass","");
903  name.ReplaceAll("Lass","");
904  name.ReplaceAll("RhoOmega","");
905  name.ReplaceAll("Bugg","");
906  name.ReplaceAll("Flatte","");
907 
908  if(0 != tree){
909  double val = frac;
910  if(!this->at(i).isSingleAmp()) name = "int_" + name;
911  TBranch* Bra_val = tree->Branch( ((string)name).c_str(), &val, ((string)(name+"/D")).c_str());
912  if(0 != Bra_val) Bra_val->Fill();
913  }
914  }
915  double val = _singleAmpFractions.sum().frac();
916  TBranch* Bra_val = tree->Branch( "Sum", &val, "Sum/D");
917  if(0 != Bra_val) Bra_val->Fill();
918 
919  if(0 != tree) tree->Fill();
920 
921  tree->Write();
922  paraFile->Close();
923  delete paraFile;
924 
925  return true;
926 }
void setSumFitError(double sfe)
virtual FitParameter & p1()=0
FitFractionList _singleAmpFractions
void setSumIntegError(double sie)
std::string name() const
Definition: FitAmplitude.h:213
double integral() const
Definition: FitAmpPair.cpp:476
FitAmpPairCovariance _cov
MINT::FitComplex & FitAmpPhase()
Definition: FitAmplitude.h:147
FitAmplitude & fitAmp1()
Definition: FitAmpPair.h:153
void add(const FitFraction &f)
double & frac()
Definition: FitFraction.h:21
void setFraction(double fr)
Definition: FitAmplitude.h:121
FitAmpPair & at(unsigned int i)
virtual double integral() const
const FitFraction & sum() const
virtual const MinuitParameterSet * parSet() const
Definition: FitParameter.h:115
void sortByMagnitudeDecending()
FitFractionList _interferenceFractions
const std::string & name() const
Definition: FitAmpPair.cpp:605

◆ makeDirectory()

bool FitAmpPairList::makeDirectory ( const std::string &  asSubdirOf = ".") const
private

Definition at line 1155 of file FitAmpPairList.cpp.

1155  {
1156  /*
1157  A mode is created from or'd permission bit masks defined
1158  in <sys/stat.h>:
1159  #define S_IRWXU 0000700 RWX mask for owner
1160  #define S_IRUSR 0000400 R for owner
1161  #define S_IWUSR 0000200 W for owner
1162  #define S_IXUSR 0000100 X for owner
1163 
1164  #define S_IRWXG 0000070 RWX mask for group
1165  #define S_IRGRP 0000040 R for group
1166  #define S_IWGRP 0000020 W for group
1167  #define S_IXGRP 0000010 X for group
1168 
1169  #define S_IRWXO 0000007 RWX mask for other
1170  #define S_IROTH 0000004 R for other
1171  #define S_IWOTH 0000002 W for other
1172  #define S_IXOTH 0000001 X for other
1173 
1174  #define S_ISUID 0004000 set user id on execution
1175  #define S_ISGID 0002000 set group id on execution
1176  #define S_ISVTX 0001000 save swapped text even after use
1177  */
1178 
1179  mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO
1180  | S_ISUID | S_ISGID;
1181  // see above for meaning. I want everybody to be allowed to read/write/exec.
1182  // Not sure about the last two bits.
1183 
1184  int zeroForSuccess = 0;
1185  zeroForSuccess |= mkdir( (asSubdirOf ).c_str(), mode );
1186  zeroForSuccess |= mkdir( (asSubdirOf + "/" + dirName() ).c_str(), mode );
1187  return (0 == zeroForSuccess);
1188 }
std::string dirName() const

◆ needToReIntegrate()

bool FitAmpPairList::needToReIntegrate ( ) const

Definition at line 1197 of file FitAmpPairList.cpp.

1197  {
1198  for(unsigned int i=0; i < this->size(); i++){
1199  if (this->at(i).needToReIntegrate() ) return true;
1200  }
1201  return false;
1202 }
FitAmpPair & at(unsigned int i)
bool needToReIntegrate() const
Definition: FitAmpPair.cpp:500

◆ numberOfFitFractionsLargerThanThreshold()

int FitAmpPairList::numberOfFitFractionsLargerThanThreshold ( double  threshold)

Definition at line 438 of file FitAmpPairList.cpp.

438  {
439  int n=0;
440  double norm = integral();
441  for(unsigned int i=0; i< this->size(); i++){
442  if(this->at(i).isSingleAmp()){
443  if(this->at(i).integral()/norm > threshold)n++ ;
444  }
445  }
446  return n;
447 }
double integral() const
Definition: FitAmpPair.cpp:476
FitAmpPair & at(unsigned int i)
virtual double integral() const
bool isSingleAmp() const
Definition: FitAmpPair.cpp:590

◆ numEvents()

int FitAmpPairList::numEvents ( ) const
virtual

Implements IIntegrationCalculator.

Definition at line 230 of file FitAmpPairList.cpp.

230  {
231  return _Nevents;
232 }

◆ oldVariance()

double FitAmpPairList::oldVariance ( ) const
privatevirtual

Definition at line 500 of file FitAmpPairList.cpp.

500  {
501  // this does not (yet) take into account
502  // that the variance changes with the
503  // fit paramters.
504  bool dbThis=false;
505  if(0 == _Nevents) return -9999.0;
506 
507  double dN = (double) _Nevents;
508 
509  double mean = _sum/dN;
510  double meansq = _sumsq/dN;
511  double v = (meansq - mean*mean)/dN;
512  double sf=1.0;
513  if(0 != integral()){
514  sf = integral()/mean;
515  v *= sf*sf;
516  // this construct allows for a scaling factor (such as _weightSum)
517  // in the integral.
518  }
519  if(dbThis){
520  cout << "FitAmpPairList::oldVariance() "
521  << " N = " << dN
522  << " sum = " << _sum
523  << " sumsq = " << _sumsq
524  << " sf " << sf
525  << " v " << v << endl;
526  }
527  return v;
528 }
virtual double integral() const

◆ operator+()

FitAmpPairList FitAmpPairList::operator+ ( const FitAmpPairList other) const

Definition at line 1241 of file FitAmpPairList.cpp.

1241  {
1242  FitAmpPairList returnVal(*this);
1243  returnVal.add(other);
1244  return returnVal;
1245 }

◆ operator+=()

FitAmpPairList & FitAmpPairList::operator+= ( const FitAmpPairList other)

Definition at line 1237 of file FitAmpPairList.cpp.

1237  {
1238  this->add(other);
1239  return *this;
1240 }
virtual bool add(const FitAmpPairList &otherList)

◆ phaseSpaceIntegral()

double FitAmpPairList::phaseSpaceIntegral ( ) const
private

Definition at line 450 of file FitAmpPairList.cpp.

450  {
451  // only for debug
452  if(_Nevents <= 0) return -9999;
453  return _psSum/((double) _Nevents);
454 }

◆ print()

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

Implements IIntegrationCalculator.

Definition at line 1190 of file FitAmpPairList.cpp.

1190  {
1191  os << "FitAmpPairList with " << this->size() << " FitAmpPairs:";
1192  for(unsigned int i=0; i < this->size(); i++){
1193  os << "\n\t" << i << ") " << this->at(i);
1194  }
1195 }
FitAmpPair & at(unsigned int i)

◆ reAddEvent()

void FitAmpPairList::reAddEvent ( IDalitzEvent evt,
double  weight = 1 
)
virtual

Definition at line 141 of file FitAmpPairList.cpp.

141  {
142  if(evt.phaseSpace() < 0) return;
143 
144  for(unsigned int i=0; i< this->size(); i++){
145  if( this->at(i).acceptEvents()){
146  this->at(i).reAdd(evt, weight, efficiency(&evt));
147  }
148  }
149 
150  // _cov.addLastEventFromList(); (need to do something about it)
151 
152  return;
153 }
bool acceptEvents() const
Definition: FitAmpPair.cpp:520
virtual double phaseSpace() const =0
FitAmpPair & at(unsigned int i)
double efficiency(IDalitzEvent *evtPtr)
double reAdd(IDalitzEvent &evt, double weight=1, double efficiency=1)
Definition: FitAmpPair.cpp:389

◆ reset()

bool FitAmpPairList::reset ( )
private

Definition at line 218 of file FitAmpPairList.cpp.

218  {
219  _Nevents=0;
220  _sum=0;
221  _sumsq=0;
222  _psSum=0;
223  _psSumSq=0;
224  _cov.reset();
227 
228  return true;
229 }
FitFractionList _singleAmpFractions
FitAmpPairCovariance _cov
FitFractionList _interferenceFractions

◆ retrieve()

bool FitAmpPairList::retrieve ( const std::string &  asSubdirOf = ".")
virtual

Implements IIntegrationCalculator.

Definition at line 1125 of file FitAmpPairList.cpp.

1125  {
1126  bool sc=true;
1127  bool verbose=true;
1128  if(verbose){
1129  cout << "FitAmpPairList::retrieve: reading from "
1130  << asSubdirOf << endl;
1131  }
1132 
1133  struct stat buf;
1134  if(stat(asSubdirOf.c_str(), &buf) != 0){
1135  if(verbose) cout << "FitAmpPairList::retrieve: " << asSubdirOf
1136  << " does not exist" << endl;
1137  return false;
1138  }
1139 
1140  ifstream is((asSubdirOf +"/"+ dirName() + "values.txt").c_str());
1141  std::string dummy;
1142  is >> dummy >> _Nevents;
1143  is >> dummy >> _sum;
1144  is >> dummy >> _sumsq;
1145  is >> dummy >> _psSum;
1146  is >> dummy >> _psSumSq;
1147  is.close();
1148  for(unsigned int i=0; i < this->size(); i++){
1149  sc &= this->at(i).retrieve(asSubdirOf +"/"+ dirName());
1150  }
1151  _cov.retrieve(asSubdirOf + "/" + dirName());
1152  return sc;
1153 }
bool retrieve(const std::string &asSubdirOf=".")
Definition: FitAmpPair.cpp:218
FitAmpPairCovariance _cov
FitAmpPair & at(unsigned int i)
bool retrieve(const std::string &fromDirectory=".")
std::string dirName() const

◆ save()

bool FitAmpPairList::save ( const std::string &  asSubdirOf = ".") const
virtual

Implements IIntegrationCalculator.

Definition at line 1102 of file FitAmpPairList.cpp.

1102  {
1103  bool sc=true;
1104  makeDirectory(asSubdirOf);
1105  ofstream os((asSubdirOf +"/"+ dirName() + "values.txt").c_str());
1106  os << "N " << _Nevents << endl;
1107  os << "sum " << setprecision(20) << _sum << endl;
1108  os << "sumsq " << setprecision(20) << _sumsq << endl;
1109  os << "psSum " << setprecision(20) << _psSum << endl;
1110  os << "psSumSq " << setprecision(20) << _psSumSq << endl;
1111  os.close();
1112 
1113  for(unsigned int i=0; i < this->size(); i++){
1114  sc &= this->at(i).save(asSubdirOf +"/"+ dirName());
1115  }
1116  if(_cov.isValid()){
1117  _cov.save(asSubdirOf + "/" + dirName());
1118  }else{
1119  cout << "WARNING IN FitAmpPairList::save(" << asSubdirOf
1120  << "): invalid _cov" << endl;
1121  }
1122 
1123  return sc;
1124 }
FitAmpPairCovariance _cov
FitAmpPair & at(unsigned int i)
bool makeDirectory(const std::string &asSubdirOf=".") const
std::string dirName() const
bool save(const std::string &asSubdirOf=".") const
bool save(const std::string &asSubdirOf=".") const
Definition: FitAmpPair.cpp:206

◆ saveEachAmpsHistograms()

void FitAmpPairList::saveEachAmpsHistograms ( const std::string &  prefix) const
virtual

Implements IIntegrationCalculator.

Definition at line 558 of file FitAmpPairList.cpp.

558  {
559  DalitzHistoSet sum;
560  int counter=0;
561  for(unsigned int i=0; i< this->size(); i++){
562  if(this->at(i).isSingleAmp()){
563  counter++;
564  std::string name = prefix + "_" + anythingToString(counter) + ".root";
565  DalitzHistoSet hs(this->at(i).histoSet());
566  std::string title = this->at(i).fitAmp1().name();
567  hs.setTitle(title);
568  cout << "FitAmpPairList::saveEachAmpsHistograms: "
569  << "saving " << title << " as " << name << endl;
570  hs.save(name);
571  }
572  }
573  return;
574 }
std::string name() const
Definition: FitAmplitude.h:213
FitAmplitude & fitAmp1()
Definition: FitAmpPair.h:153
FitAmpPair & at(unsigned int i)
std::string anythingToString(const T &anything)
Definition: Utils.h:62
bool isSingleAmp() const
Definition: FitAmpPair.cpp:590
virtual DalitzHistoSet histoSet() const

◆ saveInterferenceHistograms()

void FitAmpPairList::saveInterferenceHistograms ( const std::string &  prefix) const

Definition at line 609 of file FitAmpPairList.cpp.

609  {
610  DalitzHistoSet sum;
611  int counter=0;
612  for(unsigned int i=0; i< this->size(); i++){
613  if(!this->at(i).isSingleAmp()){
614  counter++;
615  std::string name = prefix + "_" + anythingToString(counter) + ".root";
616  DalitzHistoSet hs(this->at(i).histoSet());
617  std::string title = this->at(i).name();
618  hs.setTitle(title);
619  cout << "FitAmpPairList::saveEachAmpsHistograms: "
620  << "saving " << title << " as " << name << endl;
621  hs.save(name);
622  }
623  }
624  return;
625 }
FitAmpPair & at(unsigned int i)
std::string anythingToString(const T &anything)
Definition: Utils.h:62
bool isSingleAmp() const
Definition: FitAmpPair.cpp:590
virtual DalitzHistoSet histoSet() const
const std::string & name() const
Definition: FitAmpPair.cpp:605

◆ setEfficiency()

void FitAmpPairList::setEfficiency ( MINT::counted_ptr< MINT::IReturnRealForEvent< IDalitzEvent > >  eff)

Definition at line 534 of file FitAmpPairList.cpp.

534  {
535  _efficiency=eff;
536 }
MINT::counted_ptr< MINT::IReturnRealForEvent< IDalitzEvent > > _efficiency

◆ setFast()

void FitAmpPairList::setFast ( )

Definition at line 1230 of file FitAmpPairList.cpp.

1230  {
1231  _slow=false;
1232  for(unsigned int i=0; i < this->size(); i++){
1233  this->at(i).setFast();
1234  }
1235 }
FitAmpPair & at(unsigned int i)
void setFast()
Definition: FitAmpPair.h:177

◆ setSlow()

void FitAmpPairList::setSlow ( )

Definition at line 1224 of file FitAmpPairList.cpp.

1224  {
1225  _slow=true;
1226  for(unsigned int i=0; i < this->size(); i++){
1227  this->at(i).setSlow();
1228  }
1229 }
FitAmpPair & at(unsigned int i)
void setSlow()
Definition: FitAmpPair.h:176

◆ slow()

bool FitAmpPairList::slow ( ) const
inline

Definition at line 149 of file FitAmpPairList.h.

149 {return _slow;}

◆ startForcedReIntegration()

void FitAmpPairList::startForcedReIntegration ( )

Definition at line 1213 of file FitAmpPairList.cpp.

1213  {
1214  for(unsigned int i=0; i < this->size(); i++){
1215  this->at(i).startReIntegration();
1216  }
1217 }
FitAmpPair & at(unsigned int i)
void startReIntegration()
Definition: FitAmpPair.cpp:507

◆ startIntegration()

void FitAmpPairList::startIntegration ( )

Definition at line 1203 of file FitAmpPairList.cpp.

1203  {
1204  for(unsigned int i=0; i < this->size(); i++){
1205  this->at(i).startIntegration();
1206  }
1207 }
void startIntegration()
Definition: FitAmpPair.cpp:511
FitAmpPair & at(unsigned int i)

◆ startReIntegration()

void FitAmpPairList::startReIntegration ( )

Definition at line 1208 of file FitAmpPairList.cpp.

1208  {
1209  for(unsigned int i=0; i < this->size(); i++){
1210  if( this->at(i).needToReIntegrate() ) this->at(i).startReIntegration();
1211  }
1212 }
FitAmpPair & at(unsigned int i)
bool needToReIntegrate() const
Definition: FitAmpPair.cpp:500
void startReIntegration()
Definition: FitAmpPair.cpp:507

◆ sumOfFitFractions()

double FitAmpPairList::sumOfFitFractions ( )

Definition at line 414 of file FitAmpPairList.cpp.

414  {
415  double sum = 0;
416  for(unsigned int i=0; i< this->size(); i++){
417  if(this->at(i).isSingleAmp())sum += this->at(i).integral();
418  }
419  return sum/integral();
420 }
double integral() const
Definition: FitAmpPair.cpp:476
FitAmpPair & at(unsigned int i)
virtual double integral() const
bool isSingleAmp() const
Definition: FitAmpPair.cpp:590

◆ sumOfSqrtFitFractions()

double FitAmpPairList::sumOfSqrtFitFractions ( )

Definition at line 406 of file FitAmpPairList.cpp.

406  {
407  double sum = 0;
408  for(unsigned int i=0; i< this->size(); i++){
409  if(this->at(i).isSingleAmp())sum += sqrt(this->at(i).integral());
410  }
411  return sum;
412 }
double integral() const
Definition: FitAmpPair.cpp:476
FitAmpPair & at(unsigned int i)
bool isSingleAmp() const
Definition: FitAmpPair.cpp:590

◆ sumOfVariances()

double FitAmpPairList::sumOfVariances ( ) const
virtual

Definition at line 493 of file FitAmpPairList.cpp.

493  {
494  double sum=0;
495  for(unsigned int i=0; i < this->size(); i++){
496  sum += this->at(i).variance();
497  }
498  return sum;
499 }
double variance() const
Definition: FitAmpPair.cpp:574
FitAmpPair & at(unsigned int i)

◆ un_normalised_histoSetIm()

DalitzHistoSet FitAmpPairList::un_normalised_histoSetIm ( ) const
virtual

Definition at line 550 of file FitAmpPairList.cpp.

550  {
551  DalitzHistoSet sum;
552  for(unsigned int i=0; i< this->size(); i++){
553  sum += this->at(i).histoSetIm();
554  }
555  return sum;
556 }
DalitzHistoSet histoSetIm() const
Definition: FitAmpPair.cpp:551
FitAmpPair & at(unsigned int i)

◆ un_normalised_histoSetRe()

DalitzHistoSet FitAmpPairList::un_normalised_histoSetRe ( ) const
virtual

Definition at line 543 of file FitAmpPairList.cpp.

543  {
544  DalitzHistoSet sum;
545  for(unsigned int i=0; i< this->size(); i++){
546  sum += this->at(i).histoSetRe();
547  }
548  return sum;
549 }
DalitzHistoSet histoSetRe() const
Definition: FitAmpPair.cpp:529
FitAmpPair & at(unsigned int i)

◆ unsetEfficiency()

void FitAmpPairList::unsetEfficiency ( )

Definition at line 537 of file FitAmpPairList.cpp.

537  {
539 }
MINT::counted_ptr< MINT::IReturnRealForEvent< IDalitzEvent > > _efficiency

◆ variance()

double FitAmpPairList::variance ( ) const
virtual

Implements IIntegrationCalculator.

Definition at line 456 of file FitAmpPairList.cpp.

456  {
457  bool dbThis=false;
458  static int printouts=0;
459  static bool printedWarning=false;
460  if(_Nevents <=0)return 0;
461 
462  if(_cov.isValid()){
463  if(dbThis && printouts < 100){
464  printouts++;
465  cout << "FitAmpPairList::variance() with "
466  << _Nevents << "(" << _cov.Nevents() << ") events. Compare: "
467  << " old: " << oldVariance()
468  << " sum: " << sumOfVariances()
469  << ", new: " << _cov.getIntegralVariance()
470  << endl;
471  }
472  if(_Nevents < 10000) return oldVariance();
473  double var = _cov.getIntegralVariance();
474  if(var < 1.e-6 * oldVariance()){
475  if(dbThis) cout << "returning OLD variance " << var << endl;
476  // (if var is tiny, it usually means something went wrong)
477  return oldVariance();
478  }
479  if(dbThis) cout << "returning new variance " << var << endl;
480  return var;
481  }else{
482  if(! printedWarning){
483  cout << "WARNING in FitAmpPairList::variance()"
484  << " ignoring correlations because _cov is invalid."
485  << " (I'll print this only once)"
486  << endl;
487  printedWarning=true;
488  }
489  return sumOfVariances();
490  }
491 }
FitAmpPairCovariance _cov
virtual double oldVariance() const
virtual double sumOfVariances() const

Member Data Documentation

◆ _cov

FitAmpPairCovariance FitAmpPairList::_cov
mutableprivate

Definition at line 44 of file FitAmpPairList.h.

◆ _efficiency

MINT::counted_ptr<MINT::IReturnRealForEvent<IDalitzEvent> > FitAmpPairList::_efficiency
private

Definition at line 46 of file FitAmpPairList.h.

◆ _interferenceFractions

FitFractionList FitAmpPairList::_interferenceFractions
private

Definition at line 48 of file FitAmpPairList.h.

◆ _Nevents

int FitAmpPairList::_Nevents
private

Definition at line 35 of file FitAmpPairList.h.

◆ _psSum

double FitAmpPairList::_psSum
private

Definition at line 39 of file FitAmpPairList.h.

◆ _psSumSq

double FitAmpPairList::_psSumSq
private

Definition at line 40 of file FitAmpPairList.h.

◆ _singleAmpFractions

FitFractionList FitAmpPairList::_singleAmpFractions
private

Definition at line 48 of file FitAmpPairList.h.

◆ _slow

bool FitAmpPairList::_slow
private

Definition at line 42 of file FitAmpPairList.h.

◆ _sum

double FitAmpPairList::_sum
private

Definition at line 36 of file FitAmpPairList.h.

◆ _sumsq

double FitAmpPairList::_sumsq
private

Definition at line 37 of file FitAmpPairList.h.

◆ HistoOption

MINT::NamedParameter<std::string> FitAmpPairList::HistoOption
private

Definition at line 32 of file FitAmpPairList.h.


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