264{
265 std::map<G4int, std::pair<G4double,G4double> > densiMinMax;
266 std::map<G4int, std::pair<G4double,G4double> >::iterator mpite;
268 {
269 densiMinMax[ii] = std::pair<G4double,G4double>(DBL_MAX,-DBL_MAX);
270 }
271
272
273
274 char* part = std::getenv( "DICOM_CHANGE_MATERIAL_DENSITY" );
275 G4double densityDiff = -1.;
276 if( part ) densityDiff = G4UIcommand::ConvertToDouble(part);
277 std::map<G4int,G4double> densityDiffs;
278 if( densityDiff != -1. )
279 {
281 {
282 densityDiffs[ii] = densityDiff;
283
284 }
285 }
286 else
287 {
290 {
292 }
293 }
294 }
295
296
297
298 std::map< std::pair<G4Material*,G4int>,
matInfo* > newMateDens;
299
300 G4double dens1;
301 G4int ifxmin1, ifxmax1;
302
303
304 G4int copyNo = 0;
306 {
310 {
311 ifxmin1 = ifmin[iy];
312 ifxmax1 = ifmax[iy];
314 {
315 if( ix >= G4int(ifxmin1) && ix <= G4int(ifxmax1) ) {
316 fin >> dens1;
317
318
319 mpite = densiMinMax.find( G4int(
fMateIDs[copyNo]) );
320 if( dens1 < (*mpite).second.first ) (*mpite).second.first = dens1;
321 if( dens1 > (*mpite).second.second ) (*mpite).second.second = dens1;
322
323
324 G4int mateID = G4int(
fMateIDs[copyNo]);
326
327
328 if( std::fabs(dens1 - mate->GetDensity()/g*cm3 ) < 1.e-9 ) continue;
329
330
331
332
333 G4String newMateName = mate->GetName();
334
335 G4int densityBin = 0;
336
337
338
339 if( densityDiff != -1.) {
340 densityBin = (G4int(dens1/densityDiffs[mateID]));
341 newMateName =
342 mate->GetName()+G4UIcommand::ConvertToString(densityBin);
343 }
344
345
346 std::pair<G4Material*,G4int> matdens(mate, densityBin );
347
348 auto mppite = newMateDens.find( matdens );
349 if( mppite != newMateDens.cend() ){
350 matInfo* mi = (*mppite).second;
354
355
356 } else {
360 mi->
fId = G4int(newMateDens.size()+1);
361 newMateDens[matdens] = mi;
363
364
365 }
366 copyNo++;
367
368
369
370 }
371 }
372 }
373 }
374
375
376
379 {
381 }
382
383
384 for( auto mppite= newMateDens.cbegin();
385 mppite != newMateDens.cend(); ++mppite )
386 {
387 G4double averdens = (*mppite).second->fSumdens/(*mppite).second->fNvoxels;
388 G4double saverdens = G4int(1000.001*averdens)/1000.;
389 G4cout << "GmReadPhantomGeometry::ReadVoxelDensities AVER DENS "
390 << averdens << " -> " << saverdens << " -> "
391 << G4int(1000*averdens) << " " << G4int(1000*averdens)/1000 << " "
392 << G4int(1000*averdens)/1000. << G4endl;
393
394 G4cout << "GmReadPhantomGeometry::ReadVoxelDensities AVER DENS "
395 << averdens << " -> " << saverdens << " -> "
396 << G4UIcommand::ConvertToString(saverdens) << " Nvoxels "
397 <<(*mppite).second->fNvoxels << G4endl;
398 G4String mateName = ((*mppite).first).first->GetName() +
"_" +
399 G4UIcommand::ConvertToString(saverdens);
401 (*mppite).first.first,
402 G4float(averdens), mateName ) );
403 }
404}
std::vector< G4Material * > fMaterials
G4Material * BuildMaterialWithChangingDensity(const G4Material *origMate, G4float density, G4String newMateName)
std::vector< G4Material * > fOriginalMaterials
Dicom detector construction.