286{
287
288
289
290 if ( actualMult.
Get() == NULL ) {
291 actualMult.
Get() =
new std::vector<G4int>( nDiscrete );
292 }
294 G4int nSecondaries = 0;
296
297 if (repFlag==1) {
299 for (i = 0; i < nDiscrete; i++) {
300 current = theYield[i].
GetY(anEnergy);
302 if (nDiscrete == 1 && current < 1.0001) {
303 actualMult.
Get()->at(i) =
static_cast<G4int>(current);
304 if(current<1)
305 {
306 actualMult.
Get()->at(i) = 0;
308 }
309 }
310 nSecondaries += actualMult.
Get()->at(i);
311 }
312
313 for (i = 0; i < nSecondaries; i++) {
316 thePhotons->push_back(theOne);
317 }
318
320
321 if (nDiscrete == 1 && nPartials == 1) {
322 if (actualMult.
Get()->at(0) > 0) {
323 if (disType[0] == 1) {
324
326 temp = partials[ 0 ]->
GetY(anEnergy);
328
329
330
331 std::vector< G4double > photons_e_best( actualMult.
Get()->at(0) , 0.0 );
334 for (
G4int j = 0; j < maxTry; j++) {
335 std::vector<G4double> photons_e(actualMult.
Get()->at(0), 0.0);
336 for (std::vector<G4double>::iterator it = photons_e.begin(); it < photons_e.end(); it++) {
338 }
339
340 if (std::accumulate(photons_e.begin(), photons_e.end(), 0.0) > maximumE) {
341 if (std::accumulate(photons_e.begin(), photons_e.end(), 0.0) < best)
342 photons_e_best = photons_e;
343 continue;
344
345 } else {
347 for (std::vector<G4double>::iterator it = photons_e.begin(); it < photons_e.end(); it++) {
348 thePhotons->operator[](iphot)->SetKineticEnergy(*it);
349
350
351 iphot++;
352 }
353
354
355
356
357
358 break;
359 }
360
361
362
363 }
364
365 delete temp;
366
367 } else {
368
369 thePhotons->operator[](count)->SetKineticEnergy(energy[i]);
370 }
371 count++;
372 if (count > nSecondaries)
throw G4HadronicException(__FILE__, __LINE__,
"G4ParticleHPPhotonDist::GetPhotons inconsistency");
373 }
374
375 } else {
376 for (i=0; i<nDiscrete; i++) {
377 for (ii=0; ii< actualMult.
Get()->at(i); ii++) {
378 if (disType[i] == 1) {
379
381 for (iii = 0; iii < nPartials; iii++) sum+=probs[iii].GetY(anEnergy);
384 for (iii = 0; iii < nPartials; iii++) {
385 run+=probs[iii].
GetY(anEnergy);
386 theP = iii;
387 if(random<run/sum) break;
388 }
389
390 if (theP == nPartials) theP=nPartials-1;
391 sum = 0;
393 temp = partials[theP]->
GetY(anEnergy);
395 thePhotons->operator[](count)->SetKineticEnergy(eGamm);
396 delete temp;
397
398 } else {
399
400 thePhotons->operator[](count)->SetKineticEnergy(energy[i]);
401 }
402 count++;
403 if (count > nSecondaries)
throw G4HadronicException(__FILE__, __LINE__,
"G4ParticleHPPhotonDist::GetPhotons inconsistency");
404 }
405 }
406 }
407
408
409 if (isoFlag == 1) {
410 for (i=0; i< nSecondaries; i++)
411 {
413 G4double theta = std::acos(costheta);
416 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
417 G4ThreeVector temp(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
418 thePhotons->operator[](i)->SetMomentum( temp ) ;
419
420 }
421 }
422 else
423 {
424 for(i=0; i<nSecondaries; i++)
425 {
426 G4double currentEnergy = thePhotons->operator[](i)->GetTotalEnergy();
427 for(ii=0; ii<nDiscrete2; ii++)
428 {
429 if (std::abs(currentEnergy-theGammas[ii])<0.1*keV) break;
430 }
431 if(ii==nDiscrete2) ii--;
432 if(ii<nIso)
433 {
434
435
436
437
439 G4double theta = std::acos(costheta);
442 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
443
444 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*costheta );
445 thePhotons->operator[](i)->SetMomentum( tempVector ) ;
446 }
447 else if(tabulationType==1)
448 {
449
451 for (iii=0; iii<nNeu[ii-nIso]; iii++)
452 {
453 it = iii;
454 if(theLegendre[ii-nIso][iii].GetEnergy()>anEnergy)
455 break;
456 }
458 aStore.SetCoeff(1, &(theLegendre[ii-nIso][it]));
459
460
461 if ( it > 0 )
462 {
463 aStore.SetCoeff(0, &(theLegendre[ii-nIso][it-1]));
464 }
465 else
466 {
467 aStore.SetCoeff(0, &(theLegendre[ii-nIso][it]));
468 }
469 G4double cosTh = aStore.SampleMax(anEnergy);
473 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
474 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
475 thePhotons->operator[](i)->SetMomentum( tempVector ) ;
476 }
477 else
478 {
479
481 for (iii=0; iii<nNeu[ii-nIso]; iii++)
482 {
483 it = iii;
484 if(theAngular[ii-nIso][iii].GetEnergy()>anEnergy)
485 break;
486 }
491 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
492 G4ThreeVector tmpVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*costh );
493 thePhotons->operator[](i)->SetMomentum( tmpVector ) ;
494 }
495 }
496 }
497
498 } else if (repFlag == 2) {
500 running[0]=theTransitionProbabilities[0];
501
502 for(i=1; i<nGammaEnergies; i++)
503 {
504 running[i]=running[i-1]+theTransitionProbabilities[i];
505 }
508 for(i=0; i<nGammaEnergies; i++)
509 {
510 it = i;
511 if(random < running[i]/running[nGammaEnergies-1]) break;
512 }
513 delete [] running;
514 G4double totalEnergy = theBaseEnergy - theLevelEnergies[it];
518 if(theInternalConversionFlag==2 && random>thePhotonTransitionFraction[it])
519 {
521
522
524 }
526 if( isoFlag == 1 )
527 {
529 G4double theta = std::acos(costheta);
532
533
535
536 G4ThreeVector temp(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
538 }
539 else
540 {
542 for(ii=0; ii<nDiscrete2; ii++)
543 {
544 if (std::abs(currentEnergy-theGammas[ii])<0.1*keV) break;
545 }
546 if(ii==nDiscrete2) ii--;
547 if(ii<nIso)
548 {
549
550
551
553
556
557
559
560 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
562 }
563 else if(tabulationType==1)
564 {
565
567 for (iii=0; iii<nNeu[ii-nIso]; iii++)
568 {
569 itt = iii;
570 if(theLegendre[ii-nIso][iii].GetEnergy()>anEnergy)
571 break;
572 }
574 aStore.SetCoeff(1, &(theLegendre[ii-nIso][itt]));
575
576
577 if ( itt > 0 )
578 {
579 aStore.SetCoeff(0, &(theLegendre[ii-nIso][itt-1]));
580 }
581 else
582 {
583 aStore.SetCoeff(0, &(theLegendre[ii-nIso][itt]));
584 }
585 G4double cosTh = aStore.SampleMax(anEnergy);
589
590
592
593 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
595 }
596 else
597 {
598
600 for (iii=0; iii<nNeu[ii-nIso]; iii++)
601 {
602 itt = iii;
603 if(theAngular[ii-nIso][iii].GetEnergy()>anEnergy)
604 break;
605 }
610
611
613
614 G4ThreeVector tmpVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*costh );
616 }
617 }
618 thePhotons->push_back(theOne);
619 }
620 else if( repFlag==0 )
621 {
622
623
624 if ( thePartialXsec == 0 )
625 {
626
627
628 return thePhotons;
629 }
630
631
632
635 thePhotons->push_back( theOne );
636
637
638
639
641 std::vector < G4double > dif( nDiscrete , 0.0 );
642 for (
G4int j = 0 ; j < nDiscrete ; j++ )
643 {
645 if ( x > 0 )
646 {
647 sum += x;
648 }
649 dif [ j ] = sum;
650
651 }
652
654
656 for (
G4int j = 0 ; j < nDiscrete ; j++ )
657 {
659 if ( dif [ j ] > y )
660 {
661 iphoton = j;
662 break;
663 }
664 }
665
666
667
668
669
670 if (theReactionXsec) {
671 if (thePartialXsec[iphoton].GetXsec(anEnergy)/theReactionXsec->
GetXsec(anEnergy) <
G4UniformRand() ) {
672 delete thePhotons;
673 thePhotons = 0;
674 return thePhotons;
675 }
676 }
677
678
680
681 if ( isoFlag == 1 )
682 {
683
684
685
687
688 }
689 else
690 {
691
692 if ( iphoton < nIso )
693 {
694
695
696
698
699 }
700 else
701 {
702
703
704
705
706
707
708
709
710 if ( tabulationType == 1 )
711 {
712
713
715 for (
G4int j = 0 ; j < nNeu [ iphoton - nIso ] ; j++ )
716 {
717 iangle = j;
718 if ( theLegendre[ iphoton - nIso ][ j ].GetEnergy() > anEnergy ) break;
719 }
720
722 aStore.SetCoeff( 1 , &( theLegendre[ iphoton - nIso ][ iangle ] ) );
723 aStore.SetCoeff( 0 , &( theLegendre[ iphoton - nIso ][ iangle - 1 ] ) );
724
725 cosTheta = aStore.SampleMax( anEnergy );
726
727 }
728 else if ( tabulationType == 2 )
729 {
730
731
732
734 for (
G4int j = 0 ; j < nNeu [ iphoton - nIso ] ; j++ )
735 {
736 iangle = j;
737 if ( theAngular[ iphoton - nIso ][ j ].GetEnergy() > anEnergy ) break;
738 }
739
740 cosTheta = theAngular[iphoton-nIso][ iangle ].
GetCosTh();
741
742 }
743 }
744 }
745
746
748 G4double theta = std::acos( cosTheta );
749 G4double sinTheta = std::sin( theta );
750
751 G4double photonE = theGammas[ iphoton ];
752 G4ThreeVector direction ( sinTheta*std::cos( phi ) , sinTheta * std::sin( phi ) , cosTheta );
754 thePhotons->operator[]( 0 )->SetMomentum( photonP ) ;
755
756 }
757 else
758 {
759 delete thePhotons;
760 thePhotons = 0;
761 }
762 return thePhotons;
763}
G4long G4Poisson(G4double mean)
std::vector< G4ReactionProduct * > G4ReactionProductVector
static G4Electron * Electron()
G4double GetPDGMass() const
G4double GetCosTh(G4int l)
G4double GetY(G4int i, G4int j)
G4double GetXsec(G4int i)
G4double GetY(G4double x)
G4double GetX(G4int i) const
G4int GetVectorLength() const
void SetMomentum(const G4double x, const G4double y, const G4double z)
void SetTotalEnergy(const G4double en)
G4double GetTotalMomentum() const
G4double GetTotalEnergy() const
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)