Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:29:55

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 //
0028 // Author: Elena Guardincerri (Elena.Guardincerri@ge.infn.it)
0029 //
0030 // History:
0031 // -----------
0032 //  28 Nov 2001  Elena Guardincerri   Created
0033 //     Nov 2002  Alfonso Mantero materials added, Material selection implementation
0034 //  16 Jul 2003  Alfonso Mantero Detector type selection added + minor fixes
0035 //  21 Aug 2003  Alfonso Mantero Material Management moved to XrayFluoMaterials 
0036 //
0037 // -------------------------------------------------------------------
0038 
0039 #ifndef XrayFluoDetectorConstruction_hh
0040 #define XrayFluoDetectorConstruction_hh 1
0041 
0042 #include "globals.hh"
0043 #include "G4RotationMatrix.hh"
0044 #include "G4VUserDetectorConstruction.hh"
0045 #include "G4Navigator.hh"
0046 #include "G4Cache.hh"
0047 
0048 #include "XrayFluoSiLiDetectorType.hh"
0049 #include "XrayFluoHPGeDetectorType.hh"
0050 #include "XrayFluoSD.hh"
0051 #include "XrayFluoGeometry.hh"
0052 
0053 class G4Box;
0054 class G4Tubs;
0055 class G4Sphere;
0056 class G4LogicalVolume;
0057 class G4VPhysicalVolume;
0058 class G4Material;
0059 class XrayFluoDetectorMessenger;
0060 class XrayFluoNistMaterials;
0061 
0062 //class XrayFluoSD;
0063 //class XrayFluoVDetectorType;
0064 
0065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0066 
0067 class XrayFluoDetectorConstruction : public G4VUserDetectorConstruction
0068 {
0069 public:
0070   
0071 
0072   ~XrayFluoDetectorConstruction();
0073   
0074 public:
0075   
0076   G4VPhysicalVolume* Construct();
0077   
0078   void ConstructSDandField();
0079 
0080   void UpdateGeometry();
0081 
0082   void SetOhmicPosThickness(G4double);
0083 
0084   void SetSampleMaterial(G4String newMaterial);
0085 
0086   void SetDetectorType(G4String type);
0087 
0088   static XrayFluoDetectorConstruction* GetInstance();
0089 
0090   inline void SetSampleGranularity(G4bool granularity) 
0091   {sampleGranularity = granularity;};
0092 
0093   inline void PhaseSpaceOn() 
0094   {phaseSpaceFlag = true;};
0095 
0096   inline void PhaseSpaceOff() 
0097   {phaseSpaceFlag = false;};
0098   
0099   inline G4bool GetPhaseSpaceFlag() const 
0100   {return phaseSpaceFlag;};
0101 
0102   inline void SetGrainDia(G4double size)
0103   {grainDia = size;};
0104 
0105   void DeleteGrainObjects();
0106   
0107 public:
0108   
0109   void PrintApparateParameters(); 
0110 
0111   XrayFluoVDetectorType* GetDetectorType() const;
0112 
0113 
0114   G4double GetWorldSizeZ()  const         {return WorldSizeZ;}; 
0115   G4double GetWorldSizeXY() const     {return WorldSizeXY;};
0116   
0117   G4double GetDeviceThickness() const     {return DeviceThickness;}; 
0118   G4double GetDeviceSizeX() const          {return DeviceSizeX;};
0119   G4double GetDeviceSizeY() const         {return DeviceSizeY;};
0120   G4double GetPixelSizeXY() const         {return PixelSizeXY;};
0121   G4double GetContactSizeXY() const       {return ContactSizeXY;};
0122   
0123   G4int GetNbOfPixels() const             {return NbOfPixels;}; 
0124   G4int GetNbOfPixelRows() const        {return NbOfPixelRows;}; 
0125   G4int GetNbOfPixelColumns() const       {return NbOfPixelColumns;}; 
0126   
0127   G4Material* GetOhmicPosMaterial() const  {return OhmicPosMaterial;};
0128   G4double    GetOhmicPosThickness() const {return OhmicPosThickness;};      
0129   
0130   G4Material* GetOhmicNegMaterial() const  {return OhmicNegMaterial;};
0131   G4double    GetOhmicNegThickness() const {return OhmicNegThickness;};      
0132   
0133   G4ThreeVector GetDetectorPosition() const;
0134   G4ThreeVector GetSamplePosition() const {return G4ThreeVector(0,0,0);};
0135 
0136   const G4VPhysicalVolume* GetphysiWorld() const {return physiWorld;};  
0137   const G4VPhysicalVolume* GetHPGe() const       {return physiHPGe;};
0138   const G4VPhysicalVolume* GetSample() const    {return physiSample;};
0139   const G4VPhysicalVolume* GetDia1() const       {return physiDia1;};
0140   const G4VPhysicalVolume* GetDia3() const       {return physiDia3;};
0141   
0142   const G4VPhysicalVolume* GetphysiPixel() const {return physiPixel;};           
0143   const G4VPhysicalVolume* GetOhmicPos() const   {return physiOhmicPos;};
0144   const G4VPhysicalVolume* GetOhmicNeg() const   {return physiOhmicNeg;};
0145   const G4VPhysicalVolume* GetWindow  () const   {return physiWindow  ;};
0146 private:
0147 
0148   G4Navigator* aNavigator;  
0149 
0150   XrayFluoDetectorConstruction();
0151 
0152   static XrayFluoDetectorConstruction* instance;
0153 
0154   XrayFluoVDetectorType* detectorType;
0155 
0156   G4bool sampleGranularity;
0157   G4bool phaseSpaceFlag;
0158 
0159   G4double           DeviceSizeX;
0160   G4double           DeviceSizeY;
0161   G4double           DeviceThickness;
0162   
0163   G4Box*             solidWorld;    //pointer to the solid World 
0164   G4LogicalVolume*   logicWorld;    //pointer to the logical World
0165   G4VPhysicalVolume* physiWorld;    //pointer to the physical World
0166   
0167   G4Box*             solidHPGe; //pointer to the solid Sensor
0168   G4LogicalVolume*   logicHPGe; //pointer to the logical Sensor
0169   G4VPhysicalVolume* physiHPGe; //pointer to the physical Sensor
0170   
0171   G4Box*             solidSample;    //pointer to the solid Sample
0172   G4LogicalVolume*   logicSample;    //pointer to the logical Sample
0173   G4VPhysicalVolume* physiSample;    //pointer to the physical Sample
0174   
0175   G4Tubs*             solidDia1; //pointer to the solid  Diaphragm
0176   G4LogicalVolume*   logicDia1; //pointer to the logical  Diaphragm
0177   G4VPhysicalVolume* physiDia1; //pointer to the physical Diaphragm 
0178   
0179   G4Tubs*             solidDia3; //pointer to the solid  Diaphragm
0180   G4LogicalVolume*   logicDia3; //pointer to the logical  Diaphragm
0181   G4VPhysicalVolume* physiDia3; //pointer to the physical Diaphragm  
0182   
0183   G4Box*             solidOhmicPos;
0184   G4LogicalVolume*   logicOhmicPos; 
0185   G4VPhysicalVolume* physiOhmicPos; 
0186 
0187   G4Box*             solidWindow; // added
0188   G4LogicalVolume*   logicWindow; // added
0189   G4VPhysicalVolume* physiWindow; // added
0190   
0191   G4Box*             solidOhmicNeg;
0192   G4LogicalVolume*   logicOhmicNeg; 
0193   G4VPhysicalVolume* physiOhmicNeg;     
0194   
0195   G4Box*             solidPixel;   
0196   G4LogicalVolume*   logicPixel;  
0197   G4VPhysicalVolume* physiPixel;    
0198  
0199   G4Sphere*          solidGrain;
0200   G4LogicalVolume*   logicGrain;
0201   G4VPhysicalVolume* physiGrain;
0202 
0203 
0204   //materials management
0205   XrayFluoNistMaterials* materials;
0206 
0207   G4Material*        OhmicPosMaterial;
0208   G4Material*        OhmicNegMaterial; 
0209   G4Material*        pixelMaterial;
0210   G4Material*        sampleMaterial;
0211   G4Material*        Dia1Material;
0212   G4Material*        Dia3Material;
0213   G4Material*        defaultMaterial;
0214   G4Material*        windowMaterial; //added
0215 
0216 
0217   //apparate parameters
0218 
0219   G4double           OhmicPosThickness;
0220   
0221   G4double           OhmicNegThickness;
0222 
0223   G4double           windowThickness; //added
0224   
0225   G4int              PixelCopyNb;
0226   G4int              grainCopyNb;
0227   G4int              NbOfPixels;
0228   G4int              NbOfPixelRows;
0229   G4int              NbOfPixelColumns;
0230   G4double           PixelThickness; // added
0231 
0232 
0233   
0234   G4double           PixelSizeXY;
0235   G4double           ContactSizeXY;
0236   
0237 public:
0238 
0239   G4Material* GetSampleMaterial() const {return sampleMaterial;};
0240   G4Material* GetPixelMaterial() const {return pixelMaterial;}; 
0241   G4Material* GetDia1Material()  const {return Dia1Material;}; 
0242   G4Material* GetDia3Material()  const {return Dia3Material;}; 
0243  
0244 
0245   G4Navigator* GetGeometryNavigator() const {return aNavigator;};
0246   
0247 private:
0248 
0249   G4double           SampleThickness;
0250   G4double           SampleSizeXY;
0251   G4double           grainDia;
0252   G4double           Dia1Thickness;
0253   G4double           Dia1SizeXY;
0254   G4double           Dia3Thickness;
0255   G4double           Dia3SizeXY;
0256   G4double           DiaInnerSize;
0257   G4double           Dia3InnerSize;
0258   //  G4double           DistSi;
0259 public: 
0260   
0261   
0262   G4double GetSampleThickness() const {return SampleThickness;};
0263   G4double GetSampleSizeXY() const  {return SampleSizeXY;};
0264   
0265   G4double GetDia1Thickness() const {return Dia1Thickness;};
0266   G4double GetDia1SizeXY() const {return Dia1SizeXY;};
0267   
0268   G4double GetDia3Thickness() const {return Dia3Thickness;};
0269   G4double GetDia3SizeXY() const {return Dia3SizeXY;};
0270   
0271   
0272 private:
0273 
0274   
0275   G4double           ThetaHPGe;
0276   G4double           ThetaDia1;
0277   G4double           ThetaDia3;
0278   
0279   G4double           DistDe;
0280   G4double           DistDia;
0281   G4double           Dia3Dist;
0282   G4double           PhiHPGe;
0283   G4double           PhiDia1;
0284   G4double           PhiDia3;
0285   G4double AlphaDia1;
0286   G4double AlphaDia3;
0287   
0288   
0289   G4RotationMatrix   zRotPhiHPGe;
0290   G4RotationMatrix   zRotPhiDia1;
0291   G4RotationMatrix   zRotPhiDia3;
0292   G4double           WorldSizeXY;
0293   G4double           WorldSizeZ;
0294   
0295   
0296   XrayFluoDetectorMessenger* detectorMessenger; //pointer to the Messenger
0297 
0298   G4Cache<XrayFluoSD*> HPGeSD;  //pointer to the sensitive detector
0299 
0300   G4Region* sampleRegion;
0301 
0302   
0303 private:
0304   
0305   void DefineDefaultMaterials();
0306   G4VPhysicalVolume* ConstructApparate();
0307 
0308   //calculates some quantities used to construct geometry
0309   void ComputeApparateParameters();
0310 
0311 };
0312 
0313 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0314 
0315 inline void XrayFluoDetectorConstruction::ComputeApparateParameters()
0316 {     
0317   // Compute derived parameters of the apparate
0318   
0319   if (phaseSpaceFlag) {    
0320 
0321     WorldSizeZ = 10 *CLHEP::m; 
0322     WorldSizeXY = 10 *CLHEP::m;
0323 
0324   }
0325   else {
0326     
0327     DeviceThickness = PixelThickness+OhmicNegThickness+OhmicPosThickness+windowThickness;//change!
0328     
0329     G4cout << "DeviceThickness(cm): "<< DeviceThickness/CLHEP::cm << G4endl;
0330     
0331     DeviceSizeY =(NbOfPixelRows * std::max(ContactSizeXY,PixelSizeXY));
0332     DeviceSizeX =(NbOfPixelColumns * std::max(ContactSizeXY,PixelSizeXY));
0333     
0334     G4cout << "DeviceSizeX(cm): "<< DeviceSizeX/CLHEP::cm <<G4endl;
0335     G4cout << "DeviceSizeY(cm): "<< DeviceSizeY/CLHEP::cm << G4endl;
0336     
0337     WorldSizeZ = (2 * (DistDe +1.4142 *(std::max(std::max(DeviceThickness,DeviceSizeY), DeviceSizeX))))+5*CLHEP::m; 
0338     WorldSizeXY = 2 * (DistDe +1.4142 *Dia1SizeXY)+5*CLHEP::m;
0339     
0340   }
0341 }
0342 
0343 #endif