16 #include <sys/types.h> 28 , _sumName(
"AmpPair._sum")
30 , _sumSqName(
"AmpPair._sumSq")
32 , _NName(
"AmpPair._N")
34 , _weightSumName(
"AmpPair._weightSum")
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";
49 std::string name_1 =
_a1->
name();
50 std::string name_2 =
_a2->
name();
51 if(name_1 > name_2) std::swap(
_a1,
_a2);
68 , _sumName(other._sumName)
69 , _sumsq(other._sumsq)
70 , _sumSqName(other._sumSqName)
71 , _Nevents(other._Nevents)
72 , _NName(other._NName)
73 , _weightSum(other._weightSum)
74 , _weightSumName(other._weightSumName)
78 , _dirName(other._dirName)
79 , _lastEntry(other._lastEntry)
93 cout <<
"ERROR in AmpPair::add " 94 <<
"trying to add two incompatible AmpPairs: " 95 <<
"\n " << this->
name() <<
" + " << other.
name()
111 ,
const std::complex<double>& c){
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";
132 std::string::const_iterator preEnd =
_name.end();
135 for(std::string::const_iterator it =
_name.begin();
136 it !=
_name.end(); it++){
138 std::string::const_iterator next = it; next++;
139 if(
'-' == *it &&
'>' == *next){
146 else if(
' ' == *it)
_dirName +=
"_";
149 else if(
'['==*it)
_dirName +=
"_sqbra_";
150 else if(
']'==*it)
_dirName +=
"_sqket_";
183 mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO
188 int zeroForSuccess = 0;
189 zeroForSuccess |= mkdir( (asSubdirOf ).c_str(), mode );
190 zeroForSuccess |= mkdir( (asSubdirOf +
"/" +
dirName() ).c_str(), mode );
191 return (0 == zeroForSuccess);
214 cout <<
"after AmpPair::retrieve: pat = " 223 return asSubdirOf +
"/" +
dirName() +
"/value.txt";
226 return asSubdirOf +
"/" +
dirName() +
"/histoRe";
229 return asSubdirOf +
"/" +
dirName() +
"/histoIm";
248 , NamedParameterBase::QUIET);
250 ,NamedParameterBase::QUIET);
252 , NamedParameterBase::QUIET);
254 , NamedParameterBase::QUIET);
256 , NamedParameterBase::QUIET);
258 , NamedParameterBase::QUIET);
260 n_sumRe =
_sum.real();
261 n_sumIm =
_sum.imag();
262 n_sumSqRe =
_sumsq.real();
263 n_sumSqIm =
_sumsq.imag();
268 ofstream os(fname.c_str());
270 cout <<
"ERROR in AmpPair::saveValues of \n\t" <<
name()
271 <<
"\n\t unable to create file: " 272 <<
"\n\t" << fname << endl;
275 os << setprecision(20)
282 <<
'\n' << n_weightSum
290 if(dbThis)cout <<
"trying to retreive values from: " << fname << endl;
291 if(dbThis)cout <<
"current sum " <<
_sum << endl;
307 complex<double> n_sum(n_sumRe, n_sumIm);
309 if(dbThis) cout <<
"n_sumRe " << n_sumRe <<
"n_sum " << n_sum << endl;
311 if(dbThis) cout <<
"_sum = " <<
_sum << endl;
312 complex<double> n_sumsq(n_sumSqRe, n_sumSqIm);
330 if(0 == evtPtr)
return 0;
335 cout <<
"WARNING in AmpPair::addToHistograms" 336 <<
" event with phase space = " << ps << endl;
348 cout <<
" AmpPair::add, for pair " 353 complex<double> c=
ampValue(evtPtr) * efficiency * w;
359 cout <<
"\t c = " << c
363 complex<double> csq(c.real()*c.real(), c.imag()*c.imag());
373 return add(evtPtr.
get(), weight, efficiency);
379 if(0 ==
_a1 || 0 ==
_a2 || 0 == evtPtr)
return 0;
382 complex<double> c1 =
_a1->
getVal(*evtPtr);
383 complex<double> c2 =
_a2->
getVal(*evtPtr);
384 complex<double> c2star = conj(c2);
386 complex<double> val = (c1 * c2star);
399 cout <<
" AmpPair::sumWithoutFitPars for pair " 404 std::complex<double> total = ((std::complex<double>)
oneOrTwo()) *
_sum;
405 std::complex<double> returnVal;
410 returnVal = total/dN;
414 cout <<
"\t returning " << returnVal << endl;
436 complex<double> mean =
_sum/dN;
437 complex<double> meansq =
_sumsq/dN;
439 complex<double> var(meansq.real() - mean.real()*mean.real()
440 , meansq.imag() - mean.imag()*mean.imag());
494 os <<
"AmpPair " <<
name()
495 <<
": N=" <<
N() <<
", integral=" <<
integral();
504 if(0 == a && 0==b)
return false;
505 if(0 == a && 0!=b)
return true;
506 if(0 !=a && 0==b)
return false;
510 ,
const std::pair<AmpPair*, int>& bpair)
const{
511 const AmpPair* a = apair.first;
512 const AmpPair* b = bpair.first;
514 if(0 == a && 0==b)
return false;
515 if(0 == a && 0!=b)
return true;
516 if(0 !=a && 0==b)
return false;
std::complex< double > lastEntry() const
bool hasMatchingPattern() const
bool retrieve(const std::string &asSubdirOf=".")
bool operator()(const AmpPair *a, const AmpPair *b) const
bool retrieveHistos(const std::string &asSubdirOf=".")
const std::string & makeName()
virtual double getWeight() const =0
bool add(const AmpPair &other)
virtual double phaseSpace() const =0
bool save(const std::string &asSubdirOf=".") const
bool saveHistos(const std::string &asSubdirOf=".") const
std::complex< double > _lastEntry
std::complex< double > _sum
std::string valueFileName(const std::string &asSubdirOf) const
std::string histoReFileName(const std::string &asSubdirOf) const
AmpPair & operator+=(const AmpPair &other)
bool makeDirectory(const std::string &asSubdirOf=".") const
const DalitzHistoSet & histosIm() const
const ValueType & getVal() const
const std::string & dirName() const
bool isCompatibleWith(const AmpPair &other) const
AmpPair(Amplitude *a1=0, Amplitude *a2=0)
std::complex< double > integral() const
virtual std::complex< double > getVal(IDalitzEvent &evt)
std::ostream & operator<<(std::ostream &os, const AmpPair &fap)
bool retrieveFromDir(const std::string &asSubDirOf=".")
virtual bool registerFitParDependence(const IFitParDependent &fpd)
const std::string & name() const
bool operator()(const AmpPair &a, const AmpPair &b) const
bool saveValues(const std::string &asSubdirOf=".") const
void addToHistograms(IDalitzEvent *evtPtr, const std::complex< double > &c)
virtual double getGeneratorPdfRelativeToPhaseSpace() const =0
AmpPair operator+(const AmpPair &other) const
void addEvent(const IDalitzEvent &evt, double weight=1)
bool reloadFile(const std::string &id)
std::map< Key, Val >::iterator begin()
std::complex< double > _sumsq
void removeAllFitParDependencies()
const std::string & makeDirName()
std::complex< double > variance() const
bool saveAsDir(const std::string &asSubdirOf=".") const
DecayTree theBareDecay() const
const DalitzHistoSet & histosRe() const
std::complex< double > ampValue(IDalitzEvent *evtPtr)
virtual void print(std::ostream &os=std::cout) const
bool retrieveValues(const std::string &fromDirectory=".")
std::string histoImFileName(const std::string &asSubdirOf) const
std::string _weightSumName
bool operator()(const std::pair< AmpPair *, int > &a, const std::pair< AmpPair *, int > &b) const