Ignore:
Timestamp:
Jun 14, 2010, 3:54:58 PM (14 years ago)
Author:
garnier
Message:

geant4.9.4 beta rc0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/advanced/hadrontherapy/include/HadrontherapyDetectorConstruction.hh

    r1230 r1313  
    5656  void ConstructPhantom();
    5757  void ConstructDetector();
    58   void ConstructSensitiveDetector(G4ThreeVector position_respect_to_WORLD);
    59  
     58  void ConstructSensitiveDetector(G4ThreeVector positionToWORLD);
     59  void ParametersCheck();
     60
    6061public:
    6162// Get detector position relative to WORLD
     
    6566  }
    6667/////////////////////////////////////////////////////////////////////////////
    67 // Get displacement between phantom and detector by detector position, phantom and detector sizes
     68// Get displacement between phantom and detector by detector position (center of), phantom (center of) and detector sizes
    6869inline G4ThreeVector GetDetectorToPhantomPosition()
    6970{
    70     return G4ThreeVector(phantomSizeX - detectorSizeX + detectorPosition.getX(),
    71                          phantomSizeY - detectorSizeY + detectorPosition.getY(),
    72                          phantomSizeZ - detectorSizeZ + detectorPosition.getZ()
     71    return G4ThreeVector(phantomSizeX/2 - detectorSizeX/2 + detectorPosition.getX(),
     72                         phantomSizeY/2 - detectorSizeY/2 + detectorPosition.getY(),
     73                         phantomSizeZ/2 - detectorSizeZ/2 + detectorPosition.getZ()
    7374                          );
    7475}
     
    7980  {
    8081          // Adjust detector position
    81           detectorPosition.setX(detectorToPhantomPosition.getX() - phantomSizeX + detectorSizeX);
    82           detectorPosition.setY(detectorToPhantomPosition.getY() - phantomSizeY + detectorSizeY);
    83           detectorPosition.setZ(detectorToPhantomPosition.getZ() - phantomSizeZ + detectorSizeZ);
     82          detectorPosition.setX(detectorToPhantomPosition.getX() - phantomSizeX/2 + detectorSizeX/2);
     83          detectorPosition.setY(detectorToPhantomPosition.getY() - phantomSizeY/2 + detectorSizeY/2);
     84          detectorPosition.setZ(detectorToPhantomPosition.getZ() - phantomSizeZ/2 + detectorSizeZ/2);
    8485     
    85       if (detectorPhysicalVolume) detectorPhysicalVolume -> SetTranslation(detectorPosition);
     86    //G4cout << "*************** DetectorToPhantomPosition " << detectorToPhantomPosition/cm << "\n";
     87    //G4cout << "*************** DetectorPosition " << detectorPosition/cm << "\n";
    8688  }
    8789/////////////////////////////////////////////////////////////////////////////
    8890// Check whether detector is inside phantom
    89 inline bool IsInside(G4double detectorHalfX,
    90                      G4double detectorHalfY,
    91                      G4double detectorHalfZ,
    92                      G4double phantomHalfX,
    93                      G4double phantomHalfY,
    94                      G4double phantomHalfZ,
     91inline bool IsInside(G4double detectorX,
     92                     G4double detectorY,
     93                     G4double detectorZ,
     94                     G4double phantomX,
     95                     G4double phantomY,
     96                     G4double phantomZ,
    9597                     G4ThreeVector detectorToPhantomPosition)
    9698{
    9799// Dimensions check... X Y and Z
    98100// Firstly check what dimension we are modifying
    99         if (detectorHalfX > 0. && phantomHalfX > 0. && detectorToPhantomPosition.getX() >=0.)
    100101        {
    101             if (detectorHalfX > phantomHalfX)
     102            if (detectorX > phantomX)
    102103                 {
    103104                    G4cout << "Error: Detector X dimension must be smaller or equal to the corrispondent of the phantom" << G4endl;
    104105                    return false;
    105106                 }
    106             if ( 2*(phantomHalfX - detectorHalfX) < detectorToPhantomPosition.getX())
     107            if ( (phantomX - detectorX) < detectorToPhantomPosition.getX())
    107108                 {
    108109                    G4cout << "Error: X dimension doesn't fit with detector to phantom relative position" << G4endl;
     
    111112        }
    112113
    113         if (detectorHalfY > 0. && phantomHalfY > 0.&& detectorToPhantomPosition.getY() >=0.)
    114114        {
    115             if (detectorHalfY > phantomHalfY)
     115            if (detectorY > phantomY)
    116116                 {
    117117                    G4cout << "Error: Detector Y dimension must be smaller or equal to the corrispondent of the phantom" << G4endl;
    118118                    return false;
    119119                 }
    120             if ( 2*(phantomHalfY - detectorHalfY) < detectorToPhantomPosition.getY())
     120            if ( (phantomY - detectorY) < detectorToPhantomPosition.getY())
    121121             {
    122122                   G4cout << "Error: Y dimension doesn't fit with detector to phantom relative position" << G4endl;
     
    125125        }                       
    126126
    127         if (detectorHalfZ > 0. && phantomHalfZ > 0.&& detectorToPhantomPosition.getZ() >=0.)
    128127        {
    129             if (detectorHalfZ > phantomHalfZ)
     128            if (detectorZ > phantomZ)
    130129                 {
    131130                    G4cout << "Error: Detector Z dimension must be smaller or equal to the corrispondent of the phantom" << G4endl;
    132131                    return false;
    133132                 }
    134             if ( 2*(phantomHalfZ - detectorHalfZ) < detectorToPhantomPosition.getZ())
     133            if ( (phantomZ - detectorZ) < detectorToPhantomPosition.getZ())
    135134             {
    136135                   G4cout << "Error: Z dimension doesn't fit with detector to phantom relative position" << G4endl;
     
    138137             }
    139138        }
    140 /*
    141     G4cout << "Displacement between Phantom and Detector is: ";
    142     G4cout << "DX= "<< G4BestUnit(detectorToPhantomPosition.getX(),"Length") <<
    143               "DY= "<< G4BestUnit(detectorToPhantomPosition.getY(),"Length") <<
    144               "DZ= "<< G4BestUnit(detectorToPhantomPosition.getZ(),"Length") << G4endl;
    145 */
     139
    146140        return true;
    147141}
    148142/////////////////////////////////////////////////////////////////////////////
    149143
    150   G4bool SetNumberOfVoxelBySize(G4double sizeX, G4double sizeY, G4double sizeZ);
    151   G4bool SetDetectorSize(G4double sizeX, G4double sizeY, G4double sizeZ);
    152   G4bool SetPhantomSize(G4double sizeX, G4double sizeY, G4double sizeZ);
    153   G4bool SetPhantomPosition(G4ThreeVector);
    154   G4bool SetDetectorToPhantomPosition(G4ThreeVector DetectorToPhantomPosition);
     144  G4bool  SetPhantomMaterial(G4String material);
     145  void SetVoxelSize(G4double sizeX, G4double sizeY, G4double sizeZ);
     146  void SetDetectorSize(G4double sizeX, G4double sizeY, G4double sizeZ);
     147  void SetPhantomSize(G4double sizeX, G4double sizeY, G4double sizeZ);
     148  void SetPhantomPosition(G4ThreeVector);
     149  void SetDetectorToPhantomPosition(G4ThreeVector DetectorToPhantomPosition);
     150  void UpdateGeometry();
     151  void PrintParameters();
    155152  G4LogicalVolume* GetDetectorLogicalVolume(){ return detectorLogicalVolume;}
    156153
     
    169166  HadrontherapyMatrix*             matrix;
    170167
    171   G4VPhysicalVolume* phantomPhysicalVolume;
    172   G4LogicalVolume*   phantomLogicalVolume;
    173   G4LogicalVolume*   detectorLogicalVolume;
    174   G4VPhysicalVolume* detectorPhysicalVolume;
     168  G4Box *phantom , *detector;
     169  G4LogicalVolume *phantomLogicalVolume, *detectorLogicalVolume;
     170  G4VPhysicalVolume *phantomPhysicalVolume, *detectorPhysicalVolume;
    175171 
    176172  G4double phantomSizeX;
     
    192188  G4int numberOfVoxelsAlongZ; 
    193189
    194   G4Box* phantom;
    195   G4Box* detector;
     190  G4double volumeOfVoxel, massOfVoxel;
    196191
     192  G4Material *phantomMaterial, *detectorMaterial;
     193  G4Region* aRegion;
    197194};
    198195#endif
Note: See TracChangeset for help on using the changeset viewer.