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

#include <AmpPair.h>

Inheritance diagram for AmpPair:
MINT::FitParDependent MINT::IFitParRegister MINT::PolymorphVector< FitParRef > MINT::IFitParDependent

Public Member Functions

 AmpPair (Amplitude *a1=0, Amplitude *a2=0)
 
 AmpPair (const AmpPair &other)
 
bool add (const AmpPair &other)
 
const std::string & name () const
 
const std::string & name ()
 
const std::string & dirName () const
 
const std::string & dirName ()
 
bool save (const std::string &asSubdirOf=".") const
 
bool retrieve (const std::string &asSubdirOf=".")
 
bool isSingleAmp () const
 
bool hasMatchingPattern () const
 
std::complex< double > add (IDalitzEvent *evt, double weight=1, double efficiency=1)
 
std::complex< double > add (const MINT::counted_ptr< IDalitzEvent > &evt, double weight=1, double efficiency=1)
 
std::complex< double > integral () const
 
std::complex< double > variance () const
 
double weightSum () const
 
long int N () const
 
std::complex< double > lastEntry () const
 
DalitzHistoSet histoSet () const
 
Amplitudeamp1 ()
 
Amplitudeamp2 ()
 
const Amplitudeamp1 () const
 
const Amplitudeamp2 () const
 
virtual void print (std::ostream &os=std::cout) const
 
virtual ~AmpPair ()
 
AmpPairoperator+= (const AmpPair &other)
 
AmpPair operator+ (const AmpPair &other) const
 
- Public Member Functions inherited from MINT::FitParDependent
virtual unsigned int size () const
 
virtual const FitParRefoperator[] (unsigned int i) const
 
virtual FitParRefoperator[] (unsigned int i)
 
virtual bool changedSinceLastCall () const
 
virtual void rememberFitParValues ()
 
virtual bool registerFitParDependence (const IFitParDependent &fpd)
 
bool registerFitParDependence (const FitParRef &fpr)
 
void removeAllFitParDependencies ()
 
 FitParDependent (IFitParRegister *daddy=0)
 
 FitParDependent (const FitParDependent &other, IFitParRegister *newDaddy=0)
 
void listFitParDependencies (std::ostream &os=std::cout) const
 
- Public Member Functions inherited from MINT::PolymorphVector< FitParRef >
 PolymorphVector ()
 
 PolymorphVector (unsigned int N)
 
 PolymorphVector (unsigned int N, const FitParRef &c)
 
 PolymorphVector (const PolymorphVector &other)
 
 PolymorphVector (const typename std::vector< FitParRef > &other)
 
virtual ~PolymorphVector ()
 
std::vector< FitParRef > & theVector ()
 
const std::vector< FitParRef > & theVector () const
 
FitParRefoperator[] (unsigned int i)
 
const FitParRefoperator[] (unsigned int i) const
 
FitParRefat (unsigned int i)
 
const FitParRefat (unsigned int i) const
 
std::vector< FitParRef >::iterator begin ()
 
std::vector< FitParRef >::const_iterator begin () const
 
std::vector< FitParRef >::iterator end ()
 
std::vector< FitParRef >::const_iterator end () const
 
std::vector< FitParRef >::iterator find (const FitParRef &c)
 
std::vector< FitParRef >::const_iterator find (const FitParRef &c) const
 
FitParReffront ()
 
const FitParReffront () const
 
FitParRefback ()
 
const FitParRefback () const
 
unsigned int size () const
 
bool empty () const
 
void push_back (const FitParRef &c)
 
void pop_back ()
 
void erase (typename std::vector< FitParRef >::iterator pos)
 
void erase (typename std::vector< FitParRef >::iterator first, typename std::vector< FitParRef >::iterator last)
 
PolymorphVector< FitParRef > & operator= (const PolymorphVector< FitParRef > &other)
 
void clear ()
 
void resize (unsigned int N)
 
void resize (unsigned int N, const FitParRef &c)
 
 operator const typename std::vector< FitParRef > & () const
 
 operator typename std::vector< FitParRef > & ()
 
bool operator== (const MINT::PolymorphVector< FitParRef > &v2) const
 
bool operator!= (const MINT::PolymorphVector< FitParRef > &v2) const
 
bool operator< (const MINT::PolymorphVector< FitParRef > &v2) const
 
bool operator> (const MINT::PolymorphVector< FitParRef > &v2) const
 

Private Member Functions

std::complex< double > ampValue (IDalitzEvent *evtPtr)
 
int oneOrTwo () const
 
const DalitzHistoSethistosRe () const
 
const DalitzHistoSethistosIm () const
 
DalitzHistoSethistosRe ()
 
DalitzHistoSethistosIm ()
 
void addToHistograms (IDalitzEvent *evtPtr, const std::complex< double > &c)
 
const std::string & makeName ()
 
const std::string & makeDirName ()
 
bool makeDirectory (const std::string &asSubdirOf=".") const
 
std::string valueFileName (const std::string &asSubdirOf) const
 
std::string histoReFileName (const std::string &asSubdirOf) const
 
std::string histoImFileName (const std::string &asSubdirOf) const
 
bool saveValues (const std::string &asSubdirOf=".") const
 
bool retrieveValues (const std::string &fromDirectory=".")
 
bool saveHistos (const std::string &asSubdirOf=".") const
 
bool retrieveHistos (const std::string &asSubdirOf=".")
 
bool isCompatibleWith (const AmpPair &other) const
 

Private Attributes

Amplitude_a1
 
Amplitude_a2
 
std::complex< double > _sum
 
std::string _sumName
 
std::complex< double > _sumsq
 
std::string _sumSqName
 
long int _Nevents
 
std::string _NName
 
double _weightSum
 
std::string _weightSumName
 
DalitzHistoSet _hsRe
 
DalitzHistoSet _hsIm
 
std::string _name
 
std::string _dirName
 
std::complex< double > _lastEntry
 

Additional Inherited Members

- Protected Attributes inherited from MINT::PolymorphVector< FitParRef >
std::vector< FitParRef_vec
 

Detailed Description

Definition at line 20 of file AmpPair.h.

Constructor & Destructor Documentation

◆ AmpPair() [1/2]

AmpPair::AmpPair ( Amplitude a1 = 0,
Amplitude a2 = 0 
)

Definition at line 24 of file AmpPair.cpp.

25  : _a1(a1)
26  , _a2(a2)
27  , _sum(0)
28  , _sumName("AmpPair._sum")
29  , _sumsq(0)
30  , _sumSqName("AmpPair._sumSq")
31  , _Nevents(0)
32  , _NName("AmpPair._N")
33  , _weightSum(0)
34  , _weightSumName("AmpPair._weightSum")
35  , _hsRe()
36  , _hsIm()
37  , _name("")
38  , _dirName("")
39  , _lastEntry(0)
40 {
41  if(0 == _a1 || 0 == _a2){
42  cout << "ERROR in AmpPair::AmpPair !"
43  << "\n\t One of the amplitude pointers is zero:"
44  << "\n\t _a1 = " << _a1 << ", _a2 = " << _a2
45  << "\n\t ... will crash now" << endl;
46  throw "zero amp pointer in AmpPair constructor";
47  }
48 
49  std::string name_1 = _a1->name();
50  std::string name_2 = _a2->name();
51  if(name_1 > name_2) std::swap(_a1, _a2);
52  // this ensures that the amplitudes are always stored in
53  // a well-defined order. Determines sign of imagninary part.
54  // Since we want Re(A1 A2*), this doesn't matter, however
55  // we have to be consistent when we save and retrive and then add to this.
56  // Also ensures consistent file and directory naming etc.
57  makeName();
58  makeDirName();
59 
62 }
DalitzHistoSet _hsIm
Definition: AmpPair.h:38
long int _Nevents
Definition: AmpPair.h:31
std::string name() const
Definition: Amplitude.cpp:446
const std::string & makeName()
Definition: AmpPair.cpp:116
std::string _sumSqName
Definition: AmpPair.h:29
DalitzHistoSet _hsRe
Definition: AmpPair.h:37
std::complex< double > _lastEntry
Definition: AmpPair.h:43
std::complex< double > _sum
Definition: AmpPair.h:25
Amplitude * _a1
Definition: AmpPair.h:22
virtual bool registerFitParDependence(const IFitParDependent &fpd)
double _weightSum
Definition: AmpPair.h:34
Amplitude * _a2
Definition: AmpPair.h:23
std::string _NName
Definition: AmpPair.h:32
std::string _name
Definition: AmpPair.h:40
std::complex< double > _sumsq
Definition: AmpPair.h:28
const std::string & makeDirName()
Definition: AmpPair.cpp:128
std::string _dirName
Definition: AmpPair.h:41
std::string _sumName
Definition: AmpPair.h:26
std::string _weightSumName
Definition: AmpPair.h:35

◆ AmpPair() [2/2]

AmpPair::AmpPair ( const AmpPair other)

Definition at line 63 of file AmpPair.cpp.

64  : FitParDependent(other)
65  , _a1(other._a1)
66  , _a2(other._a2)
67  , _sum(other._sum)
68  , _sumName(other._sumName)
69  , _sumsq(other._sumsq)
70  , _sumSqName(other._sumSqName)
71  , _Nevents(other._Nevents)
72  , _NName(other._NName)
73  , _weightSum(other._weightSum)
75  , _hsRe(other._hsRe)
76  , _hsIm(other._hsIm)
77  , _name(other._name)
78  , _dirName(other._dirName)
79  , _lastEntry(other._lastEntry)
80 {
81 
85 }
FitParDependent(IFitParRegister *daddy=0)
DalitzHistoSet _hsIm
Definition: AmpPair.h:38
long int _Nevents
Definition: AmpPair.h:31
std::string _sumSqName
Definition: AmpPair.h:29
DalitzHistoSet _hsRe
Definition: AmpPair.h:37
std::complex< double > _lastEntry
Definition: AmpPair.h:43
std::complex< double > _sum
Definition: AmpPair.h:25
Amplitude * _a1
Definition: AmpPair.h:22
virtual bool registerFitParDependence(const IFitParDependent &fpd)
double _weightSum
Definition: AmpPair.h:34
Amplitude * _a2
Definition: AmpPair.h:23
std::string _NName
Definition: AmpPair.h:32
std::string _name
Definition: AmpPair.h:40
std::complex< double > _sumsq
Definition: AmpPair.h:28
std::string _dirName
Definition: AmpPair.h:41
std::string _sumName
Definition: AmpPair.h:26
std::string _weightSumName
Definition: AmpPair.h:35

◆ ~AmpPair()

virtual AmpPair::~AmpPair ( )
inlinevirtual

Definition at line 109 of file AmpPair.h.

109 {}

Member Function Documentation

◆ add() [1/3]

bool AmpPair::add ( const AmpPair other)

Definition at line 91 of file AmpPair.cpp.

91  {
92  if(! isCompatibleWith(other)){
93  cout << "ERROR in AmpPair::add "
94  << "trying to add two incompatible AmpPairs: "
95  << "\n " << this->name() << " + " << other.name()
96  << endl;
97  return false;
98  }
99 
100  _sum += other._sum;
101  _sumsq += other._sumsq;
102  _Nevents += other._Nevents;
103  _weightSum += other._weightSum;
104 
105  _hsRe += other._hsRe;
106  _hsIm += other._hsIm;
107 
108  return true;
109 }
DalitzHistoSet _hsIm
Definition: AmpPair.h:38
long int _Nevents
Definition: AmpPair.h:31
DalitzHistoSet _hsRe
Definition: AmpPair.h:37
std::complex< double > _sum
Definition: AmpPair.h:25
bool isCompatibleWith(const AmpPair &other) const
Definition: AmpPair.cpp:87
const std::string & name() const
Definition: AmpPair.cpp:464
double _weightSum
Definition: AmpPair.h:34
std::complex< double > _sumsq
Definition: AmpPair.h:28

◆ add() [2/3]

std::complex< double > AmpPair::add ( IDalitzEvent evt,
double  weight = 1,
double  efficiency = 1 
)

Definition at line 323 of file AmpPair.cpp.

326  {
327  bool dbThis=false;
328 
329  _Nevents++;
330  if(0 == evtPtr) return 0;
331 
332  double ps = evtPtr->phaseSpace();
333  if(ps <= 0.0000){
334  if(!(_Nevents%100000)){
335  cout << "WARNING in AmpPair::addToHistograms"
336  << " event with phase space = " << ps << endl;
337  }
338  return 0; // should not happen.
339  }
340 
341  double w = evtPtr->getWeight()
342  /evtPtr->getGeneratorPdfRelativeToPhaseSpace();
343  w *= weight;
344 
345  _weightSum += w;// / ps;
346 
347  if(dbThis){
348  cout << " AmpPair::add, for pair "
349  << _a1->name() << " / " << _a2->name()
350  << endl;
351  }
352 
353  complex<double> c=ampValue(evtPtr) * efficiency * w;
354  _lastEntry = c;
355  _sum += c;
356  this->addToHistograms(evtPtr, c);
357 
358  if(dbThis){
359  cout << "\t c = " << c
360  << " _sum " << _sum
361  << endl;
362  }
363  complex<double> csq(c.real()*c.real(), c.imag()*c.imag());
364  _sumsq += csq;
365 
366  return c;
367 }
long int _Nevents
Definition: AmpPair.h:31
std::string name() const
Definition: Amplitude.cpp:446
std::complex< double > _lastEntry
Definition: AmpPair.h:43
std::complex< double > _sum
Definition: AmpPair.h:25
Amplitude * _a1
Definition: AmpPair.h:22
double _weightSum
Definition: AmpPair.h:34
Amplitude * _a2
Definition: AmpPair.h:23
void addToHistograms(IDalitzEvent *evtPtr, const std::complex< double > &c)
Definition: AmpPair.cpp:110
std::complex< double > _sumsq
Definition: AmpPair.h:28
std::complex< double > ampValue(IDalitzEvent *evtPtr)
Definition: AmpPair.cpp:378

◆ add() [3/3]

std::complex< double > AmpPair::add ( const MINT::counted_ptr< IDalitzEvent > &  evt,
double  weight = 1,
double  efficiency = 1 
)

Definition at line 369 of file AmpPair.cpp.

372  {
373  return add(evtPtr.get(), weight, efficiency);
374 }
bool add(const AmpPair &other)
Definition: AmpPair.cpp:91

◆ addToHistograms()

void AmpPair::addToHistograms ( IDalitzEvent evtPtr,
const std::complex< double > &  c 
)
private

Definition at line 110 of file AmpPair.cpp.

111  {
112  _hsRe.addEvent(*evtPtr, c.real());
113  _hsIm.addEvent(*evtPtr, c.imag());
114 }
DalitzHistoSet _hsIm
Definition: AmpPair.h:38
DalitzHistoSet _hsRe
Definition: AmpPair.h:37
void addEvent(const IDalitzEvent &evt, double weight=1)

◆ amp1() [1/2]

Amplitude* AmpPair::amp1 ( )
inline

Definition at line 102 of file AmpPair.h.

102 {return _a1;}
Amplitude * _a1
Definition: AmpPair.h:22

◆ amp1() [2/2]

const Amplitude* AmpPair::amp1 ( ) const
inline

Definition at line 104 of file AmpPair.h.

104 {return _a1;}
Amplitude * _a1
Definition: AmpPair.h:22

◆ amp2() [1/2]

Amplitude* AmpPair::amp2 ( )
inline

Definition at line 103 of file AmpPair.h.

103 {return _a2;}
Amplitude * _a2
Definition: AmpPair.h:23

◆ amp2() [2/2]

const Amplitude* AmpPair::amp2 ( ) const
inline

Definition at line 105 of file AmpPair.h.

105 {return _a2;}
Amplitude * _a2
Definition: AmpPair.h:23

◆ ampValue()

complex< double > AmpPair::ampValue ( IDalitzEvent evtPtr)
private

Definition at line 378 of file AmpPair.cpp.

378  {
379  if(0 == _a1 || 0 == _a2 || 0 == evtPtr) return 0;
380 
381 
382  complex<double> c1 = _a1->getVal(*evtPtr);
383  complex<double> c2 = _a2->getVal(*evtPtr);
384  complex<double> c2star = conj(c2);
385 
386  complex<double> val = (c1 * c2star);
387 
388  return val;
389 }
Amplitude * _a1
Definition: AmpPair.h:22
virtual std::complex< double > getVal(IDalitzEvent &evt)
Definition: Amplitude.h:122
Amplitude * _a2
Definition: AmpPair.h:23

◆ dirName() [1/2]

const std::string & AmpPair::dirName ( ) const

Definition at line 472 of file AmpPair.cpp.

472  {
473  return _dirName;
474 }
std::string _dirName
Definition: AmpPair.h:41

◆ dirName() [2/2]

const std::string & AmpPair::dirName ( )

Definition at line 468 of file AmpPair.cpp.

468  {
469  if("" == _dirName) makeDirName();
470  return _dirName;
471 }
const std::string & makeDirName()
Definition: AmpPair.cpp:128
std::string _dirName
Definition: AmpPair.h:41

◆ hasMatchingPattern()

bool AmpPair::hasMatchingPattern ( ) const

Definition at line 453 of file AmpPair.cpp.

453  {
454  if(_a1->theBareDecay().getVal() == _a2->theBareDecay().getVal() )return true;
455  return false;
456 }
const ValueType & getVal() const
Definition: DDTree.h:102
Amplitude * _a1
Definition: AmpPair.h:22
Amplitude * _a2
Definition: AmpPair.h:23
DecayTree theBareDecay() const
Definition: Amplitude.h:157

◆ histoImFileName()

std::string AmpPair::histoImFileName ( const std::string &  asSubdirOf) const
private

Definition at line 228 of file AmpPair.cpp.

228  {
229  return asSubdirOf + "/" + dirName() + "/histoIm";
230 }
const std::string & dirName() const
Definition: AmpPair.cpp:472

◆ histoReFileName()

std::string AmpPair::histoReFileName ( const std::string &  asSubdirOf) const
private

Definition at line 225 of file AmpPair.cpp.

225  {
226  return asSubdirOf + "/" + dirName() + "/histoRe";
227 }
const std::string & dirName() const
Definition: AmpPair.cpp:472

◆ histoSet()

DalitzHistoSet AmpPair::histoSet ( ) const

◆ histosIm() [1/2]

const DalitzHistoSet& AmpPair::histosIm ( ) const
inlineprivate

Definition at line 49 of file AmpPair.h.

49 {return _hsIm;}
DalitzHistoSet _hsIm
Definition: AmpPair.h:38

◆ histosIm() [2/2]

DalitzHistoSet& AmpPair::histosIm ( )
inlineprivate

Definition at line 51 of file AmpPair.h.

51 {return _hsIm;}
DalitzHistoSet _hsIm
Definition: AmpPair.h:38

◆ histosRe() [1/2]

const DalitzHistoSet& AmpPair::histosRe ( ) const
inlineprivate

Definition at line 48 of file AmpPair.h.

48 {return _hsRe;}
DalitzHistoSet _hsRe
Definition: AmpPair.h:37

◆ histosRe() [2/2]

DalitzHistoSet& AmpPair::histosRe ( )
inlineprivate

Definition at line 50 of file AmpPair.h.

50 {return _hsRe;}
DalitzHistoSet _hsRe
Definition: AmpPair.h:37

◆ integral()

std::complex< double > AmpPair::integral ( ) const

Definition at line 396 of file AmpPair.cpp.

396  {
397  bool dbThis=false;
398  if(dbThis){
399  cout << " AmpPair::sumWithoutFitPars for pair "
400  << _a1->name() << " / " << _a2->name()
401  << endl;
402  }
403  double dN = (double) _Nevents;
404  std::complex<double> total = ((std::complex<double>)oneOrTwo()) * _sum;
405  std::complex<double> returnVal;
406 
407  if(_weightSum > 0){
408  returnVal = total/_weightSum;
409  }else{
410  returnVal = total/dN;
411  }
412 
413  if(dbThis){
414  cout << "\t returning " << returnVal << endl;
415  cout << "\t = Real( " << oneOrTwo()
416  << " * " << _sum
417  << " / " << _Nevents
418  << " )"
419  << endl;
420  }
421  return returnVal;
422 }
long int _Nevents
Definition: AmpPair.h:31
std::string name() const
Definition: Amplitude.cpp:446
std::complex< double > _sum
Definition: AmpPair.h:25
Amplitude * _a1
Definition: AmpPair.h:22
double _weightSum
Definition: AmpPair.h:34
Amplitude * _a2
Definition: AmpPair.h:23
int oneOrTwo() const
Definition: AmpPair.cpp:391

◆ isCompatibleWith()

bool AmpPair::isCompatibleWith ( const AmpPair other) const
private

Definition at line 87 of file AmpPair.cpp.

87  {
88  return (amp1()->name() == other.amp1()->name() &&
89  amp2()->name() == other.amp2()->name());
90 }
Amplitude * amp1()
Definition: AmpPair.h:102
std::string name() const
Definition: Amplitude.cpp:446
Amplitude * amp2()
Definition: AmpPair.h:103
const std::string & name() const
Definition: AmpPair.cpp:464

◆ isSingleAmp()

bool AmpPair::isSingleAmp ( ) const

Definition at line 449 of file AmpPair.cpp.

449  {
450  return _a1 == _a2;
451 }
Amplitude * _a1
Definition: AmpPair.h:22
Amplitude * _a2
Definition: AmpPair.h:23

◆ lastEntry()

complex< double > AmpPair::lastEntry ( ) const

Definition at line 375 of file AmpPair.cpp.

375  {
376  return _lastEntry;
377 }
std::complex< double > _lastEntry
Definition: AmpPair.h:43

◆ makeDirectory()

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

Definition at line 159 of file AmpPair.cpp.

159  {
160  /*
161  A mode is created from or'd permission bit masks defined
162  in <sys/stat.h>:
163  #define S_IRWXU 0000700 RWX mask for owner
164  #define S_IRUSR 0000400 R for owner
165  #define S_IWUSR 0000200 W for owner
166  #define S_IXUSR 0000100 X for owner
167 
168  #define S_IRWXG 0000070 RWX mask for group
169  #define S_IRGRP 0000040 R for group
170  #define S_IWGRP 0000020 W for group
171  #define S_IXGRP 0000010 X for group
172 
173  #define S_IRWXO 0000007 RWX mask for other
174  #define S_IROTH 0000004 R for other
175  #define S_IWOTH 0000002 W for other
176  #define S_IXOTH 0000001 X for other
177 
178  #define S_ISUID 0004000 set user id on execution
179  #define S_ISGID 0002000 set group id on execution
180  #define S_ISVTX 0001000 save swapped text even after use
181  */
182 
183  mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO
184  | S_ISUID | S_ISGID;
185  // see above for meaning. I want everybody to be allowed to read/write/exec.
186  // Not sure about the last two bits.
187 
188  int zeroForSuccess = 0;
189  zeroForSuccess |= mkdir( (asSubdirOf ).c_str(), mode );
190  zeroForSuccess |= mkdir( (asSubdirOf + "/" + dirName() ).c_str(), mode );
191  return (0 == zeroForSuccess);
192 }
const std::string & dirName() const
Definition: AmpPair.cpp:472

◆ makeDirName()

const std::string & AmpPair::makeDirName ( )
private

Definition at line 128 of file AmpPair.cpp.

128  {
129  _dirName="";
130  if("" == _name) makeName();
131 
132  std::string::const_iterator preEnd = _name.end();
133  preEnd--;
134 
135  for(std::string::const_iterator it = _name.begin();
136  it != _name.end(); it++){
137  if(it != preEnd){
138  std::string::const_iterator next = it; next++;
139  if('-' == *it && '>' == *next){
140  _dirName += "_to_";
141  it++;
142  continue;
143  }
144  }
145  if('*' == *it) _dirName += "star";
146  else if(' ' == *it) _dirName += "_";
147  // else if('(' == *it) _dirName +="_bra_";
148  // else if(')'==*it) _dirName +="_ket_";
149  else if('['==*it) _dirName += "_sqbra_";
150  else if(']'==*it) _dirName += "_sqket_";
151  // else if(','==*it) _dirName += "_comma_";
152  // else if('-' == *it) _dirName += "min";
153  // else if('+' == *it) _dirName += "pls";
154  else _dirName += *it;
155  }
156  return _dirName;
157 }
const std::string & makeName()
Definition: AmpPair.cpp:116
std::string _name
Definition: AmpPair.h:40
std::string _dirName
Definition: AmpPair.h:41

◆ makeName()

const std::string & AmpPair::makeName ( )
private

Definition at line 116 of file AmpPair.cpp.

116  {
117  if(0 == amp1() || 0 == amp2()){
118  cout << "ERROR in AmpPair::makeName():"
119  << " At least one of the amplitude pointers is 0:"
120  << " _a1 = " << _a1 << ", _a2 = " << _a2 << endl;
121  cout << "I'll crash. " << endl;
122  throw "zero amplitude pointers";
123  }
124  _name = "A(" + amp1()->name() + ")_x_A(" + amp2()->name() + ")*";
125  return _name;
126 }
Amplitude * amp1()
Definition: AmpPair.h:102
std::string name() const
Definition: Amplitude.cpp:446
Amplitude * amp2()
Definition: AmpPair.h:103
Amplitude * _a1
Definition: AmpPair.h:22
Amplitude * _a2
Definition: AmpPair.h:23
std::string _name
Definition: AmpPair.h:40

◆ N()

long int AmpPair::N ( ) const

Definition at line 429 of file AmpPair.cpp.

429  {
430  return _Nevents;
431 }
long int _Nevents
Definition: AmpPair.h:31

◆ name() [1/2]

const std::string & AmpPair::name ( ) const

Definition at line 464 of file AmpPair.cpp.

464  {
465  return _name;
466 }
std::string _name
Definition: AmpPair.h:40

◆ name() [2/2]

const std::string & AmpPair::name ( )

Definition at line 458 of file AmpPair.cpp.

458  {
459  if("" == _name) makeName();
460  return _name;
461  // if(isSingleAmp()) return "| " + _a1->name() + " |^2";
462  // else return "(" + _a1->name() +") * (" + _a2->name() + ")*";
463 }
const std::string & makeName()
Definition: AmpPair.cpp:116
std::string _name
Definition: AmpPair.h:40

◆ oneOrTwo()

int AmpPair::oneOrTwo ( ) const
private

Definition at line 391 of file AmpPair.cpp.

391  {
392  if(isSingleAmp()) return 1;
393  else return 2;
394 }
bool isSingleAmp() const
Definition: AmpPair.cpp:449

◆ operator+()

AmpPair AmpPair::operator+ ( const AmpPair other) const

Definition at line 525 of file AmpPair.cpp.

525  {
526  AmpPair returnVal(*this);
527  returnVal += other;
528  return returnVal;
529 }

◆ operator+=()

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

Definition at line 521 of file AmpPair.cpp.

521  {
522  this->add(other);
523  return *this;
524 }
bool add(const AmpPair &other)
Definition: AmpPair.cpp:91

◆ print()

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

Definition at line 493 of file AmpPair.cpp.

493  {
494  os << "AmpPair " << name()
495  << ": N=" << N() << ", integral=" << integral();
496 }
long int N() const
Definition: AmpPair.cpp:429
std::complex< double > integral() const
Definition: AmpPair.cpp:396
const std::string & name() const
Definition: AmpPair.cpp:464

◆ retrieve()

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

Definition at line 206 of file AmpPair.cpp.

206  {
207  bool dbThis=false;
208  bool success=true;
209 
210  success &= retrieveValues(asSubdirOf);
211  success &= retrieveHistos(asSubdirOf);
212 
213  if(dbThis){
214  cout << "after AmpPair::retrieve: pat = "
215  << histosRe().begin()->second.pattern() << ", "
216  << histosIm().begin()->second.pattern() << endl;
217  }
218  return success;
219 }
bool retrieveHistos(const std::string &asSubdirOf=".")
Definition: AmpPair.cpp:238
const DalitzHistoSet & histosIm() const
Definition: AmpPair.h:49
std::map< Key, Val >::iterator begin()
Definition: PolymorphMap.h:26
const DalitzHistoSet & histosRe() const
Definition: AmpPair.h:48
bool retrieveValues(const std::string &fromDirectory=".")
Definition: AmpPair.cpp:287

◆ retrieveHistos()

bool AmpPair::retrieveHistos ( const std::string &  asSubdirOf = ".")
private

Definition at line 238 of file AmpPair.cpp.

238  {
239  bool sc = true;
240  sc |= histosRe().retrieveFromDir(histoReFileName(asSubdirOf));
241  sc |= histosIm().retrieveFromDir(histoImFileName(asSubdirOf));
242  return sc;
243 }
std::string histoReFileName(const std::string &asSubdirOf) const
Definition: AmpPair.cpp:225
const DalitzHistoSet & histosIm() const
Definition: AmpPair.h:49
bool retrieveFromDir(const std::string &asSubDirOf=".")
const DalitzHistoSet & histosRe() const
Definition: AmpPair.h:48
std::string histoImFileName(const std::string &asSubdirOf) const
Definition: AmpPair.cpp:228

◆ retrieveValues()

bool AmpPair::retrieveValues ( const std::string &  fromDirectory = ".")
private

Definition at line 287 of file AmpPair.cpp.

287  {
288  bool dbThis=false;
289  std::string fname = valueFileName(fromDirectory);
290  if(dbThis)cout << "trying to retreive values from: " << fname << endl;
291  if(dbThis)cout << "current sum " << _sum << endl;
292 
293  NamedParameter<double> n_sumRe(_sumName + ".real()", fname.c_str()
294  );
295  n_sumRe.reloadFile(fname.c_str());
296  NamedParameter<double> n_sumIm(_sumName + ".imag()", fname.c_str()
297  );//,NamedParameterBase::QUIET);
298  NamedParameter<double> n_sumSqRe(_sumSqName + ".real()", fname.c_str()
299  );//, NamedParameterBase::QUIET);
300  NamedParameter<double> n_sumSqIm(_sumSqName + ".imag()", fname.c_str()
301  );//, NamedParameterBase::QUIET);
302  NamedParameter<long int> n_Nevents(_NName, fname.c_str()
303  );// , NamedParameterBase::QUIET);
304  NamedParameter<double> n_weightSum(_weightSumName, fname.c_str()
305  );//, NamedParameterBase::QUIET);
306 
307  complex<double> n_sum(n_sumRe, n_sumIm);
308 
309  if(dbThis) cout << "n_sumRe " << n_sumRe << "n_sum " << n_sum << endl;
310  _sum = n_sum;
311  if(dbThis) cout << "_sum = " << _sum << endl;
312  complex<double> n_sumsq(n_sumSqRe, n_sumSqIm);
313  _sumsq = n_sumsq;
314  _Nevents = n_Nevents;
315  _weightSum = n_weightSum;
316 
317  return true;
318 }
long int _Nevents
Definition: AmpPair.h:31
std::string _sumSqName
Definition: AmpPair.h:29
std::complex< double > _sum
Definition: AmpPair.h:25
std::string valueFileName(const std::string &asSubdirOf) const
Definition: AmpPair.cpp:222
double _weightSum
Definition: AmpPair.h:34
std::string _NName
Definition: AmpPair.h:32
bool reloadFile(const std::string &id)
std::complex< double > _sumsq
Definition: AmpPair.h:28
std::string _sumName
Definition: AmpPair.h:26
std::string _weightSumName
Definition: AmpPair.h:35

◆ save()

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

Definition at line 194 of file AmpPair.cpp.

194  {
195  bool success=true;
196  makeDirectory(asSubdirOf); // ignore error codes from mkdir, they could
197  // be because directory already exists - if
198  // not, we'll pick it up when we try to save
199  // the files.
200 
201  success &= saveValues(asSubdirOf);
202  success &= saveHistos(asSubdirOf);
203 
204  return success;
205 }
bool saveHistos(const std::string &asSubdirOf=".") const
Definition: AmpPair.cpp:232
bool makeDirectory(const std::string &asSubdirOf=".") const
Definition: AmpPair.cpp:159
bool saveValues(const std::string &asSubdirOf=".") const
Definition: AmpPair.cpp:245

◆ saveHistos()

bool AmpPair::saveHistos ( const std::string &  asSubdirOf = ".") const
private

Definition at line 232 of file AmpPair.cpp.

232  {
233  bool sc = true;
234  sc |= histosRe().saveAsDir(histoReFileName(asSubdirOf));
235  sc |= histosIm().saveAsDir(histoImFileName(asSubdirOf));
236  return sc;
237 }
std::string histoReFileName(const std::string &asSubdirOf) const
Definition: AmpPair.cpp:225
const DalitzHistoSet & histosIm() const
Definition: AmpPair.h:49
bool saveAsDir(const std::string &asSubdirOf=".") const
const DalitzHistoSet & histosRe() const
Definition: AmpPair.h:48
std::string histoImFileName(const std::string &asSubdirOf) const
Definition: AmpPair.cpp:228

◆ saveValues()

bool AmpPair::saveValues ( const std::string &  asSubdirOf = ".") const
private

Definition at line 245 of file AmpPair.cpp.

245  {
246 
247  NamedParameter<double> n_sumRe(_sumName + ".real()"
248  , NamedParameterBase::QUIET);
249  NamedParameter<double> n_sumIm(_sumName + ".imag()"
250  ,NamedParameterBase::QUIET);
251  NamedParameter<double> n_sumSqRe(_sumSqName + ".real()"
252  , NamedParameterBase::QUIET);
253  NamedParameter<double> n_sumSqIm(_sumSqName + ".imag()"
254  , NamedParameterBase::QUIET);
256  , NamedParameterBase::QUIET);
258  , NamedParameterBase::QUIET);
259 
260  n_sumRe = _sum.real();
261  n_sumIm = _sum.imag();
262  n_sumSqRe = _sumsq.real();
263  n_sumSqIm = _sumsq.imag();
264  n_Nevents = _Nevents;
265  n_weightSum = _weightSum;
266 
267  std::string fname = valueFileName(asSubdirOf);
268  ofstream os(fname.c_str());
269  if(os.bad()){
270  cout << "ERROR in AmpPair::saveValues of \n\t" << name()
271  << "\n\t unable to create file: "
272  << "\n\t" << fname << endl;
273  return false;
274  }
275  os << setprecision(20)
276  << name()
277  << '\n' << n_sumRe
278  << '\n' << n_sumIm
279  << '\n' << n_sumSqRe
280  << '\n' << n_sumSqIm
281  << '\n' << n_Nevents
282  << '\n' << n_weightSum
283  << endl;
284  os.close();
285  return true;
286 }
long int _Nevents
Definition: AmpPair.h:31
std::string _sumSqName
Definition: AmpPair.h:29
std::complex< double > _sum
Definition: AmpPair.h:25
std::string valueFileName(const std::string &asSubdirOf) const
Definition: AmpPair.cpp:222
const std::string & name() const
Definition: AmpPair.cpp:464
double _weightSum
Definition: AmpPair.h:34
std::string _NName
Definition: AmpPair.h:32
std::complex< double > _sumsq
Definition: AmpPair.h:28
std::string _sumName
Definition: AmpPair.h:26
std::string _weightSumName
Definition: AmpPair.h:35

◆ valueFileName()

std::string AmpPair::valueFileName ( const std::string &  asSubdirOf) const
private

Definition at line 222 of file AmpPair.cpp.

222  {
223  return asSubdirOf + "/" + dirName() + "/value.txt";
224 }
const std::string & dirName() const
Definition: AmpPair.cpp:472

◆ variance()

std::complex< double > AmpPair::variance ( ) const

Definition at line 433 of file AmpPair.cpp.

433  {
434  if(_Nevents <=0) return 0;
435  double dN = (double) _Nevents;
436  complex<double> mean = _sum/dN;
437  complex<double> meansq = _sumsq/dN;
438 
439  complex<double> var(meansq.real() - mean.real()*mean.real()
440  , meansq.imag() - mean.imag()*mean.imag());
441 
442  var /= dN;
443 
444  if(_weightSum > 0) var *= dN*dN/(_weightSum*_weightSum);
445 
446  return ((double) oneOrTwo()) * var;
447 }
long int _Nevents
Definition: AmpPair.h:31
std::complex< double > _sum
Definition: AmpPair.h:25
double _weightSum
Definition: AmpPair.h:34
int oneOrTwo() const
Definition: AmpPair.cpp:391
std::complex< double > _sumsq
Definition: AmpPair.h:28

◆ weightSum()

double AmpPair::weightSum ( ) const

Definition at line 424 of file AmpPair.cpp.

424  {
425  if(_weightSum > 0) return _weightSum;
426  else return (double) _Nevents;
427 }
long int _Nevents
Definition: AmpPair.h:31
double _weightSum
Definition: AmpPair.h:34

Member Data Documentation

◆ _a1

Amplitude* AmpPair::_a1
private

Definition at line 22 of file AmpPair.h.

◆ _a2

Amplitude* AmpPair::_a2
private

Definition at line 23 of file AmpPair.h.

◆ _dirName

std::string AmpPair::_dirName
private

Definition at line 41 of file AmpPair.h.

◆ _hsIm

DalitzHistoSet AmpPair::_hsIm
private

Definition at line 38 of file AmpPair.h.

◆ _hsRe

DalitzHistoSet AmpPair::_hsRe
private

Definition at line 37 of file AmpPair.h.

◆ _lastEntry

std::complex<double> AmpPair::_lastEntry
private

Definition at line 43 of file AmpPair.h.

◆ _name

std::string AmpPair::_name
private

Definition at line 40 of file AmpPair.h.

◆ _Nevents

long int AmpPair::_Nevents
private

Definition at line 31 of file AmpPair.h.

◆ _NName

std::string AmpPair::_NName
private

Definition at line 32 of file AmpPair.h.

◆ _sum

std::complex<double> AmpPair::_sum
private

Definition at line 25 of file AmpPair.h.

◆ _sumName

std::string AmpPair::_sumName
private

Definition at line 26 of file AmpPair.h.

◆ _sumsq

std::complex<double> AmpPair::_sumsq
private

Definition at line 28 of file AmpPair.h.

◆ _sumSqName

std::string AmpPair::_sumSqName
private

Definition at line 29 of file AmpPair.h.

◆ _weightSum

double AmpPair::_weightSum
private

Definition at line 34 of file AmpPair.h.

◆ _weightSumName

std::string AmpPair::_weightSumName
private

Definition at line 35 of file AmpPair.h.


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