42 std::vector<Gep::GepCaloCell> cells;
45 CHECK(h_gepCellsMap.isValid());
46 const auto & gepCellsMap = *h_gepCellsMap;
48 auto cell_map = gepCellsMap.getCellMap();
51 for (
auto const& cell_itr : *cell_map) {
52 cells.push_back(cell_itr.second);
58 CHECK(h_outputCaloClusters.
record(std::make_unique<xAOD::CaloClusterContainer>(),
59 std::make_unique<xAOD::CaloClusterAuxContainer>()));
63 std::vector<std::vector<unsigned int>> cell_ids;
64 auto customTowers = std::make_unique<xAOD::CaloTowerContainer>();
65 auto aux = std::make_unique<xAOD::CaloTowerAuxContainer>();
66 customTowers->setStore(aux.get());
69 static constexpr int nEta{98};
70 static constexpr int nPhi{64};
71 customTowers->configureGrid(nEta,-4.9,4.9,nPhi);
73 int nTowers = customTowers->nTowers();
74 cell_ids.resize(nTowers);
76 std::vector<std::vector<float>> layerEnergies;
77 layerEnergies.resize(nTowers);
78 for (
int iTower=0; iTower < nTowers; ++iTower) layerEnergies[iTower].resize((
int)CaloSampling::Unknown);
80 for (
int iTower=0; iTower < nTowers; ++iTower) {
81 auto tower = std::make_unique<xAOD::CaloTower>();
82 customTowers->push_back(std::move(tower));
83 customTowers->at(iTower)->reset();
87 for (
const auto& cell : cells) {
88 if (cell.isBadCell())
continue;
90 int idx = customTowers->index(cell.eta,cell.phi);
91 if (idx < 0)
continue;
95 customTowers->at(idx)->addEnergy(cell.et);
96 layerEnergies[idx][cell.sampling] += cell.et;
97 cell_ids[idx].push_back(cell.id);
101 for(
auto tower: *customTowers){
102 auto p4 = tower->p4();
105 if ( p4.E() <=
m_minEt )
continue;
108 auto *ptr = h_outputCaloClusters->push_back(std::make_unique<xAOD::CaloCluster>());
114 double eta = p4.Eta();
115 double phi = p4.Phi();
116 double e = p4.E() * std::cosh(
eta);
138 uint32_t samplingPattern=0;
139 for(
int i=0;i<(int)CaloSampling::Unknown;i++) {
140 if (layerEnergies[tower->index()].at(i)!=0) samplingPattern |= (0x1U<<i);
143 ptr->clearSamplingData();
144 ptr->setSamplingPattern(samplingPattern);
147 for(
int i=0;i<(int)CaloSampling::Unknown;i++) {
149 if (layerEnergies[tower->index()].at(i)!=0) ptr->setEnergy(sampling_i, layerEnergies[tower->index()].at(i) * std::cosh(
eta));
152 auto cccl = std::make_unique<CaloClusterCellLink>();
154 for (
auto cell_id : cell_ids[tower->index()])
155 cccl->addCell(cell_map->at(cell_id).index, 1.0);
157 ptr->addCellLink(std::move(cccl));
161 return StatusCode::SUCCESS;