6#include "CLHEP/Units/SystemOfUnits.h"
8#include "GaudiKernel/AlgTool.h"
10#include "Gaudi/Property.h"
11#include "GaudiKernel/Service.h"
12#include "GaudiKernel/IToolSvc.h"
21#include "CaloEvent/CaloTower.h"
22#include "CaloEvent/CaloTowerContainer.h"
28#include "CaloEvent/CaloCluster.h"
36 const std::string&
type,
37 const IInterface* parent)
41 declareInterface<ICaloTopoTowerBuilderToolBase>(
this);
58 return StatusCode::SUCCESS;
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;
102 ATH_MSG_DEBUG(
"Energy cuts " << minimumCellEnergy <<
" " << minimumClusterEnergy <<
" " << useCellWeights);
108 ATH_MSG_DEBUG(
"Noise cuts "<< noiseSigma0 <<
" " << cellESignificanceThreshold);
111 std::vector<CaloCell_ID::SUBCALO> caloIndices = theTowers->
GetCaloIndices();
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);
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)
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);
193 const CaloCell* cell = (*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;
223 ATH_MSG_VERBOSE(
" Cell has E = " << signedE <<
" eta,phi " << cell->eta() <<
" " << cell->phi() );
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);
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 );
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);
295 msg(MSG::VERBOSE) << cell->e()*weight <<
" " << cell->eta() <<
" " << cell->phi() <<
" / ";
301 if(delete_cellToClusterMap){
303 delete cellToClusterMap;
308 return StatusCode::SUCCESS;
319 Identifier::size_type maxRange =
m_calo_id->calo_cell_hash_max();
320 cell2ClusterMap->
resize(maxRange);
322 ATH_MSG_DEBUG(
"CaloCluster container contains " << clusColl->
size() <<
" clusters");
327 if ((clust->getNumberOfCells()) == 0 ) {
328 ATH_MSG_DEBUG(
" no cells for this cluster... No reverse navigation possible...");
333 for( ;cellIter!=cellIterEnd;cellIter++) {
343 (*cell2ClusterMap)[myHashId] = theNav;
353 return cell2ClusterMap;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
CaloPhiRange class declaration.
map of CaloCluster objects each CaloCell belongs to
Container class for CaloCell.
CaloCell_Base_ID::SUBCALO SUBCALO
Data object for each calorimeter readout cell.
Storable container for CaloCluster.
Principal data class for CaloCell clusters.
virtual double getBasicEnergy() const
Access basic energy scale signal.
CaloCompositeCellBase< CaloClusterNavigable >::cell_iterator cell_iterator
Iterator on CaloCell s.
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.
Storable container class for CaloTower.
DataLink< CaloClusterContainer > GetClusters() const
float GetCellESignificanceThreshold() const
DataLink< CaloTowerContainer > GetTowers() const
bool GetUseCellWeights() const
double GetMinimumCellEnergy() const
DataLink< CaloCellContainer > GetCells() const
float GetNoiseSigma() const
const std::vector< CaloCell_ID::SUBCALO > & GetCaloIndices() const
bool GetCaloSelection() const
double GetMinimumClusterEnergy() const
const CaloCell2ClusterMap * GetCellToClusterMap() const
Storable container class for CaloTower.
index_t getTowerIndex(const CaloTower *aTower) const
Returns the combined index of a tower on the grid.
CaloTower * getTower(index_t eta, index_t phi)
Returns a pointer to a tower with given indices.
Data class for calorimeter cell towers.
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
void resize(size_type sz)
Resizes the collection to the specified number of elements.
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.
ElementLink implementation for ROOT usage.
This is a "hash" representation of an Identifier.
Navigable template generalization to handle navigation.
virtual unsigned int size() const
virtual object_iter begin() const
void putElement(const CONT *objectContainer, const constituent_type *constituentObject, const RPAR &objectParameter=RPAR(), size_t sizeHint=0)
NavigableIterator< CaloClusterContainer, NavigationDefaults::DefaultWeight, typename NavigationDefaults::DefaultChildColl< CaloClusterContainer, NavigationDefaults::DefaultWeight >::type > object_iter
virtual object_iter end() const
const CONT * getContainer(const constituent_type *aConstituent) const
virtual void setE(double theE)
set energy data member
std::string find(const std::string &s)
return a remapped string