|
ATLAS Offline Software
|
Go to the documentation of this file.
2 #include "GaudiKernel/MsgStream.h"
3 #include "GaudiKernel/SystemOfUnits.h"
15 #include "CaloGeoHelpers/CaloSampling.h"
21 #include "CaloDetDescr/CaloDetDescrElement.h"
51 const std::string&
name,
52 const IInterface* pParent)
54 , m_clusterContainerKey(
"CaloTopoClusters")
55 , m_cellContainerKey(
"AllCalo")
56 , m_energyThreshold(m_energyThresholdDef-1.)
57 , m_clusterRange(m_clusterRangeDef)
63 declareInterface<CaloTowerCollectionProcessor>(
this);
96 ATH_MSG_INFO(
"Configure for building topo-towers (filtered mode):");
99 ATH_MSG_WARNING(
"[ignore] cannot apply energy thresholds to topo-towers!");
114 ATH_MSG_INFO(
"[accept] configure exclusive towers: use cell energy threshold");
118 return StatusCode::FAILURE;
148 ATH_MSG_INFO(
"Cells from all samplings used for topo-cluster included");
157 for (
size_t i(0);
i<nex; ++
i ) {
166 std::map<bool,std::string> blu { {
true,
"true" }, {
false,
"false" } };
177 return StatusCode::SUCCESS;
181 {
return StatusCode::SUCCESS; }
195 return StatusCode::FAILURE;
217 size_t numberOfTowers=towerGeo->
towerBins();
218 protocont_t pProtoCont; pProtoCont.reserve(numberOfTowers);
240 if ( !pTopoClusCont.
isValid() ) {
242 return StatusCode::FAILURE;
259 for (
uint_t ipc(0); ipc<pProtoCont.size(); ++ipc ) {
289 volatile double pt1(pc1->pt());
290 volatile double pt2(pc2->pt());
291 return ( pt1 > pt2 );
296 return StatusCode::SUCCESS;
313 for (
const auto *pClus : pClusCont ) {
314 for (
auto fCell(pClus->cell_begin()); fCell != pClus->cell_end(); ++fCell ) {
315 uint_t cidx(
static_cast<uint_t>((*fCell)->caloDDE()->calo_hash()));
316 if ( cidx < cellTags.size() ) {
317 if ( !cellTags.at(cidx) ) { cellTags[cidx] = this->
addCellToProtoCluster(towerGeo,*fCell,pProtoCont); }
327 std::vector<std::tuple<const CaloCell*,double> > cellList(towerGeo->
totalNumberCells(),std::tuple<const CaloCell*,double>(
nullptr,0.));
328 for (
const auto *pClus : pClusCont ) {
330 for (
auto fCell(pClus->cell_begin()); fCell != pClus->cell_end(); ++fCell ) {
331 uint_t cidx(
static_cast<uint_t>((*fCell)->caloDDE()->calo_hash()));
332 if ( cellTags.at(cidx) ) {
333 std::get<1>(cellList[cidx]) += fCell.weight();
335 cellList[cidx] = std::tuple<const CaloCell*,double>(*fCell,fCell.weight());
336 cellTags[cidx] =
true;
344 for (
auto tpl : cellList ) { this->
addCellToProtoCluster(towerGeo,std::get<0>(tpl),pProtoCont,std::get<1>(tpl)); }
348 return cCtr+pProtoCont.size();
365 for (
const auto *pClus : pClusCont ) {
367 for (
auto fCell(pClus->cell_begin()); fCell != pClus->cell_end(); ++fCell ) {
371 cellWeights->
set(*fCell,fCell.weight());
376 for (
const auto *pClus : pClusCont ) {
380 for (
auto fCell(pClus->cell_begin()); fCell != pClus->cell_end(); ++fCell ) {
384 cellWeights->
set(*fCell,fCell.weight());
393 return cCtr+pProtoCont.size();
405 for (
const auto *cptr : pCellCont ) {
406 if ( cptr ==
nullptr ) {
415 return pProtoCont.size();
423 for (
const auto *cptr : pCellCont ) {
424 if ( cptr ==
nullptr ) {
434 return pProtoCont.size();
442 if ( cptr ==
nullptr ) {
return false; }
450 uint_t cellIdx(pProtoCont.at(towerIdx).getCellLinks()->getCellContainer()->findIndex(cptr->
caloDDE()->
calo_hash()));
451 pProtoCont[towerIdx].addCell(cellIdx,towerGeo->
cellWeight(elm)*
weight); ++nctr;
468 return nTowers == 6400
481 int nrc(0);
int hid(0);
482 auto fcell(clk->
begin());
483 while ( fcell != clk->
end() ) {
487 if ( pCell ==
nullptr ) {
490 (
void*)pCell,(
void*)aCell,++nrc,clk->
size()) );
505 }
else if ( fcell.weight() <= 0.0000001 ) {
519 {
return clnk.
size() > 0; }
529 if ( pCellCont ==
nullptr ) {
531 }
else if ( pCellCont->
empty() ) {
541 if ( algname.find_last_of(
'.') != std::string::npos ) {
algname =
algname.substr(
algname.find_last_of(
'.')+1); }
543 std::ofstream logstream; logstream.open(
logname);
544 if ( !logstream.is_open() ) {
548 logstream <<
"##########################################################################" << std::endl;
549 logstream <<
"### This file contains a list of CaloCell indices in CaloCellContainer ###" << std::endl;
550 logstream <<
"### for which this index is not the same as the calorimeter cell hash ###" << std::endl;
551 logstream <<
"### identifier. An empty list indicates full consistency between this ###" << std::endl;
552 logstream <<
"### index and the hash identifier for all cells. ###" << std::endl;
553 logstream <<
"##########################################################################" << std::endl;
554 logstream <<
"<begin list>--------------------------------------------------------------" << std::endl;
561 size_t ifc(0); std::bitset<200000> chkflg; chkflg.reset();
562 for (
size_t i(0);
i<pCellCont->
size(); ++
i ) {
563 if ( pCellCont->
at(
i) !=
nullptr ) {
566 std::string cni(
"UKNOWN");
567 double etai(0.);
double phii(0.);
569 if ( iel !=
nullptr ) {
570 cni = CaloRec::Lookup::getSamplingName(iel->
getSampling());
574 std::string cnc(
"UNKNOWN");
575 double etac(0.);
double phic(0.);
577 if ( cel !=
nullptr ) {
578 cnc = CaloRec::Lookup::getSamplingName(cel->
getSampling());
582 size_t cidx(pCellCont->
findIndex(chash));
583 logstream <<
CaloRec::Helpers::fmtMsg(
"[%06zu] Cell %6zu [%12.12s %5.3f %5.3f] non-matching id %6zu [%12.12s %5.3f %5.3f] findCell() index %6zu",
584 ++ifc,
i,cni.c_str(),etai,phii,chash,cnc.c_str(),etac,phic,cidx) << std::endl;
589 logstream <<
"<end list>----------------------------------------------------------------" << std::endl;
602 for (
size_t i(0);
i<chl.size(); ++
i ) {
if ( !chkflg.test(
i) ) { chl.push_back(
i); } }
603 if ( !chl.empty() ) {
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
uint_t buildLCWTopoTowers(const CaloTowerGeometry *towerGeo, const xAOD::CaloClusterContainer &clusCont, protocont_t &protoCont, CaloCellClusterWeights *cellWeights) const
LCW topo-towers.
bool m_orderByPt
Orders cluster container by , default true.
static bool filterProtoCluster(const CaloClusterCellLink &clnk)
Checks for and removes invalid cell links
ClusterSize
Enumeration to identify different cluster sizes.
const_pointer_type cptr()
Dereference the pointer.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
void clearSamplingData()
Clear the sampling data.
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
provides Calorimeter Sampling enum
const_iterator begin() const
const begin method
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_clusterContainerKey
Topo-cluster container key.
bool msgLvl(const MSG::Level lvl) const
bool check(size_t hash) const
Safe checking if cell is used by any cluster.
std::string fmtMsg(const char *fmt,...)
double towerPhi(index_t towerIndex) const
Return azimuth from global tower index (bin center)
bool m_applyCellEnergyThreshold
Apply cell energy threshold, default is false.
void set(size_t hash, double value)
uint_t buildExclTowers(const CaloTowerGeometry *towerGeo, const CaloCellContainer &pCellCont, protocont_t &pProtoCont) const
Exclusive towers.
Definition of CaloDetDescrManager.
SG::ReadHandleKey< CaloCellContainer > m_cellContainerKey
Calorimeter cell container.
float eta_raw() const
cell eta_raw
bool checkCellIndices(const CaloTowerGeometry *towerGeo, const CaloDetDescrManager *caloDDM, const CaloCellContainer *pCellCont) const
Checks consistency between cell indices and hash identifiers.
Bookkeeping of cells that make up a cluster Simplified replacement for CaloCellLink,...
static const double m_energyThresholdDef
Default energy threshold.
uint_t maxCellHash() const
Maximum cell hash value.
std::vector< CaloProtoCluster > protocont_t
Container for CaloProtoCluster objects.
Description of a calorimeter cluster.
const CaloCellContainer * getCellContainer() const
Method to access underlying cell container.
IdentifierHash calo_hash() const
cell calo hash
double m_clusterRange
Range where topo-clusters are used when m_buildCombinedSignal = true
bool m_doCellIndexCheck
Check cell hash index consistency if true (default false)
void setPhi0(flt_t)
Set raw of cluster seed.
bool m_buildCombinedSignal
Build topo-clusters within given range, else topo-towers.
bool isValidIndex(uint_t idx) const
Checks if argument is a valid index value.
::StatusCode StatusCode
StatusCode definition for legacy code.
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
SG::ReadCondHandleKey< CaloTowerGeometry > m_towerGeoKey
the name of the key of the CaloTowerGeometry object in the ConditonsStore
std::vector< CaloSampling::CaloSample > m_excludedSamplings
List of excluded samplings (CaloSampling::CaloSample enumerators)
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
double towerEta(index_t towerIndex) const
Return pseudorapidity from global tower index (bin center)
static xAOD::CaloCluster::ClusterSize getClusterSize(uint_t etaBins, uint_t phiBins)
Returns a cluster size tag from number of eta and phi bins in tower grid.
CaloTopoTowerFromClusterMaker(const std::string &type, const std::string &name, const IInterface *pParent)
Tool constructor.
CaloPhiRange class declaration.
uint_t buildInclTowers(const CaloTowerGeometry *towerGeo, const CaloCellContainer &pCellCont, protocont_t &pProtoCont) const
Inclusive towers.
CaloClusterCellLink::iterator removeCell(iterator cellItr)
Method to remove a cell.
bool addCellToProtoCluster(const CaloTowerGeometry *towerGeo, const CaloCell *cptr, protocont_t &pProtoCont, double weight=1.) const
Adding cells to proto-clusters.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
std::atomic< bool > CaloTopoTowerFromClusterMaker_checkCellIndices(false)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
uint_t towerBins() const
Total number of towers.
bool m_prepareLCW
Prepare LCW calibration, default is false.
virtual StatusCode initialize() override
Setting up the operational mode and corresponding parameters.
bool calculateKine(xAOD::CaloCluster *pClus, bool onlyKine=false)
Kinematic updates.
static const uint_t m_errorValueUINT
Error value for uint_t type values.
std::size_t uint_t
Unsigned integral type.
size_t size() const
size method
Tower geometry store and description provider.
std::vector< std::string > m_excludedSamplingsName
List of excluded samplings (human-readable names)
uint_t m_numberOfSamplings
Number of samplings.
std::ostream & operator<<(std::ostream &lhs, const TestGaudiProperty &rhs)
value_type push_back(value_type pElem)
Add an element to the end of the collection.
StatusCode initialize(bool used=true)
Wrapper to avoid constant divisions when using units.
Container class for CaloCell.
const_iterator end() const
const end method
bool m_removeSamplingData
Remove sampling data for towers.
Hash lookup of calibration weights for calorimeter cells.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
index_t towerIndex(IdentifierHash cellHash) const
Get global tower index for a calorimeter cell referenced by its hash identifier.
uint_t totalNumberCells() const
Total number of cells.
CaloClusterCellLink * releaseCellLinks()
Hand over ownership of CaloClusterCellLink to client.
void addCellLink(CaloClusterCellLink *CCCL)
This class provides the client interface for accessing the detector description information common to...
Data object for each calorimeter readout cell.
void setClusterSize(const ClusterSize)
Get cluster size.
CaloCell_ID::CaloSample getSampling() const
cell sampling
#define ATH_MSG_WARNING(x)
static const double m_clusterRangeDef
Default cluster range.
calo_element_vec_size element_size() const
total number of elements
int findIndex(const IdentifierHash theHash) const
Return index of the cell with a given hash.
uint_t buildEMTopoTowers(const CaloTowerGeometry *towerGeo, const xAOD::CaloClusterContainer &clusCont, protocont_t &protoCont) const
EM topo-towers.
virtual StatusCode execute(const EventContext &ctx, xAOD::CaloClusterContainer *pClusCont, CaloCellClusterWeights *cellWeights) const override
Execute the tool and fill the xAOD::CaloClusterContainer pointed to by pClusCont.
std::bitset< _CALOTOPOTOWERFROMCLUSTERMAKER_BITSET_SIZE > m_excludedSamplingsPattern
Bit pattern indicates if sampling is excluded.
virtual StatusCode finalize() override
Finalize the tool (no action)
static std::string getSamplingName(CaloSample theSample)
Returns a string (name) for each CaloSampling.
const T * at(size_type n) const
Access an element, as an rvalue.
bool m_useCellsFromClusters
Use cells from topo-clusters if true, else use all cells, default is true.
double cellWeight(const element_t &elm) const
Retrieve cell signal weight from lookup table entry.
size_type size() const noexcept
Returns the number of elements in the collection.
elementvector_t getTowers(IdentifierHash cellHash) const
Retrieve the list of towers associated with a calorimeter cell referenced by its hash identifier.
bool empty() const noexcept
Returns true if the collection is empty.
int cleanupCells(const CaloTowerGeometry *towerGeo, CaloClusterCellLink *clk, uint_t nclus) const
Checks CaloClusterCellLink for consistency.
double m_energyThreshold
Cell energy threshold, default is set in m_energyThresholdDef.
bool isInvalidIndex(index_t idx) const
Returns true if argument is equal to the value provided by invalidIndex()
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
float phi_raw() const
cell phi_raw