146 for (
G4int i = 0 ; i < j ; ++i )
155 G4double gammaij = ( p4i + p4j ).gamma();
163 rbrb = irelcr * rbrb;
164 G4double gamma2_ij = gammaij*gammaij;
166 rr2[i][j] = rij2 + gamma2_ij * rbrb*rbrb;
167 rr2[j][i] = rr2[i][j];
169 rbij[i][j] = gamma2_ij * rbrb;
170 rbij[j][i] = - rbij[i][j];
177 pp2[j][i] = pp2[i][j];
186 rh1 =
G4Exp( expa1 );
196 rha[i][j] = ibry*jbry*rh1;
197 rha[j][i] = rha[i][j];
209 if ( rrs*c0sw < 5.8 )
214 xerf = std::erf ( rrs*c0sw );
224 rhe[i][j] = icharge*jcharge * erfij;
225 rhe[j][i] = rhe[i][j];
226 rhc[i][j] = icharge*jcharge * ( - erfij + clw * rh1 ) / rrs2;
227 rhc[j][i] = rhc[i][j];
443 std::vector < G4double > rhoa ( n , 0.0 );
444 std::vector < G4double > rho3 ( n , 0.0 );
445 std::vector < G4double > rho3_tau ( n , 0.0 );
447 std::vector < G4double > fsij_rhoa ( n , 0.0 );
448 std::vector < G4double > rhos ( n , 0.0 );
449 std::vector < G4double > rhoc ( n , 0.0 );
451 for (
G4int i = 0 ; i < n ; ++i )
456 for (
G4int j = 0 ; j < n ; ++j )
460 G4double fsij = 3.0/(2*wl) - rr2[j][i]/(2*wl)/(2*wl);
462 rhoa[i] += rha[j][i];
463 fsij_rhoa[i] += fsij * rha[j][i];
464 rhoc[i] += rhe[j][i];
465 rhos[i] += rha[j][i] * jnuc * inuc
467 * ( 1. - 2. * std::abs( jcharge - icharge ) )
468 * (1. - kappas * fsij);
478 G4double potential = c0 * std::accumulate( rhoa.cbegin() , rhoa.cend() , 0.0 )
479 + c3 * std::accumulate( rho3.cbegin() , rho3.cend() , 0.0 )
480 + g0 * std::accumulate( fsij_rhoa.cbegin() , fsij_rhoa.cend() , 0.0 )
482 + gtau0 * std::accumulate( rho3_tau.cbegin() , rho3_tau.cend() , 0.0 )
483 + cs * std::accumulate( rhos.cbegin() , rhos.cend() , 0.0 )
484 + cl * std::accumulate( rhoc.cbegin() , rhoc.cend() , 0.0 );
624 std::vector < G4double > rhoa;
627 for (
G4int i = 0 ; i < n ; ++i )
633 for (
G4int j = 0 ; j < n ; ++j )
636 rhoa[i] += rha[i][j];
644 std::vector < G4bool > is_already_belong_some_cluster;
647 std::multimap < G4int , G4int > comb_map;
648 std::multimap < G4int , G4int > assign_map;
651 std::vector < G4int > mascl;
652 std::vector < G4int > num;
655 is_already_belong_some_cluster.resize ( n );
657 std::vector < G4int > is_assigned_to ( n , -1 );
658 std::multimap < G4int , G4int > clusters;
660 for (
G4int i = 0 ; i < n ; ++i )
664 is_already_belong_some_cluster[i] =
false;
669 G4int cluster_id = -1;
670 for (
G4int i = 0 ; i < n-1 ; ++i )
672 G4bool hasThisCompany =
false;
677 for (
G4int j = j1 ; j < n ; ++j )
679 std::vector < G4int > cluster_participants;
685 * ( rhoa[ i ] + rhoa[ j ] )
686 * ( rhoa[ i ] + rhoa[ j ] );
689 if ( rdist2 < rcc2 && pdist2 < pcc2 )
691 if ( is_assigned_to [ j ] == -1 )
693 if ( is_assigned_to [ i ] == -1 )
695 if ( clusters.size() != 0 )
697 id = clusters.rbegin()->first + 1;
703 clusters.insert ( std::multimap<G4int,G4int>::value_type (
id , i ) );
704 is_assigned_to [ i ] = id;
705 clusters.insert ( std::multimap<G4int,G4int>::value_type (
id , j ) );
706 is_assigned_to [ j ] = id;
710 clusters.insert ( std::multimap<G4int,G4int>::value_type ( is_assigned_to [ i ] , j ) );
711 is_assigned_to [ j ] = is_assigned_to [ i ];
717 if ( is_assigned_to [ i ] == -1 )
719 clusters.insert ( std::multimap<G4int,G4int>::value_type ( is_assigned_to [ j ] , i ) );
720 is_assigned_to [ i ] = is_assigned_to [ j ];
725 if ( is_assigned_to [ i ] != is_assigned_to [ j ] )
728 std::multimap< G4int , G4int > clusters_tmp;
729 G4int target_cluster_id;
730 if ( is_assigned_to [ i ] > is_assigned_to [ j ] )
732 target_cluster_id = is_assigned_to [ i ];
736 target_cluster_id = is_assigned_to [ j ];
738 for (
auto it = clusters.cbegin() ; it != clusters.cend() ; ++it )
740 if ( it->first == target_cluster_id )
742 is_assigned_to [ it->second ] = is_assigned_to [ j ];
743 clusters_tmp.insert ( std::multimap<G4int,G4int>::value_type ( is_assigned_to [ j ] , it->second ) );
747 clusters_tmp.insert ( std::multimap<G4int,G4int>::value_type ( it->first , it->second ) );
750 clusters = clusters_tmp;
755 comb_map.insert( std::multimap<G4int,G4int>::value_type ( i , j ) );
756 cluster_participants.push_back ( j );
758 if ( assign_map.find( cluster_id ) == assign_map.end() )
760 is_already_belong_some_cluster[i] =
true;
761 assign_map.insert ( std::multimap<G4int,G4int>::value_type ( cluster_id , i ) );
762 hasThisCompany =
true;
764 assign_map.insert ( std::multimap<G4int,G4int>::value_type ( cluster_id , j ) );
765 is_already_belong_some_cluster[j] =
true;
775 if ( hasThisCompany ==
true ) { ++cluster_id; }
781 std::multimap< G4int , G4int > sorted_cluster_map;
782 for (
G4int i = 0 ; i <= id ; ++i )
784 sorted_cluster_map.insert ( std::multimap<G4int,G4int>::value_type ( (
G4int) clusters.count( i ) , i ) );
788 std::vector < G4LightIonQMDNucleus* > result;
789 for (
auto it = sorted_cluster_map.crbegin(); it != sorted_cluster_map.crend(); ++it )
791 if ( it->first != 0 )
794 for (
auto itt = clusters.cbegin(); itt != clusters.cend(); ++itt )
796 if ( it->second == itt->first )
801 result.push_back( nucleus );
806 for (
auto it = result.cbegin(); it != result.cend(); ++it )