Skip to content

Commit

Permalink
Merge pull request #381 from vvolkl/fix-newacts
Browse files Browse the repository at this point in the history
Update Acts code for Compatibility with newer versions
  • Loading branch information
vvolkl authored Jan 9, 2020
2 parents 9bbf8eb + 35ec5ba commit 1de09f2
Show file tree
Hide file tree
Showing 21 changed files with 60 additions and 787 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ if (SAS)
)
endif(SAS)


#---------------------------------------------------------------
# to use ROOT targets, find_package ROOT must come before find_package Gaudi
# (for now) # see issue Gaudi#103
find_package(ROOT COMPONENTS Geom)

# Load macros and functions for Gaudi-based projects
find_package(GaudiProject)
#---------------------------------------------------------------
Expand Down Expand Up @@ -57,4 +62,4 @@ install(FILES ${CMAKE_BINARY_DIR}/setup.sh
WORLD_READ)

gaudi_project(FCCSW v0r11
USE Gaudi v32r0 )
USE Gaudi v32r2 )
2 changes: 1 addition & 1 deletion Detector/DetComponents/src/TrackingGeoSvc.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "TrackingGeoSvc.h"

#include "Acts/Detector/TrackingGeometry.hpp"
#include "Acts/Geometry/TrackingGeometry.hpp"
#include "Acts/Plugins/DD4hep/ConvertDD4hepDetector.hpp"

DECLARE_COMPONENT(TrackingGeoSvc)
Expand Down
6 changes: 2 additions & 4 deletions Detector/DetFCChhTrackerTkLayout/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ find_package(DD4hep)
find_package(Eigen)
find_package(Geant4)
find_package(Acts COMPONENTS Core IdentificationPlugin TGeoPlugin DD4hepPlugin DigitizationPlugin)
include(${Geant4_USE_FILE})

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DD4hep_ROOT}/cmake )
include( DD4hep )
#include( DD4hep )

find_package(ROOT COMPONENTS MathCore GenVector Geom REQUIRED)

Expand All @@ -23,7 +21,7 @@ install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/triplet DESTINATION ${CMAKE_INSTALL_
gaudi_add_module(DetFCChhTrackerTkLayout
src/*.cpp
INCLUDE_DIRS FWCore DD4hep ROOT Geant4 DetCommon Eigen Acts
LINK_LIBRARIES FWCore GaudiKernel DD4hep ROOT Geant4 DetCommon ActsCore ActsDD4hepPlugin ActsDigitizationPlugin)
LINK_LIBRARIES FWCore GaudiKernel DD4hep ROOT Geant4 DetCommon ActsCore ActsDD4hepPlugin)

set(LIBRARY_OUTPUT_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
message(STATUS "LIBRARY_OUTPUT_PATH -> ${LIBRARY_OUTPUT_PATH}")
Expand Down
7 changes: 3 additions & 4 deletions Detector/DetFCChhTrackerTkLayout/src/BeamTube_geo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& lcdd, xml_h e, dd4hep::Sen
std::string det_name = x_det.nameStr();
// Make DetElement
DetElement beamtube(det_name, x_det.id());
Acts::ActsExtension::Config volConfig;
volConfig.isBeampipe = true;
Acts::ActsExtension* detvolume = new Acts::ActsExtension(volConfig);
beamtube.addExtension<Acts::IActsExtension>(detvolume);
Acts::ActsExtension* detvolume = new Acts::ActsExtension();
detvolume->addType("beampipe", "layer");
beamtube.addExtension<Acts::ActsExtension>(detvolume);
dd4hep::xml::Dimension x_det_dim(x_det.dimensions());
Tube tube_shape(x_det_dim.rmin(), x_det_dim.rmax(), x_det_dim.z());
Volume tube_vol(det_name, tube_shape, lcdd.material(x_det_dim.attr<std::string>("material")));
Expand Down
64 changes: 12 additions & 52 deletions Detector/DetFCChhTrackerTkLayout/src/TkLayoutBarrel_Geo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
#include "DetCommon/DetUtils.h"

#include "Acts/Plugins/DD4hep/ActsExtension.hpp"
#include "Acts/Plugins/DD4hep/IActsExtension.hpp"
#include "Acts/Plugins/Digitization/CartesianSegmentation.hpp"
#include "Acts/Plugins/Digitization/DigitizationModule.hpp"
#include "Acts/Surfaces/PlanarBounds.hpp"
#include "Acts/Surfaces/RectangleBounds.hpp"
#include "Acts/Surfaces/TrapezoidBounds.hpp"
#include "Acts/Utilities/Units.hpp"

#include "DD4hep/DetFactoryHelper.h"

Expand All @@ -18,25 +16,6 @@ using dd4hep::PlacedVolume;

namespace det {

std::shared_ptr<const Acts::DigitizationModule>
rectangleDigiModuleXZ(double halflengthX, double halflengthZ, double thickness, double gridSizeX, double gridSizeZ) {
// convert to ACTS units
double scalor = Acts::units::_cm;
halflengthX *= scalor;
halflengthZ *= scalor;
thickness *= scalor;
auto bounds = std::make_shared<const Acts::RectangleBounds>(halflengthX, halflengthZ);
// the Acts segmentation of the DigitizationModule
size_t bins0 = (gridSizeX != 0) ? (2 * halflengthX) / (gridSizeX * scalor) : 0;
size_t bins1 = (gridSizeZ != 0) ? (2 * halflengthZ) / (gridSizeZ * scalor) : 0;

std::shared_ptr<const Acts::CartesianSegmentation> actsSegmentation =
std::make_shared<const Acts::CartesianSegmentation>(bounds, bins0, bins1);

// finally create the digitization module
// @todo set lorentz angle
return (std::make_shared<const Acts::DigitizationModule>(actsSegmentation, thickness, 1, 0));
};

static dd4hep::Ref_t createTkLayoutTrackerBarrel(dd4hep::Detector& lcdd,
dd4hep::xml::Handle_t xmlElement,
Expand All @@ -53,11 +32,10 @@ static dd4hep::Ref_t createTkLayoutTrackerBarrel(dd4hep::Detector& lcdd,
// has min/max dimensions of tracker for visualization etc.
std::string detectorName = xmlDet.nameStr();
DetElement topDetElement(detectorName, xmlDet.id());
Acts::ActsExtension::Config barrelConfig;
barrelConfig.isBarrel = true;
// detElement owns extension
Acts::ActsExtension* detWorldExt = new Acts::ActsExtension(barrelConfig);
topDetElement.addExtension<Acts::IActsExtension>(detWorldExt);
Acts::ActsExtension* detWorldExt = new Acts::ActsExtension();
detWorldExt->addType("barrel", "detector");
topDetElement.addExtension<Acts::ActsExtension>(detWorldExt);
dd4hep::Tube topVolumeShape(dimensions.rmin(), dimensions.rmax(), (dimensions.zmax() - dimensions.zmin()) * 0.5);
Volume topVolume(detectorName, topVolumeShape, lcdd.air());
topVolume.setVisAttributes(lcdd.invisible());
Expand All @@ -83,29 +61,17 @@ static dd4hep::Ref_t createTkLayoutTrackerBarrel(dd4hep::Detector& lcdd,
PlacedVolume placedLayerVolume = topVolume.placeVolume(layerVolume);
placedLayerVolume.addPhysVolID("layer", layerCounter);
DetElement lay_det(topDetElement, "layer" + std::to_string(layerCounter), layerCounter);
Acts::ActsExtension::Config layConfig;
layConfig.isLayer = true;
// the local coordinate systems of modules in dd4hep and acts differ
// see http://acts.web.cern.ch/ACTS/latest/doc/group__DD4hepPlugins.html
layConfig.axes = "XzY"; // correct translation of local x axis in dd4hep to local x axis in acts
// detElement owns extension
Acts::ActsExtension* layerExtension = new Acts::ActsExtension(layConfig);
lay_det.addExtension<Acts::IActsExtension>(layerExtension);
Acts::ActsExtension* layerExtension = new Acts::ActsExtension();
layerExtension->addType("sensitive cylinder", "layer");
layerExtension->addType("axes", "definitions", "XzY");
lay_det.addExtension<Acts::ActsExtension>(layerExtension);
lay_det.setPlacement(placedLayerVolume);
dd4hep::xml::Component xModuleComponentsOdd = xModulePropertiesOdd.child("components");
integratedModuleComponentThickness = 0;
int moduleCounter = 0;
Volume moduleVolume;
// store the materials of each tracking module for tracking geometry
std::vector<std::pair<dd4hep::Material, double>> compMaterials;
// go through all components to collect the material to later attach it to the modoule
for (dd4hep::xml::Collection_t xModuleComponentOddColl(xModuleComponentsOdd, _U(component));
nullptr != xModuleComponentOddColl;
++xModuleComponentOddColl) {
dd4hep::xml::Component xModuleComponentOdd = static_cast<dd4hep::xml::Component>(xModuleComponentOddColl);
compMaterials.push_back(
std::make_pair(lcdd.material(xModuleComponentOdd.materialStr()), xModuleComponentOdd.thickness()));
}

for (dd4hep::xml::Collection_t xModuleComponentOddColl(xModuleComponentsOdd, _U(component));
nullptr != xModuleComponentOddColl;
Expand All @@ -119,10 +85,6 @@ static dd4hep::Ref_t createTkLayoutTrackerBarrel(dd4hep::Detector& lcdd,
dd4hep::Box(moduleWidth, moduleThickness, moduleLength),
lcdd.material(xModuleComponentOdd.materialStr()));

// Create digitization module
// with readout given by layer
auto digiModule = rectangleDigiModuleXZ(moduleWidth, moduleLength, moduleThickness, 0.025, 0.05);

moduleVolume.setVisAttributes(lcdd.invisible());
unsigned int nPhi = xRods.repeat();
for (unsigned int phiIndex = 0; phiIndex < nPhi; phiIndex += 2) {
Expand All @@ -131,7 +93,6 @@ static dd4hep::Ref_t createTkLayoutTrackerBarrel(dd4hep::Detector& lcdd,
double lZ = 0;
for (auto currentComp : rodLists) {
if (currentComp.ptr()) {

phi = 2 * M_PI * static_cast<double>(phiIndex) / static_cast<double>(nPhi);
for (dd4hep::xml::Collection_t xModuleColl(currentComp.child(_Unicode(modules)), _U(module));
nullptr != xModuleColl;
Expand All @@ -141,8 +102,8 @@ static dd4hep::Ref_t createTkLayoutTrackerBarrel(dd4hep::Detector& lcdd,
double componentOffset = integratedModuleComponentThickness -
0.5 * xModulePropertiesOdd.attr<double>("modThickness") + 0.5 * xModuleComponentOdd.thickness();
dd4hep::Translation3D offsetOnly(cos(currentPhi) * componentOffset, sin(currentPhi) * componentOffset, 0);
lX = xModule.X(); // + cos(currentPhi) * componentOffset;
lY = xModule.Y(); // + sin(currentPhi) * componentOffset;
lX = xModule.X();
lY = xModule.Y();
lZ = xModule.Z();
dd4hep::Translation3D moduleOffset(lX, lY, lZ);
dd4hep::Transform3D lTrafo(dd4hep::RotationZ(atan2(lY, lX) + 0.5 * M_PI), moduleOffset);
Expand All @@ -156,9 +117,8 @@ static dd4hep::Ref_t createTkLayoutTrackerBarrel(dd4hep::Detector& lcdd,
moduleVolume.setSensitiveDetector(sensDet);
DetElement mod_det(lay_det, "module" + std::to_string(moduleCounter), moduleCounter);

// add extension to hand over material
Acts::ActsExtension* moduleExtension = new Acts::ActsExtension(compMaterials, digiModule);
mod_det.addExtension<Acts::IActsExtension>(moduleExtension);
Acts::ActsExtension* moduleExtension = new Acts::ActsExtension();
mod_det.addExtension<Acts::ActsExtension>(moduleExtension);

mod_det.setPlacement(placedModuleVolume);
++moduleCounter;
Expand Down
70 changes: 12 additions & 58 deletions Detector/DetFCChhTrackerTkLayout/src/TkLayoutEndcap_Geo.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@

#include "DD4hep/DetFactoryHelper.h"
#include "DetCommon/DetUtils.h"

#include "DD4hep/DetFactoryHelper.h"
#include "Acts/Plugins/DD4hep/ActsExtension.hpp"
#include "Acts/Plugins/DD4hep/IActsExtension.hpp"
#include "Acts/Plugins/Digitization/CartesianSegmentation.hpp"
#include "Acts/Plugins/Digitization/DigitizationModule.hpp"
#include "Acts/Surfaces/TrapezoidBounds.hpp"

using dd4hep::Volume;
using dd4hep::DetElement;
Expand All @@ -16,31 +11,6 @@ using dd4hep::PlacedVolume;

namespace det {

inline std::shared_ptr<const Acts::DigitizationModule> trapezoidalDigiModuleXZ(double minHalflengthX,
double maxHalflengthX,
double halflengthZ,
double thickness,
double gridSizeX,
double gridSizeZ) {
// convert to ACTS units
double scalor = Acts::units::_cm;
minHalflengthX *= scalor;
maxHalflengthX *= scalor;
halflengthZ *= scalor;
thickness *= scalor;

auto bounds = std::make_shared<const Acts::TrapezoidBounds>(minHalflengthX, maxHalflengthX, halflengthZ);

// the Acts segmentation of the DigitizationModule
size_t bins0 = (gridSizeX != 0) ? (2 * maxHalflengthX) / (gridSizeX * scalor) : 0;
size_t bins1 = (gridSizeZ != 0) ? (2 * halflengthZ) / (gridSizeZ * scalor) : 0;

std::shared_ptr<const Acts::CartesianSegmentation> actsSegmentation =
std::make_shared<const Acts::CartesianSegmentation>(bounds, bins0, bins1);
// finally create the digitization module
// @todo set lorentz angle
return (std::make_shared<const Acts::DigitizationModule>(actsSegmentation, thickness, 1, 0));
};

static dd4hep::Ref_t createTkLayoutTrackerEndcap(dd4hep::Detector& lcdd,
dd4hep::xml::Handle_t xmlElement,
Expand All @@ -58,11 +28,11 @@ static dd4hep::Ref_t createTkLayoutTrackerEndcap(dd4hep::Detector& lcdd,
std::string detName = xmlDet.nameStr();
DetElement worldDetElement(detName, xmlDet.id());
DetElement posEcapDetElement(worldDetElement, "posEndcap", 0);
Acts::ActsExtension* ecapDetExt = new Acts::ActsExtension();
ecapDetExt->addType("endcap", "detector");
posEcapDetElement.addExtension<Acts::ActsExtension>(ecapDetExt);


Acts::ActsExtension::Config actsEcapConfig;
actsEcapConfig.isEndcap = true;
Acts::ActsExtension* ecapDetExt = new Acts::ActsExtension(actsEcapConfig);
posEcapDetElement.addExtension<Acts::IActsExtension>(ecapDetExt);

dd4hep::Assembly envelopeVolume("endcapEnvelope");
envelopeVolume.setVisAttributes(lcdd.invisible());
Expand Down Expand Up @@ -91,13 +61,13 @@ static dd4hep::Ref_t createTkLayoutTrackerEndcap(dd4hep::Detector& lcdd,

discVolumeVec.emplace_back("disc", discShape, lcdd.air());
discDetElementVec.emplace_back(posEcapDetElement, "disc" + std::to_string(discCounter), discCounter);
Acts::ActsExtension::Config layConfig;
Acts::ActsExtension* detlayer = new Acts::ActsExtension();
detlayer->addType("sensitive disk", "layer");
// the local coordinate systems of modules in dd4hep and acts differ
// see http://acts.web.cern.ch/ACTS/latest/doc/group__DD4hepPlugins.html
layConfig.axes = "XZY"; // correct translation of local x axis in dd4hep to local x axis in acts
layConfig.isLayer = true;
Acts::ActsExtension* detlayer = new Acts::ActsExtension(layConfig);
discDetElementVec.back().addExtension<Acts::IActsExtension>(detlayer);
detlayer->addType("axes", "definitions", "XZY");
discDetElementVec.back().addExtension<Acts::ActsExtension>(detlayer);

// iterate over rings
for (dd4hep::xml::Collection_t xRingColl(xCurrentRings, _U(ring)); (nullptr != xRingColl); ++xRingColl) {
Component xRing = static_cast<Component>(xRingColl);
Expand All @@ -108,13 +78,6 @@ static dd4hep::Ref_t createTkLayoutTrackerEndcap(dd4hep::Detector& lcdd,
Component xModulePropertiesComp = xModuleProperties.child(_Unicode(components));
Component xSensorProperties = xRing.child(_Unicode(sensorProperties));

// store component materials for Acts Extension
std::vector<std::pair<dd4hep::Material, double>> compMaterials;
for (dd4hep::xml::Collection_t xCompColl(xModulePropertiesComp, _U(component)); nullptr != xCompColl;
++xCompColl) {
dd4hep::xml::Component xComp = static_cast<Component>(xCompColl);
compMaterials.push_back(std::make_pair(lcdd.material(xComp.materialStr()), xComp.thickness()));
}

// place components in module
double integratedCompThickness = 0.;
Expand All @@ -130,10 +93,6 @@ static dd4hep::Ref_t createTkLayoutTrackerEndcap(dd4hep::Detector& lcdd,
"component",
dd4hep::Trapezoid(compMinWidth, compMaxWidth, compThickness, compThickness, compLength),
lcdd.material(xComp.materialStr()));

// Create digitization module
auto digiModule = trapezoidalDigiModuleXZ(compMinWidth, compMaxWidth, compLength, compThickness, 0.025, 0.05);

componentVolume.setVisAttributes(lcdd.invisible());
unsigned int nPhi = xRing.attr<int>("nModules");
double phi = 0;
Expand Down Expand Up @@ -181,15 +140,10 @@ static dd4hep::Ref_t createTkLayoutTrackerEndcap(dd4hep::Detector& lcdd,
componentVolume.setSensitiveDetector(sensDet);
DetElement moduleDetElement(discDetElementVec.back(), "comp" + std::to_string(compCounter), compCounter);

Acts::ActsExtension* moduleExtension = new Acts::ActsExtension(compMaterials, digiModule);
moduleDetElement.addExtension<Acts::IActsExtension>(moduleExtension);
Acts::ActsExtension* moduleExtension = new Acts::ActsExtension();
moduleDetElement.addExtension<Acts::ActsExtension>(moduleExtension);

moduleDetElement.setPlacement(placedComponentVolume);

// Acts extension with material information
// Acts::ActsExtension* moduleExtension = new Acts::ActsExtension(compMaterials);
// moduleDetElement.addExtension<Acts::IActsExtension>(moduleExtension);

++compCounter;
}
}
Expand Down
14 changes: 7 additions & 7 deletions Generation/src/components/PythiaInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,17 @@ StatusCode PythiaInterface::initialize() {
scheme = 0;
}

m_setting = std::make_shared<Pythia8::amcnlo_unitarised_interface>(scheme);
m_pythiaSignal->addUserHooksPtr(m_setting);
m_setting = std::unique_ptr<Pythia8::amcnlo_unitarised_interface>(new Pythia8::amcnlo_unitarised_interface(scheme));
m_pythiaSignal->setUserHooksPtr(m_setting.get());
}

// For jet matching, initialise the respective user hooks code.
if (m_doMePsMatching) {
m_matching = std::make_shared<Pythia8::JetMatchingMadgraph>();
if (nullptr == m_matching) {
m_matching = std::unique_ptr<Pythia8::JetMatchingMadgraph>(new Pythia8::JetMatchingMadgraph());
if (!m_matching) {
return Error(" Failed to initialise jet matching structures.");
}
m_pythiaSignal->addUserHooksPtr(m_matching);
m_pythiaSignal->setUserHooksPtr(m_matching.get());
}

// jet clustering needed for matching
Expand Down Expand Up @@ -142,12 +142,12 @@ StatusCode PythiaInterface::initialize() {


m_powhegHooks = std::make_shared<Pythia8::PowhegHooks>();
m_pythiaSignal->addUserHooksPtr(m_powhegHooks);
m_pythiaSignal->addUserHooksPtr(m_powhegHooks.get());
}
bool resonanceDecayFilter = m_pythiaSignal->settings.flag("ResonanceDecayFilter:filter");
if (resonanceDecayFilter) {
m_resonanceDecayFilterHook = std::make_shared<ResonanceDecayFilterHook>();
m_pythiaSignal->addUserHooksPtr(m_resonanceDecayFilterHook);
m_pythiaSignal->addUserHooksPtr(m_resonanceDecayFilterHook.get());
}

m_pythiaSignal->init();
Expand Down
6 changes: 3 additions & 3 deletions Generation/src/components/PythiaInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class PythiaInterface : public GaudiTool, virtual public IHepMCProviderTool {
bool m_doMePsMatching{false};
bool m_doMePsMerging{false};
/// Pythia8 engine for ME/PS matching
std::shared_ptr<Pythia8::JetMatchingMadgraph> m_matching{nullptr};
/// Pythia8 engine for aMCNLO ME/PS merging
std::shared_ptr<Pythia8::amcnlo_unitarised_interface> m_setting{nullptr};
std::unique_ptr<Pythia8::JetMatchingMadgraph> m_matching{nullptr};
/// Pythia8 engine for NLO ME/PS merging
std::unique_ptr<Pythia8::amcnlo_unitarised_interface> m_setting{nullptr};

// Powheg
bool m_doPowheg{false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
vertex = "GenVertices",
nPhiOptimFinal = [7]*8,
nEtaOptimFinal = [19]*8,
noiseFileName = "/eos/project/f/fccsw-web/testsamples/elecNoise_pileup_cluster_mu200_700files.root")
noiseFileName = "root://eospublic.cern.ch//eos/experiment/fcc/hh/testsamples/elecNoise_pileup_cluster_mu200_700files.root")

THistSvc().Output = ["rec DATAFILE='clusterCorrections_histograms.root' TYP='ROOT' OPT='RECREATE'"]
THistSvc().PrintAll=True
Expand Down
Loading

0 comments on commit 1de09f2

Please sign in to comment.