| File: | beast/cave/geometry/src/CaveCreator.cc |
| Warning: | line 77, column 65 Although the value stored to 'Z' is used in the enclosing expression, the value is never actually read from 'Z' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /************************************************************************** |
| 2 | * basf2 (Belle II Analysis Software Framework) * |
| 3 | * Author: The Belle II Collaboration * |
| 4 | * * |
| 5 | * See git log for contributors and copyright holders. * |
| 6 | * This file is licensed under LGPL-3.0, see LICENSE.md. * |
| 7 | **************************************************************************/ |
| 8 | |
| 9 | #include <beast/cave/geometry/CaveCreator.h> |
| 10 | #include <beast/cave/simulation/SensitiveDetector.h> |
| 11 | |
| 12 | #include <geometry/CreatorFactory.h> |
| 13 | #include <framework/gearbox/GearDir.h> |
| 14 | #include <framework/logging/Logger.h> |
| 15 | |
| 16 | #include <G4LogicalVolume.hh> |
| 17 | #include <G4PVPlacement.hh> |
| 18 | |
| 19 | //Shapes |
| 20 | #include <G4Box.hh> |
| 21 | #include <G4UserLimits.hh> |
| 22 | |
| 23 | using namespace std; |
| 24 | |
| 25 | namespace Belle2 { |
| 26 | |
| 27 | /** Namespace to encapsulate code needed for simulation and reconstrucion of the CAVE detector */ |
| 28 | namespace cave { |
| 29 | |
| 30 | // Register the creator |
| 31 | /** Creator creates the cave geometry */ |
| 32 | geometry::CreatorFactory<CaveCreator> CaveFactory("CAVECreator"); |
| 33 | |
| 34 | CaveCreator::CaveCreator(): m_sensitive(0) |
| 35 | { |
| 36 | //m_sensitive = new SensitiveDetector(); |
| 37 | } |
| 38 | |
| 39 | CaveCreator::~CaveCreator() |
| 40 | { |
| 41 | if (m_sensitive) delete m_sensitive; |
| 42 | } |
| 43 | |
| 44 | void CaveCreator::create(const GearDir& content, G4LogicalVolume& topVolume, geometry::GeometryTypes /* type */) |
| 45 | { |
| 46 | |
| 47 | m_sensitive = new SensitiveDetector(); |
| 48 | |
| 49 | G4double density; |
| 50 | G4double A; |
| 51 | G4int Z; |
| 52 | |
| 53 | G4String name, symbol; |
| 54 | |
| 55 | A = 1.01 * CLHEP::g / CLHEP::mole; |
| 56 | G4Element* elH = new G4Element(name = "Hydrogen", symbol = "H", Z = 1, A); |
| 57 | |
| 58 | A = 12.01 * CLHEP::g / CLHEP::mole; |
| 59 | G4Element* elC = new G4Element(name = "Carbon", symbol = "C", Z = 6, A); |
| 60 | |
| 61 | A = 16.00 * CLHEP::g / CLHEP::mole; |
| 62 | G4Element* elO = new G4Element(name = "Oxygen", symbol = "O", Z = 8, A); |
| 63 | |
| 64 | A = 22.99 * CLHEP::g / CLHEP::mole; |
| 65 | G4Element* elNa = new G4Element(name = "Natrium", symbol = "Na", Z = 11, A); |
| 66 | |
| 67 | A = 200.59 * CLHEP::g / CLHEP::mole; |
| 68 | G4Element* elHg = new G4Element(name = "Hg", symbol = "Hg", Z = 80, A); |
| 69 | |
| 70 | A = 26.98 * CLHEP::g / CLHEP::mole; |
| 71 | G4Element* elAl = new G4Element(name = "Aluminium", symbol = "Al", Z = 13, A); |
| 72 | |
| 73 | A = 28.09 * CLHEP::g / CLHEP::mole; |
| 74 | G4Element* elSi = new G4Element(name = "Silicon", symbol = "Si", Z = 14, A); |
| 75 | |
| 76 | A = 39.1 * CLHEP::g / CLHEP::mole; |
| 77 | G4Element* elK = new G4Element(name = "K", symbol = "K", Z = 19, A); |
Although the value stored to 'Z' is used in the enclosing expression, the value is never actually read from 'Z' | |
| 78 | |
| 79 | A = 69.72 * CLHEP::g / CLHEP::mole; |
| 80 | G4Element* elCa = new G4Element(name = "Calzium", symbol = "Ca", Z = 31, A); |
| 81 | |
| 82 | A = 55.85 * CLHEP::g / CLHEP::mole; |
| 83 | G4Element* elFe = new G4Element(name = "Iron", symbol = "Fe", Z = 26, A); |
| 84 | |
| 85 | density = 2.03 * CLHEP::g / CLHEP::cm3; |
| 86 | G4Material* Concrete = new G4Material("Concrete", density, 10); |
| 87 | Concrete->AddElementByMassFraction(elH, 0.01); |
| 88 | Concrete->AddElementByMassFraction(elO, 0.529); |
| 89 | Concrete->AddElementByMassFraction(elNa, 0.016); |
| 90 | Concrete->AddElementByMassFraction(elHg, 0.002); |
| 91 | Concrete->AddElementByMassFraction(elAl, 0.034); |
| 92 | Concrete->AddElementByMassFraction(elSi, 0.337); |
| 93 | Concrete->AddElementByMassFraction(elK, 0.013); |
| 94 | Concrete->AddElementByMassFraction(elCa, 0.044); |
| 95 | Concrete->AddElementByMassFraction(elFe, 0.014); |
| 96 | Concrete->AddElementByMassFraction(elC, 0.001); |
| 97 | |
| 98 | |
| 99 | //lets get the stepsize parameter with a default value of 5 µm |
| 100 | double stepSize = content.getLength("stepSize", 5 * CLHEP::um); |
| 101 | |
| 102 | //no get the array. Notice that the default framework unit is cm, so the |
| 103 | //values will be automatically converted |
| 104 | vector<double> bar = content.getArray("bar"); |
| 105 | B2INFO("Contents of bar: ")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2:: LogConfig::c_Info, 0, "beast")) { { LogVariableStream varStream ; varStream << "Contents of bar: "; Belle2::LogSystem:: Instance().sendMessage(Belle2::LogMessage(Belle2::LogConfig:: c_Info, std::move(varStream), "beast", __PRETTY_FUNCTION__, "beast/cave/geometry/src/CaveCreator.cc" , 105, 0)); }; } } while(false); |
| 106 | for (double value : bar) { |
| 107 | B2INFO("value: " << value)do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2:: LogConfig::c_Info, 0, "beast")) { { LogVariableStream varStream ; varStream << "value: " << value; Belle2::LogSystem ::Instance().sendMessage(Belle2::LogMessage(Belle2::LogConfig ::c_Info, std::move(varStream), "beast", __PRETTY_FUNCTION__, "beast/cave/geometry/src/CaveCreator.cc", 107, 0)); }; } } while (false); |
| 108 | } |
| 109 | int detID = 0; |
| 110 | //Lets loop over all the Active nodes |
| 111 | for (const GearDir& activeParams : content.getNodes("Active")) { |
| 112 | |
| 113 | //create cave volume |
| 114 | G4Box* s_CAVE = new G4Box("s_CAVE", |
| 115 | activeParams.getLength("px")*CLHEP::cm, |
| 116 | activeParams.getLength("py")*CLHEP::cm, |
| 117 | activeParams.getLength("pz")*CLHEP::cm); |
| 118 | |
| 119 | //G4LogicalVolume* l_CAVE = new G4LogicalVolume(s_CAVE, geometry::Materials::get("CAVE"), "l_CAVE", 0, m_sensitive); |
| 120 | G4LogicalVolume* l_CAVE = new G4LogicalVolume(s_CAVE, Concrete, "l_CAVE", 0, 0); |
| 121 | |
| 122 | //Lets limit the Geant4 stepsize inside the volume |
| 123 | l_CAVE->SetUserLimits(new G4UserLimits(stepSize)); |
| 124 | |
| 125 | //position cave volume |
| 126 | G4ThreeVector CAVEpos = G4ThreeVector( |
| 127 | activeParams.getLength("x_cave") * CLHEP::cm, |
| 128 | activeParams.getLength("y_cave") * CLHEP::cm, |
| 129 | activeParams.getLength("z_cave") * CLHEP::cm |
| 130 | ); |
| 131 | |
| 132 | G4RotationMatrix* rot_cave = new G4RotationMatrix(); |
| 133 | rot_cave->rotateX(activeParams.getLength("AngleX")); |
| 134 | rot_cave->rotateY(activeParams.getLength("AngleY")); |
| 135 | rot_cave->rotateZ(activeParams.getLength("AngleZ")); |
| 136 | //geometry::setColor(*l_CAVE, "#006699"); |
| 137 | //double angle = activeParams.getDouble("angle"); |
| 138 | //double rx = activeParams.getDouble("rx"); |
| 139 | //double ry = activeParams.getDouble("ry"); |
| 140 | //double rz = activeParams.getDouble("rz"); |
| 141 | //rot_cave->rotate(-angle, G4ThreeVector(rx, ry, rz)); |
| 142 | new G4PVPlacement(rot_cave, CAVEpos, l_CAVE, "p_CAVE", &topVolume, false, detID); |
| 143 | |
| 144 | detID++; |
| 145 | } |
| 146 | } |
| 147 | } // cave namespace |
| 148 | } // Belle2 namespace |