Skip to content

Commit

Permalink
Attempt to fix warnings :)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjvbrt committed Oct 24, 2023
1 parent bde81c8 commit 6099dea
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 49 deletions.
18 changes: 14 additions & 4 deletions RecCalorimeter/src/components/CaloTopoCluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
#include "DD4hep/Detector.h"
#include "DD4hep/Readout.h"

#include <GaudiKernel/StatusCode.h>
#include <algorithm>
#include <map>
#include <memory>
#include <numeric>
#include <unordered_map>
#include <vector>
Expand Down Expand Up @@ -93,7 +95,7 @@ StatusCode CaloTopoCluster::execute() {

// Create output collections
auto edmClusters = m_clusterCollection.createAndPut();
edm4hep::CalorimeterHitCollection* edmClusterCells = new edm4hep::CalorimeterHitCollection();
std::unique_ptr<edm4hep::CalorimeterHitCollection> edmClusterCells(new edm4hep::CalorimeterHitCollection());

// Finds seeds
CaloTopoCluster::findingSeeds(allCells, m_seedSigma, firstSeeds);
Expand All @@ -106,8 +108,16 @@ StatusCode CaloTopoCluster::execute() {
});

std::map<uint, std::vector<std::pair<uint64_t, int>>> preClusterCollection;
CaloTopoCluster::buildingProtoCluster(m_neighbourSigma, m_lastNeighbourSigma, firstSeeds, allCells,
preClusterCollection);
StatusCode sc = CaloTopoCluster::buildingProtoCluster(m_neighbourSigma,
m_lastNeighbourSigma,
firstSeeds,
allCells,
preClusterCollection);
if (sc.isFailure()) {
error() << "Unable to build protocluster!" << endmsg;
return sc;
}

// Build Clusters in edm
debug() << "Building " << preClusterCollection.size() << " cluster." << endmsg;
double checkTotEnergy = 0.;
Expand Down Expand Up @@ -202,7 +212,7 @@ StatusCode CaloTopoCluster::execute() {

}

m_clusterCellsCollection.put(edmClusterCells);
m_clusterCellsCollection.put(std::move(edmClusterCells));
debug() << "Number of clusters with cells in E and HCal: " << clusterWithMixedCells << endmsg;
debug() << "Total energy of clusters: " << checkTotEnergy << endmsg;
debug() << "Leftover cells : " << allCells.size() << endmsg;
Expand Down
28 changes: 21 additions & 7 deletions RecCalorimeter/src/components/CorrectCaloClusters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ CorrectCaloClusters::CorrectCaloClusters(const std::string& name,
}

StatusCode CorrectCaloClusters::initialize() {
StatusCode sc = GaudiAlgorithm::initialize();
if (sc.isFailure()) {
return sc;
{
StatusCode sc = GaudiAlgorithm::initialize();
if (sc.isFailure()) {
return sc;
}
}

// Check if readouts exist
Expand Down Expand Up @@ -88,8 +90,20 @@ StatusCode CorrectCaloClusters::initialize() {
}

// Prepare upstream and downstream correction functions
initializeCorrFunctions(m_upstreamFunctions, m_upstreamFormulas, m_upstreamParams, "upstream");
initializeCorrFunctions(m_downstreamFunctions, m_downstreamFormulas, m_downstreamParams, "downstream");
{
StatusCode sc = initializeCorrFunctions(m_upstreamFunctions, m_upstreamFormulas, m_upstreamParams, "upstream");
if (sc.isFailure()) {
error() << "Initialization of upstream correction functions not successful!" << endmsg;
return sc;
}
}
{
StatusCode sc = initializeCorrFunctions(m_downstreamFunctions, m_downstreamFormulas, m_downstreamParams, "downstream");
if (sc.isFailure()) {
error() << "Initialization of downstream correction functions not successful!" << endmsg;
return sc;
}
}

info() << "Initialized following upstream correction functions:" << endmsg;
for (size_t i = 0; i < m_upstreamFunctions.size(); ++i) {
Expand Down Expand Up @@ -307,8 +321,8 @@ StatusCode CorrectCaloClusters::applyDownstreamCorr(const edm4hep::ClusterCollec

double CorrectCaloClusters::getEnergyInLayer(edm4hep::Cluster cluster,
const std::string& readoutName,
size_t systemID,
size_t layerID) {
int systemID,
int layerID) {
dd4hep::DDSegmentation::BitFieldCoder* decoder = m_geoSvc->getDetector()->readout(readoutName).idSpec().decoder();

double energy = 0;
Expand Down
10 changes: 5 additions & 5 deletions RecCalorimeter/src/components/CorrectCaloClusters.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ class CorrectCaloClusters : public GaudiAlgorithm {
*/
double getEnergyInLayer(edm4hep::Cluster cluster,
const std::string& readoutName,
size_t systemID,
size_t layerID);
int systemID,
int layerID);

/**
* Get the theta angle of the specified cluster.
Expand Down Expand Up @@ -144,7 +144,7 @@ class CorrectCaloClusters : public GaudiAlgorithm {
std::vector<std::vector<TF1*>> m_downstreamFunctions;

/// IDs of the detectors
Gaudi::Property<std::vector<size_t>> m_systemIDs {
Gaudi::Property<std::vector<int>> m_systemIDs {
this, "systemIDs", {4}, "IDs of systems"
};
/// Names of the detector readouts, corresponding to system IDs
Expand All @@ -156,11 +156,11 @@ class CorrectCaloClusters : public GaudiAlgorithm {
Gaudi::Property<std::vector<size_t>> m_numLayers {
this, "numLayers", {12}, "Numbers of layers of the systems"};
/// IDs of the first layers of the detectors
Gaudi::Property<std::vector<size_t>> m_firstLayerIDs {
Gaudi::Property<std::vector<int>> m_firstLayerIDs {
this, "firstLayerIDs", {0}, "IDs of first layers in the systems"
};
/// IDs of the last layers of the detectors
Gaudi::Property<std::vector<size_t>> m_lastLayerIDs {
Gaudi::Property<std::vector<int>> m_lastLayerIDs {
this, "lastLayerIDs", {7}, "IDs of last layers in the systems"
};

Expand Down
14 changes: 11 additions & 3 deletions RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "TLorentzVector.h"
#include "TFitResult.h"
#include "TGraphErrors.h"
#include <GaudiKernel/MsgStream.h>

DECLARE_COMPONENT(CorrectECalBarrelSliWinCluster)

Expand All @@ -40,8 +41,10 @@ CorrectECalBarrelSliWinCluster::CorrectECalBarrelSliWinCluster(const std::string
}

StatusCode CorrectECalBarrelSliWinCluster::initialize() {
StatusCode sc = GaudiAlgorithm::initialize();
if (sc.isFailure()) return sc;
{
StatusCode sc = GaudiAlgorithm::initialize();
if (sc.isFailure()) return sc;
}

int energyStart = 0;
int energyEnd = 0;
Expand Down Expand Up @@ -159,7 +162,12 @@ StatusCode CorrectECalBarrelSliWinCluster::initialize() {
error() << "Couldn't get RndmGenSvc!!!!" << endmsg;
return StatusCode::FAILURE;
}
m_gauss.initialize(m_randSvc, Rndm::Gauss(0., 1.));
{
StatusCode sc = m_gauss.initialize(m_randSvc, Rndm::Gauss(0., 1.));
if (sc.isFailure()) {
error() << "Unable to initialize gaussian random number generator!" << endmsg;
}
}

// open and check file, read the histograms with noise constants
if (initNoiseFromFile().isFailure()) {
Expand Down
39 changes: 22 additions & 17 deletions RecCalorimeter/src/components/MassInv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ MassInv::MassInv(const std::string& name, ISvcLocator* svcLoc)
}

StatusCode MassInv::initialize() {
StatusCode sc = GaudiAlgorithm::initialize();
if (sc.isFailure()) return sc;
{
StatusCode sc = GaudiAlgorithm::initialize();
if (sc.isFailure()) return sc;
}

int energyStart = 0;
int energyEnd = 0;
Expand Down Expand Up @@ -321,7 +323,12 @@ StatusCode MassInv::initialize() {
error() << "Couldn't get RndmGenSvc!!!!" << endmsg;
return StatusCode::FAILURE;
}
m_gauss.initialize(m_randSvc, Rndm::Gauss(0., 1.));
{
StatusCode sc = m_gauss.initialize(m_randSvc, Rndm::Gauss(0., 1.));
if (sc.isFailure()) {
error() << "Failed to initialize Gaussian random number generator!" << endmsg;
}
}

// open and check file, read the histograms with noise constants
if (initNoiseFromFile().isFailure()) {
Expand Down Expand Up @@ -385,14 +392,12 @@ StatusCode MassInv::execute() {
double phiVertex = 0;
double etaVertex = 0;
double thetaVertex = 0;
double zVertex = 0;
const auto particle = m_particle.get();
if (particle->size() == 1) {
for(const auto& part : *particle) {
momentum = TVector3(part.getMomentum().x, part.getMomentum().y, part.getMomentum().z);
etaVertex = momentum.Eta();
phiVertex = momentum.Phi();
zVertex = part.getVertex().z;
thetaVertex = 2 * atan( exp( - etaVertex ) );
verbose() << " vertex eta " << etaVertex << " phi = " << phiVertex << " theta = " << thetaVertex << endmsg;
}
Expand Down Expand Up @@ -612,8 +617,8 @@ StatusCode MassInv::execute() {
}
debug() << "Number of ALL candidates: " << inClusters->size() << endmsg;

for (const auto candidate1: clustersMassInv) {
for (const auto candidate2: clustersMassInv) {
for (const auto& candidate1: clustersMassInv) {
for (const auto& candidate2: clustersMassInv) {
if ( candidate1 != candidate2) {
m_hMassInv->Fill((candidate1 + candidate2).Mag() * m_massInvCorrection);
m_hDiPT->Fill((candidate1 + candidate2).Pt());
Expand Down Expand Up @@ -655,8 +660,8 @@ StatusCode MassInv::execute() {
uint photonIdPhi = m_towerTool->idPhi(photonCandidate->Phi());
// LOOK AROUND
double sumWindow = 0;
for (int iEtaWindow = photonIdEta - halfEtaWin; iEtaWindow <= photonIdEta + halfEtaWin; iEtaWindow++) {
for (int iPhiWindow = photonIdPhi - halfPhiWin; iPhiWindow <= photonIdPhi + halfPhiWin; iPhiWindow++) {
for (size_t iEtaWindow = photonIdEta - halfEtaWin; iEtaWindow <= photonIdEta + halfEtaWin; iEtaWindow++) {
for (size_t iPhiWindow = photonIdPhi - halfPhiWin; iPhiWindow <= photonIdPhi + halfPhiWin; iPhiWindow++) {
sumWindow += m_towers[iEtaWindow][phiNeighbour(iPhiWindow, m_nPhiTower)];
}
}
Expand All @@ -671,8 +676,8 @@ StatusCode MassInv::execute() {
uint photonIdPhi = m_towerTool->idPhi(photonCandidate->Phi());
// LOOK AROUND
double sumWindow = 0;
for (int iEtaWindow = photonIdEta - halfEtaWin; iEtaWindow <= photonIdEta + halfEtaWin; iEtaWindow++) {
for (int iPhiWindow = photonIdPhi - halfPhiWin; iPhiWindow <= photonIdPhi + halfPhiWin; iPhiWindow++) {
for (size_t iEtaWindow = photonIdEta - halfEtaWin; iEtaWindow <= photonIdEta + halfEtaWin; iEtaWindow++) {
for (size_t iPhiWindow = photonIdPhi - halfPhiWin; iPhiWindow <= photonIdPhi + halfPhiWin; iPhiWindow++) {
sumWindow += m_towers[iEtaWindow][phiNeighbour(iPhiWindow, m_nPhiTower)];
}
}
Expand All @@ -687,8 +692,8 @@ StatusCode MassInv::execute() {
uint photonIdPhi = m_towerTool->idPhi(photonCandidate->Phi());
// LOOK AROUND
double sumWindow = 0;
for (int iEtaWindow = photonIdEta - halfEtaWin; iEtaWindow <= photonIdEta + halfEtaWin; iEtaWindow++) {
for (int iPhiWindow = photonIdPhi - halfPhiWin; iPhiWindow <= photonIdPhi + halfPhiWin; iPhiWindow++) {
for (size_t iEtaWindow = photonIdEta - halfEtaWin; iEtaWindow <= photonIdEta + halfEtaWin; iEtaWindow++) {
for (size_t iPhiWindow = photonIdPhi - halfPhiWin; iPhiWindow <= photonIdPhi + halfPhiWin; iPhiWindow++) {
sumWindow += m_towers[iEtaWindow][phiNeighbour(iPhiWindow, m_nPhiTower)];
}
}
Expand All @@ -703,8 +708,8 @@ StatusCode MassInv::execute() {
uint photonIdPhi = m_towerTool->idPhi(photonCandidate->Phi());
// LOOK AROUND
double sumWindow = 0;
for (int iEtaWindow = photonIdEta - halfEtaWin; iEtaWindow <= photonIdEta + halfEtaWin; iEtaWindow++) {
for (int iPhiWindow = photonIdPhi - halfPhiWin; iPhiWindow <= photonIdPhi + halfPhiWin; iPhiWindow++) {
for (size_t iEtaWindow = photonIdEta - halfEtaWin; iEtaWindow <= photonIdEta + halfEtaWin; iEtaWindow++) {
for (size_t iPhiWindow = photonIdPhi - halfPhiWin; iPhiWindow <= photonIdPhi + halfPhiWin; iPhiWindow++) {
sumWindow += m_towers[iEtaWindow][phiNeighbour(iPhiWindow, m_nPhiTower)];
}
}
Expand All @@ -719,8 +724,8 @@ StatusCode MassInv::execute() {
uint photonIdPhi = m_towerTool->idPhi(photonCandidate->Phi());
// LOOK AROUND
double sumWindow = 0;
for (int iEtaWindow = photonIdEta - halfEtaWin; iEtaWindow <= photonIdEta + halfEtaWin; iEtaWindow++) {
for (int iPhiWindow = photonIdPhi - halfPhiWin; iPhiWindow <= photonIdPhi + halfPhiWin; iPhiWindow++) {
for (size_t iEtaWindow = photonIdEta - halfEtaWin; iEtaWindow <= photonIdEta + halfEtaWin; iEtaWindow++) {
for (size_t iPhiWindow = photonIdPhi - halfPhiWin; iPhiWindow <= photonIdPhi + halfPhiWin; iPhiWindow++) {
sumWindow += m_towers[iEtaWindow][phiNeighbour(iPhiWindow, m_nPhiTower)];
}
}
Expand Down
16 changes: 12 additions & 4 deletions RecCalorimeter/src/components/NoiseCaloCellsFlatTool.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "NoiseCaloCellsFlatTool.h"
#include <GaudiKernel/StatusCode.h>

DECLARE_COMPONENT(NoiseCaloCellsFlatTool)

Expand All @@ -9,19 +10,26 @@ NoiseCaloCellsFlatTool::NoiseCaloCellsFlatTool(const std::string& type, const st
}

StatusCode NoiseCaloCellsFlatTool::initialize() {
StatusCode sc = GaudiTool::initialize();
if (sc.isFailure()) return sc;
{
StatusCode sc = GaudiTool::initialize();
if (sc.isFailure()) return sc;
}

// Initialize random service
if (service("RndmGenSvc", m_randSvc).isFailure()) {
error() << "Couldn't get RndmGenSvc" << endmsg;
return StatusCode::FAILURE;
}
m_gauss.initialize(m_randSvc, Rndm::Gauss(0., 1.));
{
StatusCode sc = m_gauss.initialize(m_randSvc, Rndm::Gauss(0., 1.));
if (sc.isFailure()) {
error() << "Failed to initialize Gaussian random number generator!" << endmsg;
}
}

info() << "Sigma of the cell noise: " << m_cellNoise * 1.e3 << " MeV" << endmsg;
info() << "Filter noise threshold: " << m_filterThreshold << "*sigma" << endmsg;
return sc;
return StatusCode::SUCCESS;
}

void NoiseCaloCellsFlatTool::addRandomCellNoise(std::unordered_map<uint64_t, double>& aCells) {
Expand Down
6 changes: 3 additions & 3 deletions RecCalorimeter/src/components/PreparePileup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ StatusCode PreparePileup::execute() {
m_energyVsAbsEta[layerId]->Fill(fabs(cellEta), cellEnergy);
// add energy of this cell to any optimised cluster where it is included
if (!(m_nEtaFinal.size() == 0 && m_nPhiFinal.size() == 0) ) {
uint etaId = m_decoder->get(cID, "eta");
uint phiId = m_decoder->get(cID, "phi");
int etaId = m_decoder->get(cID, "eta");
int phiId = m_decoder->get(cID, "phi");
for (int iEta = etaId - m_halfEtaFin[layerId]; iEta < etaId + m_halfEtaFin[layerId] + 1; iEta++) {
for (int iPhi = phiId - m_halfPhiFin[layerId]; iPhi < phiId + m_halfPhiFin[layerId] + 1; iPhi++) {
if (iEta > 0 && iEta < m_nEtaTower ) {
Expand Down Expand Up @@ -210,7 +210,7 @@ StatusCode PreparePileup::execute() {
<< endmsg;
// calculate the sum of first m_nEtaWindow bins in eta, for each phi tower
std::vector<float> sumOverEta(m_nPhiTower, 0);
for (int iEta = 0; iEta < m_etaSizes[iCluster]; iEta++) {
for (size_t iEta = 0; iEta < m_etaSizes[iCluster]; iEta++) {
std::transform(sumOverEta.begin(), sumOverEta.end(), m_towers[iEta].begin(), sumOverEta.begin(),
std::plus<float>());
}
Expand Down
13 changes: 7 additions & 6 deletions RecFCCeeCalorimeter/src/components/CaloTopoClusterFCCee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <algorithm>
#include <map>
#include <memory>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
Expand Down Expand Up @@ -104,7 +105,7 @@ StatusCode CaloTopoClusterFCCee::execute() {

// Create output collections
auto edmClusters = m_clusterCollection.createAndPut();
edm4hep::CalorimeterHitCollection* edmClusterCells = new edm4hep::CalorimeterHitCollection();
std::unique_ptr<edm4hep::CalorimeterHitCollection> edmClusterCells(new edm4hep::CalorimeterHitCollection());

// Finds seeds
CaloTopoClusterFCCee::findingSeeds(m_allCells, m_seedSigma, firstSeeds);
Expand All @@ -117,10 +118,10 @@ StatusCode CaloTopoClusterFCCee::execute() {
});

std::map<uint, std::vector<std::pair<uint64_t, int>>> preClusterCollection;
StatusCode sc_buildProtoClusters = CaloTopoClusterFCCee::buildingProtoCluster(m_neighbourSigma,
m_lastNeighbourSigma,
firstSeeds, m_allCells,
preClusterCollection);
StatusCode sc_buildProtoClusters = CaloTopoClusterFCCee::buildingProtoCluster(m_neighbourSigma,
m_lastNeighbourSigma,
firstSeeds, m_allCells,
preClusterCollection);
if (sc_buildProtoClusters.isFailure()) {
error() << "Unable to build the protoclusters!" << endmsg;
return StatusCode::FAILURE;
Expand Down Expand Up @@ -220,7 +221,7 @@ StatusCode CaloTopoClusterFCCee::execute() {

}

m_clusterCellsCollection.put(edmClusterCells);
m_clusterCellsCollection.put(std::move(edmClusterCells));
debug() << "Number of clusters with cells in E and HCal: " << clusterWithMixedCells << endmsg;
debug() << "Total energy of clusters: " << checkTotEnergy << endmsg;
debug() << "Leftover cells : " << m_allCells.size() << endmsg;
Expand Down

0 comments on commit 6099dea

Please sign in to comment.