13 struct stat statinfo ;
14 return stat(fname.c_str(), &statinfo) == 0 ;
19 decaytime(_decaytime),
30 map<string, unsigned> infoNames ;
38 const double smeareddecaytime) :
54 return getValueFromVector(ITAG) ;
58 setValueInVector(ITAG, tag) ;
62 return getValueFromVector(IDECAYTIME) ;
66 setValueInVector(IDECAYTIME, decaytime) ;
70 return getValueFromVector(ISMEAREDDECAYTIME) ;
74 setValueInVector(ISMEAREDDECAYTIME, decaytime) ;
102 double qoverp,
double phi,
double tmax,
int ntimepoints,
103 const bool saveIntegEvents,
const double tmin, TH1F* h_efficiency,
104 float resWidth,
bool addExpEffects) :
127 if(overwrite &&
exists(name)){
128 cout <<
"Deleting previous integrators in directory " << name << endl ;
129 string cmd(
"rm -rf " + name) ;
130 system(cmd.c_str()) ;
134 string cmd(
"mkdir -p " + name) ;
135 system(cmd.c_str()) ;
141 for(
int tag = -1 ; tag <= 1 ; tag += 2) {
150 vector<double> times ;
151 vector<double> integrals ;
154 double decaytime =
m_tmin + i * sampleinterval ;
157 *model *= amps.first ;
158 if(amps.second != complex<double>(0., 0.)){
160 antimodel *= amps.second ;
161 model->
add(antimodel) ;
168 ostringstream fname ;
169 fname <<
m_name <<
"/tag_" << tag <<
"_decaytime_" << decaytime ;
170 double integral(0.) ;
173 const string eventsFile(fname.str() +
"_events.root") ;
175 eventsFile,
"topUp", fname.str()) ;
177 dalitz.saveIntegrator(fname.str()) ;
178 if(!saveIntegEvents){
179 string cmd(
"rm " + eventsFile) ;
180 system(cmd.c_str()) ;
187 integral = intcalc->integral() ;
189 cout <<
"Make generator with tag " << tag <<
", decay time " << decaytime
190 <<
", coeffprod " << amps.first.real()
191 <<
" + " << amps.first.imag() <<
" j, " 192 <<
" coeffmix " << amps.second.real() <<
" + " << amps.second.imag()
193 <<
" j, integral " << integral << endl ;
195 complex<double> coeff = amps.first + amps.second ;
196 integral = sqrt(coeff.real() * coeff.real() + coeff.imag() * coeff.imag()) ;
199 times.push_back(decaytime) ;
200 integrals.push_back(integral) ;
204 ostringstream splinename ;
205 splinename <<
"timespline_tag_" << tag ;
206 string splinenamestr = splinename.str() ;
207 TSpline3 timespline(splinenamestr.c_str(), ×[0], &integrals[0], times.size()) ;
208 timespline.SetName(splinenamestr.c_str()) ;
214 cout <<
"Integrated CP asymmetry is " << (integplus - integminus)/(integplus + integminus) << endl ;
218 cout <<
"Tau minus: " << tauminus << endl ;
219 cout <<
"Tau plus: " << tauplus << endl ;
220 cout <<
"AGamma: " << (tauminus - tauplus)/(tauminus + tauplus) << endl ;
232 complex<double> expterm = exp(complex<double>(0.5 *
m_deltagamma * decaytime,
m_deltam * decaytime)) ;
233 complex<double> plusterm = 1. + expterm ;
234 complex<double> minusterm = 1. - expterm ;
235 complex<double> coeffprod = coeff * plusterm ;
236 complex<double> coeffmix = pow(polar(
m_qoverp,
m_phi), tag) * coeff * minusterm ;
237 return AmpPair(coeffprod, coeffmix) ;
242 double rndm =
m_rndm->Rndm() ;
250 double decaytime =
m_tmax + 1. ;
259 GenList::const_iterator igen = genlist.begin() ;
260 while(igen->decaytime < decaytime && igen != genlist.end())
262 if(igen == genlist.end()){
263 cerr <<
"TimeDependentGeneratorOld::generate_dalitz_event: ERROR: Got impossible decay time: " 264 << decaytime <<
" (tmax = " <<
m_tmax <<
")" << endl ;
268 if(decaytime == igen->decaytime)
269 return igen->generator->newEvent() ;
270 GenList::const_iterator igenprev(igen) ;
273 double gensel =
m_rndm->Rndm() ;
274 if(gensel < 1. - (decaytime - igenprev->decaytime)/(igen->decaytime - igenprev->decaytime))
275 return igenprev->generator->newEvent() ;
276 return igen->generator->newEvent() ;
283 double smeareddecaytime = -999. ;
289 float efficiency = 0 ;
290 int maxiter = 100000 ;
302 if(
m_rndm->Rndm() < efficiency){
312 cout <<
"WARNING: Decay time generation limit exceeded." << endl ;
TimeDependentGeneratorOld(const std::string &name, const bool overwrite, TRandom3 *rndm, double precision, const DalitzEventPattern &pattern, double width, double deltam, double deltagamma, double qoverp, double phi, double tmax, int ntimepoints, const bool saveIntegEvents=true, double tmin=0., TH1F *h_efficiency=NULL, float resWidth=0.05, bool addExpEffects=false)
const DalitzEventPattern m_cppattern
void setDecayTime(double)
virtual int add(const FitAmpListBase &other, double factor=1)
MINT::counted_ptr< IDalitzEvent > generate_dalitz_event(const int tag, const double decaytime) const
virtual const std::vector< double > & getVectorOfValues() const
bool exists(const string &fname)
double getSmearedDecayTime() const
const DalitzEventPattern m_pattern
static std::map< std::string, unsigned > infoNames
std::list< GenTimePoint > GenList
GenTimePoint(const double _decaytime, FitAmpSum *_model, const double _integral, SignalGenerator *_generator)
void setSmearedDecayTime(double)
std::pair< std::complex< double >, std::complex< double > > AmpPair
AmpPair amplitude_coefficients(const int tag, const double decaytime)
std::map< int, SplineGenerator > m_timegenerators
virtual MINT::counted_ptr< IIntegrationCalculator > makeIntegrationCalculator()
double generate_decay_time(const int tag) const
const double m_deltagamma
GenTimeEvent(const IDalitzEvent &, const int, const double, const double smeareddecaytime=-999.)
double getIntegralValue() const
virtual bool retrieve(const std::string &dirname)=0
const std::map< int, SplineGenerator > time_generators() const
double getDecayTime() const
static DalitzEventPattern anti(DalitzEventPattern pat)
static std::map< std::string, unsigned > makeInfoNames()
MINT::counted_ptr< IDalitzEvent > generate_event() const