Skip to content

Commit

Permalink
Do not use GaudiAlg
Browse files Browse the repository at this point in the history
- Change headers and add EventContext in algorithms not to use GaudiAlg
- Replace `GaudiTool` with `AlgTool`
  • Loading branch information
jmcarcell committed Jul 27, 2024
1 parent 05a64eb commit 59b1cb3
Show file tree
Hide file tree
Showing 43 changed files with 190 additions and 193 deletions.
1 change: 0 additions & 1 deletion RecCalorimeter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ gaudi_add_module(k4RecCalorimeterPlugins
SOURCES ${_module_sources}
LINK k4FWCore::k4FWCore
k4FWCore::k4Interface
Gaudi::GaudiAlgLib
Gaudi::GaudiKernel
DD4hep::DDCore
DD4hep::DDG4
Expand Down
8 changes: 4 additions & 4 deletions RecCalorimeter/src/components/CalibrateBenchmarkMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ DECLARE_COMPONENT(CalibrateBenchmarkMethod)


CalibrateBenchmarkMethod::CalibrateBenchmarkMethod(const std::string& aName, ISvcLocator* aSvcLoc)
: GaudiAlgorithm(aName, aSvcLoc),
: Gaudi::Algorithm(aName, aSvcLoc),
m_geoSvc("GeoSvc", aName),
m_histSvc("THistSvc", aName),
m_totalEnergyECal(nullptr),
Expand All @@ -43,7 +43,7 @@ CalibrateBenchmarkMethod::~CalibrateBenchmarkMethod() {}


StatusCode CalibrateBenchmarkMethod::initialize() {
if (GaudiAlgorithm::initialize().isFailure()) return StatusCode::FAILURE;
if (Gaudi::Algorithm::initialize().isFailure()) return StatusCode::FAILURE;

// Check geometry service
if (!m_geoSvc) {
Expand Down Expand Up @@ -102,7 +102,7 @@ StatusCode CalibrateBenchmarkMethod::initialize() {
}


StatusCode CalibrateBenchmarkMethod::execute() {
StatusCode CalibrateBenchmarkMethod::execute(const EventContext&) const {
double totalEnergyInECal = 0.;
double totalEnergyInHCal = 0.;
double energyInFirstLayerECal = 0;
Expand Down Expand Up @@ -253,7 +253,7 @@ StatusCode CalibrateBenchmarkMethod::finalize() {

runMinimization(n_param, variable, steps, m_fixedParameters);

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

void CalibrateBenchmarkMethod::registerHistogram(const std::string& path, TH1F*& histogramName) {
Expand Down
12 changes: 6 additions & 6 deletions RecCalorimeter/src/components/CalibrateBenchmarkMethod.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define RECCALORIMETER_CALIBRATEBENCHMARKMETHOD_H

// GAUDI
#include "GaudiAlg/GaudiAlgorithm.h"
#include "Gaudi/Algorithm.h"

// Key4HEP
#include "k4FWCore/DataHandle.h"
Expand Down Expand Up @@ -39,7 +39,7 @@ class ITHistSvc;
* @author Michaela Mlynarikova
*/

class CalibrateBenchmarkMethod : public GaudiAlgorithm {
class CalibrateBenchmarkMethod : public Gaudi::Algorithm {
public:
explicit CalibrateBenchmarkMethod(const std::string&, ISvcLocator*);
virtual ~CalibrateBenchmarkMethod();
Expand All @@ -50,7 +50,7 @@ class CalibrateBenchmarkMethod : public GaudiAlgorithm {
/** Fills the histograms.
* @return status code
*/
virtual StatusCode execute() final;
virtual StatusCode execute(const EventContext&) const final;
/** Finalize.
* @return status code
*/
Expand All @@ -68,9 +68,9 @@ class CalibrateBenchmarkMethod : public GaudiAlgorithm {
void runMinimization(int n_param, const std::vector<double>& variable, const std::vector<double>& steps, const std::vector<int>& fixedParameters) const;

/// Handle for electromagnetic barrel cells (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_ecalBarrelCells{"ecalBarrelCells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_ecalBarrelCells{"ecalBarrelCells", Gaudi::DataHandle::Reader, this};
/// Handle for hadronic barrel cells (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_hcalBarrelCells{"hcalBarrelCells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_hcalBarrelCells{"hcalBarrelCells", Gaudi::DataHandle::Reader, this};

/// Histogram of total deposited energy in the calorimeters
TH1F* m_totalEnergyECal;
Expand Down Expand Up @@ -116,4 +116,4 @@ class CalibrateBenchmarkMethod : public GaudiAlgorithm {
Gaudi::Property<std::vector<int>> m_fixedParameters = {this, "fixedParameters", {1,5},"Fixed parameters that will not be minimized"};

};
#endif /* RECCALORIMETER_CALIBRATEBENCHMARKMETHOD_H */
#endif /* RECCALORIMETER_CALIBRATEBENCHMARKMETHOD_H */
8 changes: 4 additions & 4 deletions RecCalorimeter/src/components/CaloTopoCluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

DECLARE_COMPONENT(CaloTopoCluster)

CaloTopoCluster::CaloTopoCluster(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) {
CaloTopoCluster::CaloTopoCluster(const std::string& name, ISvcLocator* svcLoc) : Gaudi::Algorithm(name, svcLoc) {
declareProperty("TopoClusterInput", m_inputTool, "Handle for input map of cells");
declareProperty("noiseTool", m_noiseTool, "Handle for the cells noise tool");
declareProperty("neigboursTool", m_neighboursTool, "Handle for tool to retrieve cell neighbours");
Expand All @@ -47,7 +47,7 @@ CaloTopoCluster::CaloTopoCluster(const std::string& name, ISvcLocator* svcLoc) :
declareProperty("clusterCells", m_clusterCellsCollection, "Handle for clusters (output collection)");
}
StatusCode CaloTopoCluster::initialize() {
if (GaudiAlgorithm::initialize().isFailure()) return StatusCode::FAILURE;
if (Gaudi::Algorithm::initialize().isFailure()) return StatusCode::FAILURE;
m_geoSvc = service("GeoSvc");
if (!m_geoSvc) {
error() << "Unable to locate Geometry Service. "
Expand Down Expand Up @@ -82,7 +82,7 @@ StatusCode CaloTopoCluster::initialize() {
return StatusCode::SUCCESS;
}

StatusCode CaloTopoCluster::execute() {
StatusCode CaloTopoCluster::execute(const EventContext&) const {

std::unordered_map<uint64_t, double> allCells;
std::vector<std::pair<uint64_t, double>> firstSeeds;
Expand Down Expand Up @@ -396,4 +396,4 @@ CaloTopoCluster::searchForNeighbours(const uint64_t aCellId,
return addedNeighbourIds;
}

StatusCode CaloTopoCluster::finalize() { return GaudiAlgorithm::finalize(); }
StatusCode CaloTopoCluster::finalize() { return Gaudi::Algorithm::finalize(); }
10 changes: 5 additions & 5 deletions RecCalorimeter/src/components/CaloTopoCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define RECCALORIMETER_CALOTOPOCLUSTER_H

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

// k4FWCore
Expand Down Expand Up @@ -42,7 +42,7 @@ class Segmentation;
* @author Coralie Neubueser
*/

class CaloTopoCluster : public GaudiAlgorithm {
class CaloTopoCluster : public Gaudi::Algorithm {
public:
CaloTopoCluster(const std::string& name, ISvcLocator* svcLoc);

Expand Down Expand Up @@ -88,15 +88,15 @@ class CaloTopoCluster : public GaudiAlgorithm {
std::map<uint, std::vector<std::pair<uint64_t, int>>>& aPreClusterCollection,
bool aAllowClusterMerge);

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

StatusCode finalize();

private:
// Cluster collection
DataHandle<edm4hep::ClusterCollection> m_clusterCollection{"calo/clusters", Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::ClusterCollection> m_clusterCollection{"calo/clusters", Gaudi::DataHandle::Writer, this};
// Cluster cells in collection
DataHandle<edm4hep::CalorimeterHitCollection> m_clusterCellsCollection{"calo/clusterCells", Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_clusterCellsCollection{"calo/clusterCells", Gaudi::DataHandle::Writer, this};
/// Pointer to the geometry service
SmartIF<IGeoSvc> m_geoSvc;
/// Handle for the input tool
Expand Down
14 changes: 7 additions & 7 deletions RecCalorimeter/src/components/CaloTopoClusterInputTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ class CaloTopoClusterInputTool : public GaudiTool, virtual public ITopoClusterIn

private:
/// Handle for electromagnetic barrel cells (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_ecalBarrelCells{"ecalBarrelCells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_ecalBarrelCells{"ecalBarrelCells", Gaudi::DataHandle::Reader, this};
/// Handle for ecal endcap calorimeter cells (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_ecalEndcapCells{"ecalEndcapCells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_ecalEndcapCells{"ecalEndcapCells", Gaudi::DataHandle::Reader, this};
/// Handle for ecal forward calorimeter cells (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_ecalFwdCells{"ecalFwdCells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_ecalFwdCells{"ecalFwdCells", Gaudi::DataHandle::Reader, this};
/// Handle for hadronic barrel cells (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_hcalBarrelCells{"hcalBarrelCells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_hcalBarrelCells{"hcalBarrelCells", Gaudi::DataHandle::Reader, this};
/// Handle for hadronic extended barrel cells (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_hcalExtBarrelCells{"hcalExtBarrelCells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_hcalExtBarrelCells{"hcalExtBarrelCells", Gaudi::DataHandle::Reader, this};
/// Handle for hcal endcap calorimeter cells (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_hcalEndcapCells{"hcalEndcapCells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_hcalEndcapCells{"hcalEndcapCells", Gaudi::DataHandle::Reader, this};
/// Handle for hcal forward calorimeter cells (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_hcalFwdCells{"hcalFwdCells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_hcalFwdCells{"hcalFwdCells", Gaudi::DataHandle::Reader, this};
/// Pointer to the geometry service
SmartIF<IGeoSvc> m_geoSvc;
/// Name of the electromagnetic barrel readout
Expand Down
14 changes: 7 additions & 7 deletions RecCalorimeter/src/components/CaloTowerTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,19 @@ class CaloTowerTool : public GaudiTool, virtual public ITowerTool {
std::pair<double, double> retrievePhiEtaExtrema(dd4hep::DDSegmentation::Segmentation* aSegmentation, SegmentationType aType);
std::pair<dd4hep::DDSegmentation::Segmentation*, SegmentationType> retrieveSegmentation(std::string aReadoutName);
/// Handle for electromagnetic barrel cells (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_ecalBarrelCells{"ecalBarrelCells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_ecalBarrelCells{"ecalBarrelCells", Gaudi::DataHandle::Reader, this};
/// Handle for ecal endcap calorimeter cells (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_ecalEndcapCells{"ecalEndcapCells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_ecalEndcapCells{"ecalEndcapCells", Gaudi::DataHandle::Reader, this};
/// Handle for ecal forward calorimeter cells (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_ecalFwdCells{"ecalFwdCells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_ecalFwdCells{"ecalFwdCells", Gaudi::DataHandle::Reader, this};
/// Handle for hadronic barrel cells (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_hcalBarrelCells{"hcalBarrelCells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_hcalBarrelCells{"hcalBarrelCells", Gaudi::DataHandle::Reader, this};
/// Handle for hadronic extended barrel cells (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_hcalExtBarrelCells{"hcalExtBarrelCells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_hcalExtBarrelCells{"hcalExtBarrelCells", Gaudi::DataHandle::Reader, this};
/// Handle for hcal endcap calorimeter cells (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_hcalEndcapCells{"hcalEndcapCells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_hcalEndcapCells{"hcalEndcapCells", Gaudi::DataHandle::Reader, this};
/// Handle for hcal forward calorimeter cells (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_hcalFwdCells{"hcalFwdCells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_hcalFwdCells{"hcalFwdCells", Gaudi::DataHandle::Reader, this};
/// Pointer to the geometry service
ServiceHandle<IGeoSvc> m_geoSvc;
/// Name of the electromagnetic barrel readout
Expand Down
8 changes: 4 additions & 4 deletions RecCalorimeter/src/components/ConeSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

DECLARE_COMPONENT(ConeSelection)

ConeSelection::ConeSelection(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) {
ConeSelection::ConeSelection(const std::string& name, ISvcLocator* svcLoc) : Gaudi::Algorithm(name, svcLoc) {
declareProperty("cells", m_cells, "The cells (input)");
declareProperty("particles", m_particles, "The geant particles (input)");
declareProperty("selCells", m_selCells, "The selected cells (output)");
Expand All @@ -36,13 +36,13 @@ StatusCode ConeSelection::initialize() {
info() << "ConeSelection initialized" << endmsg;
debug() << "Cone radius: " << m_r << endmsg;

StatusCode sc = GaudiAlgorithm::initialize();
StatusCode sc = Gaudi::Algorithm::initialize();
if (sc.isFailure()) return sc;

return StatusCode::SUCCESS;
}

StatusCode ConeSelection::execute() {
StatusCode ConeSelection::execute(const EventContext&) const {

m_cellsMap.clear();

Expand Down Expand Up @@ -89,4 +89,4 @@ StatusCode ConeSelection::execute() {
return StatusCode::SUCCESS;
}

StatusCode ConeSelection::finalize() { return GaudiAlgorithm::finalize(); }
StatusCode ConeSelection::finalize() { return Gaudi::Algorithm::finalize(); }
12 changes: 6 additions & 6 deletions RecCalorimeter/src/components/ConeSelection.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define RECCALORIMETER_CONESELECTION_H

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

// Key4HEP
#include "k4FWCore/DataHandle.h"
Expand All @@ -24,14 +24,14 @@ class IGeoSvc;
*
*/

class ConeSelection : public GaudiAlgorithm {
class ConeSelection : public Gaudi::Algorithm {

public:
ConeSelection(const std::string& name, ISvcLocator* svcLoc);

StatusCode initialize();

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

StatusCode finalize();

Expand All @@ -40,11 +40,11 @@ class ConeSelection : public GaudiAlgorithm {
ToolHandle<ICellPositionsTool> m_cellPositionsTool{"CellPositionsTool", this};

/// Handle for calo hits (input collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_cells{"cells", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_cells{"cells", Gaudi::DataHandle::Reader, this};
/// Handle for calo hits (input collection)
DataHandle<edm4hep::MCParticleCollection> m_particles{"particles", Gaudi::DataHandle::Reader, this};
mutable DataHandle<edm4hep::MCParticleCollection> m_particles{"particles", Gaudi::DataHandle::Reader, this};
/// Handle for calo cells (output collection)
DataHandle<edm4hep::CalorimeterHitCollection> m_selCells{"selCells", Gaudi::DataHandle::Writer, this};
mutable DataHandle<edm4hep::CalorimeterHitCollection> m_selCells{"selCells", Gaudi::DataHandle::Writer, this};
/// Map of cell IDs (corresponding to DD4hep IDs) and energy
std::unordered_map<uint64_t, double> m_cellsMap;

Expand Down
8 changes: 4 additions & 4 deletions RecCalorimeter/src/components/CorrectCaloClusters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ DECLARE_COMPONENT(CorrectCaloClusters)

CorrectCaloClusters::CorrectCaloClusters(const std::string& name,
ISvcLocator* svcLoc)
: GaudiAlgorithm(name, svcLoc),
: Gaudi::Algorithm(name, svcLoc),
m_geoSvc("GeoSvc", "CorrectCaloClusters") {
declareProperty("inClusters", m_inClusters,
"Input cluster collection");
Expand All @@ -43,7 +43,7 @@ CorrectCaloClusters::CorrectCaloClusters(const std::string& name,

StatusCode CorrectCaloClusters::initialize() {
{
StatusCode sc = GaudiAlgorithm::initialize();
StatusCode sc = Gaudi::Algorithm::initialize();
if (sc.isFailure()) {
return sc;
}
Expand Down Expand Up @@ -215,7 +215,7 @@ StatusCode CorrectCaloClusters::initialize() {
}


StatusCode CorrectCaloClusters::execute() {
StatusCode CorrectCaloClusters::execute(const EventContext&) const {
verbose() << "-------------------------------------------" << endmsg;

// Get the input collection with clusters
Expand Down Expand Up @@ -276,7 +276,7 @@ StatusCode CorrectCaloClusters::execute() {

StatusCode CorrectCaloClusters::finalize() {

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


Expand Down
12 changes: 6 additions & 6 deletions RecCalorimeter/src/components/CorrectCaloClusters.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "k4FWCore/DataHandle.h"

// Gaudi
#include "GaudiAlg/GaudiAlgorithm.h"
#include "Gaudi/Algorithm.h"
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/RndmGenerators.h"
Expand Down Expand Up @@ -59,14 +59,14 @@ namespace dd4hep {
* @author Juraj Smiesko, benchmark calibration added by Michaela Mlynarikova
*/

class CorrectCaloClusters : public GaudiAlgorithm {
class CorrectCaloClusters : public Gaudi::Algorithm {

public:
CorrectCaloClusters(const std::string& name, ISvcLocator* svcLoc);

StatusCode initialize();

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

StatusCode finalize();

Expand Down Expand Up @@ -163,11 +163,11 @@ class CorrectCaloClusters : public GaudiAlgorithm {
double getClusterTheta(edm4hep::Cluster cluster);

/// Handle for input calorimeter clusters collection
DataHandle<edm4hep::ClusterCollection> m_inClusters {
mutable DataHandle<edm4hep::ClusterCollection> m_inClusters {
"inClusters", Gaudi::DataHandle::Reader, this
};
/// Handle for corrected (output) calorimeter clusters collection
DataHandle<edm4hep::ClusterCollection> m_outClusters {
mutable DataHandle<edm4hep::ClusterCollection> m_outClusters {
"outClusters", Gaudi::DataHandle::Writer, this
};

Expand Down Expand Up @@ -244,4 +244,4 @@ class CorrectCaloClusters : public GaudiAlgorithm {
Gaudi::Property<bool> m_benchmarkCorr{this, "benchmarkCorr", false};
};

#endif /* RECCALORIMETER_CORRECTCALOCLUSTERS_H */
#endif /* RECCALORIMETER_CORRECTCALOCLUSTERS_H */
Loading

0 comments on commit 59b1cb3

Please sign in to comment.