61 fPartialPhantomParam(0),
118 std::ifstream finDF(dataFile.c_str());
120 if(finDF.good() != 1 ) {
121 G4Exception(
" DicomPartialDetectorConstruction::ReadPhantomData",
124 " Problem reading data file: Data.dat");
128 finDF >> compression;
132 if( numFiles != 1 ) {
133 G4Exception(
"DicomPartialDetectorConstruction::ReadPhantomData",
136 "More than 1 DICOM file is not supported");
138 for(
G4int i = 0; i < numFiles; i++ ) {
155 G4cout <<
" DicomDetectorConstruction::ReadPhantomDataFile opening file "
158 std::ifstream fin(fname.c_str(), std::ios_base::in);
159 if( !fin.is_open() ) {
160 G4Exception(
"DicomPartialDetectorConstruction::ReadPhantomDataFile",
163 G4String(
"File not found " + fname).c_str());
169 for(
G4int ii = 0; ii < nMaterials; ii++ ){
170 fin >> nmate >> stemp;
171 G4cout <<
"DicomPartialDetectorConstruction::ReadPhantomData reading nmate "
172 << ii <<
" = " << nmate <<
" mate " << stemp <<
G4endl;
174 G4Exception(
"DicomPartialDetectorConstruction::ReadPhantomData",
177 "Material number should be in increasing order: \
178 wrong material number ");
183 G4cout <<
"DicomPartialDetectorConstruction::ReadPhantomData nVoxel X/Y/Z "
190 fDimZ = (fDimZ -
fOffsetZ)/fNVoxelZ;
191 G4cout <<
"DicomPartialDetectorConstruction::ReadPhantomData voxelDimX "
193 G4cout <<
"DicomPartialDetectorConstruction::ReadPhantomData voxelDimY "
195 G4cout <<
"DicomPartialDetectorConstruction::ReadPhantomData voxelDimZ "
203 int ifxmin1, ifxmax1;
205 std::map< G4int, G4int > ifmin, ifmax;
207 fin >> ifxmin1 >> ifxmax1;
212 G4int ifxdiff = ifxmax1-ifxmin1+1;
213 if( ifxmax1 == -1 && ifxmin1 == -1 ) ifxdiff = 0;
215 G4cout <<
"DicomPartialDetectorConstruction::ReadPhantomData insert "
216 <<
" FilledIDs " << ifxdiff+
fNVoxels-1 <<
" min " << ifxmin1
220 if( ix >=
G4int(ifxmin1) && ix <=
G4int(ifxmax1) ) {
241 if( ix >=
G4int(ifxmin1) && ix <=
G4int(ifxmax1) ) {
243 if( mateID1 < 0 || mateID1 >= nMaterials ) {
244 G4Exception(
"DicomPartialDetectorConstruction::ReadPhantomData",
247 G4String(
"Wrong index in phantom file: It should be between 0 and "
267 std::map<G4int, std::pair<G4double,G4double> > densiMinMax;
268 std::map<G4int, std::pair<G4double,G4double> >::iterator mpite;
275 char* part = getenv(
"DICOM_CHANGE_MATERIAL_DENSITY" );
278 std::map<G4int,G4double> densityDiffs;
279 if( densityDiff != -1. ) {
281 densityDiffs[ii] = densityDiff;
295 std::map< std::pair<G4Material*,G4int>,
matInfo* > newMateDens;
298 size_t ifxmin1, ifxmax1;
309 if( ix >=
G4int(ifxmin1) && ix <=
G4int(ifxmax1) ) {
313 mpite = densiMinMax.find(
fMateIDs[copyNo] );
314 if( dens1 < (*mpite).second.first ) (*mpite).second.first = dens1;
315 if( dens1 > (*mpite).second.second ) (*mpite).second.second = dens1;
322 if( std::fabs(dens1 - mate->
GetDensity()/
g*
cm3 ) < 1.e-9 )
continue;
329 G4int densityBin = 0;
333 if( densityDiff != -1.) {
334 densityBin = (
G4int(dens1/densityDiffs[mateID]));
340 std::pair<G4Material*,G4int> matdens(mate, densityBin );
342 std::map< std::pair<G4Material*,G4int>,
matInfo* >::iterator mppite
343 = newMateDens.find( matdens );
344 if( mppite != newMateDens.end() ){
345 matInfo* mi = (*mppite).second;
355 mi->
id = newMateDens.size()+1;
356 newMateDens[matdens] = mi;
372 std::vector<G4Material*>::const_iterator mimite;
379 std::map< std::pair<G4Material*,G4int>,
matInfo* >::iterator mppite;
380 for( mppite= newMateDens.begin(); mppite != newMateDens.end(); mppite++ ){
381 G4double averdens = (*mppite).second->
sumdens/(*mppite).second->nvoxels;
383 G4cout <<
"GmReadPhantomGeometry::ReadVoxelDensities AVER DENS "
384 << averdens <<
" -> " << saverdens <<
" -> "
385 <<
G4int(1000*averdens) <<
" " <<
G4int(1000*averdens)/1000 <<
" "
388 G4cout <<
"GmReadPhantomGeometry::ReadVoxelDensities AVER DENS "
389 << averdens <<
" -> " << saverdens <<
" -> "
391 <<(*mppite).second->nvoxels <<
G4endl;
392 G4String mateName = ((*mppite).first).first->GetName() +
"_" +
395 (*mppite).first.first,
396 averdens, mateName ) );
408 G4String contname=
"PhantomContainer";
411 G4Tubs* container_tube =
new G4Tubs(contname,0., 200., 100., 0., 360*
deg);
438 G4bool bSkipEqualMaterials = 0;
439 G4int regStructureID = 2;
478 if( OptimAxis ==
"kUndefined" ) {
482 }
else if( OptimAxis ==
"kXAxis" ) {
490 G4Exception(
"GmReadPhantomGeometry::ConstructPhantom",
493 G4String(
"Wrong argument to parameter \
494 GmReadPhantomGeometry:Phantom:OptimAxis: \
495 Only allowed 'kUndefined' or 'kXAxis', it is: "+OptimAxis).c_str());
std::vector< G4Material * > fPhantomMaterials
std::map< G4int, std::map< G4int, G4int > > fFilledMins
CLHEP::Hep3Vector G4ThreeVector
CLHEP::HepRotation G4RotationMatrix
G4LogicalVolume * fWorld_logic
const G4String & GetName() const
G4double GetDensity() const
static G4String ConvertToString(G4bool boolVal)
void SetFilledIDs(std::multimap< G4int, G4int > fid)
void ConstructPhantomContainer()
G4PartialPhantomParameterisation * fPartialPhantomParam
std::multimap< G4int, G4int > fFilledIDs
G4LogicalVolume * fContainer_logic
void InitialisationOfMaterials()
~DicomPartialDetectorConstruction()
void ReadVoxelDensitiesPartial(std::ifstream &fin, std::map< G4int, std::map< G4int, G4int > > ifxmin, std::map< G4int, std::map< G4int, G4int > > ifxmax)
void ReadPhantomDataFile(const G4String &fname)
G4Material * BuildMaterialWithChangingDensity(const G4Material *origMate, float density, G4String newMateName)
G4GLOB_DLL std::ostream G4cout
void SetVoxelDimensions(G4double halfx, G4double halfy, G4double halfz)
Definition of the DicomPartialDetectorConstruction class.
void SetFilledMins(std::map< G4int, std::map< G4int, G4int > > fmins)
static G4double ConvertToDouble(const char *st)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual void SetRegularStructureId(G4int Code)
G4VPhysicalVolume * fContainer_phys
virtual G4VPhysicalVolume * Construct()
void SetSmartless(G4double s)
void BuildContainerWalls()
std::map< G4int, std::map< G4int, G4int > > fFilledMaxs
void SetNoVoxel(size_t nx, size_t ny, size_t nz)
virtual void ReadPhantomData()
Dicom detector construction.
void SetMaterialIndices(size_t *matInd)
DicomPartialDetectorConstruction()
void SetMaterials(std::vector< G4Material * > &mates)
std::vector< G4Material * > fMaterials
std::vector< G4Material * > fOriginalMaterials
void SetVisAttributes(const G4VisAttributes *pVA)
void SetSkipEqualMaterials(G4bool skip)
virtual void ConstructPhantom()