409 std::vector < G4double > rhoa ( n , 0.0 );
410 std::vector < G4double > rho3 ( n , 0.0 );
411 std::vector < G4double > rhos ( n , 0.0 );
412 std::vector < G4double > rhoc ( n , 0.0 );
414 for (
G4int i = 0 ; i < n ; ++i )
419 for (
G4int j = 0 ; j < n ; ++j )
424 rhoa[i] += rha[j][i];
425 rhoc[i] += rhe[j][i];
426 rhos[i] += rha[j][i] * jnuc * inuc
427 * ( 1 - 2 * std::abs ( jcharge - icharge ) );
434 return c0 * std::accumulate( rhoa.cbegin() , rhoa.cend() , 0.0 )
435 + c3 * std::accumulate( rho3.cbegin() , rho3.cend() , 0.0 )
436 + cs * std::accumulate( rhos.cbegin() , rhos.cend() , 0.0 )
437 + cl * std::accumulate( rhoc.cbegin() , rhoc.cend() , 0.0 );
551 std::vector < G4double > rhoa;
554 for (
G4int i = 0 ; i < n ; ++i )
560 for (
G4int j = 0 ; j < n ; ++j )
563 rhoa[i] += rha[i][j];
571 std::vector < G4bool > is_already_belong_some_cluster;
574 std::multimap < G4int , G4int > comb_map;
575 std::multimap < G4int , G4int > assign_map;
578 std::vector < G4int > mascl;
579 std::vector < G4int > num;
582 is_already_belong_some_cluster.resize ( n );
584 std::vector < G4int > is_assigned_to ( n , -1 );
585 std::multimap < G4int , G4int > clusters;
587 for (
G4int i = 0 ; i < n ; ++i )
591 is_already_belong_some_cluster[i] =
false;
596 G4int cluster_id = -1;
597 for (
G4int i = 0 ; i < n-1 ; ++i )
599 G4bool hasThisCompany =
false;
604 for (
G4int j = j1 ; j < n ; ++j )
606 std::vector < G4int > cluster_participants;
612 * ( rhoa[ i ] + rhoa[ j ] )
613 * ( rhoa[ i ] + rhoa[ j ] );
616 if ( rdist2 < rcc2 && pdist2 < pcc2 )
618 if ( is_assigned_to [ j ] == -1 )
620 if ( is_assigned_to [ i ] == -1 )
622 if ( clusters.size() != 0 )
624 id = clusters.rbegin()->first + 1;
630 clusters.insert ( std::multimap<G4int,G4int>::value_type (
id , i ) );
631 is_assigned_to [ i ] = id;
632 clusters.insert ( std::multimap<G4int,G4int>::value_type (
id , j ) );
633 is_assigned_to [ j ] = id;
637 clusters.insert ( std::multimap<G4int,G4int>::value_type ( is_assigned_to [ i ] , j ) );
638 is_assigned_to [ j ] = is_assigned_to [ i ];
644 if ( is_assigned_to [ i ] == -1 )
646 clusters.insert ( std::multimap<G4int,G4int>::value_type ( is_assigned_to [ j ] , i ) );
647 is_assigned_to [ i ] = is_assigned_to [ j ];
652 if ( is_assigned_to [ i ] != is_assigned_to [ j ] )
655 std::multimap< G4int , G4int > clusters_tmp;
656 G4int target_cluster_id;
657 if ( is_assigned_to [ i ] > is_assigned_to [ j ] )
659 target_cluster_id = is_assigned_to [ i ];
663 target_cluster_id = is_assigned_to [ j ];
665 for (
auto it = clusters.cbegin() ; it != clusters.cend() ; ++it )
667 if ( it->first == target_cluster_id )
669 is_assigned_to [ it->second ] = is_assigned_to [ j ];
670 clusters_tmp.insert(std::multimap<G4int,G4int>::value_type(is_assigned_to[j], it->second));
674 clusters_tmp.insert(std::multimap<G4int,G4int>::value_type(it->first, it->second));
677 clusters = clusters_tmp;
682 comb_map.insert( std::multimap<G4int,G4int>::value_type ( i , j ) );
683 cluster_participants.push_back ( j );
685 if ( assign_map.find( cluster_id ) == assign_map.end() )
687 is_already_belong_some_cluster[i] =
true;
688 assign_map.insert ( std::multimap<G4int,G4int>::value_type ( cluster_id , i ) );
689 hasThisCompany =
true;
691 assign_map.insert ( std::multimap<G4int,G4int>::value_type ( cluster_id , j ) );
692 is_already_belong_some_cluster[j] =
true;
702 if ( hasThisCompany ==
true ) { ++cluster_id; }
708 std::multimap< G4int , G4int > sorted_cluster_map;
709 for (
G4int i = 0 ; i <= id ; ++i )
711 sorted_cluster_map.insert ( std::multimap<G4int,G4int>::value_type ( (
G4int) clusters.count( i ) , i ) );
715 std::vector < G4QMDNucleus* > result;
716 for (
auto it = sorted_cluster_map.crbegin(); it != sorted_cluster_map.crend(); ++it )
718 if ( it->first != 0 )
721 for (
auto itt = clusters.cbegin(); itt != clusters.cend(); ++itt )
723 if ( it->second == itt->first )
728 result.push_back( nucleus );
733 for (
auto it = result.cbegin(); it != result.cend(); ++it )