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

#include <GepEtaSoftKillerAlg.h>

Inheritance diagram for GepEtaSoftKillerAlg:
Collaboration diagram for GepEtaSoftKillerAlg:

Public Member Functions

 GepEtaSoftKillerAlg (const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize () override
virtual StatusCode execute (const EventContext &ctx) const override
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual unsigned int cardinality () const override
 Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
virtual void setFilterPassed (bool state, const EventContext &ctx) const
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 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

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

SG::ReadHandleKey< xAOD::CaloClusterContainerm_inputClustersKey
SG::WriteHandleKey< xAOD::CaloClusterContainerm_outputClustersKey
Gaudi::Property< double > m_gridEtaSize
Gaudi::Property< double > m_gridPhiSize
Gaudi::Property< double > m_etaMax
Gaudi::Property< int > m_etaBandWidth
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
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

Definition at line 11 of file GepEtaSoftKillerAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ GepEtaSoftKillerAlg()

GepEtaSoftKillerAlg::GepEtaSoftKillerAlg ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 13 of file GepEtaSoftKillerAlg.cxx.

15 : AthReentrantAlgorithm(name, pSvcLocator) {}

Member Function Documentation

◆ cardinality()

unsigned int AthCommonReentrantAlgorithm< Gaudi::Algorithm >::cardinality ( ) const
overridevirtualinherited

Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.

Override this to return 0 for reentrant algorithms.

Definition at line 75 of file AthCommonReentrantAlgorithm.cxx.

62{
63 return 0;
64}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::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 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::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< Gaudi::Algorithm > >::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< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

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

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode GepEtaSoftKillerAlg::execute ( const EventContext & ctx) const
overridevirtual

Definition at line 26 of file GepEtaSoftKillerAlg.cxx.

26 {
27 ATH_MSG_DEBUG("Executing " << name() << "...");
28
29 auto h_input = SG::makeHandle(m_inputClustersKey, ctx);
30 ATH_CHECK(h_input.isValid());
31 const auto& inputClusters = *h_input;
32
33 ATH_MSG_DEBUG("Read in " << inputClusters.size() << " input clusters/towers");
34
35 // Build the eta-phi grid
36 const double minEta = -m_etaMax;
37 const double maxEta = m_etaMax;
38 const double twopi = 2.0 * M_PI;
39
40 int neta = std::max(static_cast<int>((maxEta - minEta) / m_gridEtaSize + 0.5), 1);
41 double deta = (maxEta - minEta) / neta;
42
43 int nphi = static_cast<int>(twopi / m_gridPhiSize + 0.5);
44 double dphi = twopi / nphi;
45
46 std::vector<double> eta_bins(neta + 1);
47 const double minPhi = -M_PI;
48 std::vector<double> phi_bins(nphi + 1);
49
50 for (int i = 0; i <= neta; ++i) {
51 eta_bins[i] = minEta + i * deta;
52 }
53 for (int i = 0; i <= nphi; ++i) {
54 phi_bins[i] = minPhi + i * dphi;
55 }
56
57 // Grid: each cell holds pointers to its clusters
58 std::vector<std::vector<std::vector<const xAOD::CaloCluster*>>>
59 grid(neta, std::vector<std::vector<const xAOD::CaloCluster*>>(nphi));
60
61 for (const auto* cluster : inputClusters) {
62 double eta = cluster->eta();
63 double phi = cluster->phi();
64
65 int eta_bin = static_cast<int>(
66 std::distance(eta_bins.begin(),
67 std::upper_bound(eta_bins.begin(), eta_bins.end(), eta))) - 1;
68 int phi_bin = static_cast<int>(
69 std::distance(phi_bins.begin(),
70 std::upper_bound(phi_bins.begin(), phi_bins.end(), phi))) - 1;
71
72 if (eta_bin >= 0 && eta_bin < neta && phi_bin >= 0 && phi_bin < nphi) {
73 grid[eta_bin][phi_bin].push_back(cluster);
74 }
75 }
76
77 // Compute the median of max-pT values per eta-band
78 // Empty grid cells contribute 0.0 (consistent with FastJet SoftKiller)
79 const int bandWidth = m_etaBandWidth;
80 int nBands = (neta + bandWidth - 1) / bandWidth;
81 std::vector<double> medianPerBand(nBands, 0.0);
82
83 for (int band = 0; band < nBands; ++band) {
84 std::vector<double> maxPtValues;
85 int etaStart = band * bandWidth;
86 int etaEnd = std::min(etaStart + bandWidth, neta);
87
88 for (int j = 0; j < nphi; ++j) {
89 for (int i = etaStart; i < etaEnd; ++i) {
90 const auto& cell = grid[i][j];
91 if (!cell.empty()) {
92 double maxPt = (*std::max_element(
93 cell.begin(), cell.end(),
94 [](const xAOD::CaloCluster* a,
95 const xAOD::CaloCluster* b) {
96 return a->pt() < b->pt();
97 }))->pt();
98 maxPtValues.push_back(maxPt);
99 } else {
100 maxPtValues.push_back(0.0);
101 }
102 }
103 }
104
105 if (!maxPtValues.empty()) {
106 std::sort(maxPtValues.begin(), maxPtValues.end());
107 size_t mid = maxPtValues.size() / 2;
108 if (maxPtValues.size() % 2 == 0) {
109 medianPerBand[band] =
110 (maxPtValues[mid - 1] + maxPtValues[mid]) / 2.0;
111 } else {
112 medianPerBand[band] = maxPtValues[mid];
113 }
114 }
115
116 ATH_MSG_DEBUG("Eta band " << band
117 << " [" << eta_bins[etaStart] << ", "
118 << eta_bins[etaEnd] << ")"
119 << ": median pT threshold = " << medianPerBand[band]);
120 }
121
122 // Create output container
123 SG::WriteHandle<xAOD::CaloClusterContainer> h_output =
125 ATH_CHECK(h_output.record(
126 std::make_unique<xAOD::CaloClusterContainer>(),
127 std::make_unique<xAOD::CaloClusterAuxContainer>()));
128
129 // Apply eta-dependent pT threshold:
130 // weight = 1.0 if cluster pT > band median, else 0.0
131 for (int i = 0; i < neta; ++i) {
132 int band = i / bandWidth;
133 double threshold = medianPerBand[band];
134
135 for (int j = 0; j < nphi; ++j) {
136 for (const auto* cluster : grid[i][j]) {
137 double weight = (cluster->pt() > threshold) ? 1.0 : 0.0;
138
139 auto* out = h_output->push_back(
140 std::make_unique<xAOD::CaloCluster>());
141 out->setE(cluster->e() * weight);
142 out->setEta(cluster->eta());
143 out->setPhi(cluster->phi());
144 out->setM(cluster->m());
145 }
146 }
147 }
148
149 ATH_MSG_DEBUG("Output " << h_output->size()
150 << " clusters after EtaSoftKiller");
151
152 return StatusCode::SUCCESS;
153}
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
static Double_t a
constexpr double twopi
Gaudi::Property< double > m_gridPhiSize
Gaudi::Property< double > m_etaMax
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_inputClustersKey
Gaudi::Property< double > m_gridEtaSize
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_outputClustersKey
Gaudi::Property< int > m_etaBandWidth
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
constexpr float maxEta
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::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

◆ extraOutputDeps()

const DataObjIDColl & AthCommonReentrantAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 94 of file AthCommonReentrantAlgorithm.cxx.

88{
89 // If we didn't find any symlinks to add, just return the collection
90 // from the base class. Otherwise, return the extended collection.
91 if (!m_extendedExtraObjects.empty()) {
93 }
95}
An algorithm that can be simultaneously executed in multiple threads.

◆ filterPassed()

virtual bool AthCommonReentrantAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Definition at line 96 of file AthCommonReentrantAlgorithm.h.

96 {
97 return execState( ctx ).filterPassed();
98 }
virtual bool filterPassed(const EventContext &ctx) const

◆ initialize()

StatusCode GepEtaSoftKillerAlg::initialize ( )
overridevirtual

Definition at line 18 of file GepEtaSoftKillerAlg.cxx.

18 {
19 ATH_MSG_INFO("Initializing " << name() << "...");
20 ATH_CHECK(m_inputClustersKey.initialize());
21 ATH_CHECK(m_outputClustersKey.initialize());
22 return StatusCode::SUCCESS;
23}
#define ATH_MSG_INFO(x)

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::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.

◆ isClonable()

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

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

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::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< Gaudi::Algorithm > >::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< Gaudi::Algorithm > >::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< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed()

virtual void AthCommonReentrantAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Definition at line 100 of file AthCommonReentrantAlgorithm.h.

100 {
102 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const

◆ sysExecute()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Definition at line 85 of file AthCommonReentrantAlgorithm.cxx.

75{
76 return BaseAlg::sysExecute (ctx);
77}

◆ sysInitialize()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in HypoBase, and InputMakerBase.

Definition at line 61 of file AthCommonReentrantAlgorithm.cxx.

105 {
107
108 if (sc.isFailure()) {
109 return sc;
110 }
111
112 ServiceHandle<ICondSvc> cs("CondSvc",name());
113 for (auto h : outputHandles()) {
114 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
115 // do this inside the loop so we don't create the CondSvc until needed
116 if ( cs.retrieve().isFailure() ) {
117 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
118 return StatusCode::SUCCESS;
119 }
120 if (cs->regHandle(this,*h).isFailure()) {
122 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
123 << " with CondSvc");
124 }
125 }
126 }
127 return sc;
128}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::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< Gaudi::Algorithm > >::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 }

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_etaBandWidth

Gaudi::Property<int> GepEtaSoftKillerAlg::m_etaBandWidth
private
Initial value:
{this, "etaBandWidth", 2,
"Number of eta rows per band for median calculation"}

Definition at line 34 of file GepEtaSoftKillerAlg.h.

34 {this, "etaBandWidth", 2,
35 "Number of eta rows per band for median calculation"};

◆ m_etaMax

Gaudi::Property<double> GepEtaSoftKillerAlg::m_etaMax
private
Initial value:
{this, "etaMax", 4.9,
"Maximum |eta| extent of the grid"}

Definition at line 31 of file GepEtaSoftKillerAlg.h.

31 {this, "etaMax", 4.9,
32 "Maximum |eta| extent of the grid"};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonReentrantAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 114 of file AthCommonReentrantAlgorithm.h.

◆ m_gridEtaSize

Gaudi::Property<double> GepEtaSoftKillerAlg::m_gridEtaSize
private
Initial value:
{this, "gridEtaSize", 0.6,
"Grid cell size in eta"}

Definition at line 25 of file GepEtaSoftKillerAlg.h.

25 {this, "gridEtaSize", 0.6,
26 "Grid cell size in eta"};

◆ m_gridPhiSize

Gaudi::Property<double> GepEtaSoftKillerAlg::m_gridPhiSize
private
Initial value:
{this, "gridPhiSize", 0.6,
"Grid cell size in phi"}

Definition at line 28 of file GepEtaSoftKillerAlg.h.

28 {this, "gridPhiSize", 0.6,
29 "Grid cell size in phi"};

◆ m_inputClustersKey

SG::ReadHandleKey<xAOD::CaloClusterContainer> GepEtaSoftKillerAlg::m_inputClustersKey
private
Initial value:
{
this, "inputClustersKey", "", "Input cluster/tower container"}

Definition at line 19 of file GepEtaSoftKillerAlg.h.

19 {
20 this, "inputClustersKey", "", "Input cluster/tower container"};

◆ m_outputClustersKey

SG::WriteHandleKey<xAOD::CaloClusterContainer> GepEtaSoftKillerAlg::m_outputClustersKey
private
Initial value:
{
this, "outputClustersKey", "", "Output EtaSK-suppressed cluster container"}

Definition at line 22 of file GepEtaSoftKillerAlg.h.

22 {
23 this, "outputClustersKey", "", "Output EtaSK-suppressed cluster container"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.


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