Skip to content

Commit

Permalink
update with k4geo for SW FCCee
Browse files Browse the repository at this point in the history
  • Loading branch information
Tong Li committed Dec 13, 2023
1 parent 35aa9fd commit 5cc6d81
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
20 changes: 10 additions & 10 deletions RecFCCeeCalorimeter/src/components/CaloTowerToolFCCee.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "CaloTowerToolFCCee.h"

// FCCSW
// k4FWCore
#include "k4Interface/IGeoSvc.h"

// datamodel
// edm4hep
#include "edm4hep/CalorimeterHitCollection.h"
#include "edm4hep/Cluster.h"
#include "edm4hep/MutableCluster.h"
Expand Down Expand Up @@ -140,12 +140,12 @@ StatusCode CaloTowerToolFCCee::finalize() {
std::pair<double, double> CaloTowerToolFCCee::retrievePhiThetaExtrema(dd4hep::DDSegmentation::Segmentation* aSegmentation, SegmentationType aType) {
double phiMax = -1;
double thetaMax = -1;
dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged* segmentation = nullptr;
dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged_k4geo* segmentation = nullptr;
if (aSegmentation != nullptr) {
switch (aType) {
case SegmentationType::kModuleTheta: {
info() << "== Retrieving segmentation " << aSegmentation->name() << endmsg;
segmentation = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged*>(aSegmentation);
segmentation = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged_k4geo*>(aSegmentation);
phiMax = M_PI - M_PI/segmentation->nModules();
thetaMax = M_PI - fabs(segmentation->offsetTheta()) + segmentation->gridSizeTheta() * .5;
break;
Expand All @@ -155,7 +155,7 @@ std::pair<double, double> CaloTowerToolFCCee::retrievePhiThetaExtrema(dd4hep::DD
double theta = -1;
info() << "== Retrieving multi segmentation " << aSegmentation->name() << endmsg;
for (const auto& subSegm: dynamic_cast<dd4hep::DDSegmentation::MultiSegmentation*>(aSegmentation)->subSegmentations()) {
segmentation = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged*>(subSegm.segmentation);
segmentation = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged_k4geo*>(subSegm.segmentation);
phi = M_PI - M_PI/segmentation->nModules();
theta = M_PI - fabs(segmentation->offsetTheta()) + segmentation->gridSizeTheta() * .5;
if (theta > thetaMax) { thetaMax = theta;}
Expand Down Expand Up @@ -345,10 +345,10 @@ void CaloTowerToolFCCee::CellsIntoTowers(std::vector<std::vector<float>>& aTower
// tower index of the borders of the cell
int iTheta = 0;
int iPhi = 0;
const dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged* segmentation = nullptr;
const dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged_k4geo* segmentation = nullptr;
const dd4hep::DDSegmentation::MultiSegmentation* multisegmentation = nullptr;
if( aType == SegmentationType::kModuleTheta) {
segmentation = dynamic_cast<const dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged*>(aSegmentation);
segmentation = dynamic_cast<const dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged_k4geo*>(aSegmentation);
} else if( aType == SegmentationType::kMulti) {
multisegmentation = dynamic_cast<const dd4hep::DDSegmentation::MultiSegmentation*>(aSegmentation);
}
Expand All @@ -357,7 +357,7 @@ void CaloTowerToolFCCee::CellsIntoTowers(std::vector<std::vector<float>>& aTower
pass = true;
// if multisegmentation is used - first find out which segmentation to use
if( aType == SegmentationType::kMulti) {
segmentation = dynamic_cast<const dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged*>(&multisegmentation->subsegmentation(cell.getCellID()));
segmentation = dynamic_cast<const dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged_k4geo*>(&multisegmentation->subsegmentation(cell.getCellID()));
}
if (m_useHalfTower) {
uint layerId = m_decoder->get(cell.getCellID(), "layer");
Expand Down Expand Up @@ -390,7 +390,7 @@ std::pair<dd4hep::DDSegmentation::Segmentation*, CaloTowerToolFCCee::Segmentatio
info() << "Readout does not exist! Please check if it is correct. Processing without it." << endmsg;
} else {
info() << "Readout " << aReadoutName << " found." << endmsg;
segmentation = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged*>(
segmentation = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged_k4geo*>(
m_geoSvc->getDetector()->readout(aReadoutName).segmentation().segmentation());
if (segmentation == nullptr) {
segmentation = dynamic_cast<dd4hep::DDSegmentation::MultiSegmentation*>(
Expand All @@ -402,7 +402,7 @@ std::pair<dd4hep::DDSegmentation::Segmentation*, CaloTowerToolFCCee::Segmentatio
// check if multisegmentation contains only module-theta sub-segmentations
dd4hep::DDSegmentation::Segmentation* subsegmentation = nullptr;
for (const auto& subSegm: dynamic_cast<dd4hep::DDSegmentation::MultiSegmentation*>(segmentation)->subSegmentations()) {
subsegmentation = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged*>(subSegm.segmentation);
subsegmentation = dynamic_cast<dd4hep::DDSegmentation::FCCSWGridModuleThetaMerged_k4geo*>(subSegm.segmentation);
if (subsegmentation == nullptr) {
warning() << "At least one of the sub-segmentations in MultiSegmentation named " << aReadoutName << " is not a module-theta grid." << endmsg;
return std::make_pair(nullptr, SegmentationType::kWrong);
Expand Down
24 changes: 14 additions & 10 deletions RecFCCeeCalorimeter/src/components/CaloTowerToolFCCee.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@
// from Gaudi
#include "GaudiAlg/GaudiTool.h"

// FCCSW
#include "DetSegmentation/FCCSWGridModuleThetaMerged.h"
// k4geo
#include "detectorSegmentations/FCCSWGridModuleThetaMerged_k4geo.h"

// k4FWCore
#include "k4FWCore/DataHandle.h"
#include "k4Interface/ITowerToolThetaModule.h"

class IGeoSvc;
#include "DDSegmentation/MultiSegmentation.h"

// datamodel
namespace edm4hep {
class CalorimeterHitCollection;
class CalorimeterHit;
class Cluster;
}
// dd4hep
#include "DDSegmentation/MultiSegmentation.h"

namespace dd4hep {
namespace DDSegmentation {
Expand All @@ -26,6 +22,14 @@ class BitFieldCoder;
}
}

// edm4hep
namespace edm4hep {
class CalorimeterHitCollection;
class CalorimeterHit;
class Cluster;
}


/** @class CaloTowerToolFCCee Reconstruction/RecFCCeeCalorimeter/src/components/CaloTowerToolFCCee.h
*
* Tool building the calorimeter towers for the sliding window algorithm.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ StatusCode CreateCaloClustersSlidingWindowFCCee::initialize() {
error() << "Unable to retrieve the tower building tool." << endmsg;
return StatusCode::FAILURE;
}

// Get number of calorimeter towers
auto towerMapSize = m_towerTool->towersNumber();
m_nThetaTower = towerMapSize.theta;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#include "GaudiAlg/GaudiAlgorithm.h"
#include "GaudiKernel/ToolHandle.h"

// FCCSW
// k4FWCore
#include "k4FWCore/DataHandle.h"
#include "k4Interface/ITowerToolThetaModule.h"

// datamodel
// edm4hep
namespace edm4hep {
class ClusterCollection;
}
Expand Down

0 comments on commit 5cc6d81

Please sign in to comment.