Set tower energy according to the energy from cells in clusters passing selections
76 if (!towerContainer || !
clusters || !Cells) {
77 msg(MSG::WARNING) <<
" Missing input container : ";
78 if (!towerContainer)
msg(MSG::WARNING) <<
" no tower ";
79 if (!
clusters)
msg(MSG::WARNING) <<
" no TopoClusters ";
80 if (!Cells)
msg(MSG::WARNING) <<
" no Cells ";
81 msg(MSG::WARNING) <<
" .. no CaloTopoTowers are made " <<
endmsg;
82 return StatusCode::SUCCESS;
88 bool delete_cellToClusterMap=
false;
89 if(cellToClusterMap==
nullptr ){
91 delete_cellToClusterMap=
true;
97 double minimumCellEnergy = theTowers->GetMinimumCellEnergy();
98 double minimumClusterEnergy = theTowers->GetMinimumClusterEnergy();
100 bool useCellWeights = theTowers->GetUseCellWeights();
102 ATH_MSG_DEBUG(
"Energy cuts " << minimumCellEnergy <<
" " << minimumClusterEnergy <<
" " << useCellWeights);
104 float noiseSigma0 = theTowers->GetNoiseSigma();
105 float cellESignificanceThreshold = theTowers->GetCellESignificanceThreshold();
108 ATH_MSG_DEBUG(
"Noise cuts "<< noiseSigma0 <<
" " << cellESignificanceThreshold);
111 std::vector<CaloCell_ID::SUBCALO> caloIndices = theTowers->GetCaloIndices();
112 bool caloSelection = theTowers->GetCaloSelection();
114 ATH_MSG_DEBUG(
"caloSelection " << caloSelection <<
" " << caloIndices.size());
122 ATH_MSG_DEBUG(
"Starting loop over Navigable CaloCell2ClusterMap");
123 while ( clusterContainer ==
nullptr && fClusMap != lClusMap ){
131 const nav_t* pNav = (*fClusMap);
132 clusterContainer = pNav->getContainer(pNav->begin());
133 ATH_MSG_DEBUG(
"Successfully picked up CaloClusterContainer ");
139 if ( clusterContainer ==
nullptr ) {
140 if (!Cells->
empty() ) {
141 ATH_MSG_WARNING(
"No cluster found from CaloCell2ClusterMap, tool unusable" );
147 if(delete_cellToClusterMap){
149 delete cellToClusterMap;
153 return StatusCode::SUCCESS;
165 for (
const CaloTower* tower : *towerContainer)
167 int towerIndex = towerContainer->getTowerIndex(tower);
169 CaloTower* newTower = theTowers->getTower(towerIndex);
172 ATH_MSG_VERBOSE(
"In loop over tower grid: tower eta-phi" << tower->eta() <<
" " << tower->phi());
177 double energyTower = 0.0;
178 double totalAttachedClusterEnergy = 0.0;
179 int numberOfCellsInTower = 0;
180 int numberOfAttachedCellsInTower = 0;
181 int numberOfClustersInTower = 0;
182 int totalNumberOfCellsInAttachedClusters = 0;
185 for ( ; cellInTowerIter != lastCellInTower; cellInTowerIter++ ){
186 numberOfCellsInTower++;
190 double signedE = 0.0;
191 double weight = tower->getCellWeight(cellInTowerIter);
196 size_t globalIndex=0;
197 if (!(tower->getCellIndex(
cell,globalIndex)) ) {
204 std::vector<CaloCell_ID::SUBCALO>::const_iterator theFound =
205 find (caloIndices.begin(),caloIndices.end(),iCaloNum);
206 if (theFound==caloIndices.end()) continue ;
210 if (!useCellWeights)
weight = 1.0;
211 double cellEnergy =
weight * signedE;
216 float noiseSigma = 1.0;
217 if (cellESignificanceThreshold>=0.) {
218 noiseSigma = noiseSigma0;
219 if ( noiseSigma > 0. ) signedRatio = signedE/noiseSigma;
228 if ( (signedE > minimumCellEnergy) && ( fabs(signedRatio) > cellESignificanceThreshold) ){
230 size_t cellIndex(
cell->caloDDE()->calo_hash());
231 ATH_MSG_VERBOSE(
"Cell index from CaloCell2ClusterMap = " << cellIndex);
232 const nav_t* nav = (cellToClusterMap->operator[])(cellIndex);
243 for ( ; clusterIterator != lastCluster; clusterIterator++ ){
244 const CaloCluster* clusterFromCell = (*clusterIterator);
246 double eClus = clusterFromCell->
energy();
251 if ( eClusRaw > minimumClusterEnergy ){
254 numberOfAttachedCellsInTower++;
255 totalNumberOfCellsInAttachedClusters += clusterFromCell->
getNumberOfCells();
256 totalAttachedClusterEnergy += eClusRaw;
257 energyTower += cellEnergy;
258 numberOfClustersInTower++;
263 ATH_MSG_VERBOSE(
" -- Found at least one cluster passing cuts. 'break'");
275 newTower->
setE(energyTower);
280 ATH_MSG_VERBOSE(
"Old/ new TopoTower energy from all cells = " << tower->e() <<
" " << newTower->
e() );
281 ATH_MSG_VERBOSE(
"TopoTower energy adding all cells in clusters = " << energyTower );
282 ATH_MSG_VERBOSE(
"Total attached cluster energy = " << totalAttachedClusterEnergy );
283 ATH_MSG_VERBOSE(
"Total number of attached clusters = " << numberOfClustersInTower );
284 ATH_MSG_VERBOSE(
"Number of cells in attached clusters = " << totalNumberOfCellsInAttachedClusters );
285 ATH_MSG_VERBOSE(
"Total number of cells originally in tower = " << numberOfCellsInTower );
286 ATH_MSG_VERBOSE(
"Total number of cells from clusters = " << numberOfAttachedCellsInTower );
291 for ( ; cellInTowerIter != lastCellInTower; cellInTowerIter++ ) {
292 double weight = tower->getCellWeight(cellInTowerIter);
301 if(delete_cellToClusterMap){
303 delete cellToClusterMap;
308 return StatusCode::SUCCESS;