ATLAS Offline Software
Loading...
Searching...
No Matches
CaloClusterLogPos Class Reference

Cluster correction tool to compute the logarithmically weighted centroid. More...

#include <CaloClusterLogPos.h>

Inheritance diagram for CaloClusterLogPos:
Collaboration diagram for CaloClusterLogPos:

Public Member Functions

StatusCode initialize () override
StatusCode execute (const EventContext &ctx, xAOD::CaloCluster *theCluster) const override
 Execute on a single cluster.
 CaloClusterLogPos (const std::string &type, const std::string &name, const IInterface *parent)
 Standard AlgTool constructor.
virtual StatusCode execute (const EventContext &ctx, xAOD::CaloClusterContainer *collection) const
 Execute on an entire collection of clusters.
virtual StatusCode execute (xAOD::CaloClusterContainer *collection) final
 Execute on an entire collection of clusters.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
 DeclareInterfaceID (CaloClusterCollectionProcessor, 1, 0)

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Standard Gaudi interface ID method.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

double m_offset
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Cluster correction tool to compute the logarithmically weighted centroid.

The eta and phi position of a cluster are re-calculated with logarithmic weights instead of the default linear weights in cell energy. This gives cells in the shower tails larger weights and thus avoids the bias towards the center of the largest cell. This tool needs to be called after all energy correction tools since any update of the cell weights re-calculates eta and phi. The weighting is done according to:

\[ \eta = 1/{\rm norm} \times \sum\limits{{\rm cell}, w_{\rm cell} > 0} w_{\rm cell} \eta_{\rm cell} \]

with

\[ w_{\rm * cell} = w_0 + \log(|E_{\rm cell}|/|E_{\rm cluster}|) \]

,

\[ {\rm * norm} = \sum\limits{{\rm cell}, w_{\rm cell} > 0} w_{\rm cell} \]

,

where \(w_0\) is an offset to cut off cells with too small energy. The absolute values of the cell and cluster energies * are used in order to keep a valid position for clusters with * negative energy.

See also B.Brabson et al. Nucl. Inst. and Methods, A332 (419-443) 1993. eqn 14.

Definition at line 50 of file CaloClusterLogPos.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ CaloClusterLogPos()

CaloClusterLogPos::CaloClusterLogPos ( const std::string & type,
const std::string & name,
const IInterface * parent )

Standard AlgTool constructor.

Definition at line 14 of file CaloClusterLogPos.cxx.

17 :CaloClusterProcessor(type, name, parent),
18 m_offset(4.7)
19{
20 declareProperty ("LogPosOffset",m_offset) ;
21}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
CaloClusterProcessor(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ DeclareInterfaceID()

CaloClusterCollectionProcessor::DeclareInterfaceID ( CaloClusterCollectionProcessor ,
1 ,
0  )
inherited

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute() [1/3]

StatusCode CaloClusterLogPos::execute ( const EventContext & ctx,
xAOD::CaloCluster * cluster ) const
overridevirtual

Execute on a single cluster.

Parameters
clusterThe cluster to process.
ctxThe event context.

Implements CaloClusterProcessor.

Definition at line 31 of file CaloClusterLogPos.cxx.

33{
34
35 if ( msgSvc()->outputLevel(name()) <= MSG::DEBUG ) {
36
37 msg(MSG::DEBUG) << " old cluster eta = " << theCluster->eta()
38 << " phi = " << theCluster->phi() << endmsg;
39
40 // std::vector<double> theEtas;
41 // std::vector<double> thePhis;
42 // theCluster->getEtaInSamples(theEtas);
43 // theCluster->getPhiInSamples(thePhis);
44 // for(int i=0;i<CaloCell_ID::Unknown;i++) {
45 // report << MSG::DEBUG << " old sampling " << i << " eta = " << theEtas[i]
46 // << " phi = " << thePhis[i] << endmsg;
47 //}
48 }
49
50 const double absEClus = fabs(theCluster->e());
51
52 if ( absEClus > 0 ) {
53 const double inv_absEClus = 1. / absEClus;
54 std::vector<double> weightSample(CaloCell_ID::Unknown,0);
55 std::vector<double> etaSample(CaloCell_ID::Unknown,0);
56 std::vector<double> phiSample(CaloCell_ID::Unknown,0);
57
58 double weightAll(0),etaAll(0),phiAll(0);
59
60 xAOD::CaloCluster::cell_iterator itrCell = theCluster->cell_begin();
61 xAOD::CaloCluster::cell_iterator itrCellEnd = theCluster->cell_end();
62 for (;itrCell!=itrCellEnd; ++itrCell) {
63 const CaloCell* thisCell = *itrCell;
64 double weight = itrCell.weight();//theCluster->getCellWeight(itrCell);
65 // Identifier myId = thisCell->ID();
66 int theSample = thisCell->caloDDE()->getSampling();
67 double absE = fabs(weight*thisCell->e());
68
69 if ( absE > 0 ) {
70 double lw = m_offset + log(absE*inv_absEClus);
71 if ( lw > 0 ) {
72
73 ATH_MSG_VERBOSE(" add cell with eta "
74 << thisCell->eta() << " phi " << thisCell->phi()
75 << " energy " << thisCell->e() << " weight " << weight
76 << " sampling " << theSample << " cluster e "
77 << theCluster->e() << " log weight " << lw);
78
79
80 etaAll += thisCell->eta()*lw;
81
82 // first cell decides the sign in order to avoid
83 // overlap problem at phi = -pi == +pi
84 // need to be normalized to the range [-pi,+pi] in the end
85
86 if ( weightAll > 0
87 && phiAll/weightAll < CaloPhiRange::phi_min() + 90*deg
88 && thisCell->phi() > CaloPhiRange::phi_max() - 90*deg)
89 phiAll += (thisCell->phi()-360*deg)*lw;
90 else if ( weightAll > 0
91 && phiAll/weightAll > CaloPhiRange::phi_max() - 90*deg
92 && thisCell->phi() < CaloPhiRange::phi_min() + 90*deg)
93 phiAll += (thisCell->phi()+360*deg)*lw;
94 else
95 phiAll += thisCell->phi()*lw;
96
97 weightAll += lw;
98
99 etaSample[theSample] += thisCell->eta()*lw;
100 if ( weightSample[theSample] > 0
101 && phiSample[theSample]/weightSample[theSample]
103 && thisCell->phi() > CaloPhiRange::phi_max() - 90*deg)
104 phiSample[theSample] += (thisCell->phi()-360*deg)*lw;
105 else if ( weightSample[theSample] > 0
106 && phiSample[theSample]/weightSample[theSample]
108 && thisCell->phi() < CaloPhiRange::phi_min() + 90*deg)
109 phiSample[theSample] += (thisCell->phi()+360*deg)*lw;
110 else
111 phiSample[theSample] += thisCell->phi()*lw;
112 weightSample[theSample] += lw;
113
114 }
115 }
116 }
117
118 if ( weightAll > 0 ) {
119 const double inv_weightAll = 1. / weightAll;
120 theCluster->setEta(etaAll * inv_weightAll);
121 theCluster->setPhi(CaloPhiRange::fix(phiAll * inv_weightAll));
122 }
123
124 // std::vector<double> theEtas(CaloCell_ID::Unknown,0);
125 // std::vector<double> thePhis(CaloCell_ID::Unknown,0);
126 // for (int i=0;i<CaloCell_ID::Unknown;i++) {
127 // if (theCluster->hasSampling(i)) {
128 // theEtas[i]=theCluster->etaSampl(i);
129 // thePhis[i]=theCluster->phiSampl(i);
130 // }
131
132 for(int i=0;i<CaloCell_ID::Unknown;i++) {
134 if ( theCluster->hasSampling(s) && weightSample[i] > 0 ) {
135 float etaSample=theCluster->etaSample(s);
136 float phiSample=theCluster->phiSample(s);
137 etaSample /= weightSample[i];
138 phiSample /= weightSample[i];
139 phiSample = CaloPhiRange::fix(phiSample);
140 theCluster->setEta(s,etaSample);
141 theCluster->setPhi(s,phiSample);
142 }
143 }//end loop over samples
144 }
145
146 if ( msgSvc()->outputLevel(name()) <= MSG::DEBUG ) {
147
148 ATH_MSG_DEBUG(" new cluster eta = " << theCluster->eta()
149 << " phi = " << theCluster->phi());
150
151 // std::vector<double> theEtas;
152 // std::vector<double> thePhis;
153
154 // theCluster->getEtaInSamples(theEtas);
155 // theCluster->getPhiInSamples(thePhis);
156 // for(int i=0;i<CaloCell_ID::Unknown;i++) {
157 // msg(MSG::DEBUG) << " new sampling " << i << " eta = " << theEtas[i]
158 // << " phi = " << thePhis[i] << endmsg;
159 // }
160 }
161
162 return StatusCode::SUCCESS;
163}
#define endmsg
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
#define deg
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition CaloCell.h:333
virtual double phi() const override final
get phi (through CaloDetDescrElement)
Definition CaloCell.h:375
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition CaloCell.h:321
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition CaloCell.h:382
CaloCell_ID::CaloSample getSampling() const
cell sampling
static double phi_max()
static double fix(double phi)
static double phi_min()
CaloClusterCellLink::iterator cell_iterator
Iterator of the underlying CaloClusterCellLink (non-const version)
msgSvc
Provide convenience handles for various services.
Definition StdJOSetup.py:36
MsgStream & msg
Definition testRead.cxx:32

◆ execute() [2/3]

StatusCode CaloClusterProcessor::execute ( const EventContext & ctx,
xAOD::CaloClusterContainer * collection ) const
virtual

Execute on an entire collection of clusters.

Parameters
collectionThe container of clusters.

This will iterate over all the clusters in collection and call execute on each one individually.

Parameters
collectionThe container of clusters.
ctxThe event context.

This will iterate over all the clusters in collection and call execute on each one individually.

Reimplemented from CaloClusterProcessor.

Definition at line 65 of file CaloClusterProcessor.cxx.

47{
48 for (xAOD::CaloCluster* clu : *collection) {
49 ATH_CHECK( execute (ctx, clu) );
50 }
51 return StatusCode::SUCCESS;
52}
#define ATH_CHECK
Evaluate an expression and check for errors.
StatusCode execute(const EventContext &ctx, xAOD::CaloCluster *theCluster) const override
Execute on a single cluster.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.

◆ execute() [3/3]

virtual StatusCode CaloClusterCollectionProcessor::execute ( xAOD::CaloClusterContainer * collection)
inlinefinalvirtualinherited

Execute on an entire collection of clusters.

Parameters
collectionThe container of clusters. (deprecated)

Reimplemented from CaloClusterCollectionProcessor.

Definition at line 50 of file CaloClusterCollectionProcessor.h.

51 {
52 return execute (Gaudi::Hive::currentContext(), collection);
53 }
virtual StatusCode execute(const EventContext &ctx, xAOD::CaloCluster *cluster) const =0
Execute on a single cluster.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ initialize()

StatusCode CaloClusterLogPos::initialize ( )
override

Definition at line 24 of file CaloClusterLogPos.cxx.

24 {
25
26 ATH_MSG_DEBUG("Initializing " << name() << endmsg ) ;
27
28 return StatusCode::SUCCESS;
29}

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & CaloClusterProcessor::interfaceID ( )
inlinestaticinherited

Standard Gaudi interface ID method.

Definition at line 72 of file CaloClusterProcessor.h.

static const InterfaceID IID_CaloClusterProcessor("CaloClusterProcessor", 1, 0)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_offset

double CaloClusterLogPos::m_offset
private

Definition at line 69 of file CaloClusterLogPos.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: