63 ATH_CHECK(m_inputCellContainerKey.initialize());
64 ATH_CHECK(m_inputTileCellContainerKey.initialize(!m_energyWeightedCluster && m_use_tileCells));
65 ATH_CHECK(m_inputTriggerTowerContainerKey.initialize(!m_use_tileCells));
68 ATH_CHECK(m_outputClusterContainerKey.initialize());
70 ATH_CHECK(m_eFexEWClusterTool.retrieve());
71 ATH_CHECK(m_eFexDefaultClusterTool.retrieve());
72 return StatusCode::SUCCESS;
80 if (!scellsHandle.isValid())
82 ATH_MSG_ERROR(
"Failed to retrieve " << m_inputCellContainerKey.key());
83 return StatusCode::FAILURE;
86 if (m_useProvenanceSkim)
88 for (
const CaloCell *scell : *scellsHandle)
89 if (scell->provenance() & m_qualBitMask)
93 scells.
assign(scellsHandle->begin(), scellsHandle->end());
95 auto clusters = std::make_unique<xAOD::TrigEMClusterContainer>();
96 auto auxClusters = std::make_unique<xAOD::TrigEMClusterAuxContainer>();
97 clusters->setStore(auxClusters.get());
99 if (!m_energyWeightedCluster)
105 const TileID *tileIDHelper{
nullptr};
109 auto tileCellHandle =
SG::makeHandle(m_inputTileCellContainerKey, ctx);
110 if (!tileCellHandle.isValid())
112 ATH_MSG_ERROR(
"Failed to retrieve " << m_inputTileCellContainerKey.key());
113 return StatusCode::FAILURE;
115 tileCellCont.
assign(tileCellHandle->begin(), tileCellHandle->end());
116 tileIDHelper = caloMgr->getTileID();
120 auto triggerTowerHandle =
SG::makeHandle(m_inputTriggerTowerContainerKey, ctx);
121 if (!triggerTowerHandle.isValid())
123 ATH_MSG_ERROR(
"Failed to retrieve " << m_inputTriggerTowerContainerKey.key());
124 return StatusCode::FAILURE;
126 TTs = triggerTowerHandle.cptr();
129 std::vector<LVL1::EFexEMClusterTool::AlgResult> algResults = m_eFexDefaultClusterTool->clusterAlg(m_apply_BaseLineCuts, &scells, TTs, idHelper, tileIDHelper, &tileCellCont);
130 for (
const auto &algCl : algResults)
134 cl->setEta(algCl.eta);
135 cl->setPhi(algCl.phi);
136 cl->setEt(algCl.clusterET);
137 cl->setWstot(algCl.l1Width);
138 if (algCl.hadET > -999)
140 cl->setEhad1(algCl.hadET);
142 cl->setE233(algCl.l2ClusterET33);
143 cl->setE237(algCl.l2ClusterET37);
144 decRun3REta(*
cl) = algCl.rEta;
145 decRun3RHad(*
cl) = algCl.rHad;
146 decRun3REtaL12(*
cl) = algCl.rEtaL12;
147 decPassRun3ClusterEnergy(*
cl) = algCl.passClusterEnergy;
148 decPassRun3REta(*
cl) = algCl.passREta;
149 decPassRun3RHad(*
cl) = algCl.passRHad;
150 decPassRun3wstot(*
cl) = algCl.passWstot;
169 if (!m_use_tileCells)
171 auto ttHandle =
SG::makeHandle(m_inputTriggerTowerContainerKey, ctx);
172 if (!ttHandle.isValid())
174 ATH_MSG_ERROR(
"Failed to retrieve " << m_inputTriggerTowerContainerKey.key());
175 return StatusCode::FAILURE;
177 TTs = ttHandle.cptr();
180 std::vector<const CaloCell *> cellsAround;
181 std::vector<const CaloCell *> cellsAboveThr;
182 cellsAround.reserve(200);
183 cellsAboveThr.reserve(200);
186 m_eFexEWClusterTool->findCellsAbove_EMB2_EMEC2(&scells, m_seedE, cellsAboveThr);
188 for (
auto cellAbove : cellsAboveThr)
191 m_eFexEWClusterTool->findCellsAround(&scells, cellAbove, cellsAround, m_deta_cellFormation, m_dphi_cellFormation);
194 float etaCluster{0}, phiCluster{0};
195 m_eFexEWClusterTool->findCluster(cellsAround, etaCluster, phiCluster);
196 if (std::abs(etaCluster) > 998.0)
202 m_eFexEWClusterTool->findCellsAround(&scells, etaCluster, phiCluster, cellsAround, m_deta, m_dphi);
204 if (std::abs(etaCluster) >= m_eta_limit)
209 if (!m_eFexEWClusterTool->isCellEmMaximum(cellsAround, cellAbove))
211 float clusterTime = 0;
212 float clusterTimeWeight = 0;
213 for (
auto cellAround : cellsAround)
215 if (cellAround->et() < m_timeThr)
217 clusterTime += cellAround->time() * cellAround->et();
218 clusterTimeWeight += cellAround->et();
220 if (std::abs(clusterTimeWeight) > 0.1)
222 clusterTime /= clusterTimeWeight;
226 clusterTime = -999.99;
228 ATH_MSG_DEBUG(
"CELL versus CLUSTER : " << cellAbove->eta() <<
" " << cellAbove->phi() <<
" " << etaCluster <<
" " << phiCluster <<
" " << cellAbove->eta() - etaCluster <<
" " << cellAbove->phi() - phiCluster);
231 std::vector<const CaloCell *> cellsAround2;
232 m_eFexEWClusterTool->findCellsAround(&scells, (
float)etaCluster, (
float)phiCluster, cellsAround2, m_deta_clusterFormation_2, m_dphi_clusterFormation_2);
235 std::vector<const xAOD::TriggerTower *> TTsAround;
236 m_eFexEWClusterTool->findTTsAround(TTs, etaCluster, phiCluster, TTsAround);
238 float et = m_eFexEWClusterTool->sumEmCells(cellsAround) / TMath::CosH(cellAbove->eta());
239 float clusterEmEnergy32 = m_eFexEWClusterTool->sumEmCells2nd(cellsAround2);
240 if (clusterEmEnergy32 < m_clusterE_EMB2_EMEC2)
245 float clusterEmEnergy72 = m_eFexEWClusterTool->sumEmCells2nd(cellsAround);
246 float clusterHadEnergy = m_eFexEWClusterTool->sumHadCells(cellsAround) + m_eFexEWClusterTool->sumHadTTs(TTsAround);
255 cl->setEnergy(
et * TMath::CosH(cellAbove->eta()));
257 cl->setEta(cellAbove->eta());
258 cl->setPhi(cellAbove->phi());
259 cl->setE237(clusterEmEnergy32);
260 cl->setE277(clusterEmEnergy72);
261 cl->setEhad1(clusterHadEnergy);
262 cl->setE233(clusterTime);
264 float wstot_nor = 0.;
265 for (
auto cellAround : cellsAround)
267 unsigned int layer = cellAround->caloDDE()->getSampling();
271 if (cellAround->et() < 10)
273 wstot += (cellAround->et() *
pow(cellAround->eta() - etaCluster, 2));
274 wstot_nor += (cellAround->et());
277 if (std::abs(wstot_nor) > 0.01)
286 return StatusCode::SUCCESS;