38 std::vector<Gep::GepCaloCell> cells;
41 CHECK(h_gepCellsMap.isValid());
42 const auto & gepCellsMap = *h_gepCellsMap;
44 auto cell_map = gepCellsMap.getCellMap();
47 for (
auto const& cell_itr : *cell_map) {
48 cells.push_back(cell_itr.second);
54 CHECK(h_outputCaloClusters.
record(std::make_unique<xAOD::CaloClusterContainer>(),
55 std::make_unique<xAOD::CaloClusterAuxContainer>()));
59 std::vector<std::vector<unsigned int>> cell_ids;
60 auto customTowers = std::make_unique<xAOD::CaloTowerContainer>();
61 auto aux = std::make_unique<xAOD::CaloTowerAuxContainer>();
62 customTowers->setStore(
aux.get());
65 static constexpr int nEta{98};
66 static constexpr int nPhi{64};
67 customTowers->configureGrid(nEta,-4.9,4.9,nPhi);
69 int nTowers = customTowers->nTowers();
70 cell_ids.resize(nTowers);
72 for (
int iTower=0; iTower < nTowers; ++iTower) {
73 auto tower = std::make_unique<xAOD::CaloTower>();
74 customTowers->push_back(std::move(tower));
75 customTowers->at(iTower)->reset();
79 for (
const auto& cell : cells) {
80 if (cell.sigma < 2)
continue;
81 if (cell.isBadCell())
continue;
83 int idx = customTowers->index(cell.eta,cell.phi);
84 if (idx < 0)
continue;
88 customTowers->at(idx)->addEnergy(cell.et);
89 cell_ids[idx].push_back(cell.id);
93 for(
auto tower: *customTowers){
94 auto p4 = tower->p4();
97 if ( p4.E() == 0 )
continue;
100 auto *ptr = h_outputCaloClusters->push_back(std::make_unique<xAOD::CaloCluster>());
106 double eta = p4.Eta();
107 double phi = p4.Phi();
108 double e = p4.E() * std::cosh(
eta);
120 auto cccl = std::make_unique<CaloClusterCellLink>();
122 for (
auto cell_id : cell_ids[tower->index()])
123 cccl->addCell(cell_map->at(cell_id).index, 1.0);
125 ptr->addCellLink(std::move(cccl));
129 return StatusCode::SUCCESS;