Skip to content

Commit

Permalink
CellPositionsTools to edm4hep
Browse files Browse the repository at this point in the history
  • Loading branch information
BrieucF authored and vvolkl committed Apr 14, 2021
1 parent 52c0d52 commit 920776d
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 73 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "CellPositionsCaloDiscsTool.h"

#include "datamodel/CaloHitCollection.h"
#include "datamodel/PositionedCaloHitCollection.h"
#include "edm4hep/CalorimeterHitCollection.h"

DECLARE_COMPONENT(CellPositionsCaloDiscsTool)

Expand Down Expand Up @@ -41,20 +40,22 @@ StatusCode CellPositionsCaloDiscsTool::initialize() {
return sc;
}

void CellPositionsCaloDiscsTool::getPositions(const fcc::CaloHitCollection& aCells,
fcc::PositionedCaloHitCollection& outputColl) {
void CellPositionsCaloDiscsTool::getPositions(const edm4hep::CalorimeterHitCollection& aCells,
edm4hep::CalorimeterHitCollection& outputColl) {
debug() << "Input collection size : " << aCells.size() << endmsg;
// Loop through cell collection
for (const auto& cell : aCells) {
auto outPos = CellPositionsCaloDiscsTool::xyzPosition(cell.core().cellId);
auto outPos = CellPositionsCaloDiscsTool::xyzPosition(cell.getCellID());

auto edmPos = fcc::Point();
auto edmPos = edm4hep::Vector3f();
edmPos.x = outPos.x() / dd4hep::mm;
edmPos.y = outPos.y() / dd4hep::mm;
edmPos.z = outPos.z() / dd4hep::mm;
auto positionedHit = outputColl.create(edmPos, cell.core());
auto positionedHit = cell.clone();
positionedHit.setPosition(edmPos);
outputColl.push_back(positionedHit);
// Debug information about cell position
debug() << "Cell energy (GeV) : " << cell.core().energy << "\tcellID " << cell.core().cellId << endmsg;
debug() << "Cell energy (GeV) : " << positionedHit.getEnergy() << "\tcellID " << positionedHit.getCellID() << endmsg;
debug() << "Position of cell (mm) : \t" << outPos.x() / dd4hep::mm << "\t" << outPos.y() / dd4hep::mm << "\t"
<< outPos.z() / dd4hep::mm << endmsg;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CellPositionsCaloDiscsTool : public GaudiTool, virtual public ICellPositio

virtual StatusCode finalize() final;

virtual void getPositions(const fcc::CaloHitCollection& aCells, fcc::PositionedCaloHitCollection& outputColl) final;
virtual void getPositions(const edm4hep::CalorimeterHitCollection& aCells, edm4hep::CalorimeterHitCollection& outputColl) final;

virtual dd4hep::Position xyzPosition(const uint64_t& aCellId) const final;

Expand Down
17 changes: 9 additions & 8 deletions RecFCChhCalorimeter/src/components/CellPositionsDummyTool.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "CellPositionsDummyTool.h"

#include "datamodel/CaloHitCollection.h"
#include "datamodel/PositionedCaloHitCollection.h"
#include "edm4hep/CalorimeterHitCollection.h"

DECLARE_COMPONENT(CellPositionsDummyTool)

Expand All @@ -22,20 +21,22 @@ StatusCode CellPositionsDummyTool::initialize() {
return sc;
}

void CellPositionsDummyTool::getPositions(const fcc::CaloHitCollection& aCells,
fcc::PositionedCaloHitCollection& outputColl) {
void CellPositionsDummyTool::getPositions(const edm4hep::CalorimeterHitCollection& aCells,
edm4hep::CalorimeterHitCollection& outputColl) {
debug() << "Input collection size : " << aCells.size() << endmsg;
// Loop through cell collection
for (const auto& cell : aCells) {
auto outPos = CellPositionsDummyTool::xyzPosition(cell.core().cellId);
auto outPos = CellPositionsDummyTool::xyzPosition(cell.getCellID());

auto edmPos = fcc::Point();
auto edmPos = edm4hep::Vector3f();
edmPos.x = outPos.x() / dd4hep::mm;
edmPos.y = outPos.y() / dd4hep::mm;
edmPos.z = outPos.z() / dd4hep::mm;
auto positionedHit = outputColl.create(edmPos, cell.core());
auto positionedHit = cell.clone();
positionedHit.setPosition(edmPos);
outputColl.push_back(positionedHit);
// Debug information about cell position
debug() << "Cell energy (GeV) : " << cell.core().energy << "\tcellID " << cell.core().cellId << endmsg;
debug() << "Cell energy (GeV) : " << positionedHit.getEnergy() << "\tcellID " << positionedHit.getCellID() << endmsg;
debug() << "Position of cell (mm) : \t" << outPos.x() / dd4hep::mm << "\t" << outPos.y() / dd4hep::mm << "\t"
<< outPos.z() / dd4hep::mm << endmsg;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CellPositionsDummyTool : public GaudiTool, virtual public ICellPositionsTo

virtual StatusCode finalize() final;

virtual void getPositions(const fcc::CaloHitCollection& aCells, fcc::PositionedCaloHitCollection& outputColl) final;
virtual void getPositions(const edm4hep::CalorimeterHitCollection& aCells, edm4hep::CalorimeterHitCollection& outputColl) final;

virtual dd4hep::Position xyzPosition(const uint64_t& aCellId) const final;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "CellPositionsECalBarrelTool.h"

// EDM
#include "datamodel/CaloHitCollection.h"
#include "datamodel/PositionedCaloHitCollection.h"
#include "edm4hep/CalorimeterHitCollection.h"

DECLARE_COMPONENT(CellPositionsECalBarrelTool)

Expand Down Expand Up @@ -42,22 +41,24 @@ StatusCode CellPositionsECalBarrelTool::initialize() {
return sc;
}

void CellPositionsECalBarrelTool::getPositions(const fcc::CaloHitCollection& aCells,
fcc::PositionedCaloHitCollection& outputColl) {
void CellPositionsECalBarrelTool::getPositions(const edm4hep::CalorimeterHitCollection& aCells,
edm4hep::CalorimeterHitCollection& outputColl) {

debug() << "Input collection size : " << aCells.size() << endmsg;
// Loop through cell collection
for (const auto& cell : aCells) {
auto outSeg = CellPositionsECalBarrelTool::xyzPosition(cell.core().cellId);
auto edmPos = fcc::Point();
auto outSeg = CellPositionsECalBarrelTool::xyzPosition(cell.getCellID());
auto edmPos = edm4hep::Vector3f();
edmPos.x = outSeg.x() / dd4hep::mm;
edmPos.y = outSeg.y() / dd4hep::mm;
edmPos.z = outSeg.z() / dd4hep::mm;

auto positionedHit = outputColl.create(edmPos, cell.core());
auto positionedHit = cell.clone();
positionedHit.setPosition(edmPos);
outputColl.push_back(positionedHit);

// Debug information about cell position
debug() << "Cell energy (GeV) : " << cell.core().energy << "\tcellID " << cell.core().cellId << endmsg;
debug() << "Cell energy (GeV) : " << positionedHit.getEnergy() << "\tcellID " << positionedHit.getCellID() << endmsg;
debug() << "Position of cell (mm) : \t" << outSeg.x() / dd4hep::mm << "\t" << outSeg.y() / dd4hep::mm << "\t"
<< outSeg.z() / dd4hep::mm << "\n"
<< endmsg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CellPositionsECalBarrelTool : public GaudiTool, virtual public ICellPositi

virtual StatusCode finalize() final;

virtual void getPositions(const fcc::CaloHitCollection& aCells, fcc::PositionedCaloHitCollection& outputColl) final;
virtual void getPositions(const edm4hep::CalorimeterHitCollection& aCells, edm4hep::CalorimeterHitCollection& outputColl) final;

virtual dd4hep::Position xyzPosition(const uint64_t& aCellId) const final;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "CellPositionsHCalBarrelNoSegTool.h"

#include "datamodel/CaloHitCollection.h"
#include "datamodel/PositionedCaloHitCollection.h"
#include "edm4hep/CalorimeterHitCollection.h"

DECLARE_COMPONENT(CellPositionsHCalBarrelNoSegTool)

Expand Down Expand Up @@ -41,22 +40,24 @@ StatusCode CellPositionsHCalBarrelNoSegTool::initialize() {
return sc;
}

void CellPositionsHCalBarrelNoSegTool::getPositions(const fcc::CaloHitCollection& aCells,
fcc::PositionedCaloHitCollection& outputColl) {
void CellPositionsHCalBarrelNoSegTool::getPositions(const edm4hep::CalorimeterHitCollection& aCells,
edm4hep::CalorimeterHitCollection& outputColl) {
debug() << "Input collection size : " << aCells.size() << endmsg;
// Loop through cell collection
for (const auto& cell : aCells) {
auto outPos = CellPositionsHCalBarrelNoSegTool::xyzPosition(cell.core().cellId);
auto outPos = CellPositionsHCalBarrelNoSegTool::xyzPosition(cell.getCellID());

auto edmPos = fcc::Point();
auto edmPos = edm4hep::Vector3f();
edmPos.x = outPos.x() / dd4hep::mm;
edmPos.y = outPos.y() / dd4hep::mm;
edmPos.z = outPos.z() / dd4hep::mm;

auto positionedHit = outputColl.create(edmPos, cell.core());
auto positionedHit = cell.clone();
positionedHit.setPosition(edmPos);
outputColl.push_back(positionedHit);

// Debug information about cell position
debug() << "Cell energy (GeV) : " << cell.core().energy << "\tcellID " << cell.core().cellId << endmsg;
debug() << "Cell energy (GeV) : " << positionedHit.getEnergy() << "\tcellID " << positionedHit.getCellID() << endmsg;
debug() << "Position of cell (mm) : \t" << outPos.x() / dd4hep::mm << "\t" << outPos.y() / dd4hep::mm << "\t"
<< outPos.z() / dd4hep::mm << endmsg;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CellPositionsHCalBarrelNoSegTool : public GaudiTool, virtual public ICellP

virtual StatusCode finalize() final;

virtual void getPositions(const fcc::CaloHitCollection& aCells, fcc::PositionedCaloHitCollection& outputColl) final;
virtual void getPositions(const edm4hep::CalorimeterHitCollection& aCells, edm4hep::CalorimeterHitCollection& outputColl) final;

virtual dd4hep::Position xyzPosition(const uint64_t& aCellId) const final;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "CellPositionsHCalBarrelPhiSegTool.h"

#include "datamodel/CaloHitCollection.h"
#include "datamodel/PositionedCaloHitCollection.h"
#include "edm4hep/CalorimeterHitCollection.h"

DECLARE_COMPONENT(CellPositionsHCalBarrelPhiSegTool)

Expand Down Expand Up @@ -40,22 +39,24 @@ StatusCode CellPositionsHCalBarrelPhiSegTool::initialize() {
return sc;
}

void CellPositionsHCalBarrelPhiSegTool::getPositions(const fcc::CaloHitCollection& aCells,
fcc::PositionedCaloHitCollection& outputColl) {
void CellPositionsHCalBarrelPhiSegTool::getPositions(const edm4hep::CalorimeterHitCollection& aCells,
edm4hep::CalorimeterHitCollection& outputColl) {
debug() << "Input collection size : " << aCells.size() << endmsg;
// Loop through cell collection
for (const auto& cell : aCells) {
auto outPos = CellPositionsHCalBarrelPhiSegTool::xyzPosition(cell.core().cellId);
auto outPos = CellPositionsHCalBarrelPhiSegTool::xyzPosition(cell.getCellID());

auto edmPos = fcc::Point();
auto edmPos = edm4hep::Vector3f();
edmPos.x = outPos.x() / dd4hep::mm;
edmPos.y = outPos.y() / dd4hep::mm;
edmPos.z = outPos.z() / dd4hep::mm;

auto positionedHit = outputColl.create(edmPos, cell.core());
auto positionedHit = cell.clone();
positionedHit.setPosition(edmPos);
outputColl.push_back(positionedHit);

// Debug information about cell position
debug() << "Cell energy (GeV) : " << cell.core().energy << "\tcellID " << cell.core().cellId << endmsg;
debug() << "Cell energy (GeV) : " << positionedHit.getEnergy() << "\tcellID " << positionedHit.getCellID() << endmsg;
debug() << "Position of cell (mm) : \t" << outPos.x() / dd4hep::mm << "\t" << outPos.y() / dd4hep::mm << "\t"
<< outPos.z() / dd4hep::mm << endmsg;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CellPositionsHCalBarrelPhiSegTool : public GaudiTool, virtual public ICell

virtual StatusCode finalize() final;

virtual void getPositions(const fcc::CaloHitCollection& aCells, fcc::PositionedCaloHitCollection& outputColl) final;
virtual void getPositions(const edm4hep::CalorimeterHitCollection& aCells, edm4hep::CalorimeterHitCollection& outputColl) final;

virtual dd4hep::Position xyzPosition(const uint64_t& aCellId) const final;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "CellPositionsHCalBarrelTool.h"

#include "datamodel/CaloHitCollection.h"
#include "datamodel/PositionedCaloHitCollection.h"
#include "edm4hep/CalorimeterHitCollection.h"

DECLARE_COMPONENT(CellPositionsHCalBarrelTool)

Expand Down Expand Up @@ -41,22 +40,24 @@ StatusCode CellPositionsHCalBarrelTool::initialize() {
return sc;
}

void CellPositionsHCalBarrelTool::getPositions(const fcc::CaloHitCollection& aCells,
fcc::PositionedCaloHitCollection& outputColl) {
void CellPositionsHCalBarrelTool::getPositions(const edm4hep::CalorimeterHitCollection& aCells,
edm4hep::CalorimeterHitCollection& outputColl) {
debug() << "Input collection size : " << aCells.size() << endmsg;
// Loop through cell collection
for (const auto& cell : aCells) {
auto outSeg = CellPositionsHCalBarrelTool::xyzPosition(cell.core().cellId);
auto outSeg = CellPositionsHCalBarrelTool::xyzPosition(cell.getCellID());

auto edmPos = fcc::Point();
auto edmPos = edm4hep::Vector3f();
edmPos.x = outSeg.x() / dd4hep::mm;
edmPos.y = outSeg.y() / dd4hep::mm;
edmPos.z = outSeg.z() / dd4hep::mm;

auto positionedHit = outputColl.create(edmPos, cell.core());
auto positionedHit = cell.clone();
positionedHit.setPosition(edmPos);
outputColl.push_back(positionedHit);

// Debug information about cell position
debug() << "Cell energy (GeV) : " << cell.core().energy << "\tcellID " << cell.core().cellId << endmsg;
debug() << "Cell energy (GeV) : " << positionedHit.getEnergy() << "\tcellID " << positionedHit.getCellID() << endmsg;
debug() << "Position of cell (mm) : \t" << outSeg.x() / dd4hep::mm << "\t" << outSeg.y() / dd4hep::mm << "\t"
<< outSeg.z() / dd4hep::mm << endmsg;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CellPositionsHCalBarrelTool : public GaudiTool, virtual public ICellPositi

virtual StatusCode finalize() final;

virtual void getPositions(const fcc::CaloHitCollection& aCells, fcc::PositionedCaloHitCollection& outputColl) final;
virtual void getPositions(const edm4hep::CalorimeterHitCollection& aCells, edm4hep::CalorimeterHitCollection& outputColl) final;

virtual dd4hep::Position xyzPosition(const uint64_t& aCellId) const final;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "CellPositionsTailCatcherTool.h"

#include "datamodel/CaloHitCollection.h"
#include "datamodel/PositionedCaloHitCollection.h"
#include "edm4hep/CalorimeterHitCollection.h"

DECLARE_COMPONENT(CellPositionsTailCatcherTool)

Expand Down Expand Up @@ -42,23 +41,25 @@ StatusCode CellPositionsTailCatcherTool::initialize() {
return sc;
}

void CellPositionsTailCatcherTool::getPositions(const fcc::CaloHitCollection& aCells,
fcc::PositionedCaloHitCollection& outputColl) {
void CellPositionsTailCatcherTool::getPositions(const edm4hep::CalorimeterHitCollection& aCells,
edm4hep::CalorimeterHitCollection& outputColl) {
debug() << "Input collection size : " << aCells.size() << endmsg;
// Loop through cell collection
for (const auto& cell : aCells) {
auto outSeg = CellPositionsTailCatcherTool::xyzPosition(cell.core().cellId);
auto outSeg = CellPositionsTailCatcherTool::xyzPosition(cell.getCellID());

auto edmPos = fcc::Point();
auto edmPos = edm4hep::Vector3f();
edmPos.x = outSeg.x() / dd4hep::mm;
edmPos.y = outSeg.y() / dd4hep::mm;
edmPos.z = outSeg.z() / dd4hep::mm;

auto positionedHit = outputColl.create(edmPos, cell.core());
auto positionedHit = cell.clone();
positionedHit.setPosition(edmPos);
outputColl.push_back(positionedHit);
;

// Debug information about cell position
debug() << "Cell energy (GeV) : " << cell.core().energy << "\tcellID " << cell.core().cellId << endmsg;
debug() << "Cell energy (GeV) : " << positionedHit.getEnergy() << "\tcellID " << positionedHit.getCellID() << endmsg;
debug() << "Position of cell (mm) : \t" << outSeg.x() / dd4hep::mm << "\t" << outSeg.y() / dd4hep::mm << "\t"
<< outSeg.z() / dd4hep::mm << endmsg;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CellPositionsTailCatcherTool : public GaudiTool, virtual public ICellPosit

virtual StatusCode finalize() final;

virtual void getPositions(const fcc::CaloHitCollection& aCells, fcc::PositionedCaloHitCollection& outputColl) final;
virtual void getPositions(const edm4hep::CalorimeterHitCollection& aCells, edm4hep::CalorimeterHitCollection& outputColl) final;

virtual dd4hep::Position xyzPosition(const uint64_t& aCellId) const final;

Expand Down
5 changes: 1 addition & 4 deletions RecFCChhCalorimeter/src/components/CreateCellPositions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
#include "DD4hep/Detector.h"

// EDM
#include "datamodel/CaloHitCollection.h"
#include "datamodel/PositionedCaloHitCollection.h"
#include "datamodel/PositionedTrackHitCollection.h"
#include "datamodel/TrackHitCollection.h"
#include "edm4hep/CalorimeterHitCollection.h"

DECLARE_COMPONENT(CreateCellPositions)

Expand Down
10 changes: 4 additions & 6 deletions RecFCChhCalorimeter/src/components/CreateCellPositions.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
#include "GaudiAlg/GaudiAlgorithm.h"
#include "GaudiKernel/ToolHandle.h"

#include "datamodel/CaloHit.h"
#include "datamodel/CaloHitCollection.h"
#include "datamodel/PositionedCaloHit.h"
#include "datamodel/PositionedCaloHitCollection.h"
#include "edm4hep/CalorimeterHit.h"
#include "edm4hep/CalorimeterHitCollection.h"

class IGeoSvc;

Expand Down Expand Up @@ -48,9 +46,9 @@ class CreateCellPositions : public GaudiAlgorithm {
/// Handle for tool to get positions
ToolHandle<ICellPositionsTool> m_cellPositionsTool;
/// Input collection
DataHandle<fcc::CaloHitCollection> m_hits{"hits/hits", Gaudi::DataHandle::Reader, this};
DataHandle<edm4hep::CalorimeterHitCollection> m_hits{"hits/hits", Gaudi::DataHandle::Reader, this};
/// Output collection
DataHandle<fcc::PositionedCaloHitCollection> m_positionedHits{"hits/positionedHits", Gaudi::DataHandle::Writer, this};
DataHandle<edm4hep::CalorimeterHitCollection> m_positionedHits{"hits/positionedHits", Gaudi::DataHandle::Writer, this};
};

#endif /* DETCOMPONENTS_CREATECELLPOSITIONS_H */

0 comments on commit 920776d

Please sign in to comment.