Geant4 Cross Reference |
1 /* 1 2 # <<BEGIN-copyright>> 3 # <<END-copyright>> 4 */ 5 6 #include <iostream> 7 #include <stdlib.h> 8 9 #include "GIDI_settings.hh" 10 11 /* 12 ============================================== 13 */ 14 GIDI_settings_group::GIDI_settings_group( std: 15 16 initialize( label, size1, size1, NULL ); 17 } 18 /* 19 ============================================== 20 */ 21 GIDI_settings_group::GIDI_settings_group( std: 22 23 initialize( label, length, length, boundar 24 } 25 /* 26 ============================================== 27 */ 28 GIDI_settings_group::GIDI_settings_group( std: 29 30 int size1 = (int) boundaries.size( ); 31 32 initialize( label, size1, size1, &(boundar 33 } 34 /* 35 ============================================== 36 */ 37 GIDI_settings_group::GIDI_settings_group( GIDI 38 39 initialize( group.mLabel, group.size( ), g 40 } 41 /* 42 ============================================== 43 */ 44 void GIDI_settings_group::initialize( std::str 45 46 int i1; 47 48 mLabel = label; 49 if( size1 < length ) size1 = length; 50 if( size1 < 0 ) size1 = 0; 51 mBoundaries.resize( size1, 0 ); 52 for( i1 = 0; i1 < length; ++i1 ) mBoundari 53 } 54 /* 55 ============================================== 56 */ 57 GIDI_settings_group& GIDI_settings_group::oper 58 if ( this != &group ) { 59 initialize( group.mLabel, group.size(), gr 60 } 61 return *this; 62 } 63 /* 64 ============================================== 65 */ 66 GIDI_settings_group::~GIDI_settings_group( ) { 67 68 } 69 /* 70 ============================================== 71 */ 72 int GIDI_settings_group::getGroupIndexFromEner 73 74 int iMin = 0, iMid, iMax = (int) mBoundari 75 76 if( iMax == 0 ) return( -3 ); 77 if( energy < mBoundaries[0] ) { 78 if( encloseOutOfRange ) return( 0 ); 79 return( -2 ); 80 } 81 if( energy > mBoundaries[iMaxM1] ) { 82 if( encloseOutOfRange ) return( iMax - 83 return( -1 ); 84 } 85 while( 1 ) { // Loop checking, 11.06.2015, 86 iMid = ( iMin + iMax ) >> 1; 87 if( iMid == iMin ) break; 88 if( energy < mBoundaries[iMid] ) { 89 iMax = iMid; } 90 else { 91 iMin = iMid; 92 } 93 } 94 if( iMin == iMaxM1 ) iMin--; 95 return( iMin ); 96 } 97 /* 98 ============================================== 99 */ 100 void GIDI_settings_group::print( bool outline, 101 102 int nbs = size( ); 103 char buffer[128]; 104 105 std::cout << "GROUP: label = '" << mLabel 106 if( outline ) return; 107 for( int ib = 0; ib < nbs; ib++ ) { 108 snprintf( buffer, sizeof buffer, "%16. 109 std::cout << buffer; 110 if( ( ( ib + 1 ) % valuesPerLine ) == 111 } 112 if( nbs % valuesPerLine ) std::cout << std 113 } 114 115 #if 0 116 /* ---- GIDI_settings_groups_from_bdfls ---- 117 /* 118 ============================================== 119 */ 120 GIDI_settings_groups_from_bdfls::GIDI_settings 121 122 initialize( fileName.c_str( ) ); 123 } 124 /* 125 ============================================== 126 */ 127 GIDI_settings_groups_from_bdfls::GIDI_settings 128 129 initialize( fileName ); 130 } 131 /* 132 ============================================== 133 */ 134 GIDI_settings_groups_from_bdfls::GIDI_settings 135 136 initialize2( bdfls ); 137 } 138 /* 139 ============================================== 140 */ 141 void GIDI_settings_groups_from_bdfls::initiali 142 143 cbdfls_file *bdfls; 144 cbdflsErrors Error; 145 146 if( ( bdfls = cbdflsOpen( fileName, &Error 147 initialize2( bdfls ); 148 cbdflsRelease( bdfls ); 149 } 150 /* 151 ============================================== 152 */ 153 void GIDI_settings_groups_from_bdfls::initiali 154 155 int ng, ngbs, *gids; 156 double *boundaries; 157 std::string label( "" ); 158 char cLabel[100]; 159 160 ng = cbdflsGIDs( (cbdfls_file *) bdfls, &g 161 for( int ig = 0; ig < ng; ++ig ) { 162 ngbs = cbdflsGetGroup( (cbdfls_file *) 163 snprintf( cLabel, sizeof xLabel, "LLNL 164 label = cLabel; 165 mGroups.push_back( GIDI_settings_group 166 } 167 } 168 /* 169 ============================================== 170 */ 171 GIDI_settings_groups_from_bdfls::~GIDI_setting 172 173 } 174 /* 175 ============================================== 176 */ 177 GIDI_settings_group GIDI_settings_groups_from_ 178 179 std::string label( "" ); 180 char cLabel[100]; 181 182 snprintf( cLabel, sizeof cLabel, "LLNL_gid 183 label = cLabel; 184 for( int ig = 0; ig < (int) mGroups.size( 185 if( mGroups[ig].isLabel( label ) ) ret 186 } 187 throw 1; 188 } 189 /* 190 ============================================== 191 */ 192 std::vector<std::string> GIDI_settings_groups_ 193 194 int size = (int) mGroups.size( ); 195 std::vector<std::string> labels( size ); 196 197 for( int if1 = 0; if1 < size; ++if1 ) labe 198 return( labels ); 199 } 200 /* 201 ============================================== 202 */ 203 std::vector<int> GIDI_settings_groups_from_bdf 204 205 int size = (int) mGroups.size( ); 206 std::vector<int> fids( size ); 207 char *e; 208 209 for( int if1 = 0; if1 < size; ++if1 ) { 210 fids[if1] = (int) strtol( &(mGroups[if 211 } 212 return( fids ); 213 } 214 /* 215 ============================================== 216 */ 217 void GIDI_settings_groups_from_bdfls::print( b 218 219 int ngs = (int) mGroups.size( ); 220 221 std::cout << "BDFLS GROUPs: number of grou 222 for( int if1 = 0; if1 < ngs ; ++if1 ) mGro 223 } 224 #endif 225