67{
69
70
74 const CaloCellContainer* Cells=theTowers->GetCells();
75
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;
83 }
84
85 const ElementLink<CaloCellContainer> CellsEL (*Cells, 0, ctx);
86
87 const CaloCell2ClusterMap* cellToClusterMap=theTowers->GetCellToClusterMap();
88 bool delete_cellToClusterMap=false;
89 if(cellToClusterMap==nullptr ){
91 delete_cellToClusterMap=true;
92 }
96
97 double minimumCellEnergy = theTowers->GetMinimumCellEnergy();
98 double minimumClusterEnergy = theTowers->GetMinimumClusterEnergy();
99
100 bool useCellWeights = theTowers->GetUseCellWeights();
101
102 ATH_MSG_DEBUG(
"Energy cuts " << minimumCellEnergy <<
" " << minimumClusterEnergy <<
" " << useCellWeights);
103
104 float noiseSigma0 = theTowers->GetNoiseSigma();
105 float cellESignificanceThreshold = theTowers->GetCellESignificanceThreshold();
106
107
108 ATH_MSG_DEBUG(
"Noise cuts "<< noiseSigma0 <<
" " << cellESignificanceThreshold);
109
110
111 std::vector<CaloCell_ID::SUBCALO> caloIndices = theTowers->GetCaloIndices();
112 bool caloSelection = theTowers->GetCaloSelection();
113
114 ATH_MSG_DEBUG(
"caloSelection " << caloSelection <<
" " << caloIndices.size());
115
116
122 ATH_MSG_DEBUG(
"Starting loop over Navigable CaloCell2ClusterMap");
123 while ( clusterContainer == nullptr && fClusMap != lClusMap ){
125 if (*fClusMap) {
126
127
128
129
131 const nav_t* pNav = (*fClusMap);
132 clusterContainer = pNav->getContainer(pNav->begin());
133 ATH_MSG_DEBUG(
"Successfully picked up CaloClusterContainer ");
134 }
135 else ++fClusMap;
136 }
137
138
139 if ( clusterContainer == nullptr ) {
140 if (!Cells->
empty() ) {
141 ATH_MSG_WARNING(
"No cluster found from CaloCell2ClusterMap, tool unusable" );
142 }
143 else {
145 }
146
147 if(delete_cellToClusterMap){
149 delete cellToClusterMap;
151 }
152
153 return StatusCode::SUCCESS;
154 }
155 else
157
160
161
162
164
165 for (const CaloTower* tower : *towerContainer)
166 {
167 int towerIndex = towerContainer->getTowerIndex(tower);
168
169 CaloTower* newTower = theTowers->getTower(towerIndex);
170
172 ATH_MSG_VERBOSE(
"In loop over tower grid: tower eta-phi" << tower->eta() <<
" " << tower->phi());
175
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++;
187
188
189
190 double signedE = 0.0;
191 double weight = tower->getCellWeight(cellInTowerIter);
192
193 const CaloCell*
cell = (*cellInTowerIter);
194 if (!cell) continue;
195
196 size_t globalIndex=0;
197 if (!(tower->getCellIndex(cell,globalIndex)) ) {
199 continue;
200 }
201
202 if (caloSelection) {
204 std::vector<CaloCell_ID::SUBCALO>::const_iterator theFound =
205 find (caloIndices.begin(),caloIndices.end(),iCaloNum);
206 if (theFound==caloIndices.end()) continue ;
207 }
208
210 if (!useCellWeights)
weight = 1.0;
211 double cellEnergy =
weight * signedE;
212
213
214 float signedRatio=0;
215
216 float noiseSigma = 1.0;
217 if (cellESignificanceThreshold>=0.) {
218 noiseSigma = noiseSigma0;
219 if ( noiseSigma > 0. ) signedRatio = signedE/noiseSigma;
220 }
221
222
228 if ( (signedE > minimumCellEnergy) && ( fabs(signedRatio) > cellESignificanceThreshold) ){
229
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);
233
235 if (!nav) {
237 }
238 else{
243 for ( ; clusterIterator != lastCluster; clusterIterator++ ){
244 const CaloCluster* clusterFromCell = (*clusterIterator);
246 double eClus = clusterFromCell->
energy();
249
251 if ( eClusRaw > minimumClusterEnergy ){
253
254 numberOfAttachedCellsInTower++;
255 totalNumberOfCellsInAttachedClusters += clusterFromCell->
getNumberOfCells();
256 totalAttachedClusterEnergy += eClusRaw;
257 energyTower += cellEnergy;
258 numberOfClustersInTower++;
259
261
262
263 ATH_MSG_VERBOSE(
" -- Found at least one cluster passing cuts. 'break'");
264 break;
265
266 }
267 }
269 }
270 }
271 }
273
275 newTower->
setE(energyTower);
276
277
278 if (msgLvl(MSG::VERBOSE)) {
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 );
287
290 msg(MSG::VERBOSE) <<
" E*weight, eta, phi of cells in new tower ";
291 for ( ; cellInTowerIter != lastCellInTower; cellInTowerIter++ ) {
292 double weight = tower->getCellWeight(cellInTowerIter);
293 const CaloCell*
cell = (*cellInTowerIter);
294 if (!cell) continue;
296 }
298 }
299
300 }
301 if(delete_cellToClusterMap){
303 delete cellToClusterMap;
305 }
307
308 return StatusCode::SUCCESS;
309}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Athena::TPCnvVers::Old Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Current CaloTowerContainer
CaloCell_Base_ID::SUBCALO SUBCALO
virtual double getBasicEnergy() const
Access basic energy scale signal.
unsigned int getNumberOfCells() const
Return the number of cells in the store.
virtual double energy() const
Return energy.
void addUniqueCellNoKine(const CaloCellContainer *theContainer, index_type theIndex, double weight, size_t size_hint=0)
Add a cell (very fast)
cell_iterator cell_begin() const
Retrieve a STL-type begin() iterator for the cell store.
cell_iterator cell_end() const
Retrieve a STL-type end() iterator for the cell store.
virtual double e() const override final
get energy data member
CaloEnergyCluster::cell_iterator cell_iterator
Iterator on CaloCell s.
DataModel_detail::const_iterator< DataVector > const_iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
NavigableIterator< CaloClusterContainer, NavigationDefaults::DefaultWeight, typename NavigationDefaults::DefaultChildColl< CaloClusterContainer, NavigationDefaults::DefaultWeight >::type > object_iter
virtual void setE(double theE)
set energy data member
std::string find(const std::string &s)
return a remapped string