9#include "G4Transform3D.hh"
10#include "G4PVPlacement.hh"
11#include "G4SDManager.hh"
12#include "G4UserLimits.hh"
13#include <G4VisAttributes.hh>
16#include <ecl/geometry/GeoECLCreator.h>
17#include <ecl/geometry/shapes.h>
18#include <ecl/simulation/SensitiveDetector.h>
19#include <geometry/CreatorFactory.h>
20#include <geometry/Materials.h>
21#include <framework/gearbox/GearDir.h>
22#include "ecl/dbobjects/ECLCrystalsShapeAndPosition.h"
23#include <framework/database/IntervalOfValidity.h>
24#include <framework/database/Database.h>
25#include <framework/database/DBObjPtr.h>
26#include <framework/logging/Logger.h>
47 G4SDManager::GetSDMpointer()->AddNewDetector(
m_sensitive);
54 for (
auto a :
m_atts)
delete a.second;
60 G4SDManager::GetSDMpointer()->AddNewDetector(
m_sensediode);
63 if (!crystals.
isValid()) B2FATAL(
"No crystal's data in the database.");
80 G4SDManager::GetSDMpointer()->AddNewDetector(
m_sensediode);
92 std::string prefix(
"sv_"); prefix += endcap; prefix +=
"_wrap";
95 std::string name(
"lv_"); name += endcap +
"_wrap_" + std::to_string(s->nshape);
96 G4Material* wrap =
nullptr;
97 if (wrapthickness < 0.170)
99 else if (wrapthickness < 0.200)
103 G4LogicalVolume* wrapped_logical =
new G4LogicalVolume(
wrapped_crystal, wrap, name.c_str(), 0, 0, 0);
104 wrapped_logical->SetVisAttributes(
att(
"wrap"));
106 prefix =
"sv_"; prefix += endcap; prefix +=
"_crystal";
108 G4VSolid* crystal_solid = s->get_solid(prefix, 0, tc);
109 name =
"lv_" + endcap +
"_crystal_" + std::to_string(s->nshape);
110 G4LogicalVolume* crystal_logical =
new G4LogicalVolume(crystal_solid,
Materials::get(
"G4_CESIUM_IODIDE"), name.c_str(),
112 crystal_logical->SetVisAttributes(
att(
"cryst"));
113 crystal_logical->SetSensitiveDetector(
m_sensitive);
115 new G4PVPlacement(
nullptr, G4ThreeVector(), crystal_logical, name.c_str(), wrapped_logical,
false, 0, 0);
116 return wrapped_logical;
121 m_atts[
"wrap"] =
new G4VisAttributes(G4Colour(0.5, 0.5, 1.0));
122 m_atts[
"cryst"] =
new G4VisAttributes(G4Colour(0.7, 0.7, 1.0));
124 m_atts[
"iron"] =
new G4VisAttributes(G4Colour(1., 0.1, 0.1));
125 m_atts[
"iron2"] =
new G4VisAttributes(G4Colour(1., 0.5, 0.5));
126 m_atts[
"alum"] =
new G4VisAttributes(G4Colour(0.25, 0.25, 1.0, 0.5));
127 m_atts[
"alum2"] =
new G4VisAttributes(G4Colour(0.5, 0.5, 1.0));
128 m_atts[
"silv"] =
new G4VisAttributes(G4Colour(0.9, 0., 0.9));
129 m_atts[
"air"] =
new G4VisAttributes(G4Colour(1., 1., 1.));
130 m_atts[
"air"]->SetVisibility(
false);
131 m_atts[
"preamp"] =
new G4VisAttributes(G4Colour(0.1, 0.1, 0.8));
132 m_atts[
"plate"] =
new G4VisAttributes(G4Colour(0.2, 0.8, 0.2));
133 m_atts[
"connector"] =
new G4VisAttributes(G4Colour(0.1, 0.1, 0.1));
134 m_atts[
"capacitor"] =
new G4VisAttributes(G4Colour(0.1, 0.1, 0.8));
135 m_atts[
"holder"] =
new G4VisAttributes(G4Colour(0.4, 0.8, 0.8));
136 m_atts[
"asolid6"] =
new G4VisAttributes(G4Colour(1., 0.3, 0.2));
137 m_atts[
"asolid7"] =
new G4VisAttributes(G4Colour(1., 0.3, 0.2));
138 m_atts[
"asolid13"] =
new G4VisAttributes(G4Colour(1., 0.5, 0.5));
144 assert(p !=
m_atts.end());
150 static G4LogicalVolume* lv_preamplifier =
nullptr;
151 if (lv_preamplifier ==
nullptr) {
152 G4VSolid* sv_preamplifier =
new G4Box(
"sv_preamplifier", 58. / 2, 51. / 2,
get_pa_box_height() / 2);
153 lv_preamplifier =
new G4LogicalVolume(sv_preamplifier,
Materials::get(
"A5052"),
"lv_preamplifier", 0, 0, 0);
154 G4VSolid* sv_diode =
new G4Box(
"sv_diode", 20. / 2, 20. / 2, 0.3 / 2);
155 G4LogicalVolume* lv_diode =
new G4LogicalVolume(sv_diode,
Materials::get(
"G4_Si"),
"lv_diode", 0, 0, 0);
156 lv_diode->SetUserLimits(
new G4UserLimits(0.01));
158 new G4PVPlacement(G4TranslateZ3D(-
get_pa_box_height() / 2 + 0.3 / 2), lv_diode,
"pv_diode", lv_preamplifier,
false, 0,
m_overlap);
166 lv_preamplifier->SetVisAttributes(
att(
"preamp"));
168 return lv_preamplifier;
bool isValid() const
Check whether a valid object was obtained from the database.
Class for accessing objects in the database.
Crystal shapes and positions.
void barrel(G4LogicalVolume &)
Make the ECL barrel and then place elements inside it.
void defineVisAttributes()
Define visual attributes.
Simulation::SensitiveDetectorBase * m_sensediode
Sensitive diode.
double get_pa_box_height() const
Getter for preamplifier box height (hard-coded to be 2)
const G4VisAttributes * att(const std::string &n) const
Define visual attributes.
virtual void createFromDB(const std::string &name, G4LogicalVolume &topVolume, geometry::GeometryTypes type) override
Function to create the geometry from the Database.
virtual void createPayloads(const GearDir &content, const IntervalOfValidity &iov) override
Function to create the geometry database.
void backward(G4LogicalVolume &)
Place elements inside the backward endcap.
~GeoECLCreator()
The destructor of the GeoECLCreator class.
const ECLCrystalsShapeAndPosition * m_sap
pointer to a storage with crystal shapes and positions
std::map< std::string, G4VisAttributes * > m_atts
Vector of background-Sensitive detectors.
Simulation::SensitiveDetectorBase * m_sensitive
Sensitive detector.
G4LogicalVolume * get_preamp() const
Get Logical volume of preamplifier.
G4LogicalVolume * wrapped_crystal(const shape_t *s, const std::string &endcap, double wrapthickness)
Wrapped crystal.
void forward(G4LogicalVolume &)
Place elements inside the forward endcap.
GeoECLCreator()
Constructor of the GeoECLCreator class.
virtual void create(const GearDir &content, G4LogicalVolume &topVolume, geometry::GeometryTypes type) override
Function to actually create the geometry, has to be overridden by derived classes.
Class for ECL Sensitive Detector.
Class for ECL Sensitive Detector.
GearDir is the basic class used for accessing the parameter store.
A class that describes the interval of experiments/runs for which an object in the database is valid.
static G4Material * get(const std::string &name)
Find given material.
static Database & Instance()
Instance of a singleton Database.
bool storeData(const std::string &name, TObject *object, const IntervalOfValidity &iov)
Store an object in the database.
Common code concerning the geometry representation of the detector.
GeometryTypes
Flag indiciating the type of geometry to be used.
Abstract base class for different kinds of events.
Very simple class to provide an easy way to register creators with the CreatorManager.