Skip to content

Commit

Permalink
Do not use GaudiAlg (#38)
Browse files Browse the repository at this point in the history
* Do not use GaudiAlg, use Gaudi::Algorithm instead

These are the initial changes that are necessary to get rid
of GaudiAlg.

* Don't link to GaudiAlgLib, add a few mutables

* Fix typo

* Remove unrelated formatting changes

---------

Co-authored-by: jmcarcell <[email protected]>
  • Loading branch information
jmcarcell and jmcarcell authored Jul 30, 2024
1 parent b87c867 commit 47c8390
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 63 deletions.
1 change: 0 additions & 1 deletion DRdigi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ gaudi_add_module(DRdigi
LINK
EDM4HEP::edm4hep
sipm::sipm
Gaudi::GaudiAlgLib
Gaudi::GaudiKernel
k4FWCore::k4FWCore
)
Expand Down
14 changes: 7 additions & 7 deletions DRdigi/include/DigiSiPM.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@

#include "k4FWCore/DataHandle.h"

#include "GaudiAlg/GaudiAlgorithm.h"
#include "Gaudi/Algorithm.h"
#include "GaudiKernel/ToolHandle.h"

#include "SiPMSensor.h"

class DigiSiPM : public GaudiAlgorithm {
class DigiSiPM : public Gaudi::Algorithm {
public:
DigiSiPM(const std::string& name, ISvcLocator* svcLoc);
virtual ~DigiSiPM() {};

StatusCode initialize();
StatusCode execute();
StatusCode execute(const EventContext&) const;
StatusCode finalize();

private:
DataHandle<edm4hep::RawCalorimeterHitCollection> m_rawHits{"RawCalorimeterHits", Gaudi::DataHandle::Reader, this};
DataHandle<edm4hep::RawTimeSeriesCollection> m_timeStruct{"RawTimeStructs", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::RawCalorimeterHitCollection> m_rawHits{"RawCalorimeterHits", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::RawTimeSeriesCollection> m_timeStruct{"RawTimeStructs", Gaudi::DataHandle::Reader, this};

DataHandle<edm4hep::CalorimeterHitCollection> m_digiHits{"DigiCalorimeterHits", Gaudi::DataHandle::Writer, this};
DataHandle<edm4hep::TimeSeriesCollection> m_waveforms{"DigiWaveforms", Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_digiHits{"DigiCalorimeterHits", Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::TimeSeriesCollection> m_waveforms{"DigiWaveforms", Gaudi::DataHandle::Writer, this};

std::unique_ptr<sipm::SiPMSensor> m_sensor;

Expand Down
8 changes: 4 additions & 4 deletions DRdigi/src/DigiSiPM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

DECLARE_COMPONENT(DigiSiPM)

DigiSiPM::DigiSiPM(const std::string& aName, ISvcLocator* aSvcLoc) : GaudiAlgorithm(aName, aSvcLoc) {}
DigiSiPM::DigiSiPM(const std::string& aName, ISvcLocator* aSvcLoc) : Gaudi::Algorithm(aName, aSvcLoc) {}

StatusCode DigiSiPM::initialize() {
StatusCode sc = GaudiAlgorithm::initialize();
StatusCode sc = Gaudi::Algorithm::initialize();

if (sc.isFailure()) return sc;

Expand All @@ -32,7 +32,7 @@ StatusCode DigiSiPM::initialize() {
return StatusCode::SUCCESS;
}

StatusCode DigiSiPM::execute() {
StatusCode DigiSiPM::execute(const EventContext&) const {
const edm4hep::RawTimeSeriesCollection* timeStructs = m_timeStruct.get();
const edm4hep::RawCalorimeterHitCollection* rawHits = m_rawHits.get();

Expand Down Expand Up @@ -104,5 +104,5 @@ StatusCode DigiSiPM::execute() {
}

StatusCode DigiSiPM::finalize() {
return GaudiAlgorithm::finalize();
return Gaudi::Algorithm::finalize();
}
1 change: 0 additions & 1 deletion DRreco/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ gaudi_add_module(DRreco
LINK
EDM4HEP::edm4hep
DRsegmentation
Gaudi::GaudiAlgLib
Gaudi::GaudiKernel
k4FWCore::k4FWCore
CLHEP::CLHEP
Expand Down
14 changes: 7 additions & 7 deletions DRreco/include/DRcalib2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "k4FWCore/DataHandle.h"

#include "GaudiAlg/GaudiAlgorithm.h"
#include "Gaudi/Algorithm.h"
#include "GaudiKernel/ToolHandle.h"

#include "edm4hep/CalorimeterHitCollection.h"
Expand All @@ -13,26 +13,26 @@

class IGeoSvc;

class DRcalib2D : public GaudiAlgorithm {
class DRcalib2D : public Gaudi::Algorithm {
public:
DRcalib2D(const std::string& name, ISvcLocator* svcLoc);
virtual ~DRcalib2D() {};

StatusCode initialize();
StatusCode execute();
StatusCode execute(const EventContext&) const;
StatusCode finalize();

void readCSV(std::string filename);

private:
edm4hep::Vector3f getPosition(dd4hep::DDSegmentation::CellID& cID);
edm4hep::Vector3f getPosition(dd4hep::DDSegmentation::CellID& cID) const;

ServiceHandle<IGeoSvc> m_geoSvc;
dd4hep::DDSegmentation::GridDRcalo* pSeg;
dd4hep::DDSegmentation::DRparamBase* pParamBase;
mutable dd4hep::DDSegmentation::DRparamBase* pParamBase;

DataHandle<edm4hep::CalorimeterHitCollection> m_digiHits{"DigiCalorimeterHits", Gaudi::DataHandle::Reader, this};
DataHandle<edm4hep::CalorimeterHitCollection> m_caloHits{"DRcalo2dHits", Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_digiHits{"DigiCalorimeterHits", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_caloHits{"DRcalo2dHits", Gaudi::DataHandle::Writer, this};

Gaudi::Property<std::string> m_calibPath{this, "calibPath", "share/calib.csv", "relative path to calibration csv file"};
Gaudi::Property<std::string> m_readoutName{this, "readoutName", "DRcaloSiPMreadout", "readout name of DRcalo"};
Expand Down
20 changes: 10 additions & 10 deletions DRreco/include/DRcalib3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "k4FWCore/DataHandle.h"

#include "GaudiAlg/GaudiAlgorithm.h"
#include "Gaudi/Algorithm.h"
#include "GaudiKernel/ToolHandle.h"

#include "edm4hep/CalorimeterHitCollection.h"
Expand All @@ -15,29 +15,29 @@
class TH1D;
class IGeoSvc;

class DRcalib3D : public GaudiAlgorithm {
class DRcalib3D : public Gaudi::Algorithm {
public:
DRcalib3D(const std::string& name, ISvcLocator* svcLoc);
virtual ~DRcalib3D() {};

StatusCode initialize();
StatusCode execute();
StatusCode execute(const EventContext&) const;
StatusCode finalize();

TH1* processFFT(TH1* waveHist);
TH1* processFFT(TH1* waveHist) const;

private:
ServiceHandle<IGeoSvc> m_geoSvc;
dd4hep::DDSegmentation::GridDRcalo* pSeg;
dd4hep::DDSegmentation::DRparamBase* pParamBase;
mutable dd4hep::DDSegmentation::DRparamBase* pParamBase;
std::unique_ptr<TH1D> m_veloC;
std::unique_ptr<TH1D> m_veloS;

DataHandle<edm4hep::CalorimeterHitCollection> m_digiHits{"DigiCalorimeterHits", Gaudi::DataHandle::Reader, this};
DataHandle<edm4hep::TimeSeriesCollection> m_waveforms{"DigiWaveforms", Gaudi::DataHandle::Reader, this};
DataHandle<edm4hep::CalorimeterHitCollection> m_2dHits{"DRcalo2dHits", Gaudi::DataHandle::Reader, this};
DataHandle<edm4hep::CalorimeterHitCollection> m_caloHits{"DRcalo3dHits", Gaudi::DataHandle::Writer, this};
DataHandle<edm4hep::TimeSeriesCollection> m_postprocTime{"DRpostprocTime", Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_digiHits{"DigiCalorimeterHits", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::TimeSeriesCollection> m_waveforms{"DigiWaveforms", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_2dHits{"DRcalo2dHits", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_caloHits{"DRcalo3dHits", Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::TimeSeriesCollection> m_postprocTime{"DRpostprocTime", Gaudi::DataHandle::Writer, this};

Gaudi::Property<std::string> m_readoutName{this, "readoutName", "DRcaloSiPMreadout", "readout name of DRcalo"};
Gaudi::Property<std::string> m_veloFile{this, "veloFile", "share/velo.root", "velocity profile file name"};
Expand Down
10 changes: 5 additions & 5 deletions DRreco/src/DRcalib2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

DECLARE_COMPONENT(DRcalib2D)

DRcalib2D::DRcalib2D(const std::string& aName, ISvcLocator* aSvcLoc) : GaudiAlgorithm(aName, aSvcLoc), m_geoSvc("GeoSvc", aName) {
DRcalib2D::DRcalib2D(const std::string& aName, ISvcLocator* aSvcLoc) : Gaudi::Algorithm(aName, aSvcLoc), m_geoSvc("GeoSvc", aName) {
declareProperty("GeoSvc", m_geoSvc);

pSeg = nullptr;
pParamBase = nullptr;
}

StatusCode DRcalib2D::initialize() {
StatusCode sc = GaudiAlgorithm::initialize();
StatusCode sc = Gaudi::Algorithm::initialize();

if (sc.isFailure()) return sc;

Expand All @@ -40,7 +40,7 @@ StatusCode DRcalib2D::initialize() {
return StatusCode::SUCCESS;
}

StatusCode DRcalib2D::execute() {
StatusCode DRcalib2D::execute(const EventContext&) const {
const edm4hep::CalorimeterHitCollection* digiHits = m_digiHits.get();
edm4hep::CalorimeterHitCollection* caloHits = m_caloHits.createAndPut();

Expand Down Expand Up @@ -70,10 +70,10 @@ StatusCode DRcalib2D::execute() {
StatusCode DRcalib2D::finalize() {
m_calibs.clear();

return GaudiAlgorithm::finalize();
return Gaudi::Algorithm::finalize();
}

edm4hep::Vector3f DRcalib2D::getPosition(dd4hep::DDSegmentation::CellID& cID) {
edm4hep::Vector3f DRcalib2D::getPosition(dd4hep::DDSegmentation::CellID& cID) const {
auto globalPos = pSeg->position( cID );
return { static_cast<float>( globalPos.x() * CLHEP::millimeter/dd4hep::millimeter ),
static_cast<float>( globalPos.y() * CLHEP::millimeter/dd4hep::millimeter ),
Expand Down
10 changes: 5 additions & 5 deletions DRreco/src/DRcalib3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

DECLARE_COMPONENT(DRcalib3D)

DRcalib3D::DRcalib3D(const std::string& aName, ISvcLocator* aSvcLoc) : GaudiAlgorithm(aName, aSvcLoc), m_geoSvc("GeoSvc", aName) {
DRcalib3D::DRcalib3D(const std::string& aName, ISvcLocator* aSvcLoc) : Gaudi::Algorithm(aName, aSvcLoc), m_geoSvc("GeoSvc", aName) {
declareProperty("GeoSvc", m_geoSvc);

pSeg = nullptr;
pParamBase = nullptr;
}

StatusCode DRcalib3D::initialize() {
StatusCode sc = GaudiAlgorithm::initialize();
StatusCode sc = Gaudi::Algorithm::initialize();

if (sc.isFailure()) return sc;

Expand All @@ -44,7 +44,7 @@ StatusCode DRcalib3D::initialize() {
return StatusCode::SUCCESS;
}

StatusCode DRcalib3D::execute() {
StatusCode DRcalib3D::execute(const EventContext&) const {
const edm4hep::CalorimeterHitCollection* digiHits = m_digiHits.get();
const edm4hep::CalorimeterHitCollection* hits2d = m_2dHits.get();
const edm4hep::TimeSeriesCollection* waveforms = m_waveforms.get();
Expand Down Expand Up @@ -162,9 +162,9 @@ StatusCode DRcalib3D::execute() {
return StatusCode::SUCCESS;
}

StatusCode DRcalib3D::finalize() { return GaudiAlgorithm::finalize(); }
StatusCode DRcalib3D::finalize() { return Gaudi::Algorithm::finalize(); }

TH1* DRcalib3D::processFFT(TH1* waveHist) {
TH1* DRcalib3D::processFFT(TH1* waveHist) const {
int firstBin = waveHist->FindFirstBinAbove( m_zero.value()*waveHist->GetMaximum() );
int lastBin = firstBin;

Expand Down
1 change: 0 additions & 1 deletion DRsim/DRsimG4Components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ file(GLOB headers
gaudi_add_module(DRsimG4Components
SOURCES ${sources}
LINK
Gaudi::GaudiAlgLib
Gaudi::GaudiKernel
k4FWCore::k4FWCore
EDM4HEP::edm4hep
Expand Down
10 changes: 5 additions & 5 deletions DRsim/DRsimG4Components/include/SimG4SaveDRcaloHits.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
#include "edm4hep/RawCalorimeterHitCollection.h"
#include "edm4hep/RawTimeSeriesCollection.h"

#include "GaudiAlg/GaudiTool.h"
#include "GaudiKernel/AlgTool.h"
#include "k4FWCore/DataHandle.h"
#include "k4Interface/ISimG4SaveOutputTool.h"
#include "k4Interface/IGeoSvc.h"

class IGeoSvc;

class SimG4SaveDRcaloHits : public GaudiTool, virtual public ISimG4SaveOutputTool {
class SimG4SaveDRcaloHits : public AlgTool, virtual public ISimG4SaveOutputTool {
public:
explicit SimG4SaveDRcaloHits(const std::string& aType, const std::string& aName, const IInterface* aParent);
virtual ~SimG4SaveDRcaloHits();
Expand All @@ -30,9 +30,9 @@ class SimG4SaveDRcaloHits : public GaudiTool, virtual public ISimG4SaveOutputToo

Gaudi::Property<std::vector<std::string>> m_readoutNames{this, "readoutNames", {"DRcaloSiPMreadout"}, "Name of the readouts (hits collections) to save"};

DataHandle<edm4hep::RawCalorimeterHitCollection> mRawCaloHits{"RawCalorimeterHits", Gaudi::DataHandle::Writer, this};
DataHandle<edm4hep::RawTimeSeriesCollection> mTimeStruct{"RawTimeStructs", Gaudi::DataHandle::Writer, this};
DataHandle<edm4hep::RawTimeSeriesCollection> mWavlenStruct{"RawWavlenStructs", Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::RawCalorimeterHitCollection> mRawCaloHits{"RawCalorimeterHits", Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::RawTimeSeriesCollection> mTimeStruct{"RawTimeStructs", Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::RawTimeSeriesCollection> mWavlenStruct{"RawWavlenStructs", Gaudi::DataHandle::Writer, this};
};

#endif
10 changes: 5 additions & 5 deletions DRsim/DRsimG4Components/include/SimG4SaveDRcaloMCTruth.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "edm4hep/MCParticleCollection.h"
#include "edm4hep/SimCalorimeterHitCollection.h"

#include "GaudiAlg/GaudiTool.h"
#include "GaudiKernel/AlgTool.h"
#include "k4FWCore/DataHandle.h"
#include "k4Interface/ISimG4Svc.h"
#include "k4Interface/ISimG4SaveOutputTool.h"
Expand All @@ -14,7 +14,7 @@

class IGeoSvc;

class SimG4SaveDRcaloMCTruth : public GaudiTool, virtual public ISimG4SaveOutputTool {
class SimG4SaveDRcaloMCTruth : public AlgTool, virtual public ISimG4SaveOutputTool {
public:
explicit SimG4SaveDRcaloMCTruth(const std::string& aType, const std::string& aName, const IInterface* aParent);
virtual ~SimG4SaveDRcaloMCTruth();
Expand All @@ -25,9 +25,9 @@ class SimG4SaveDRcaloMCTruth : public GaudiTool, virtual public ISimG4SaveOutput
virtual StatusCode saveOutput(const G4Event& aEvent) final;

private:
DataHandle<edm4hep::SimCalorimeterHitCollection> m_Edeps{"SimCalorimeterHits", Gaudi::DataHandle::Writer, this};
DataHandle<edm4hep::SimCalorimeterHitCollection> m_Edeps3d{"Sim3dCalorimeterHits", Gaudi::DataHandle::Writer, this};
DataHandle<edm4hep::MCParticleCollection> m_Leakages{"Leakages", Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::SimCalorimeterHitCollection> m_Edeps{"SimCalorimeterHits", Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::SimCalorimeterHitCollection> m_Edeps3d{"Sim3dCalorimeterHits", Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::MCParticleCollection> m_Leakages{"Leakages", Gaudi::DataHandle::Writer, this};

drc::SimG4DRcaloEventAction* m_eventAction;

Expand Down
6 changes: 3 additions & 3 deletions DRsim/DRsimG4Components/src/SimG4SaveDRcaloHits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
DECLARE_COMPONENT(SimG4SaveDRcaloHits)

SimG4SaveDRcaloHits::SimG4SaveDRcaloHits(const std::string& aType, const std::string& aName, const IInterface* aParent)
: GaudiTool(aType, aName, aParent), m_geoSvc("GeoSvc", aName) {
: AlgTool(aType, aName, aParent), m_geoSvc("GeoSvc", aName) {
declareInterface<ISimG4SaveOutputTool>(this);
}

SimG4SaveDRcaloHits::~SimG4SaveDRcaloHits() {}

StatusCode SimG4SaveDRcaloHits::initialize() {
if (GaudiTool::initialize().isFailure())
if (AlgTool::initialize().isFailure())
return StatusCode::FAILURE;

if (!m_geoSvc) {
Expand All @@ -39,7 +39,7 @@ StatusCode SimG4SaveDRcaloHits::initialize() {
return StatusCode::SUCCESS;
}

StatusCode SimG4SaveDRcaloHits::finalize() { return GaudiTool::finalize(); }
StatusCode SimG4SaveDRcaloHits::finalize() { return AlgTool::finalize(); }

StatusCode SimG4SaveDRcaloHits::saveOutput(const G4Event& aEvent) {
G4HCofThisEvent* collections = aEvent.GetHCofThisEvent();
Expand Down
6 changes: 3 additions & 3 deletions DRsim/DRsimG4Components/src/SimG4SaveDRcaloMCTruth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
DECLARE_COMPONENT(SimG4SaveDRcaloMCTruth)

SimG4SaveDRcaloMCTruth::SimG4SaveDRcaloMCTruth(const std::string& aType, const std::string& aName, const IInterface* aParent)
: GaudiTool(aType, aName, aParent), m_geantSvc("SimG4Svc", aName) {
: AlgTool(aType, aName, aParent), m_geantSvc("SimG4Svc", aName) {
declareInterface<ISimG4SaveOutputTool>(this);
}

SimG4SaveDRcaloMCTruth::~SimG4SaveDRcaloMCTruth() {}

StatusCode SimG4SaveDRcaloMCTruth::initialize() {
if (GaudiTool::initialize().isFailure())
if (AlgTool::initialize().isFailure())
return StatusCode::FAILURE;

if (!m_geantSvc) {
Expand All @@ -33,7 +33,7 @@ StatusCode SimG4SaveDRcaloMCTruth::initialize() {
return StatusCode::SUCCESS;
}

StatusCode SimG4SaveDRcaloMCTruth::finalize() { return GaudiTool::finalize(); }
StatusCode SimG4SaveDRcaloMCTruth::finalize() { return AlgTool::finalize(); }

StatusCode SimG4SaveDRcaloMCTruth::saveOutput(const G4Event&) {
auto* edeps = m_eventAction->getEdepsCollection();
Expand Down
1 change: 0 additions & 1 deletion DRsim/DRsimG4Fast/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ file(GLOB headers
gaudi_add_module(DRsimG4Fast
SOURCES ${sources}
LINK
Gaudi::GaudiAlgLib
Gaudi::GaudiKernel
k4FWCore::k4FWCore
${Geant4_LIBRARIES}
Expand Down
4 changes: 2 additions & 2 deletions DRsim/DRsimG4Fast/include/SimG4FastSimOpFiberRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

#include "G4LogicalVolume.hh"

#include "GaudiAlg/GaudiTool.h"
#include "GaudiKernel/AlgTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "k4Interface/ISimG4RegionTool.h"

// Geant
class G4VFastSimulationModel;
class G4Region;

class SimG4FastSimOpFiberRegion : public GaudiTool, virtual public ISimG4RegionTool {
class SimG4FastSimOpFiberRegion : public AlgTool, virtual public ISimG4RegionTool {
public:
explicit SimG4FastSimOpFiberRegion(const std::string& type, const std::string& name, const IInterface* parent);
virtual ~SimG4FastSimOpFiberRegion();
Expand Down
Loading

0 comments on commit 47c8390

Please sign in to comment.