BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
BesEvtGen-00-04-08/src/EvtGen/EvtGenBase/EvtAmp.cc
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3// Environment:
4// This software is part of the EvtGen package developed jointly
5// for the BaBar and CLEO collaborations. If you use all or part
6// of it, please give an appropriate acknowledgement.
7//
8// Copyright Information: See EvtGen/COPYRIGHT
9// Copyright (C) 1998 Caltech, UCSB
10//
11// Module: EvtAmp.cc
12//
13// Description: Class to manipulate the amplitudes in the decays.
14//
15// Modification history:
16//
17// RYD May 29, 1997 Module created
18//
19//------------------------------------------------------------------------
20//
21#include "EvtGenBase/EvtPatches.hh"
22#include <iostream>
23#include <math.h>
24#include <assert.h>
25#include "EvtGenBase/EvtComplex.hh"
26#include "EvtGenBase/EvtSpinDensity.hh"
27#include "EvtGenBase/EvtAmp.hh"
28#include "EvtGenBase/EvtReport.hh"
29#include "EvtGenBase/EvtId.hh"
30#include "EvtGenBase/EvtPDL.hh"
31#include "EvtGenBase/EvtParticle.hh"
32using std::endl;
33using std::cout;
34
35
37 _ndaug=0;
38 _pstates=0;
39 _nontrivial=0;
40}
41
42
43EvtAmp::EvtAmp(const EvtAmp& amp){
44
45 int i;
46
47 _ndaug=amp._ndaug;
48 _pstates=amp._pstates;
49 for(i=0;i<_ndaug;i++){
50 dstates[i]=amp.dstates[i];
51 _dnontrivial[i]=amp._dnontrivial[i];
52 }
53 _nontrivial=amp._nontrivial;
54
55 int namp=_pstates;
56
57 for(i=0;i<_nontrivial;i++){
58 _nstate[i]=amp._nstate[i];
59 namp*=_nstate[i];
60 }
61
62 for(i=0;i<namp;i++){
63 _amp[i]=amp._amp[i];
64 }
65
66}
67
68
69
70void EvtAmp::init(EvtId p,int ndaugs,EvtId *daug){
71 setNDaug(ndaugs);
72 int ichild;
73 int daug_states[100],parstates;
74 for(ichild=0;ichild<ndaugs;ichild++){
75
76 daug_states[ichild]=
78
79 }
80
82
83 setNState(parstates,daug_states);
84
85}
86
87
88
89
90void EvtAmp::setNDaug(int n){
91 _ndaug=n;
92}
93
94void EvtAmp::setNState(int parent_states,int *daug_states){
95
96 _nontrivial=0;
97 _pstates=parent_states;
98
99 if(_pstates>1) {
100 _nstate[_nontrivial]=_pstates;
101 _nontrivial++;
102 }
103
104 int i;
105
106 for(i=0;i<_ndaug;i++){
107 dstates[i]=daug_states[i];
108 _dnontrivial[i]=-1;
109 if(daug_states[i]>1) {
110 _nstate[_nontrivial]=daug_states[i];
111 _dnontrivial[i]=_nontrivial;
112 _nontrivial++;
113 }
114 }
115
116 if (_nontrivial>5) {
117 report(ERROR,"EvtGen") << "Too many nontrivial states in EvtAmp!"<<endl;
118 }
119
120}
121
122void EvtAmp::setAmp(int *ind, const EvtComplex& a){
123
124 int nstatepad = 1;
125 int position = ind[0];
126
127 for ( int i=1; i<_nontrivial; i++ ) {
128 nstatepad *= _nstate[i-1];
129 position += nstatepad*ind[i];
130 }
131 _amp[position] = a;
132
133}
134
135const EvtComplex& EvtAmp::getAmp(int *ind)const{
136
137 int nstatepad = 1;
138 int position = ind[0];
139
140 for ( int i=1; i<_nontrivial; i++ ) {
141 nstatepad *= _nstate[i-1];
142 position += nstatepad*ind[i];
143 }
144
145 return _amp[position];
146}
147
148
150
151 EvtSpinDensity rho;
152 rho.SetDim(_pstates);
153
154 EvtComplex temp;
155
156 int i,j,n;
157
158 if (_pstates==1) {
159
160 if (_nontrivial==0) {
161
162 rho.Set(0,0,_amp[0]*conj(_amp[0]));
163 return rho;
164
165 }
166
167 n=1;
168
169 temp = EvtComplex(0.0);
170
171 for(i=0;i<_nontrivial;i++){
172 n*=_nstate[i];
173 }
174
175 for(i=0;i<n;i++){
176 temp+=_amp[i]*conj(_amp[i]);
177 }
178
179 rho.Set(0,0,temp);;
180
181 return rho;
182
183 }
184
185 else{
186
187 for(i=0;i<_pstates;i++){
188 for(j=0;j<_pstates;j++){
189
190 temp = EvtComplex(0.0);
191
192 int kk;
193
194 int allloop = 1;
195 for (kk=0;kk<(_nontrivial-1); kk++ ) {
196 allloop *= dstates[kk];
197 }
198
199 for (kk=0; kk<allloop; kk++) {
200 temp += _amp[_pstates*kk+i]*conj(_amp[_pstates*kk+j]);}
201
202 // if (_nontrivial>3){
203 //report(ERROR,"EvtGen") << "Can't handle so many states in EvtAmp!"<<endl;
204 //}
205
206 rho.Set(i,j,temp);
207
208 }
209 }
210 return rho;
211 }
212
213}
214
215
217
218 EvtSpinDensity rho;
219
220 rho.SetDim(_pstates);
221
222 if (_pstates==1){
223 rho.Set(0,0,EvtComplex(1.0,0.0));
224 return rho;
225 }
226
227 int k;
228
229 EvtAmp ampprime;
230
231 ampprime=(*this);
232
233 for(k=0;k<_ndaug;k++){
234
235 if (dstates[k]!=1){
236 ampprime=ampprime.contract(_dnontrivial[k],rho_list[k+1]);
237 }
238 }
239
240 return ampprime.contract(0,(*this));
241
242}
243
244
246
247 EvtSpinDensity rho;
248
249 rho.SetDim(dstates[i]);
250
251 int k;
252
253 if (dstates[i]==1) {
254
255 rho.Set(0,0,EvtComplex(1.0,0.0));
256
257 return rho;
258
259 }
260
261 EvtAmp ampprime;
262
263 ampprime=(*this);
264
265 if (_pstates!=1){
266 ampprime=ampprime.contract(0,rho_list[0]);
267 }
268
269 for(k=0;k<i;k++){
270
271 if (dstates[k]!=1){
272 ampprime=ampprime.contract(_dnontrivial[k],rho_list[k+1]);
273 }
274
275 }
276
277 return ampprime.contract(_dnontrivial[i],(*this));
278
279}
280
281EvtAmp EvtAmp::contract(int k,const EvtSpinDensity& rho){
282
283 EvtAmp temp;
284
285 int i,j;
286 temp._ndaug=_ndaug;
287 temp._pstates=_pstates;
288 temp._nontrivial=_nontrivial;
289
290 for(i=0;i<_ndaug;i++){
291 temp.dstates[i]=dstates[i];
292 temp._dnontrivial[i]=_dnontrivial[i];
293 }
294
295 if (_nontrivial==0) {
296 report(ERROR,"EvtGen")<<"Should not be here EvtAmp!"<<endl;
297 }
298
299
300 for(i=0;i<_nontrivial;i++){
301 temp._nstate[i]=_nstate[i];
302 }
303
304
305 EvtComplex c;
306
307 int index[10];
308 for (i=0;i<10;i++) {
309 index[i] = 0;
310 }
311
312 int allloop = 1;
313 int indflag,ii;
314 for (i=0;i<_nontrivial;i++) {
315 allloop *= _nstate[i];
316 }
317
318 for ( i=0;i<allloop;i++) {
319
320 c = EvtComplex(0.0);
321 int tempint = index[k];
322 for (j=0;j<_nstate[k];j++) {
323 index[k] = j;
324 c+=rho.Get(j,tempint)*getAmp(index);
325 }
326 index[k] = tempint;
327
328 temp.setAmp(index,c);
329
330 indflag = 0;
331 for ( ii=0;ii<_nontrivial;ii++) {
332 if ( indflag == 0 ) {
333 if ( index[ii] == (_nstate[ii]-1) ) {
334 index[ii] = 0;
335 }
336 else {
337 indflag = 1;
338 index[ii] += 1;
339 }
340 }
341 }
342
343 }
344 return temp;
345
346}
347
348
349EvtSpinDensity EvtAmp::contract(int k,const EvtAmp& amp2){
350
351 int i,j,l;
352
353 EvtComplex temp;
354 EvtSpinDensity rho;
355
356 rho.SetDim(_nstate[k]);
357
358 int allloop = 1;
359 int indflag,ii;
360 for (i=0;i<_nontrivial;i++) {
361 allloop *= _nstate[i];
362 }
363
364 int index[10];
365 int index1[10];
366 // int l;
367 for(i=0;i<_nstate[k];i++){
368
369 for(j=0;j<_nstate[k];j++){
370 if (_nontrivial==0) {
371 report(ERROR,"EvtGen")<<"Should not be here1 EvtAmp!"<<endl;
372 rho.Set(0,0,EvtComplex(1.0,0.0));
373 return rho;
374 }
375
376 for (ii=0;ii<10;ii++) {
377 index[ii] = 0;
378 index1[ii] = 0;
379 }
380 index[k] = i;
381 index1[k] = j;
382
383 temp = EvtComplex(0.0);
384
385 for ( l=0;l<int(allloop/_nstate[k]);l++) {
386
387 temp+=getAmp(index)*conj(amp2.getAmp(index1));
388 indflag = 0;
389 for ( ii=0;ii<_nontrivial;ii++) {
390 if ( ii!= k) {
391 if ( indflag == 0 ) {
392 if ( index[ii] == (_nstate[ii]-1) ) {
393 index[ii] = 0;
394 index1[ii] = 0;
395 }
396 else {
397 indflag = 1;
398 index[ii] += 1;
399 index1[ii] += 1;
400 }
401 }
402 }
403 }
404 }
405 rho.Set(i,j,temp);
406
407 }
408 }
409
410 return rho;
411}
412
413
414EvtAmp EvtAmp::contract(int i, const EvtAmp& a1,const EvtAmp& a2){
415
416 assert(a2._pstates>1&&a2._nontrivial==1);
417
418 EvtAmp tmp;
419 report(DEBUG,"EvtGen") << "EvtAmp::contract not written yet" << endl;
420 return tmp;
421
422}
423
424
425void EvtAmp::dump(){
426
427 int i,list[10];
428
429 report(DEBUG,"EvtGen") << "Number of daugthers:"<<_ndaug<<endl;
430 report(DEBUG,"EvtGen") << "Number of states of the parent:"<<_pstates<<endl;
431 report(DEBUG,"EvtGen") << "Number of states on daughters:";
432 for (i=0;i<_ndaug;i++){
433 report(DEBUG,"EvtGen") <<dstates[i]<<" ";
434 }
435 report(DEBUG,"EvtGen") << endl;
436 report(DEBUG,"EvtGen") << "Nontrivial index of daughters:";
437 for (i=0;i<_ndaug;i++){
438 report(DEBUG,"EvtGen") <<_dnontrivial[i]<<" ";
439 }
440 report(DEBUG,"EvtGen") <<endl;
441 report(DEBUG,"EvtGen") <<"number of nontrivial states:"<<_nontrivial<<endl;
442 report(DEBUG,"EvtGen") << "Nontrivial particles number of states:";
443 for (i=0;i<_nontrivial;i++){
444 report(DEBUG,"EvtGen") <<_nstate[i]<<" ";
445 }
446 report(DEBUG,"EvtGen") <<endl;
447 report(DEBUG,"EvtGen") <<"Amplitudes:"<<endl;
448 if (_nontrivial==0){
449 list[0] = 0;
450 report(DEBUG,"EvtGen") << getAmp(list) << endl;
451 }
452
453 int allloop[10];
454 allloop[0]=1;
455 for (i=0;i<_nontrivial;i++) {
456 if (i==0){
457 allloop[i] *= _nstate[i];
458 }
459 else{
460 allloop[i] = allloop[i-1]*_nstate[i];
461 }
462 }
463 int index = 0;
464 for (i=0;i<allloop[_nontrivial-1];i++) {
465 report(DEBUG,"EvtGen") << getAmp(list) << " ";
466 if ( i==allloop[index]-1 ) {
467 index ++;
468 report(DEBUG,"EvtGen") << endl;
469 }
470 }
471
472 report(DEBUG,"EvtGen") << "-----------------------------------"<<endl;
473
474}
475
476
477void EvtAmp::vertex(const EvtComplex& c){
478 int list[1];
479 list[0] = 0;
480 setAmp(list,c);
481}
482
483void EvtAmp::vertex(int i,const EvtComplex& c){
484 int list[1];
485 list[0] = i;
486 setAmp(list,c);
487}
488
489void EvtAmp::vertex(int i,int j,const EvtComplex& c){
490 int list[2];
491 list[0] = i;
492 list[1] = j;
493 setAmp(list,c);
494}
495
496void EvtAmp::vertex(int i,int j,int k,const EvtComplex& c){
497 int list[3];
498 list[0] = i;
499 list[1] = j;
500 list[2] = k;
501 setAmp(list,c);
502}
503
504void EvtAmp::vertex(int *i1,const EvtComplex& c){
505
506 setAmp(i1,c);
507}
508
509
510EvtAmp& EvtAmp::operator=(const EvtAmp& amp){
511
512 int i;
513
514 _ndaug=amp._ndaug;
515 _pstates=amp._pstates;
516 for(i=0;i<_ndaug;i++){
517 dstates[i]=amp.dstates[i];
518 _dnontrivial[i]=amp._dnontrivial[i];
519 }
520 _nontrivial=amp._nontrivial;
521
522 int namp=_pstates;
523
524 for(i=0;i<_nontrivial;i++){
525 _nstate[i]=amp._nstate[i];
526 namp*=_nstate[i];
527 }
528
529 for(i=0;i<namp;i++){
530 _amp[i]=amp._amp[i];
531 }
532
533 return *this;
534}
535
536
537
538
539
540
541
542
543
544
545
const Int_t n
Evt3Rank3C conj(const Evt3Rank3C &t2)
ostream & report(Severity severity, const char *facility)
const EvtComplex & getAmp(int *ind) const
EvtSpinDensity contract(int i, const EvtAmp &a)
void setAmp(int *ind, const EvtComplex &amp)
void init(EvtId p, int ndaug, EvtId *daug)
EvtSpinDensity getBackwardSpinDensity(EvtSpinDensity *rho_list)
EvtSpinDensity getForwardSpinDensity(EvtSpinDensity *rho_list, int k)
static EvtSpinType::spintype getSpinType(EvtId i)
void Set(int i, int j, const EvtComplex &rhoij)