]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TEvtGen/EvtGenBase/EvtPto3PAmpFactory.cxx
o updates to fix the 11a pass4 problem of T0 (Alla)
[u/mrichter/AliRoot.git] / TEvtGen / EvtGenBase / EvtPto3PAmpFactory.cxx
CommitLineData
da0e9ce3 1//-----------------------------------------------------------------------
2// File and Version Information:
3// $Id: EvtPto3PAmpFactory.cc,v 1.22 2009/02/19 03:22:30 ryd Exp $
4//
5// Environment:
6// This software is part of the EvtGen package developed jointly
7// for the BaBar and CLEO collaborations. If you use all or part
8// of it, please give an appropriate acknowledgement.
9//
10// Copyright Information:
11// Copyright (C) 1998 Caltech, UCSB
12//
13// Module creator:
14// Alexei Dvoretskii, Caltech, 2001-2002.
15//-----------------------------------------------------------------------
16#include "EvtGenBase/EvtPatches.hh"
17
18// AmpFactory for building a P -> 3P decay
19// (pseudoscalar to three pseudoscalars)
20
21#include <assert.h>
22#include <math.h>
23#include <stdio.h>
24#include <stdlib.h>
25
26#include "EvtGenBase/EvtId.hh"
27#include "EvtGenBase/EvtPDL.hh"
28#include "EvtGenBase/EvtConst.hh"
29#include "EvtGenBase/EvtComplex.hh"
30#include "EvtGenBase/EvtCyclic3.hh"
31#include "EvtGenBase/EvtSpinType.hh"
32#include "EvtGenBase/EvtPto3PAmp.hh"
33#include "EvtGenBase/EvtNonresonantAmp.hh"
34#include "EvtGenBase/EvtFlatAmp.hh"
35#include "EvtGenBase/EvtLASSAmp.hh"
36#include "EvtGenBase/EvtPto3PAmpFactory.hh"
37#include "EvtGenBase/EvtPropBreitWigner.hh"
38#include "EvtGenBase/EvtPropFlatte.hh"
39#include "EvtGenBase/EvtPropBreitWignerRel.hh"
40#include "EvtGenBase/EvtDalitzResPdf.hh"
41#include "EvtGenBase/EvtDalitzFlatPdf.hh"
42
43using namespace EvtCyclic3;
44#include <iostream>
45
46void EvtPto3PAmpFactory::processAmp(EvtComplex c, std::vector<std::string> vv, bool conj)
47{
48 if(_verbose) {
49
50 printf("Make %samplitude\n",conj ? "CP conjugate" : "");
51 unsigned i;
52 for(i=0;i<vv.size();i++) printf("%s\n",vv[i].c_str());
53 printf("\n");
54 }
55
56 EvtAmplitude<EvtDalitzPoint>* amp = 0;
57 EvtPdf<EvtDalitzPoint>* pdf = 0;
58 std::string name;
59 Pair pairRes=AB;
60
61 size_t i;
62 /*
63 Experimental amplitudes
64 */
65 if(vv[0] == "PHASESPACE") {
66
67 pdf = new EvtDalitzFlatPdf(_dp);
68 amp = new EvtFlatAmp<EvtDalitzPoint>();
69 name = "NR";
70 }
71 else if (!vv[0].find("NONRES")) {
72 double alpha=0;
73 EvtPto3PAmp::NumType typeNRes=EvtPto3PAmp::NONRES;
74 if (vv[0]=="NONRES_LIN") {
75 typeNRes=EvtPto3PAmp::NONRES_LIN;
76 pairRes=strToPair(vv[1].c_str());
77 }
78 else if (vv[0]=="NONRES_EXP") {
79 typeNRes=EvtPto3PAmp::NONRES_EXP;
80 pairRes = strToPair(vv[1].c_str());
81 alpha = strtod(vv[2].c_str(),0);
82 }
83 else assert(0);
84 pdf = new EvtDalitzFlatPdf(_dp);
85 amp = new EvtNonresonantAmp( &_dp, typeNRes, pairRes, alpha);
86 }
87 else if (vv[0]=="LASS") {
88 pairRes = strToPair(vv[1].c_str());
89 double m0 = strtod(vv[2].c_str(),0);
90 double g0 = strtod(vv[3].c_str(),0);
91 double a = strtod(vv[4].c_str(),0);
92 double r = strtod(vv[5].c_str(),0);
93 double cutoff = strtod(vv[6].c_str(),0);
94 pdf = new EvtDalitzResPdf(_dp,m0,g0,pairRes);
95 amp = new EvtLASSAmp( &_dp, pairRes, m0, g0, a, r, cutoff);
96 }
97
98 /*
99 Resonant amplitudes
100 */
101 else if(vv[0] == "RESONANCE") {
102 EvtPto3PAmp* partAmp = 0;
103
104 // RESONANCE stanza
105
106 pairRes = strToPair(vv[1].c_str());
107 EvtSpinType::spintype spinR;
108 double mR, gR;
109 name = vv[2];
110 EvtId resId = EvtPDL::getId(vv[2]);
111 if(_verbose) printf("Particles %s form %sresonance %s\n",
112 vv[1].c_str(),vv[2].c_str(), conj ? "(conj) " : "");
113
114 // If no valid particle name is given, assume that
115 // it is the spin, the mass and the width of the particle.
116
117 if(resId.getId() == -1) {
118
119 switch(atoi(vv[2].c_str())) {
120
121 case 0: { spinR = EvtSpinType::SCALAR; break; }
122 case 1: { spinR = EvtSpinType::VECTOR; break; }
123 case 2: { spinR = EvtSpinType::TENSOR; break; }
124 case 3: { spinR = EvtSpinType::SPIN3; break; }
125 case 4: { spinR = EvtSpinType::SPIN4; break; }
126 default: { assert(0); break; }
127 }
128
129 mR = strtod(vv[3].c_str(),0);
130 gR = strtod(vv[4].c_str(),0);
131 i = 4;
132 }
133 else {
134
135 // For a valid particle get spin, mass and width
136
137 spinR = EvtPDL::getSpinType(resId);
138 mR = EvtPDL::getMeanMass(resId);
139 gR = EvtPDL::getWidth(resId);
140 i = 2;
141
142 // It's possible to specify mass and width of a particle
143 // explicitly
144
145 if(vv[3] != "ANGULAR") {
146
147 if(_verbose)
148 printf("Setting m(%s)=%s g(%s)=%s\n",
149 vv[2].c_str(),vv[3].c_str(),vv[2].c_str(),vv[4].c_str());
150
151 mR = strtod(vv[3].c_str(),0);
152 gR = strtod(vv[4].c_str(),0);
153 i = 4;
154 }
155 }
156
157 // ANGULAR stanza
158
159 if(vv[++i] != "ANGULAR") {
160
161 printf("%s instead of ANGULAR\n",vv[i].c_str());
162 exit(0);
163 }
164 Pair pairAng = strToPair(vv[++i].c_str());
165 if(_verbose) printf("Angle is measured between particles %s\n",vv[i].c_str());
166
167 // TYPE stanza
168
169 assert(vv[++i] == "TYPE");
170 std::string type = vv[++i];
171 if(_verbose) printf("Propagator type %s\n",vv[i].c_str());
172
173 if(type == "NBW") {
174
175 EvtPropBreitWigner prop(mR,gR);
176 partAmp = new EvtPto3PAmp(_dp,pairAng,pairRes,spinR,prop,EvtPto3PAmp::NBW);
177 }
178 else if(type == "RBW_ZEMACH") {
179
180 EvtPropBreitWignerRel prop(mR,gR);
181 partAmp = new EvtPto3PAmp(_dp,pairAng,pairRes,spinR,prop,EvtPto3PAmp::RBW_ZEMACH);
182 }
183 else if(type == "RBW_KUEHN") {
184
185 EvtPropBreitWignerRel prop(mR,gR);
186 partAmp = new EvtPto3PAmp(_dp,pairAng,pairRes,spinR,prop,EvtPto3PAmp::RBW_KUEHN);
187 }
188 else if(type == "RBW_CLEO") {
189
190 EvtPropBreitWignerRel prop(mR,gR);
191 partAmp = new EvtPto3PAmp(_dp,pairAng,pairRes,spinR,prop,EvtPto3PAmp::RBW_CLEO);
192 }
193 else if(type == "FLATTE") {
194
195 double m1a = _dp.m( first(pairRes) );
196 double m1b = _dp.m( second(pairRes) );
197 // 2nd channel
198 double g2 = strtod(vv[++i].c_str(),0);
199 double m2a = strtod(vv[++i].c_str(),0);
200 double m2b = strtod(vv[++i].c_str(),0);
201 EvtPropFlatte prop( mR, gR, m1a, m1b, g2, m2a, m2b );
202 partAmp = new EvtPto3PAmp(_dp,pairAng,pairRes,spinR,prop,EvtPto3PAmp::FLATTE);
203 }
204 else assert(0);
205
206 // Optional DVFF, BVFF stanzas
207
208 if(i < vv.size() - 1) {
209 if(vv[i+1] == "DVFF") {
210 i++;
211 if(vv[++i] == "BLATTWEISSKOPF") {
212
213 double R = strtod(vv[++i].c_str(),0);
214 partAmp->set_fd(R);
215 }
216 else assert(0);
217 }
218 }
219
220 if(i < vv.size() - 1) {
221 if(vv[i+1] == "BVFF") {
222 i++;
223 if(vv[++i] == "BLATTWEISSKOPF") {
224
225 if(_verbose) printf("BVFF=%s\n",vv[i].c_str());
226 double R = strtod(vv[++i].c_str(),0);
227 partAmp->set_fb(R);
228 }
229 else assert(0);
230 }
231 }
232
233 const int minwidths=5;
234 //Optional resonance minimum and maximum
235 if(i < vv.size() - 1) {
236 if(vv[i+1] == "CUTOFF") {
237 i++;
238 if(vv[i+1] == "MIN") {
239 i++;
240 double min = strtod(vv[++i].c_str(),0);
241 if(_verbose) std::cout<<"CUTOFF MIN = "<<min<<std::endl;
242 //ensure against cutting off too close to the resonance
243 assert( min<(mR-minwidths*gR) );
244 partAmp->setmin(min);
245 }
246 else if (vv[i+1] == "MAX") {
247 i++;
248 double max = strtod(vv[++i].c_str(),0);
249 if(_verbose) std::cout<<"CUTOFF MAX = "<<max<<std::endl;
250 //ensure against cutting off too close to the resonance
251 assert( max>(mR+minwidths*gR) );
252 partAmp->setmax(max);
253 }
254 else assert(0);
255 }
256 }
257
258 //2nd iteration in case min and max are both specified
259 if(i < vv.size() - 1) {
260 if(vv[i+1] == "CUTOFF") {
261 i++;
262 if(vv[i+1] == "MIN") {
263 i++;
264 double min = strtod(vv[++i].c_str(),0);
265 if(_verbose) std::cout<<"CUTOFF MIN = "<<min<<std::endl;
266 //ensure against cutting off too close to the resonance
267 assert( min<(mR-minwidths*gR) );
268 partAmp->setmin(min);
269 }
270 else if (vv[i+1] == "MAX") {
271 i++;
272 double max = strtod(vv[++i].c_str(),0);
273 if(_verbose) std::cout<<"CUTOFF MAX = "<<max<<std::endl;
274 //ensure against cutting off too close to the resonance
275 assert( max>(mR+minwidths*gR) );
276 partAmp->setmax(max);
277 }
278 else assert(0);
279 }
280 }
281
282
283 i++;
284
285 pdf = new EvtDalitzResPdf(_dp,mR,gR,pairRes);
286 amp = partAmp;
287 }
288
289 assert(amp);
290 assert(pdf);
291
292 if(!conj) {
293 _amp->addOwnedTerm(c,amp);
294 }
295 else {
296 _ampConj->addOwnedTerm(c,amp);
297 }
298
299 double scale = matchIsobarCoef(_amp, pdf, pairRes);
300 _pc->addOwnedTerm(abs2(c)*scale,pdf);
301
302 _names.push_back(name);
303}
304
305double EvtPto3PAmpFactory::matchIsobarCoef(EvtAmplitude<EvtDalitzPoint>* amp,
306 EvtPdf<EvtDalitzPoint>* pdf,
307 EvtCyclic3::Pair ipair) {
308
309 // account for differences in the definition of amplitudes by matching
310 // Integral( c'*pdf ) = Integral( c*|A|^2 )
311 // to improve generation efficiency ...
312
313 double Ipdf = pdf->compute_integral(10000).value();
314 double Iamp2 = 0;
315
316
317 EvtCyclic3::Pair jpair = EvtCyclic3::next(ipair);
318 EvtCyclic3::Pair kpair = EvtCyclic3::next(jpair);
319
320 // Trapezoidal integral
321 int N=10000;
322
323 double di = (_dp.qAbsMax(ipair) - _dp.qAbsMin(ipair))/((double) N);
324
325 double siMin = _dp.qAbsMin(ipair);
326
327 double s[3]; // playing with fire
328 for(int i=1; i<N; i++) {
329
330 s[ipair] = siMin + di*i;
331 s[jpair] = _dp.q(jpair, 0.9999, ipair, s[ipair]);
332 s[kpair] = _dp.bigM()*_dp.bigM() - s[ipair] - s[jpair]
333 + _dp.mA()*_dp.mA() + _dp.mB()*_dp.mB() + _dp.mC()*_dp.mC();
334
335 EvtDalitzPoint point( _dp.mA(), _dp.mB(), _dp.mC(),
336 s[EvtCyclic3::AB], s[EvtCyclic3::BC], s[EvtCyclic3::CA]);
337
338 if (!point.isValid()) continue;
339
340 double p = point.p(other(ipair), ipair);
341 double q = point.p(first(ipair), ipair);
342
343 double itg = abs2( amp->evaluate(point) )*di*4*q*p;
344 Iamp2 += itg;
345
346 }
347 if (_verbose) std::cout << "integral = " << Iamp2 << " pdf="<<Ipdf << std::endl;
348
349 assert(Ipdf>0 && Iamp2>0);
350
351 return Iamp2/Ipdf;
352}