MINT2
FitAmpPair.h
Go to the documentation of this file.
1 #ifndef FIT_AMP_PAIR_HH
2 #define FIT_AMP_PAIR_HH
3 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
4 // status: Mon 9 Feb 2009 19:18:03 GMT
5 
6 #include "Mint/counted_ptr.h"
7 #include <complex>
8 #include <string>
9 #include <map>
10 #include <iostream>
11 
12 #include "Mint/DalitzHistoSet.h"
13 #include "Mint/FitAmplitude.h"
14 #include "Mint/FitParDependent.h"
15 #include "Mint/IFitParDependent.h"
16 #include "Mint/AmpPair.h"
17 #include "Mint/NamedParameter.h"
18 
19 //class FitAmplitude;
20 class IDalitzEvent;
21 
23 
26 
27  bool _slow;
30 
31  std::complex<double> _sum;
32  std::string _sumName;
33 
34  std::complex<double> _sumsq;
35  std::string _sumSqName;
36 
37  long int _Nevents;
38  std::string _NName;
39 
40  double _weightSum;
41  std::string _weightSumName;
42 
45 
46  std::string _name;
47  std::string _dirName;
48 
49  std::complex<double> _lastEntry;
50 
51  inline std::complex<double> ampValue(IDalitzEvent& evtPtr){
52  std::complex<double> c1 = rawAmp1().getVal(evtPtr);
53  if(0.0 == c1) return 0;
54  std::complex<double> c2 = rawAmp2().getVal(evtPtr);
55  return (c1 * conj(c2)); // c1 x c2*
56  }
57 
58  inline std::complex<double> fitParValue()const{
59  std::complex<double> c1 = fitAmp1().AmpPhase();
60  if(0.0 == c1) return 0;
61  std::complex<double> c2 = fitAmp2().AmpPhase();
62  return c1* conj(c2); // c1 x c2*
63  }
64 
65  inline int oneOrTwo()const{
66  if(isSingleAmp()) return 1;
67  else return 2;
68  }
69 
70  // std::complex<double> ampValue(IDalitzEvent& evt);
71  // int oneOrTwo() const;
72 
73  const DalitzHistoSet& histosRe() const{return _hsRe;}
74  const DalitzHistoSet& histosIm() const{return _hsIm;}
77  /*
78  double ReSquared() const;
79  double ImSquared() const;
80  double ImRe() const;
81  */
82 
83  void addToHistograms(IDalitzEvent* evtPtr, const std::complex<double>& c);
84 
85  const std::string& makeName();
86  const std::string& makeDirName();
87 
88  bool makeDirectory(const std::string& asSubdirOf = ".")const;
89  std::string valueFileName(const std::string& asSubdirOf) const;
90  std::string histoReFileName(const std::string& asSubdirOf) const;
91  std::string histoImFileName(const std::string& asSubdirOf) const;
92  bool saveValues(const std::string& asSubdirOf = ".") const;
93  bool retrieveValues(const std::string& fromDirectory = ".");
94  bool saveHistos(const std::string& asSubdirOf = ".") const;
95  bool retrieveHistos(const std::string& asSubdirOf = ".");
96 
97  bool isCompatibleWith(const FitAmpPair& other) const;
98 
100  public:
101  FitAmpPair();// required by some STL containers
103  FitAmpPair(const FitAmpPair& other);
104 
105  bool add(const FitAmpPair& other);
106 
107  const std::string& name() const;
108  const std::string& name();
109  const std::string& dirName()const;
110  const std::string& dirName();
111 
112  bool save(const std::string& asSubdirOf=".") const;
113  bool retrieve(const std::string& asSubdirOf=".");
114 
115  bool isSingleAmp() const;
116  bool hasMatchingPattern() const;
117 
118  double reAdd(IDalitzEvent& evt, double weight=1, double efficiency=1);
119  double add(IDalitzEvent& evt, double weight=1, double efficiency=1);
120  double add(IDalitzEvent* evt, double weight=1, double efficiency=1);
121  double add(const MINT::counted_ptr<IDalitzEvent>& evt, double weight=1, double efficiency=1);
122 
123  // integral of things that depend on position in Dalitz space:
124  std::complex<double> valNoFitPars() const;
125 
126  inline std::complex<double> complexVal() const{
127  return valNoFitPars() * fitParValue();
128  }
129 
130  // factors that that don't
131  //std::complex<double> fitParValue() const;
132  // product of the above
133  // std::complex<double> complexVal() const;
134  // real part of the above.
135  double integral() const;
136  double variance() const;
137  double weightSum() const;
138  long int N() const;
139 
140  void reset();
141  bool needToReIntegrate() const;
142  void startReIntegration();
143  void startIntegration();
144  void endIntegration();
145  bool acceptEvents() const;
146 
147  std::complex<double> lastEntry() const;
148 
149  DalitzHistoSet histoSetRe() const; // these two are...
150  DalitzHistoSet histoSetIm() const; // ... not usually used...
151  inline DalitzHistoSet histoSet() const{return histoSetRe();} // ..this is.
152 
154  if(0 == _fitA1){
155  std::cout << "ERROR in FitAmpPair::fitAmp1: zero pointer " << std::endl;
156  throw "zero ptr";
157  }
158  return *_fitA1;
159  }
161  if(0 == _fitA2){
162  std::cout << "ERROR in FitAmpPair::fitAmp2: zero pointer " << std::endl;
163  throw "zero ptr";
164  }
165  return *_fitA2;
166  }
167  const FitAmplitude& fitAmp1() const{return *_fitA1;}
168  const FitAmplitude& fitAmp2() const{return *_fitA2;}
169 
170  Amplitude& rawAmp1(){return fitAmp1().amp();}
171  Amplitude& rawAmp2(){return fitAmp2().amp();}
172  const Amplitude& rawAmp1() const{return fitAmp1().amp();}
173  const Amplitude& rawAmp2() const{return fitAmp2().amp();}
174 
175 
176  void setSlow(){_slow = true;}
177  void setFast(){_slow = false;}
178 
179  bool slow() const{return _slow;}
180  bool fast() const{return !_slow;}
181 
182  virtual void print(std::ostream& os=std::cout) const;
183 
184  virtual ~FitAmpPair(){}
185 
186  FitAmpPair& operator+=(const FitAmpPair& other);
187  FitAmpPair operator+(const FitAmpPair& other) const;
188 
189  friend class FitAmpPairCovariance;
190 };
191 
193  public:
194  bool operator()(const FitAmpPair& a, const FitAmpPair& b) const;
195 };
196 
198  public:
199  bool operator()(const FitAmpPair* a, const FitAmpPair* b) const;
200 };
201 
202 
203 std::ostream& operator<<(std::ostream& os, const FitAmpPair& fap);
204 
206  public:
207  bool operator()(const std::pair<FitAmpPair*, int>& a, const std::pair<FitAmpPair*, int>& b) const;
208 };
209 
210 
211 #endif
212 
std::complex< double > AmpPhase() const
Definition: FitAmplitude.h:153
std::string _sumName
Definition: FitAmpPair.h:32
std::string histoReFileName(const std::string &asSubdirOf) const
Definition: FitAmpPair.cpp:237
std::string _sumSqName
Definition: FitAmpPair.h:35
bool _slow
Definition: FitAmpPair.h:27
bool acceptEvents() const
Definition: FitAmpPair.cpp:520
std::complex< double > fitParValue() const
Definition: FitAmpPair.h:58
DalitzHistoSet & histosRe()
Definition: FitAmpPair.h:75
void startIntegration()
Definition: FitAmpPair.cpp:511
virtual void print(std::ostream &os=std::cout) const
Definition: FitAmpPair.cpp:634
const DalitzHistoSet & histosRe() const
Definition: FitAmpPair.h:73
FitAmplitude * _fitA1
Definition: FitAmpPair.h:24
std::string _dirName
Definition: FitAmpPair.h:47
MINT::FitParDependent _eventDependentParameters
Definition: FitAmpPair.h:29
std::complex< double > _sumsq
Definition: FitAmpPair.h:34
const std::string & makeDirName()
Definition: FitAmpPair.cpp:140
std::complex< double > complexVal() const
Definition: FitAmpPair.h:126
bool add(const FitAmpPair &other)
Definition: FitAmpPair.cpp:110
std::complex< double > _lastEntry
Definition: FitAmpPair.h:49
bool operator()(const std::pair< FitAmpPair *, int > &a, const std::pair< FitAmpPair *, int > &b) const
Definition: FitAmpPair.cpp:650
std::string _name
Definition: FitAmpPair.h:46
double integral() const
Definition: FitAmpPair.cpp:476
void reset()
Definition: FitAmpPair.cpp:489
bool operator()(const FitAmpPair &a, const FitAmpPair &b) const
Definition: FitAmpPair.cpp:638
Amplitude & rawAmp1()
Definition: FitAmpPair.h:170
DalitzHistoSet histoSet() const
Definition: FitAmpPair.h:151
std::string valueFileName(const std::string &asSubdirOf) const
Definition: FitAmpPair.cpp:234
const DalitzHistoSet & histosIm() const
Definition: FitAmpPair.h:74
double variance() const
Definition: FitAmpPair.cpp:574
bool retrieve(const std::string &asSubdirOf=".")
Definition: FitAmpPair.cpp:218
DalitzHistoSet _hsRe
Definition: FitAmpPair.h:43
const FitAmplitude & fitAmp2() const
Definition: FitAmpPair.h:168
std::complex< double > lastEntry() const
Definition: FitAmpPair.cpp:443
const std::string & dirName() const
Definition: FitAmpPair.cpp:613
FitAmplitude & fitAmp2()
Definition: FitAmpPair.h:160
bool saveHistos(const std::string &asSubdirOf=".") const
Definition: FitAmpPair.cpp:244
std::ostream & operator<<(std::ostream &os, const FitAmpPair &fap)
Definition: FitAmpPair.cpp:672
const std::string & makeName()
Definition: FitAmpPair.cpp:135
bool fast() const
Definition: FitAmpPair.h:180
DalitzHistoSet histoSetRe() const
Definition: FitAmpPair.cpp:529
std::string histoImFileName(const std::string &asSubdirOf) const
Definition: FitAmpPair.cpp:240
virtual std::complex< double > getVal(IDalitzEvent &evt)
Definition: Amplitude.h:122
bool retrieveHistos(const std::string &asSubdirOf=".")
Definition: FitAmpPair.cpp:250
bool operator()(const FitAmpPair *a, const FitAmpPair *b) const
Definition: FitAmpPair.cpp:643
DalitzHistoSet & histosIm()
Definition: FitAmpPair.h:76
FitAmplitude & fitAmp1()
Definition: FitAmpPair.h:153
const Amplitude & rawAmp2() const
Definition: FitAmpPair.h:173
std::string _NName
Definition: FitAmpPair.h:38
bool hasMatchingPattern() const
Definition: FitAmpPair.cpp:594
virtual ~FitAmpPair()
Definition: FitAmpPair.h:184
Amplitude & rawAmp2()
Definition: FitAmpPair.h:171
double _weightSum
Definition: FitAmpPair.h:40
DalitzHistoSet histoSetIm() const
Definition: FitAmpPair.cpp:551
int oneOrTwo() const
Definition: FitAmpPair.h:65
const FitAmplitude & fitAmp1() const
Definition: FitAmpPair.h:167
double weightSum() const
Definition: FitAmpPair.cpp:480
long int _Nevents
Definition: FitAmpPair.h:37
const Amplitude & rawAmp1() const
Definition: FitAmpPair.h:172
bool _beingIntegrated
Definition: FitAmpPair.h:28
bool retrieveValues(const std::string &fromDirectory=".")
Definition: FitAmpPair.cpp:299
Amplitude & amp()
Definition: FitAmplitude.h:163
bool needToReIntegrate() const
Definition: FitAmpPair.cpp:500
bool saveValues(const std::string &asSubdirOf=".") const
Definition: FitAmpPair.cpp:257
void rememberEventDependentParameters()
Definition: FitAmpPair.cpp:503
FitAmpPair & operator+=(const FitAmpPair &other)
Definition: FitAmpPair.cpp:662
void setFast()
Definition: FitAmpPair.h:177
std::string _weightSumName
Definition: FitAmpPair.h:41
void startReIntegration()
Definition: FitAmpPair.cpp:507
void endIntegration()
Definition: FitAmpPair.cpp:515
bool isSingleAmp() const
Definition: FitAmpPair.cpp:590
bool makeDirectory(const std::string &asSubdirOf=".") const
Definition: FitAmpPair.cpp:171
bool slow() const
Definition: FitAmpPair.h:179
FitAmplitude * _fitA2
Definition: FitAmpPair.h:25
void addToHistograms(IDalitzEvent *evtPtr, const std::complex< double > &c)
Definition: FitAmpPair.cpp:129
DalitzHistoSet _hsIm
Definition: FitAmpPair.h:44
std::complex< double > _sum
Definition: FitAmpPair.h:31
long int N() const
Definition: FitAmpPair.cpp:485
std::complex< double > valNoFitPars() const
Definition: FitAmpPair.cpp:447
const std::string & name() const
Definition: FitAmpPair.cpp:605
void setSlow()
Definition: FitAmpPair.h:176
double reAdd(IDalitzEvent &evt, double weight=1, double efficiency=1)
Definition: FitAmpPair.cpp:389
bool isCompatibleWith(const FitAmpPair &other) const
Definition: FitAmpPair.cpp:106
std::complex< double > ampValue(IDalitzEvent &evtPtr)
Definition: FitAmpPair.h:51
bool save(const std::string &asSubdirOf=".") const
Definition: FitAmpPair.cpp:206
FitAmpPair operator+(const FitAmpPair &other) const
Definition: FitAmpPair.cpp:666