282{
283
284
285
287 G4int nSecondaries = 0;
289 if(repFlag==1)
290 {
292 for(i=0; i<nDiscrete; i++)
293 {
294 current = theYield[i].
GetY(anEnergy);
296 if(nDiscrete==1&¤t<1.0001)
297 {
298 actualMult[i] =
static_cast<G4int>(current);
299 if(current<1)
300 {
301 actualMult[i] = 0;
303 }
304 }
305 nSecondaries += actualMult[i];
306 }
307
308 for(i=0;i<nSecondaries;i++)
309 {
312 thePhotons->push_back(theOne);
313 }
315
316
317
318
319
320
321
322
323
324 if ( nDiscrete == 1 && nPartials == 1 )
325 {
326 if ( actualMult[ 0 ] > 0 )
327 {
328 if ( disType[0] == 1 )
329 {
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
365 temp = partials[ 0 ]->
GetY(anEnergy);
367
368
369
370 std::vector< G4double > photons_e_best( actualMult[ 0 ] , 0.0 );
373 for (
G4int j = 0 ; j < maxTry ; j++ )
374 {
375 std::vector< G4double > photons_e( actualMult[ 0 ] , 0.0 );
376 for ( std::vector< G4double >::iterator
377 it = photons_e.begin() ; it < photons_e.end() ; it++ )
378 {
380 }
381 if ( std::accumulate( photons_e.begin() , photons_e.end() , 0.0 ) > maximumE )
382 {
383 if ( std::accumulate( photons_e.begin() , photons_e.end() , 0.0 ) < best )
384 photons_e_best = photons_e;
385 continue;
386 }
387 else
388 {
389 for ( std::vector< G4double >::iterator
390 it = photons_e.begin() ; it < photons_e.end() ; it++ )
391 {
392 thePhotons->operator[](count)->SetKineticEnergy( *it );
393 }
394
395
396
397
398 break;
399 }
400 G4cout <<
"NeutronHPPhotonDist could not find fitted energy set for multiplicity of " << actualMult[0] <<
"." <<
G4endl;
401 G4cout <<
"NeutronHPPhotonDist will use the best set." <<
G4endl;
402 for ( std::vector< G4double >::iterator
403 it = photons_e_best.begin() ; it < photons_e_best.end() ; it++ )
404 {
405 thePhotons->operator[](count)->SetKineticEnergy( *it );
406 }
407
408
409
410 }
411
412 delete temp;
413 }
414 else
415 {
416 thePhotons->operator[](count)->SetKineticEnergy(energy[i]);
417 }
418 count++;
419 if(count > nSecondaries)
throw G4HadronicException(__FILE__, __LINE__,
"G4NeutronHPPhotonDist::GetPhotons inconsistancy");
420 }
421
422 }
423 else
424 {
425 for(i=0; i<nDiscrete; i++)
426 {
427 for(ii=0; ii< actualMult[i]; ii++)
428 {
429 if(disType[i]==1)
430 {
432 for(iii=0; iii<nPartials; iii++) sum+=probs[iii].GetY(anEnergy);
435 for(iii=0; iii<nPartials; iii++)
436 {
437 run+=probs[iii].
GetY(anEnergy);
438 theP = iii;
439 if(random<run/sum) break;
440 }
441 if(theP==nPartials) theP=nPartials-1;
442 sum=0;
444 temp = partials[theP]->
GetY(anEnergy);
446 thePhotons->operator[](count)->SetKineticEnergy(eGamm);
447 delete temp;
448 }
449 else
450 {
451 thePhotons->operator[](count)->SetKineticEnergy(energy[i]);
452 }
453 count++;
454 if(count > nSecondaries)
throw G4HadronicException(__FILE__, __LINE__,
"G4NeutronHPPhotonDist::GetPhotons inconsistancy");
455 }
456 }
457 }
458
459 if( isoFlag == 1)
460 {
461 for (i=0; i< nSecondaries; i++)
462 {
464 G4double theta = std::acos(costheta);
467 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
468 G4ThreeVector temp(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
469 thePhotons->operator[](i)->SetMomentum( temp ) ;
470
471 }
472 }
473 else
474 {
475 for(i=0; i<nSecondaries; i++)
476 {
477 G4double currentEnergy = thePhotons->operator[](i)->GetTotalEnergy();
478 for(ii=0; ii<nDiscrete2; ii++)
479 {
480 if (std::abs(currentEnergy-theGammas[ii])<0.1*keV) break;
481 }
482 if(ii==nDiscrete2) ii--;
483 if(ii<nIso)
484 {
485
489 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
490 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
491 thePhotons->operator[](i)->SetMomentum( tempVector ) ;
492 }
493 else if(tabulationType==1)
494 {
495
497 for (iii=0; iii<nNeu[ii-nIso]; iii++)
498 {
499 it = iii;
500 if(theLegendre[ii-nIso][iii].GetEnergy()>anEnergy)
501 break;
502 }
504 aStore.SetCoeff(1, &(theLegendre[ii-nIso][it]));
505
506
507 if ( it > 0 )
508 {
509 aStore.SetCoeff(0, &(theLegendre[ii-nIso][it-1]));
510 }
511 else
512 {
513 aStore.SetCoeff(0, &(theLegendre[ii-nIso][it]));
514 }
515 G4double cosTh = aStore.SampleMax(anEnergy);
519 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
520 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
521 thePhotons->operator[](i)->SetMomentum( tempVector ) ;
522 }
523 else
524 {
525
527 for (iii=0; iii<nNeu[ii-nIso]; iii++)
528 {
529 it = iii;
530 if(theAngular[ii-nIso][iii].GetEnergy()>anEnergy)
531 break;
532 }
537 G4double en = thePhotons->operator[](i)->GetTotalEnergy();
538 G4ThreeVector tmpVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*costh );
539 thePhotons->operator[](i)->SetMomentum( tmpVector ) ;
540 }
541 }
542 }
543 }
544 else if(repFlag == 2)
545 {
547 running[0]=theTransitionProbabilities[0];
548
549 for(i=1; i<nGammaEnergies; i++)
550 {
551 running[i]=running[i-1]+theTransitionProbabilities[i];
552 }
555 for(i=0; i<nGammaEnergies; i++)
556 {
557 it = i;
558 if(random < running[i]/running[nGammaEnergies-1]) break;
559 }
560 delete [] running;
561 G4double totalEnergy = theBaseEnergy - theLevelEnergies[it];
565 if(theInternalConversionFlag==2 && random>thePhotonTransitionFraction[it])
566 {
568
569
571 }
573 if( isoFlag == 1 )
574 {
576 G4double theta = std::acos(costheta);
579
580
582
583 G4ThreeVector temp(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
585 }
586 else
587 {
589 for(ii=0; ii<nDiscrete2; ii++)
590 {
591 if (std::abs(currentEnergy-theGammas[ii])<0.1*keV) break;
592 }
593 if(ii==nDiscrete2) ii--;
594 if(ii<nIso)
595 {
596
597
598
600
603
604
606
607 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
609 }
610 else if(tabulationType==1)
611 {
612
614 for (iii=0; iii<nNeu[ii-nIso]; iii++)
615 {
616 itt = iii;
617 if(theLegendre[ii-nIso][iii].GetEnergy()>anEnergy)
618 break;
619 }
621 aStore.SetCoeff(1, &(theLegendre[ii-nIso][itt]));
622
623
624 if ( itt > 0 )
625 {
626 aStore.SetCoeff(0, &(theLegendre[ii-nIso][itt-1]));
627 }
628 else
629 {
630 aStore.SetCoeff(0, &(theLegendre[ii-nIso][itt]));
631 }
632 G4double cosTh = aStore.SampleMax(anEnergy);
636
637
639
640 G4ThreeVector tempVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*std::cos(theta) );
642 }
643 else
644 {
645
647 for (iii=0; iii<nNeu[ii-nIso]; iii++)
648 {
649 itt = iii;
650 if(theAngular[ii-nIso][iii].GetEnergy()>anEnergy)
651 break;
652 }
657
658
660
661 G4ThreeVector tmpVector(en*sinth*std::cos(phi), en*sinth*std::sin(phi), en*costh );
663 }
664 }
665 thePhotons->push_back(theOne);
666 }
667 else if( repFlag==0 )
668 {
669
670
671 if ( thePartialXsec == 0 )
672 {
673
674
675 return thePhotons;
676 }
677
678
679
682 thePhotons->push_back( theOne );
683
684
685
686
688 std::vector < G4double > dif( nDiscrete , 0.0 );
689 for (
G4int j = 0 ; j < nDiscrete ; j++ )
690 {
692 if ( x > 0 )
693 {
694 sum += x;
695 }
696 dif [ j ] = sum;
697
698 }
699
701
703 for (
G4int j = 0 ; j < nDiscrete ; j++ )
704 {
706 if ( dif [ j ] > y )
707 {
708 iphoton = j;
709 break;
710 }
711 }
712
713
714
715
717
718 if ( isoFlag == 1 )
719 {
720
721
722
724
725 }
726 else
727 {
728
729 if ( iphoton < nIso )
730 {
731
732
733
735
736 }
737 else
738 {
739
740
741
742
743
744
745
746
747 if ( tabulationType == 1 )
748 {
749
750
752 for (
G4int j = 0 ; j < nNeu [ iphoton - nIso ] ; j++ )
753 {
754 iangle = j;
755 if ( theLegendre[ iphoton - nIso ][ j ].GetEnergy() > anEnergy ) break;
756 }
757
759 aStore.SetCoeff( 1 , &( theLegendre[ iphoton - nIso ][ iangle ] ) );
760 aStore.SetCoeff( 0 , &( theLegendre[ iphoton - nIso ][ iangle - 1 ] ) );
761
762 cosTheta = aStore.SampleMax( anEnergy );
763
764 }
765 else if ( tabulationType == 2 )
766 {
767
768
769
771 for (
G4int j = 0 ; j < nNeu [ iphoton - nIso ] ; j++ )
772 {
773 iangle = j;
774 if ( theAngular[ iphoton - nIso ][ j ].GetEnergy() > anEnergy ) break;
775 }
776
777 cosTheta = theAngular[iphoton-nIso][ iangle ].
GetCosTh();
778
779 }
780 }
781 }
782
783
785 G4double theta = std::acos( cosTheta );
786 G4double sinTheta = std::sin( theta );
787
788 G4double photonE = theGammas[ iphoton ];
789 G4ThreeVector direction ( sinTheta*std::cos( phi ) , sinTheta * std::sin( phi ) , cosTheta );
791 thePhotons->operator[]( 0 )->SetMomentum( photonP ) ;
792
793 }
794 else
795 {
796 delete thePhotons;
797 thePhotons = 0;
798 }
799 return thePhotons;
800}
G4long G4Poisson(G4double mean)
std::vector< G4ReactionProduct * > G4ReactionProductVector
G4DLLIMPORT std::ostream G4cout
static G4Electron * Electron()
G4double GetCosTh(G4int l)
G4double GetY(G4int i, G4int j)
G4int GetVectorLength() const
G4double GetX(G4int i) const
G4double GetXsec(G4int i)
G4double GetY(G4double x)
G4double GetPDGMass() 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(G4ParticleDefinition *aParticleDefinition)