CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtSpinAmp Class Reference

#include <EvtSpinAmp.hh>

Public Member Functions

 EvtSpinAmp ()
 
 EvtSpinAmp (const vector< EvtSpinType::spintype > &twospin)
 
 EvtSpinAmp (const vector< EvtSpinType::spintype > &twospin, const EvtComplex &val)
 
 EvtSpinAmp (const vector< EvtSpinType::spintype > &twospin, const vector< EvtComplex > &elem)
 
 EvtSpinAmp (const EvtSpinAmp &)
 
 ~EvtSpinAmp ()
 
EvtComplexoperator() (const vector< int > &)
 
const EvtComplexoperator() (const vector< int > &) const
 
EvtComplexoperator() (int,...)
 
const EvtComplexoperator() (int,...) const
 
EvtSpinAmpoperator= (const EvtSpinAmp &)
 
EvtSpinAmp operator+ (const EvtSpinAmp &) const
 
EvtSpinAmpoperator+= (const EvtSpinAmp &)
 
EvtSpinAmp operator- (const EvtSpinAmp &) const
 
EvtSpinAmpoperator-= (const EvtSpinAmp &)
 
EvtSpinAmp operator* (const EvtSpinAmp &) const
 
EvtSpinAmpoperator*= (const EvtSpinAmp &)
 
EvtSpinAmpoperator*= (const EvtComplex &)
 
EvtSpinAmpoperator/= (const EvtComplex &)
 
void intcont (int, int)
 
void extcont (const EvtSpinAmp &, int, int)
 
void assign (const EvtComplex &val)
 
int rank () const
 
const vector< int > & dims () const
 
void addspin (int twospin)
 
void setelem (const vector< EvtComplex > &elem)
 
bool iterate (vector< int > &index) const
 
vector< int > iterinit () const
 
bool allowed (const vector< int > &index) const
 
bool iterateallowed (vector< int > &index) const
 
vector< int > iterallowedinit () const
 

Friends

EvtSpinAmp operator* (const EvtComplex &real, const EvtSpinAmp &cont)
 
EvtSpinAmp operator* (const EvtSpinAmp &cont, const EvtComplex &real)
 
EvtSpinAmp operator/ (const EvtSpinAmp &cont, const EvtComplex &real)
 
std::ostream & operator<< (std::ostream &os, const EvtSpinAmp &amp)
 

Detailed Description

Definition at line 17 of file EvtSpinAmp.hh.

Constructor & Destructor Documentation

◆ EvtSpinAmp() [1/5]

EvtSpinAmp::EvtSpinAmp ( )
inline

Definition at line 27 of file EvtSpinAmp.hh.

27{};

◆ EvtSpinAmp() [2/5]

EvtSpinAmp::EvtSpinAmp ( const vector< EvtSpinType::spintype > & twospin)

Definition at line 63 of file EvtSpinAmp.cc.

64{
65 int num = 1;
66 _type = type;
67 _twospin=calctwospin( type );
68
69 for( int i=0; i<_twospin.size(); ++i )
70 num*=_twospin[i]+1;
71
72 _elem=vector<EvtComplex>( num );
73}
int num[96]
Definition ranlxd.c:373

◆ EvtSpinAmp() [3/5]

EvtSpinAmp::EvtSpinAmp ( const vector< EvtSpinType::spintype > & twospin,
const EvtComplex & val )

Definition at line 75 of file EvtSpinAmp.cc.

76{
77 int num = 1;
78 _type = type;
79 _twospin=calctwospin( type );
80
81 for( int i=0; i<_twospin.size(); ++i )
82 num*=_twospin[i]+1;
83
84 _elem=vector<EvtComplex>( num, val );
85}

◆ EvtSpinAmp() [4/5]

EvtSpinAmp::EvtSpinAmp ( const vector< EvtSpinType::spintype > & twospin,
const vector< EvtComplex > & elem )

Definition at line 87 of file EvtSpinAmp.cc.

89{
90 int num = 1;
91
92 _type = type;
93 _twospin=calctwospin( type );
94 _elem=elem;
95
96 for( int i=0; i<_twospin.size(); ++i )
97 num*=_twospin[i]+1;
98
99 if(_elem.size() != num ) {
100 report(ERROR,"EvtGen")<<"Wrong number of elements input:"
101 <<_elem.size()<<" vs. "<<num<<endl;
102 ::abort();
103 }
104
105}
ostream & report(Severity severity, const char *facility)
Definition EvtReport.cc:36
@ ERROR
Definition EvtReport.hh:49

◆ EvtSpinAmp() [5/5]

EvtSpinAmp::EvtSpinAmp ( const EvtSpinAmp & copy)

Definition at line 107 of file EvtSpinAmp.cc.

108{
109 _twospin = copy._twospin;
110 _elem = copy._elem;
111 _type = copy._type;
112}
uint32_t copy(const node_t &list, uint32_t *dest, size_t max)
Definition node.cxx:64

◆ ~EvtSpinAmp()

EvtSpinAmp::~EvtSpinAmp ( )
inline

Definition at line 33 of file EvtSpinAmp.hh.

33{};

Member Function Documentation

◆ addspin()

void EvtSpinAmp::addspin ( int twospin)
inline

Definition at line 71 of file EvtSpinAmp.hh.

71{ _twospin.push_back( twospin ); }

◆ allowed()

bool EvtSpinAmp::allowed ( const vector< int > & index) const

Definition at line 386 of file EvtSpinAmp.cc.

387{
388 if( index.size() != _type.size() ) {
389 report(ERROR,"EvtGen")
390 <<"Wrong dimensino index input to allowed."<<endl;
391 ::abort();
392 }
393
394 for(int i=0; i<index.size(); ++i) {
395 switch(_type[i]) {
397 if(abs(index[i])!=2) return false;
398 break;
400 report(ERROR,"EvtGen")
401 <<"EvMultibody currently cannot handle neutrinos."<<endl;
402 ::abort();
403 default:
404 break;
405 }
406 }
407
408 return true;
409}
double abs(const EvtComplex &c)

Referenced by EvtMHelAmp::EvtMHelAmp(), iterallowedinit(), and iterateallowed().

◆ assign()

void EvtSpinAmp::assign ( const EvtComplex & val)
inline

Definition at line 61 of file EvtSpinAmp.hh.

61{ _elem.assign( _elem.size(), val ); }

◆ dims()

const vector< int > & EvtSpinAmp::dims ( ) const
inline

Definition at line 67 of file EvtSpinAmp.hh.

67{ return _twospin; }

Referenced by EvtMultibody::decay().

◆ extcont()

void EvtSpinAmp::extcont ( const EvtSpinAmp & cont,
int a,
int b )

Definition at line 489 of file EvtSpinAmp.cc.

490{
491 EvtSpinAmp ret = (*this)*cont;
492 ret.intcont( a, rank()+b );
493
494 *this=ret;
495}
EvtComplex cont(const EvtTensor4C &t1, const EvtTensor4C &t2)
int rank() const
Definition EvtSpinAmp.hh:64
void intcont(int, int)

Referenced by EvtMHelAmp::amplitude(), and EvtMultibody::decay().

◆ intcont()

void EvtSpinAmp::intcont ( int a,
int b )

Definition at line 431 of file EvtSpinAmp.cc.

432{
433 int newrank=rank()-2;
434 if(newrank<=0) {
435 report(ERROR,"EvtGen")<<"EvtSpinAmp can't handle no indices" << endl;
436 ::abort();
437 }
438
439 if(_twospin[a]!=_twospin[b]) {
440 report(ERROR,"EvtGen")
441 <<"Contaction called on indices of different dimension"
442 <<endl;
443 report(ERROR,"EvtGen")
444 <<"Called on "<<_twospin[a]<<" and "<<_twospin[b]
445 <<endl;
446 ::abort();
447 }
448
449 vector<int> newtwospin( newrank );
450 vector<EvtSpinType::spintype> newtype( newrank );
451
452 for( int i=0, j=0; i<_twospin.size(); ++i ){
453 if(i==a || i==b) continue;
454
455 newtwospin[j] = _twospin[i];
456 newtype[j] = _type[i];
457 ++j;
458 }
459
460 EvtSpinAmp newamp( newtype );
461 vector<int> index( rank() ), newindex = newamp.iterinit();
462
463 for( int i=0; i<newrank; ++i )
464 newindex[i] = -newtwospin[i];
465
466 while(true) {
467
468 for( int i=0, j=0; i<rank(); ++i ) {
469 if(i==a || i==b) continue;
470 index[i]=newindex[j];
471 ++j;
472 }
473
474 index[b]=index[a]=-_twospin[a];
475 newamp(newindex) = (*this)(index);
476 for( int i=-_twospin[a]+2; i<=_twospin[a]; i+=2 ) {
477 index[b]=index[a]=i;
478 newamp(newindex) += (*this)(index);
479 }
480
481 if(!newamp.iterate(newindex)) break;
482 }
483
484 *this=newamp;
485}

Referenced by extcont().

◆ iterallowedinit()

vector< int > EvtSpinAmp::iterallowedinit ( ) const

Definition at line 421 of file EvtSpinAmp.cc.

422{
423 vector<int> init = iterinit();
424 while(!allowed(init)) {
425 iterate(init);
426 }
427
428 return init;
429}
vector< int > iterinit() const
bool iterate(vector< int > &index) const
bool allowed(const vector< int > &index) const

Referenced by EvtMHelAmp::amplitude(), and EvtMultibody::decay().

◆ iterate()

bool EvtSpinAmp::iterate ( vector< int > & index) const

Definition at line 369 of file EvtSpinAmp.cc.

370{
371 int last = _twospin.size() - 1;
372
373 index[0]+=2;
374 for( int j=0; j<last; ++j ) {
375 if( index[j] > _twospin[j] ) {
376 index[j] = -_twospin[j];
377 index[j+1]+=2;
378 }
379 }
380
381 return abs(index[last])<=_twospin[last];
382}

Referenced by EvtMHelAmp::EvtMHelAmp(), intcont(), iterallowedinit(), iterateallowed(), and operator*().

◆ iterateallowed()

bool EvtSpinAmp::iterateallowed ( vector< int > & index) const

Definition at line 411 of file EvtSpinAmp.cc.

412{
413 while(true) {
414 if(!iterate( index ))
415 return false;
416 if(allowed( index ))
417 return true;
418 }
419}

Referenced by EvtMHelAmp::amplitude(), and EvtMultibody::decay().

◆ iterinit()

vector< int > EvtSpinAmp::iterinit ( ) const

Definition at line 359 of file EvtSpinAmp.cc.

360{
361 vector<int> init( _twospin.size() );
362
363 for( int i=0; i<_twospin.size(); ++i )
364 init[i]=-_twospin[i];
365
366 return init;
367}

Referenced by EvtMHelAmp::EvtMHelAmp(), intcont(), and iterallowedinit().

◆ operator()() [1/4]

EvtComplex & EvtSpinAmp::operator() ( const vector< int > & index)

Definition at line 168 of file EvtSpinAmp.cc.

169{
170 checkindexargs( index );
171
172 int trueindex = findtrueindex(index);
173 if(trueindex >= _elem.size()) {
174 report(ERROR,"EvtGen")<<"indexing error "<<trueindex<<" "<<_elem.size()<<endl;
175 for(int i=0; i<_twospin.size(); ++i) {
176 report(ERROR,"")<<_twospin[i]<<" ";
177 }
178 report(ERROR,"")<<endl;
179
180 for(int i=0; i<index.size(); ++i) {
181 report(ERROR,"")<<index[i]<<" ";
182 }
183 report(ERROR,"")<<endl;
184
185 ::abort();
186 }
187
188 return _elem[trueindex];
189}

◆ operator()() [2/4]

const EvtComplex & EvtSpinAmp::operator() ( const vector< int > & index) const

Definition at line 191 of file EvtSpinAmp.cc.

192{
193 checkindexargs( index );
194
195 int trueindex = findtrueindex(index);
196 if(trueindex >= _elem.size()) {
197 report(ERROR,"EvtGen")<<"indexing error "<<trueindex<<" "<<_elem.size()<<endl;
198 for(int i=0; i<_twospin.size(); ++i) {
199 report(ERROR,"")<<_twospin[i]<<" ";
200 }
201 report(ERROR,"")<<endl;
202
203 for(int i=0; i<index.size(); ++i) {
204 report(ERROR,"")<<index[i]<<" ";
205 }
206 report(ERROR,"")<<endl;
207
208 ::abort();
209 }
210
211 return _elem[trueindex];
212}

◆ operator()() [3/4]

EvtComplex & EvtSpinAmp::operator() ( int i,
... )

Definition at line 214 of file EvtSpinAmp.cc.

215{
216 va_list ap;
217 vector<int> index( _twospin.size() );
218
219 va_start(ap, i);
220
221 index[0]=i;
222 for(int n=1; n<_twospin.size(); ++n )
223 index[n]=va_arg( ap, int );
224
225 va_end(ap);
226
227 return (*this)( index );
228}
const Int_t n

◆ operator()() [4/4]

const EvtComplex & EvtSpinAmp::operator() ( int i,
... ) const

Definition at line 230 of file EvtSpinAmp.cc.

231{
232 vector<int> index( _twospin.size() );
233 va_list ap;
234
235 va_start(ap, i);
236
237 index[0]=i;
238 for(int n=1; n<_twospin.size(); ++n )
239 index[n]=va_arg( ap, int );
240
241 va_end(ap);
242
243 return (*this)( index );
244}

◆ operator*()

EvtSpinAmp EvtSpinAmp::operator* ( const EvtSpinAmp & amp2) const

Definition at line 300 of file EvtSpinAmp.cc.

301{
302 vector<int> index(rank()+amp2.rank());
303 vector<int> index1(rank()), index2(amp2.rank());
304 EvtSpinAmp amp;
305
306 amp._twospin=_twospin;
307 amp._type=_type;
308
309 for( int i=0; i<amp2._twospin.size(); ++i ) {
310 amp._twospin.push_back( amp2._twospin[i] );
311 amp._type.push_back( amp2._type[i] );
312 }
313
314 amp._elem = vector<EvtComplex>( _elem.size() * amp2._elem.size() );
315
316 for( int i=0; i<index1.size(); ++i )
317 index[i]=index1[i]=-_twospin[i];
318
319 for( int i=0; i<index2.size(); ++i )
320 index[i+rank()]=index2[i]=-amp2._twospin[i];
321
322 while(true) {
323 amp( index ) = (*this)( index1 )*amp2( index2 );
324 if(!amp.iterate( index )) break;
325
326 for( int i=0; i<index1.size(); ++i )
327 index1[i]=index[i];
328
329 for( int i=0; i<index2.size(); ++i )
330 index2[i]=index[i+rank()];
331 }
332
333 return amp;
334}

◆ operator*=() [1/2]

EvtSpinAmp & EvtSpinAmp::operator*= ( const EvtComplex & real)

Definition at line 343 of file EvtSpinAmp.cc.

344{
345 for( int i=0; i<_elem.size(); ++i )
346 _elem[i] *= real;
347
348 return *this;
349}
double real(const EvtComplex &c)

◆ operator*=() [2/2]

EvtSpinAmp & EvtSpinAmp::operator*= ( const EvtSpinAmp & cont)

Definition at line 336 of file EvtSpinAmp.cc.

337{
338 EvtSpinAmp ret = (*this)*cont;
339 *this=ret;
340 return *this;
341}

◆ operator+()

EvtSpinAmp EvtSpinAmp::operator+ ( const EvtSpinAmp & cont) const

Definition at line 255 of file EvtSpinAmp.cc.

256{
257 checktwospin( cont._twospin );
258
259 EvtSpinAmp ret( cont );
260 for( int i=0; i<ret._elem.size(); ++i ) {
261 ret._elem[i]+=_elem[i];
262 }
263
264 return ret;
265}

◆ operator+=()

EvtSpinAmp & EvtSpinAmp::operator+= ( const EvtSpinAmp & cont)

Definition at line 267 of file EvtSpinAmp.cc.

269{
270 checktwospin( cont._twospin );
271
272 for( int i=0; i<_elem.size(); ++i )
273 _elem[i]+=cont._elem[i];
274
275 return *this;
276}

◆ operator-()

EvtSpinAmp EvtSpinAmp::operator- ( const EvtSpinAmp & cont) const

Definition at line 278 of file EvtSpinAmp.cc.

279{
280 checktwospin( cont._twospin );
281
282 EvtSpinAmp ret( *this );
283 for( int i=0; i<ret._elem.size(); ++i )
284 ret._elem[i]-=cont._elem[i];
285
286 return ret;
287}

◆ operator-=()

EvtSpinAmp & EvtSpinAmp::operator-= ( const EvtSpinAmp & cont)

Definition at line 289 of file EvtSpinAmp.cc.

290{
291 checktwospin( cont._twospin );
292
293 for( int i=0; i<_elem.size(); ++i )
294 _elem[i]-=cont._elem[i];
295
296 return *this;
297}

◆ operator/=()

EvtSpinAmp & EvtSpinAmp::operator/= ( const EvtComplex & real)

Definition at line 351 of file EvtSpinAmp.cc.

352{
353 for( int i=0; i<_elem.size(); ++i )
354 _elem[i] /= real;
355
356 return *this;
357}

◆ operator=()

EvtSpinAmp & EvtSpinAmp::operator= ( const EvtSpinAmp & cont)

Definition at line 246 of file EvtSpinAmp.cc.

247{
248 _twospin=cont._twospin;
249 _elem=cont._elem;
250 _type=cont._type;
251
252 return *this;
253}

◆ rank()

int EvtSpinAmp::rank ( ) const
inline

Definition at line 64 of file EvtSpinAmp.hh.

64{ return _twospin.size(); }

Referenced by EvtMultibody::decay(), extcont(), intcont(), and operator*().

◆ setelem()

void EvtSpinAmp::setelem ( const vector< EvtComplex > & elem)
inline

Definition at line 72 of file EvtSpinAmp.hh.

72{ _elem = elem; }

Friends And Related Symbol Documentation

◆ operator* [1/2]

EvtSpinAmp operator* ( const EvtComplex & real,
const EvtSpinAmp & cont )
friend

Definition at line 25 of file EvtSpinAmp.cc.

26{
27 EvtSpinAmp ret( cont );
28
29 for( int i=0; i<ret._elem.size(); ++i ) {
30 ret._elem[i] *= real;
31 }
32
33 return ret;
34}

◆ operator* [2/2]

EvtSpinAmp operator* ( const EvtSpinAmp & cont,
const EvtComplex & real )
friend

Definition at line 36 of file EvtSpinAmp.cc.

37{
38 return real*cont;
39}

◆ operator/

EvtSpinAmp operator/ ( const EvtSpinAmp & cont,
const EvtComplex & real )
friend

Definition at line 41 of file EvtSpinAmp.cc.

42{
43 EvtSpinAmp ret( cont );
44
45 for( int i=0; i<ret._elem.size(); ++i ) {
46 ret._elem[i] /= real;
47 }
48
49 return ret;
50}

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const EvtSpinAmp & amp )
friend

Definition at line 8 of file EvtSpinAmp.cc.

10{
11 vector<int> index = amp.iterinit();
12
13 os << ":";
14 do {
15 os<<"<";
16 for(int i=0; i<index.size()-1; ++i) {
17 os<<index[i];
18 }
19 os<<index[index.size()-1]<<">"<<amp(index)<<":";
20 } while( amp.iterate( index ) );
21
22 return os;
23}

The documentation for this class was generated from the following files: