Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:32

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 /// \file Par01/src/Par01DetectorConstruction.cc
0027 /// \brief Implementation of the Par01DetectorConstruction class
0028 //
0029 //
0030 //
0031 #include "Par01DetectorConstruction.hh"
0032 
0033 #include "Par01CalorimeterSD.hh"
0034 #include "Par01EMShowerModel.hh"
0035 #include "Par01PiModel.hh"
0036 
0037 #include "G4Box.hh"
0038 #include "G4Colour.hh"
0039 #include "G4Element.hh"
0040 #include "G4ElementTable.hh"
0041 #include "G4LogicalVolume.hh"
0042 #include "G4Material.hh"
0043 #include "G4MaterialTable.hh"
0044 #include "G4NistManager.hh"
0045 #include "G4PVPlacement.hh"
0046 #include "G4ProductionCuts.hh"
0047 #include "G4RegionStore.hh"
0048 #include "G4SDManager.hh"
0049 #include "G4SystemOfUnits.hh"
0050 #include "G4ThreeVector.hh"
0051 #include "G4Tubs.hh"
0052 #include "G4VisAttributes.hh"
0053 
0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0055 
0056 Par01DetectorConstruction::Par01DetectorConstruction()
0057 {
0058   ;
0059 }
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0062 
0063 Par01DetectorConstruction::~Par01DetectorConstruction()
0064 {
0065   ;
0066 }
0067 
0068 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0069 
0070 G4VPhysicalVolume* Par01DetectorConstruction::Construct()
0071 {
0072   G4cout << "\nPar01DetectorConstruction....\n" << G4endl;
0073 
0074   //--------- Material definition ---------
0075   // Get nist material manager
0076   G4NistManager* nistManager = G4NistManager::Instance();
0077 
0078   // Build materials
0079   G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
0080   G4Material* csi = nistManager->FindOrBuildMaterial("G4_CESIUM_IODIDE");
0081   G4Material* helium = nistManager->FindOrBuildMaterial("G4_He");
0082   G4Material* iron = nistManager->FindOrBuildMaterial("G4_Fe");
0083 
0084   //--------- G4VSolid, G4LogicalVolume, G4VPhysicalVolume  ---------
0085 
0086   //--------------
0087   // World:
0088   //--------------
0089   G4Box* WorldBox = new G4Box("WorldBox", 400 * cm, 400 * cm, 400 * cm);
0090   G4LogicalVolume* WorldLog = new G4LogicalVolume(WorldBox, air, "WorldLogical", 0, 0, 0);
0091   G4PVPlacement* WorldPhys =
0092     new G4PVPlacement(0, G4ThreeVector(), "WorldPhysical", WorldLog, 0, false, 0);
0093   // Size of detectors:
0094   G4double detectSize = 125 * cm;
0095 
0096   //-----------------------------
0097   // "Drift Chamber":
0098   // Not used in parameterisation.
0099   //-----------------------------
0100   // -- Logical volume:
0101   G4Box* driftChamberBox = new G4Box("DriftChamberSolid", detectSize, detectSize, 40 * cm);
0102   G4LogicalVolume* driftChamberLog =
0103     new G4LogicalVolume(driftChamberBox, helium, "DriftChamberLogical", 0, 0, 0);
0104   // -- Placement:
0105   // G4PVPlacement *driftChamberPhys  =
0106   new G4PVPlacement(0, G4ThreeVector(0., 0., 50 * cm), "DriftChamberPhysical", driftChamberLog,
0107                     WorldPhys, false, 0);
0108 
0109   //--------------------------
0110   // "Calorimeter": used in
0111   // parameterisation below
0112   //--------------------------
0113   // -- Logical volume:
0114   G4Box* calorimeterBox = new G4Box("CalorimeterSolid", detectSize, detectSize, 20 * cm);
0115   G4LogicalVolume* calorimeterLog =
0116     new G4LogicalVolume(calorimeterBox, air, "CalorimeterLogical", 0, 0, 0);
0117   // -- Placement:
0118   G4PVPlacement* calorimeterPhys = new G4PVPlacement(
0119     0, G4ThreeVector(0., 0., 120 * cm), "CalorimeterPhysical", calorimeterLog, WorldPhys, false, 0);
0120 
0121   //--------------------------------------
0122   // The calorimeter is filled with
0123   // crystals:
0124   //--------------------------------------
0125   // -- Logical volume:
0126   G4double CrystalX = 2.5 * cm;
0127   G4double CrystalY = CrystalX;
0128   G4double CrystalZ = 20 * cm;
0129   G4Box* CrystalSolid = new G4Box("CrystalSolid", CrystalX, CrystalY, CrystalZ);
0130   fCrystalLog = new G4LogicalVolume(CrystalSolid, csi, "CrystalLogical", 0, 0, 0);
0131 
0132   G4String tName1("Crystal");  // Allow all target physicals to share
0133   // same name (delayed copy)
0134 
0135   // -- and placements inside the calorimeter:
0136   G4int copyNo = 0;
0137   G4double xTlate, yTlate;
0138   fnX = 48;
0139   fnY = 48;
0140   for (G4int j = 0; j < fnY; j++) {
0141     yTlate = -detectSize + 3 * CrystalY + j * 2 * CrystalY;
0142     for (G4int i = 0; i < fnX; i++) {
0143       xTlate = -detectSize + 3 * CrystalX + i * 2 * CrystalX;
0144       new G4PVPlacement(0, G4ThreeVector(xTlate, yTlate, 0 * cm), tName1, fCrystalLog,
0145                         calorimeterPhys, false, copyNo++);
0146     }
0147   }
0148 
0149   //--------------------------
0150   // "Hadron Calorimeter": used
0151   // in parameterisation with
0152   // a parallel geometry
0153   //--------------------------
0154   // -- Logical volume:
0155   G4Box* hadCaloBox = new G4Box("HadCaloSolid", detectSize, detectSize, 50 * cm);
0156   G4LogicalVolume* hadCaloLog = new G4LogicalVolume(hadCaloBox, air, "HadCaloLogical", 0, 0, 0);
0157   // -- Placement:
0158   G4PVPlacement* hadCaloPhys = new G4PVPlacement(
0159     0, G4ThreeVector(0., 0., 200 * cm), "HadCaloPhysical", hadCaloLog, WorldPhys, false, 0);
0160 
0161   //--------------------------------------
0162   // The calorimeter is filled with
0163   // towers:
0164   //--------------------------------------
0165   // -- Logical volume:
0166   G4double TowerX = 5 * cm;
0167   G4double TowerY = TowerX;
0168   G4double TowerZ = 45 * cm;
0169   G4Box* TowerSolid = new G4Box("TowerSolid", TowerX, TowerY, TowerZ);
0170   fTowerLog = new G4LogicalVolume(TowerSolid, iron, "TowerLogical", 0, 0, 0);
0171 
0172   G4String tName2("Tower");
0173 
0174   // -- and placements inside the calorimeter:
0175   copyNo = 0;
0176   fnXhad = 23;
0177   fnYhad = 23;
0178   for (G4int jj = 0; jj < fnYhad; jj++) {
0179     yTlate = -detectSize + 3 * TowerY + jj * 2 * TowerY;
0180     for (G4int i = 0; i < fnXhad; i++) {
0181       xTlate = -detectSize + 3 * TowerX + i * 2 * TowerX;
0182       new G4PVPlacement(0, G4ThreeVector(xTlate, yTlate, 0 * cm), tName2, fTowerLog, hadCaloPhys,
0183                         false, copyNo++);
0184     }
0185   }
0186 
0187   // -- Makes the calorimeterLog volume becoming a G4Region:
0188   G4Region* caloRegion = new G4Region("EM_calo_region");
0189   caloRegion->AddRootLogicalVolume(calorimeterLog);
0190   std::vector<double> cuts;
0191   cuts.push_back(1.0 * mm);
0192   cuts.push_back(1.0 * mm);
0193   cuts.push_back(1.0 * mm);
0194   cuts.push_back(1.0 * mm);
0195   caloRegion->SetProductionCuts(new G4ProductionCuts());
0196   caloRegion->GetProductionCuts()->SetProductionCuts(cuts);
0197 
0198   //  Makes had. calo a region to:
0199   G4Region* hadRegion = new G4Region("HAD_calo_region");
0200   hadRegion->AddRootLogicalVolume(hadCaloLog);
0201   cuts.clear();
0202   cuts.push_back(1.0 * cm);
0203   cuts.push_back(1.0 * cm);
0204   cuts.push_back(1.0 * cm);
0205   cuts.push_back(1.0 * cm);
0206   hadRegion->SetProductionCuts(new G4ProductionCuts());
0207   hadRegion->GetProductionCuts()->SetProductionCuts(cuts);
0208 
0209   //--------- Visualization attributes -------------------------------
0210   WorldLog->SetVisAttributes(G4VisAttributes::GetInvisible());
0211 
0212   auto driftchamberTubeVisAtt = new G4VisAttributes(G4Colour(0.0, 1.0, 0.0));
0213   driftchamberTubeVisAtt->SetForceWireframe(true);
0214   driftChamberLog->SetVisAttributes(driftchamberTubeVisAtt);
0215 
0216   auto calorimeterBoxVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0));
0217   calorimeterBoxVisAtt->SetForceWireframe(true);
0218   calorimeterLog->SetVisAttributes(calorimeterBoxVisAtt);
0219 
0220   auto crystalVisAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
0221   crystalVisAtt->SetForceWireframe(true);
0222   fCrystalLog->SetVisAttributes(crystalVisAtt);
0223 
0224   auto hadCaloBoxVisAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0));
0225   hadCaloBoxVisAtt->SetForceWireframe(true);
0226   hadCaloLog->SetVisAttributes(hadCaloBoxVisAtt);
0227 
0228   auto towerVisAtt = new G4VisAttributes(G4Colour(0.5, 0.0, 1.0));
0229   towerVisAtt->SetForceWireframe(true);
0230   fTowerLog->SetVisAttributes(towerVisAtt);
0231 
0232   //------------------------------------------------------------------
0233 
0234   //-----------------------
0235   // Returns the pointer to
0236   // the physical world:
0237   //-----------------------
0238   return WorldPhys;
0239 }
0240 
0241 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0242 
0243 void Par01DetectorConstruction::ConstructSDandField()
0244 {
0245   //--------- Sensitive detector -------------------------------------
0246   G4SDManager* SDman = G4SDManager::GetSDMpointer();
0247   G4String calorimeterSDname = "Par01/Calorimeter";
0248   Par01CalorimeterSD* CalorimeterSD =
0249     new Par01CalorimeterSD(calorimeterSDname, fnX * fnY, "CalCollection");
0250   SDman->AddNewDetector(CalorimeterSD);
0251   fCrystalLog->SetSensitiveDetector(CalorimeterSD);
0252 
0253   G4String hadCalorimeterSDname = "Par01/HadronCalorimeter";
0254   Par01CalorimeterSD* HadCalorimeterSD =
0255     new Par01CalorimeterSD(hadCalorimeterSDname, fnXhad * fnYhad, "HadCollection");
0256   SDman->AddNewDetector(HadCalorimeterSD);
0257   fTowerLog->SetSensitiveDetector(HadCalorimeterSD);
0258 
0259   // --------------- fast simulation ----------------------------
0260   G4RegionStore* regionStore = G4RegionStore::GetInstance();
0261 
0262   G4Region* caloRegion = regionStore->GetRegion("EM_calo_region");
0263   // builds a model and sets it to the envelope of the calorimeter:
0264   new Par01EMShowerModel("emShowerModel", caloRegion);
0265 }