Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 /// \file ExGflash3ParallelWorld.cc 27 /// \file ExGflash3ParallelWorld.cc 28 /// \brief Implementation of the ExGflash3Para 28 /// \brief Implementation of the ExGflash3ParallelWorld class 29 29 30 //....oooOO0OOooo........oooOO0OOooo........oo 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 32 33 // User Classes 33 // User Classes 34 #include "ExGflash3ParallelWorld.hh" 34 #include "ExGflash3ParallelWorld.hh" 35 << 36 #include "ExGflash3SensitiveDetector.hh" 35 #include "ExGflash3SensitiveDetector.hh" 37 36 38 // G4 Classes 37 // G4 Classes 39 #include "G4AutoDelete.hh" << 40 #include "G4Box.hh" << 41 #include "G4Colour.hh" << 42 #include "G4LogicalVolume.hh" << 43 #include "G4Material.hh" << 44 #include "G4NistManager.hh" 38 #include "G4NistManager.hh" 45 #include "G4PVPlacement.hh" << 39 #include "G4Material.hh" 46 #include "G4SDManager.hh" << 47 #include "G4SystemOfUnits.hh" << 48 #include "G4ThreeVector.hh" 40 #include "G4ThreeVector.hh" >> 41 #include "G4PVPlacement.hh" 49 #include "G4VPhysicalVolume.hh" 42 #include "G4VPhysicalVolume.hh" >> 43 #include "G4LogicalVolume.hh" >> 44 #include "G4Box.hh" >> 45 #include "G4SDManager.hh" 50 #include "G4VisAttributes.hh" 46 #include "G4VisAttributes.hh" >> 47 #include "G4Colour.hh" >> 48 #include "G4SystemOfUnits.hh" >> 49 #include "G4AutoDelete.hh" 51 #include "globals.hh" 50 #include "globals.hh" 52 51 >> 52 53 //....oooOO0OOooo........oooOO0OOooo........oo 53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 54 54 55 ExGflash3ParallelWorld::ExGflash3ParallelWorld 55 ExGflash3ParallelWorld::ExGflash3ParallelWorld(G4String aWorldName) 56 : G4VUserParallelWorld(aWorldName) << 56 :G4VUserParallelWorld(aWorldName), fCrystalLog(nullptr), fCrystalPhys{} 57 { 57 { 58 G4cout << "ExGflash3ParallelWorld::Parralel << 58 G4cout<<"ExGflash3ParallelWorld::Parralel world constructor"<<G4endl; 59 } 59 } 60 60 61 //....oooOO0OOooo........oooOO0OOooo........oo 61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 62 62 63 ExGflash3ParallelWorld::~ExGflash3ParallelWorl << 63 ExGflash3ParallelWorld::~ExGflash3ParallelWorld() {} 64 64 65 //....oooOO0OOooo........oooOO0OOooo........oo 65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 66 66 67 void ExGflash3ParallelWorld::Construct() 67 void ExGflash3ParallelWorld::Construct() 68 { 68 { 69 // In parallel world material does not matte 69 // In parallel world material does not matter 70 G4Material* dummy = nullptr; << 70 G4Material* dummy = nullptr; 71 71 72 // Build parallel/ghost geometry: 72 // Build parallel/ghost geometry: 73 auto ghostLogicalVolume = GetWorld()->GetLog 73 auto ghostLogicalVolume = GetWorld()->GetLogicalVolume(); 74 << 74 75 // Use part of the Ex1GflashDetectorConstruc 75 // Use part of the Ex1GflashDetectorConstruction (without individual crystals) >> 76 >> 77 G4int nbOfCrystals = 10; // this are the crystals PER ROW in this example >> 78 // cube of 10 x 10 crystals >> 79 // don't change it @the moment, since >> 80 // the readout in event action assumes this >> 81 // dimensions and is not automatically adapted >> 82 // in this version of the example :-( >> 83 // Simplified `CMS-like` PbWO4 crystal calorimeter >> 84 G4double calo_xside = 31*cm; >> 85 G4double calo_yside = 31*cm; >> 86 G4double calo_zside = 24*cm; 76 87 77 G4int nbOfCrystals = 10; // this are the cr << 88 G4double crystalWidth = 3*cm; 78 // cube of 10 x 10 << 89 G4double crystalLength = 24*cm; 79 // don't change it << 80 // the readout in << 81 // dimensions and << 82 // in this version << 83 // Simplified `CMS-like` PbWO4 crystal calor << 84 G4double calo_xside = 31 * cm; << 85 G4double calo_yside = 31 * cm; << 86 G4double calo_zside = 24 * cm; << 87 << 88 G4double crystalWidth = 3 * cm; << 89 G4double crystalLength = 24 * cm; << 90 90 91 calo_xside = (crystalWidth * nbOfCrystals) + << 91 calo_xside = (crystalWidth*nbOfCrystals)+1*cm; 92 calo_yside = (crystalWidth * nbOfCrystals) + << 92 calo_yside = (crystalWidth*nbOfCrystals)+1*cm; 93 calo_zside = crystalLength; 93 calo_zside = crystalLength; 94 << 94 95 auto calo_box = new G4Box("CMS calorimeter", << 95 G4Box* calo_box= new G4Box("CMS calorimeter", // its name 96 calo_xside / 2., << 96 calo_xside/2., // size 97 calo_yside / 2., c << 97 calo_yside/2., 98 auto caloLog = new G4LogicalVolume(calo_box, << 98 calo_zside/2.); 99 dummy, / << 99 G4LogicalVolume* caloLog 100 "calo log << 100 = new G4LogicalVolume(calo_box, // its solid 101 nullptr, << 101 dummy, // its material 102 nullptr, << 102 "calo log", // its name 103 nullptr); << 103 0, // opt: fieldManager >> 104 0, // opt: SensitiveDetector >> 105 0); // opt: UserLimit 104 106 105 G4double xpos = 0.0; 107 G4double xpos = 0.0; 106 G4double ypos = 0.0; 108 G4double ypos = 0.0; 107 G4double zpos = 100.0 * cm; << 109 G4double zpos = 100.0*cm; 108 new G4PVPlacement(nullptr, G4ThreeVector(xpo << 110 new G4PVPlacement(0, 109 ghostLogicalVolume, false, << 111 G4ThreeVector(xpos, ypos, zpos), 110 << 112 caloLog, >> 113 "calorimeter", >> 114 ghostLogicalVolume, >> 115 false, >> 116 1); >> 117 111 // Crystals 118 // Crystals 112 G4VSolid* crystal_box = new G4Box("Crystal", << 119 G4VSolid* crystal_box 113 crystalWid << 120 = new G4Box("Crystal", // its name 114 // size << 121 crystalWidth/2, 115 fCrystalLog = new G4LogicalVolume(crystal_bo << 122 crystalWidth/2, 116 dummy, // << 123 crystalLength/2); 117 "CrystalLo << 124 // size 118 << 125 fCrystalLog 119 for (G4int i = 0; i < nbOfCrystals; i++) { << 126 = new G4LogicalVolume(crystal_box, // its solid 120 for (G4int j = 0; j < nbOfCrystals; j++) { << 127 dummy, // its material 121 G4int n = i * 10 + j; << 128 "CrystalLog"); // its name 122 G4ThreeVector crystalPos((i * crystalWid << 129 123 fCrystalPhys[n] = new G4PVPlacement(null << 130 for (G4int i=0; i<nbOfCrystals; i++) 124 crys << 131 { 125 fCry << 132 126 "cry << 133 for (G4int j=0; j<nbOfCrystals; j++) 127 calo << 134 { 128 } << 135 G4int n = i*10+j; 129 } << 136 G4ThreeVector crystalPos((i*crystalWidth)-135, 130 G4cout << "There are " << nbOfCrystals << " << 137 (j*crystalWidth)-135,0 ); 131 << nbOfCrystals * nbOfCrystals << " c << 138 fCrystalPhys[n] 132 G4cout << "They have width of " << crystalW << 139 = new G4PVPlacement(0, // no rotation 133 << crystalLength / cm << " cm. " << G << 140 crystalPos, // translation >> 141 fCrystalLog, >> 142 "crystal", // its name >> 143 caloLog, >> 144 false, >> 145 i); >> 146 } >> 147 } >> 148 G4cout << "There are " << nbOfCrystals << >> 149 " crystals per row in the calorimeter, so in total "<< >> 150 nbOfCrystals*nbOfCrystals << " crystals" << G4endl; >> 151 G4cout << "They have width of " << crystalWidth /cm << >> 152 " cm and a length of " << crystalLength /cm >> 153 <<" cm. " << G4endl; >> 154 134 155 135 auto caloVisAtt = new G4VisAttributes(G4Colo << 156 G4VisAttributes* caloVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,1.0)); 136 auto crystalVisAtt = new G4VisAttributes(G4C << 157 G4VisAttributes* crystalVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,0.0)); 137 caloLog->SetVisAttributes(caloVisAtt); 158 caloLog->SetVisAttributes(caloVisAtt); 138 fCrystalLog->SetVisAttributes(crystalVisAtt) 159 fCrystalLog->SetVisAttributes(crystalVisAtt); >> 160 139 } 161 } 140 162 141 //....oooOO0OOooo........oooOO0OOooo........oo 163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 142 164 143 void ExGflash3ParallelWorld::ConstructSD() 165 void ExGflash3ParallelWorld::ConstructSD() 144 { 166 { 145 // -- sensitive detectors: 167 // -- sensitive detectors: 146 G4SDManager* SDman = G4SDManager::GetSDMpoin 168 G4SDManager* SDman = G4SDManager::GetSDMpointer(); 147 auto CaloSD = new ExGflash3SensitiveDetector << 169 ExGflash3SensitiveDetector* CaloSD >> 170 = new ExGflash3SensitiveDetector("Calorimeter",this); 148 SDman->AddNewDetector(CaloSD); 171 SDman->AddNewDetector(CaloSD); 149 fCrystalLog->SetSensitiveDetector(CaloSD); 172 fCrystalLog->SetSensitiveDetector(CaloSD); 150 } 173 } 151 174 152 //....oooOO0OOooo........oooOO0OOooo........oo 175 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 153 176