16 #include <sys/types.h> 28 , _beingIntegrated(true)
29 , _eventDependentParameters(this)
31 , _sumName(
"FitAmpPair._sum")
33 , _sumSqName(
"FitAmpPair._sumSq")
35 , _NName(
"FitAmpPair._N")
37 , _weightSumName(
"FitAmpPair._weightSum")
50 , _beingIntegrated(true)
51 , _eventDependentParameters(this)
53 , _sumName(
"FitAmpPair._sum")
55 , _sumSqName(
"FitAmpPair._sumSq")
57 , _NName(
"FitAmpPair._N")
59 , _weightSumName(
"FitAmpPair._weightSum")
85 , _fitA1(other._fitA1)
86 , _fitA2(other._fitA2)
88 , _beingIntegrated(other._beingIntegrated)
89 , _eventDependentParameters(other._eventDependentParameters)
91 , _sumName(other._sumName)
92 , _sumsq(other._sumsq)
93 , _sumSqName(other._sumSqName)
94 , _Nevents(other._Nevents)
95 , _NName(other._NName)
96 , _weightSum(other._weightSum)
97 , _weightSumName(other._weightSumName)
101 , _dirName(other._dirName)
102 , _lastEntry(other._lastEntry)
112 cout <<
"ERROR in FitAmpPair::add " 113 <<
"trying to add two incompatible FitAmpPairs: " 114 <<
"\n " << this->
name() <<
" + " << other.
name()
130 ,
const std::complex<double>& c){
144 std::string::const_iterator preEnd =
_name.end();
147 for(std::string::const_iterator it =
_name.begin();
148 it !=
_name.end(); it++){
150 std::string::const_iterator next = it; next++;
151 if(
'-' == *it &&
'>' == *next){
158 else if(
' ' == *it)
_dirName +=
"_";
161 else if(
'['==*it)
_dirName +=
"_sqbra_";
162 else if(
']'==*it)
_dirName +=
"_sqket_";
195 mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO
200 int zeroForSuccess = 0;
201 zeroForSuccess |= mkdir( (asSubdirOf ).c_str(), mode );
202 zeroForSuccess |= mkdir( (asSubdirOf +
"/" +
dirName() ).c_str(), mode );
203 return (0 == zeroForSuccess);
225 if(dbThis &&
slow()){
226 cout <<
"after FitAmpPair::retrieve: pat = " 235 return asSubdirOf +
"/" +
dirName() +
"/value.txt";
238 return asSubdirOf +
"/" +
dirName() +
"/histoRe";
241 return asSubdirOf +
"/" +
dirName() +
"/histoIm";
260 , NamedParameterBase::QUIET);
262 ,NamedParameterBase::QUIET);
264 , NamedParameterBase::QUIET);
266 , NamedParameterBase::QUIET);
268 , NamedParameterBase::QUIET);
270 , NamedParameterBase::QUIET);
272 n_sumRe =
_sum.real();
273 n_sumIm =
_sum.imag();
274 n_sumSqRe =
_sumsq.real();
275 n_sumSqIm =
_sumsq.imag();
280 ofstream os(fname.c_str());
282 cout <<
"ERROR in FitAmpPair::saveValues of \n\t" <<
name()
283 <<
"\n\t unable to create file: " 284 <<
"\n\t" << fname << endl;
287 os << setprecision(20)
294 <<
'\n' << n_weightSum
302 if(dbThis)cout <<
"trying to retreive values from: " << fname << endl;
303 if(dbThis)cout <<
"current sum " <<
_sum << endl;
319 complex<double> n_sum(n_sumRe, n_sumIm);
321 if(dbThis) cout <<
"n_sumRe " << n_sumRe <<
"n_sum " << n_sum << endl;
323 if(dbThis) cout <<
"_sum = " <<
_sum << endl;
324 complex<double> n_sumsq(n_sumSqRe, n_sumSqIm);
340 if(0 == evtPtr)
return 0;
341 return add(*evtPtr, weight, efficiency);
354 cout <<
"WARNING in FitAmpPair::addToHistograms" 355 <<
" event with phase space = " << ps << endl;
372 complex<double> c=
ampValue(evt) * efficiency * w;
383 complex<double> csq(c.real()*c.real(), c.imag()*c.imag());
400 cout <<
"WARNING in FitAmpPair::addToHistograms" 401 <<
" event with phase space = " << ps << endl;
418 complex<double> c=
ampValue(evt) * efficiency * w;
430 complex<double> csq(c.real()*c.real(), c.imag()*c.imag());
441 return add(evtPtr.
get(), weight, efficiency);
455 std::complex<double> total = ((std::complex<double>)
oneOrTwo()) *
_sum;
456 std::complex<double> returnVal;
458 if(0.0 == total)
return 0.0;
463 returnVal = total/dN;
532 cout <<
" FitAmpPair::histograms, for pair " 555 cout <<
" FitAmpPair::histograms, for pair " 577 complex<double> mean =
_sum/dN;
578 complex<double> meansq =
_sumsq/dN;
580 complex<double> var(meansq.real() - mean.real()*mean.real()
581 , meansq.imag() - mean.imag()*mean.imag());
635 os <<
"FitAmpPair " <<
name()
636 <<
": N=" <<
N() <<
", integral=" <<
integral();
645 if(0 == a && 0==b)
return false;
646 if(0 == a && 0!=b)
return true;
647 if(0 !=a && 0==b)
return false;
651 ,
const std::pair<FitAmpPair*, int>& bpair)
const{
655 if(0 == a && 0==b)
return false;
656 if(0 == a && 0!=b)
return true;
657 if(0 !=a && 0==b)
return false;
std::string histoReFileName(const std::string &asSubdirOf) const
bool acceptEvents() const
virtual bool changedSinceLastCall() const
std::complex< double > fitParValue() const
virtual void print(std::ostream &os=std::cout) const
const DalitzHistoSet & histosRe() const
virtual double getWeight() const =0
MINT::FitParDependent _eventDependentParameters
virtual double phaseSpace() const =0
std::complex< double > _sumsq
const std::string & makeDirName()
std::complex< double > complexVal() const
bool add(const FitAmpPair &other)
std::complex< double > _lastEntry
bool operator()(const std::pair< FitAmpPair *, int > &a, const std::pair< FitAmpPair *, int > &b) const
bool operator()(const FitAmpPair &a, const FitAmpPair &b) const
std::string valueFileName(const std::string &asSubdirOf) const
const DalitzHistoSet & histosIm() const
bool retrieve(const std::string &asSubdirOf=".")
DecayTree theBareDecay() const
std::complex< double > lastEntry() const
const ValueType & getVal() const
const std::string & dirName() const
bool saveHistos(const std::string &asSubdirOf=".") const
const std::string & makeName()
DalitzHistoSet histoSetRe() const
std::string histoImFileName(const std::string &asSubdirOf) const
bool retrieveHistos(const std::string &asSubdirOf=".")
bool operator()(const FitAmpPair *a, const FitAmpPair *b) const
bool retrieveFromDir(const std::string &asSubDirOf=".")
virtual bool registerFitParDependence(const IFitParDependent &fpd)
bool hasMatchingPattern() const
DalitzHistoSet histoSetIm() const
bool retrieveValues(const std::string &fromDirectory=".")
virtual double getGeneratorPdfRelativeToPhaseSpace() const =0
void addEvent(const IDalitzEvent &evt, double weight=1)
bool needToReIntegrate() const
bool reloadFile(const std::string &id)
std::map< Key, Val >::iterator begin()
virtual void rememberFitParValues()
bool saveValues(const std::string &asSubdirOf=".") const
std::ostream & operator<<(std::ostream &os, const FitAmpPair &fap)
void rememberEventDependentParameters()
FitAmpPair & operator+=(const FitAmpPair &other)
std::string _weightSumName
void startReIntegration()
bool saveAsDir(const std::string &asSubdirOf=".") const
bool makeDirectory(const std::string &asSubdirOf=".") const
void addToHistograms(IDalitzEvent *evtPtr, const std::complex< double > &c)
std::complex< double > _sum
std::complex< double > valNoFitPars() const
const std::string & name() const
double reAdd(IDalitzEvent &evt, double weight=1, double efficiency=1)
bool isCompatibleWith(const FitAmpPair &other) const
std::complex< double > ampValue(IDalitzEvent &evtPtr)
bool save(const std::string &asSubdirOf=".") const
FitAmpPair operator+(const FitAmpPair &other) const