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 // << 27 /// \file ExGflash3ParallelWorld.cc << 28 /// \brief Implementation of the ExGflash3Para << 29 26 30 //....oooOO0OOooo........oooOO0OOooo........oo 27 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 28 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 29 33 // User Classes 30 // User Classes 34 #include "ExGflash3ParallelWorld.hh" 31 #include "ExGflash3ParallelWorld.hh" 35 << 36 #include "ExGflash3SensitiveDetector.hh" 32 #include "ExGflash3SensitiveDetector.hh" 37 33 38 // G4 Classes 34 // 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" 35 #include "G4NistManager.hh" 45 #include "G4PVPlacement.hh" << 36 #include "G4Material.hh" 46 #include "G4SDManager.hh" << 47 #include "G4SystemOfUnits.hh" << 48 #include "G4ThreeVector.hh" 37 #include "G4ThreeVector.hh" >> 38 #include "G4PVPlacement.hh" 49 #include "G4VPhysicalVolume.hh" 39 #include "G4VPhysicalVolume.hh" >> 40 #include "G4LogicalVolume.hh" >> 41 #include "G4Box.hh" >> 42 #include "G4SDManager.hh" 50 #include "G4VisAttributes.hh" 43 #include "G4VisAttributes.hh" >> 44 #include "G4Colour.hh" >> 45 #include "G4SystemOfUnits.hh" >> 46 #include "G4AutoDelete.hh" 51 #include "globals.hh" 47 #include "globals.hh" 52 48 >> 49 53 //....oooOO0OOooo........oooOO0OOooo........oo 50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 54 51 55 ExGflash3ParallelWorld::ExGflash3ParallelWorld 52 ExGflash3ParallelWorld::ExGflash3ParallelWorld(G4String aWorldName) 56 : G4VUserParallelWorld(aWorldName) << 53 :G4VUserParallelWorld(aWorldName), fCrystalLog(nullptr), fCrystalPhys{} 57 { 54 { 58 G4cout << "ExGflash3ParallelWorld::Parralel << 55 G4cout<<"ExGflash3ParallelWorld::Parralel world constructor"<<G4endl; 59 } 56 } 60 57 61 //....oooOO0OOooo........oooOO0OOooo........oo 58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 62 59 63 ExGflash3ParallelWorld::~ExGflash3ParallelWorl << 60 ExGflash3ParallelWorld::~ExGflash3ParallelWorld() {} 64 61 65 //....oooOO0OOooo........oooOO0OOooo........oo 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 66 63 67 void ExGflash3ParallelWorld::Construct() 64 void ExGflash3ParallelWorld::Construct() 68 { 65 { 69 // In parallel world material does not matte 66 // In parallel world material does not matter 70 G4Material* dummy = nullptr; << 67 G4Material* dummy = nullptr; 71 68 72 // Build parallel/ghost geometry: 69 // Build parallel/ghost geometry: 73 auto ghostLogicalVolume = GetWorld()->GetLog 70 auto ghostLogicalVolume = GetWorld()->GetLogicalVolume(); 74 << 71 75 // Use part of the Ex1GflashDetectorConstruc 72 // Use part of the Ex1GflashDetectorConstruction (without individual crystals) >> 73 >> 74 G4int nbOfCrystals = 10; // this are the crystals PER ROW in this example >> 75 // cube of 10 x 10 crystals >> 76 // don't change it @the moment, since >> 77 // the readout in event action assumes this >> 78 // dimensions and is not automatically adapted >> 79 // in this version of the example :-( >> 80 // Simplified `CMS-like` PbWO4 crystal calorimeter >> 81 G4double calo_xside = 31*cm; >> 82 G4double calo_yside = 31*cm; >> 83 G4double calo_zside = 24*cm; 76 84 77 G4int nbOfCrystals = 10; // this are the cr << 85 G4double crystalWidth = 3*cm; 78 // cube of 10 x 10 << 86 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 87 91 calo_xside = (crystalWidth * nbOfCrystals) + << 88 calo_xside = (crystalWidth*nbOfCrystals)+1*cm; 92 calo_yside = (crystalWidth * nbOfCrystals) + << 89 calo_yside = (crystalWidth*nbOfCrystals)+1*cm; 93 calo_zside = crystalLength; 90 calo_zside = crystalLength; 94 << 91 95 auto calo_box = new G4Box("CMS calorimeter", << 92 G4Box* calo_box= new G4Box("CMS calorimeter", // its name 96 calo_xside / 2., << 93 calo_xside/2., // size 97 calo_yside / 2., c << 94 calo_yside/2., 98 auto caloLog = new G4LogicalVolume(calo_box, << 95 calo_zside/2.); 99 dummy, / << 96 G4LogicalVolume* caloLog 100 "calo log << 97 = new G4LogicalVolume(calo_box, // its solid 101 nullptr, << 98 dummy, // its material 102 nullptr, << 99 "calo log", // its name 103 nullptr); << 100 0, // opt: fieldManager >> 101 0, // opt: SensitiveDetector >> 102 0); // opt: UserLimit 104 103 105 G4double xpos = 0.0; 104 G4double xpos = 0.0; 106 G4double ypos = 0.0; 105 G4double ypos = 0.0; 107 G4double zpos = 100.0 * cm; << 106 G4double zpos = 100.0*cm; 108 new G4PVPlacement(nullptr, G4ThreeVector(xpo << 107 new G4PVPlacement(0, 109 ghostLogicalVolume, false, << 108 G4ThreeVector(xpos, ypos, zpos), 110 << 109 caloLog, >> 110 "calorimeter", >> 111 ghostLogicalVolume, >> 112 false, >> 113 1); >> 114 111 // Crystals 115 // Crystals 112 G4VSolid* crystal_box = new G4Box("Crystal", << 116 G4VSolid* crystal_box 113 crystalWid << 117 = new G4Box("Crystal", // its name 114 // size << 118 crystalWidth/2, 115 fCrystalLog = new G4LogicalVolume(crystal_bo << 119 crystalWidth/2, 116 dummy, // << 120 crystalLength/2); 117 "CrystalLo << 121 // size 118 << 122 fCrystalLog 119 for (G4int i = 0; i < nbOfCrystals; i++) { << 123 = new G4LogicalVolume(crystal_box, // its solid 120 for (G4int j = 0; j < nbOfCrystals; j++) { << 124 dummy, // its material 121 G4int n = i * 10 + j; << 125 "CrystalLog"); // its name 122 G4ThreeVector crystalPos((i * crystalWid << 126 123 fCrystalPhys[n] = new G4PVPlacement(null << 127 for (G4int i=0; i<nbOfCrystals; i++) 124 crys << 128 { 125 fCry << 129 126 "cry << 130 for (G4int j=0; j<nbOfCrystals; j++) 127 calo << 131 { 128 } << 132 G4int n = i*10+j; 129 } << 133 G4ThreeVector crystalPos((i*crystalWidth)-135, 130 G4cout << "There are " << nbOfCrystals << " << 134 (j*crystalWidth)-135,0 ); 131 << nbOfCrystals * nbOfCrystals << " c << 135 fCrystalPhys[n] 132 G4cout << "They have width of " << crystalW << 136 = new G4PVPlacement(0, // no rotation 133 << crystalLength / cm << " cm. " << G << 137 crystalPos, // translation >> 138 fCrystalLog, >> 139 "crystal", // its name >> 140 caloLog, >> 141 false, >> 142 i); >> 143 } >> 144 } >> 145 G4cout << "There are " << nbOfCrystals << >> 146 " crystals per row in the calorimeter, so in total "<< >> 147 nbOfCrystals*nbOfCrystals << " crystals" << G4endl; >> 148 G4cout << "They have width of " << crystalWidth /cm << >> 149 " cm and a length of " << crystalLength /cm >> 150 <<" cm. " << G4endl; >> 151 134 152 135 auto caloVisAtt = new G4VisAttributes(G4Colo << 153 G4VisAttributes* caloVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,1.0)); 136 auto crystalVisAtt = new G4VisAttributes(G4C << 154 G4VisAttributes* crystalVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,0.0)); 137 caloLog->SetVisAttributes(caloVisAtt); 155 caloLog->SetVisAttributes(caloVisAtt); 138 fCrystalLog->SetVisAttributes(crystalVisAtt) 156 fCrystalLog->SetVisAttributes(crystalVisAtt); >> 157 139 } 158 } 140 159 141 //....oooOO0OOooo........oooOO0OOooo........oo 160 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 142 161 143 void ExGflash3ParallelWorld::ConstructSD() 162 void ExGflash3ParallelWorld::ConstructSD() 144 { 163 { 145 // -- sensitive detectors: 164 // -- sensitive detectors: 146 G4SDManager* SDman = G4SDManager::GetSDMpoin 165 G4SDManager* SDman = G4SDManager::GetSDMpointer(); 147 auto CaloSD = new ExGflash3SensitiveDetector << 166 ExGflash3SensitiveDetector* CaloSD >> 167 = new ExGflash3SensitiveDetector("Calorimeter",this); 148 SDman->AddNewDetector(CaloSD); 168 SDman->AddNewDetector(CaloSD); 149 fCrystalLog->SetSensitiveDetector(CaloSD); 169 fCrystalLog->SetSensitiveDetector(CaloSD); 150 } 170 } 151 171 152 //....oooOO0OOooo........oooOO0OOooo........oo 172 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 153 173