Skip to content
Snippets Groups Projects

CMakeLists pedantic; clang-format; pre-commit

Merged Wouter Deconinck requested to merge pre-commit into master
24 files
+ 1115
1129
Compare changes
  • Side-by-side
  • Inline
Files
24
+ 42
43
#include <map>
#include "DD4hep/DetFactoryHelper.h"
#include "DD4hep/DetFactoryHelper.h"
 
#include <map>
#if defined(USE_ACTSDD4HEP)
#if defined(USE_ACTSDD4HEP)
#include "ActsDD4hep/ActsExtension.hpp"
#include "ActsDD4hep/ActsExtension.hpp"
@@ -26,19 +26,17 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
@@ -26,19 +26,17 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
bool reflect = x_det.reflect(false);
bool reflect = x_det.reflect(false);
DetElement sdet(det_name, det_id);
DetElement sdet(det_name, det_id);
Assembly assembly(det_name);
Assembly assembly(det_name);
xml::Component pos = x_det.position();
xml::Component pos = x_det.position();
xml::Component rot = x_det.rotation();
xml::Component rot = x_det.rotation();
// Material air = description.material("Air");
//Material air = description.material("Air");
// Volume assembly (det_name,Box(10000,10000,10000),vacuum);
// Volume assembly (det_name,Box(10000,10000,10000),vacuum);
Volume motherVol = description.pickMotherVolume(sdet);
Volume motherVol = description.pickMotherVolume(sdet);
int m_id = 0, c_id = 0, n_sensor = 0;
int m_id = 0, c_id = 0, n_sensor = 0;
map<string, Volume> modules;
map<string, Volume> modules;
map<string, Placements> sensitives;
map<string, Placements> sensitives;
PlacedVolume pv;
PlacedVolume pv;
Acts::ActsExtension* detWorldExt = new Acts::ActsExtension();
Acts::ActsExtension* detWorldExt = new Acts::ActsExtension();
detWorldExt->addType("endcap", "detector");
detWorldExt->addType("endcap", "detector");
sdet.addExtension<Acts::ActsExtension>(detWorldExt);
sdet.addExtension<Acts::ActsExtension>(detWorldExt);
@@ -62,11 +60,11 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
@@ -62,11 +60,11 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
y1 = y2 = total_thickness / 2;
y1 = y2 = total_thickness / 2;
Trapezoid m_solid(x1, x2, y1, y2, z);
Trapezoid m_solid(x1, x2, y1, y2, z);
Volume m_volume(m_nam, m_solid, vacuum);
Volume m_volume(m_nam, m_solid, vacuum);
m_volume.setVisAttributes(description.visAttributes(x_mod.visStr()));
m_volume.setVisAttributes(description.visAttributes(x_mod.visStr()));
Solid frame_s;
Solid frame_s;
if(x_mod.hasChild("frame")){
if (x_mod.hasChild("frame")) {
// build frame from trd (assumed to be smaller)
// build frame from trd (assumed to be smaller)
xml_comp_t m_frame = x_mod.child(_U(frame));
xml_comp_t m_frame = x_mod.child(_U(frame));
xml_comp_t f_pos = m_frame.child(_U(position));
xml_comp_t f_pos = m_frame.child(_U(position));
@@ -76,17 +74,17 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
@@ -76,17 +74,17 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
double frame_x2 = frame_trd.x2();
double frame_x2 = frame_trd.x2();
double frame_z = frame_trd.z();
double frame_z = frame_trd.z();
// make the frame match the total thickness if thickness attribute is not given
// make the frame match the total thickness if thickness attribute is not given
Trapezoid f_solid1(x1, x2,frame_thickness / 2.0, frame_thickness / 2.0, z);
Trapezoid f_solid1(x1, x2, frame_thickness / 2.0, frame_thickness / 2.0, z);
Trapezoid f_solid(frame_x1, frame_x2, frame_thickness / 2.0, frame_thickness / 2.0, frame_z) ;
Trapezoid f_solid(frame_x1, frame_x2, frame_thickness / 2.0, frame_thickness / 2.0, frame_z);
SubtractionSolid frame_shape(f_solid1, f_solid);
SubtractionSolid frame_shape(f_solid1, f_solid);
frame_s = frame_shape;
frame_s = frame_shape;
Material f_mat = description.material(m_frame.materialStr());
Material f_mat = description.material(m_frame.materialStr());
Volume f_vol(m_nam + "_frame", frame_shape, f_mat);
Volume f_vol(m_nam + "_frame", frame_shape, f_mat);
f_vol.setVisAttributes(description.visAttributes(m_frame.visStr()));
f_vol.setVisAttributes(description.visAttributes(m_frame.visStr()));
// figure out how to best place
// figure out how to best place
pv = m_volume.placeVolume(f_vol, Position(f_pos.x(), f_pos.y(), f_pos.z()));
pv = m_volume.placeVolume(f_vol, Position(f_pos.x(), f_pos.y(), f_pos.z()));
}
}
for (ci.reset(), n_sensor = 1, c_id = 0, posY = -y1; ci; ++ci, ++c_id) {
for (ci.reset(), n_sensor = 1, c_id = 0, posY = -y1; ci; ++ci, ++c_id) {
@@ -100,16 +98,16 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
@@ -100,16 +98,16 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
string c_name = _toString(c_id, "component%d");
string c_name = _toString(c_id, "component%d");
Trapezoid comp_s1(comp_x1, comp_x2, c_thick / 2e0, c_thick / 2e0, comp_height);
Trapezoid comp_s1(comp_x1, comp_x2, c_thick / 2e0, c_thick / 2e0, comp_height);
Solid comp_shape = comp_s1;
Solid comp_shape = comp_s1;
if(frame_s.isValid()) {
if (frame_s.isValid()) {
comp_shape = SubtractionSolid( comp_s1, frame_s);
comp_shape = SubtractionSolid(comp_s1, frame_s);
}
}
Volume c_vol(c_name, comp_shape, c_mat);
Volume c_vol(c_name, comp_shape, c_mat);
c_vol.setVisAttributes(description.visAttributes(c.visStr()));
c_vol.setVisAttributes(description.visAttributes(c.visStr()));
pv = m_volume.placeVolume(c_vol, Position(0, posY + c_thick / 2, 0));
pv = m_volume.placeVolume(c_vol, Position(0, posY + c_thick / 2, 0));
if (c.isSensitive()) {
if (c.isSensitive()) {
//std::cout << " adding sensitive volume" << c_name << "\n";
// std::cout << " adding sensitive volume" << c_name << "\n";
sdet.check(n_sensor > 2, "SiTrackerEndcap2::fromCompact: " + c_name + " Max of 2 modules allowed!");
sdet.check(n_sensor > 2, "SiTrackerEndcap2::fromCompact: " + c_name + " Max of 2 modules allowed!");
pv.addPhysVolID("sensor", n_sensor);
pv.addPhysVolID("sensor", n_sensor);
sens.setType("tracker");
sens.setType("tracker");
@@ -130,19 +128,20 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
@@ -130,19 +128,20 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
xml_comp_t l_env = x_layer.child(_U(envelope));
xml_comp_t l_env = x_layer.child(_U(envelope));
string layer_name = det_name + std::string("_layer") + std::to_string(l_id);
string layer_name = det_name + std::string("_layer") + std::to_string(l_id);
std::string layer_vis = l_env.attr<std::string>(_Unicode(vis));
std::string layer_vis = l_env.attr<std::string>(_Unicode(vis));
//double layer_rmin = l_env.attr<double>(_Unicode(rmin));
// double layer_rmin = l_env.attr<double>(_Unicode(rmin));
//double layer_rmax = l_env.attr<double>(_Unicode(rmax));
// double layer_rmax = l_env.attr<double>(_Unicode(rmax));
double layer_length = l_env.attr<double>(_Unicode(length));
double layer_length = l_env.attr<double>(_Unicode(length));
double layer_zstart = l_env.attr<double>(_Unicode(zstart));
double layer_zstart = l_env.attr<double>(_Unicode(zstart));
double layer_center_z = layer_zstart + layer_length/2.0;
double layer_center_z = layer_zstart + layer_length / 2.0;
//printout(INFO,"ROOTGDMLParse","+++ Read geometry from GDML file file:%s",input.c_str());
// printout(INFO,"ROOTGDMLParse","+++ Read geometry from GDML file file:%s",input.c_str());
//std::cout << "SiTracker Endcap layer " << l_id << " zstart = " << layer_zstart/dd4hep::mm << "mm ( " << layer_length/dd4hep::mm << " mm thick )\n";
// std::cout << "SiTracker Endcap layer " << l_id << " zstart = " << layer_zstart/dd4hep::mm << "mm ( " <<
// layer_length/dd4hep::mm << " mm thick )\n";
Assembly layer_vol(layer_name);
//assembly.placeVolume(layer_assembly);
Assembly layer_vol(layer_name);
//Tube layer_tub(layer_rmin, layer_rmax, layer_length / 2);
// assembly.placeVolume(layer_assembly);
//Volume layer_vol(layer_name, layer_tub, air); // Create the layer envelope volume.
// Tube layer_tub(layer_rmin, layer_rmax, layer_length / 2);
 
// Volume layer_vol(layer_name, layer_tub, air); // Create the layer envelope volume.
layer_vol.setVisAttributes(description.visAttributes(layer_vis));
layer_vol.setVisAttributes(description.visAttributes(layer_vis));
PlacedVolume layer_pv;
PlacedVolume layer_pv;
@@ -160,9 +159,9 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
@@ -160,9 +159,9 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
layer_element.setPlacement(layer_pv);
layer_element.setPlacement(layer_pv);
Acts::ActsExtension* layerExtension = new Acts::ActsExtension();
Acts::ActsExtension* layerExtension = new Acts::ActsExtension();
layerExtension->addType("layer", "layer");
layerExtension->addType("layer", "layer");
//layerExtension->addType("axes", "definitions", "XZY");
// layerExtension->addType("axes", "definitions", "XZY");
//layerExtension->addType("sensitive disk", "layer");
// layerExtension->addType("sensitive disk", "layer");
//layerExtension->addType("axes", "definitions", "XZY");
// layerExtension->addType("axes", "definitions", "XZY");
layer_element.addExtension<Acts::ActsExtension>(layerExtension);
layer_element.addExtension<Acts::ActsExtension>(layerExtension);
for (xml_coll_t ri(x_layer, _U(ring)); ri; ++ri) {
for (xml_coll_t ri(x_layer, _U(ring)); ri; ++ri) {
@@ -175,14 +174,14 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
@@ -175,14 +174,14 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
string m_nam = x_ring.moduleStr();
string m_nam = x_ring.moduleStr();
Volume m_vol = modules[m_nam];
Volume m_vol = modules[m_nam];
double iphi = 2 * M_PI / nmodules;
double iphi = 2 * M_PI / nmodules;
double dphi = dd4hep::getAttrOrDefault(x_ring,_Unicode(dphi),iphi);
double dphi = dd4hep::getAttrOrDefault(x_ring, _Unicode(dphi), iphi);
double phi = phi0;
double phi = phi0;
Placements& sensVols = sensitives[m_nam];
Placements& sensVols = sensitives[m_nam];
for (int k = 0; k < nmodules; ++k) {
for (int k = 0; k < nmodules; ++k) {
string m_base = _toString(l_id, "layer%d") + _toString(mod_num, "_module%d");
string m_base = _toString(l_id, "layer%d") + _toString(mod_num, "_module%d");
double x = -r * std::cos(phi);
double x = -r * std::cos(phi);
double y = -r * std::sin(phi);
double y = -r * std::sin(phi);
if (!reflect) {
if (!reflect) {
DetElement module(layer_element, m_base + "_pos", det_id);
DetElement module(layer_element, m_base + "_pos", det_id);
@@ -194,7 +193,7 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
@@ -194,7 +193,7 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
PlacedVolume sens_pv = sensVols[ic];
PlacedVolume sens_pv = sensVols[ic];
DetElement comp_elt(module, sens_pv.volume().name(), mod_num);
DetElement comp_elt(module, sens_pv.volume().name(), mod_num);
comp_elt.setPlacement(sens_pv);
comp_elt.setPlacement(sens_pv);
//std::cout << " adding ACTS extension" << "\n";
// std::cout << " adding ACTS extension" << "\n";
Acts::ActsExtension* moduleExtension = new Acts::ActsExtension("XZY");
Acts::ActsExtension* moduleExtension = new Acts::ActsExtension("XZY");
comp_elt.addExtension<Acts::ActsExtension>(moduleExtension);
comp_elt.addExtension<Acts::ActsExtension>(moduleExtension);
}
}
@@ -208,7 +207,7 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
@@ -208,7 +207,7 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
PlacedVolume sens_pv = sensVols[ic];
PlacedVolume sens_pv = sensVols[ic];
DetElement comp_elt(r_module, sens_pv.volume().name(), mod_num);
DetElement comp_elt(r_module, sens_pv.volume().name(), mod_num);
comp_elt.setPlacement(sens_pv);
comp_elt.setPlacement(sens_pv);
//std::cout << " adding ACTS extension" << "\n";
// std::cout << " adding ACTS extension" << "\n";
Acts::ActsExtension* moduleExtension = new Acts::ActsExtension("XZY");
Acts::ActsExtension* moduleExtension = new Acts::ActsExtension("XZY");
comp_elt.addExtension<Acts::ActsExtension>(moduleExtension);
comp_elt.addExtension<Acts::ActsExtension>(moduleExtension);
}
}
@@ -220,7 +219,7 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
@@ -220,7 +219,7 @@ static Ref_t create_B0Preshower(Detector& description, xml_h e, SensitiveDetecto
}
}
}
}
Transform3D posAndRot(RotationZYX(rot.z(), rot.y(), rot.x()), Position(pos.x(), pos.y(), pos.z()));
Transform3D posAndRot(RotationZYX(rot.z(), rot.y(), rot.x()), Position(pos.x(), pos.y(), pos.z()));
pv = motherVol.placeVolume(assembly,posAndRot );
pv = motherVol.placeVolume(assembly, posAndRot);
pv.addPhysVolID("system", det_id);
pv.addPhysVolID("system", det_id);
sdet.setPlacement(pv);
sdet.setPlacement(pv);
return sdet;
return sdet;
Loading