ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
DerivationFramework::JetGhostThinning Class Reference

#include <JetGhostThinning.h>

Inheritance diagram for DerivationFramework::JetGhostThinning:
Collaboration diagram for DerivationFramework::JetGhostThinning:

Public Member Functions

 JetGhostThinning (const std::string &t, const std::string &n, const IInterface *p)
 
virtual ~JetGhostThinning ()
 
virtual StatusCode initialize () override
 
virtual StatusCode finalize () override
 
virtual StatusCode doThinning () const override
 

Private Attributes

StringProperty m_streamName
 
SG::ReadHandleKey< xAOD::JetContainerm_jetSGKey
 
StringProperty m_selectionString
 
StringProperty m_ghostName
 
StringProperty m_ghostContainerName
 
SG::ThinningHandleKey< xAOD::IParticleContainerm_ghostContainerKey
 

Detailed Description

Definition at line 26 of file JetGhostThinning.h.

Constructor & Destructor Documentation

◆ JetGhostThinning()

DerivationFramework::JetGhostThinning::JetGhostThinning ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Definition at line 15 of file JetGhostThinning.cxx.

17  : base_class(t, n, p) {}

◆ ~JetGhostThinning()

DerivationFramework::JetGhostThinning::~JetGhostThinning ( )
virtualdefault

Member Function Documentation

◆ doThinning()

StatusCode DerivationFramework::JetGhostThinning::doThinning ( ) const
overridevirtual

Definition at line 70 of file JetGhostThinning.cxx.

70  {
71  const EventContext &ctx = Gaudi::Hive::currentContext();
72 
73  // Retrieve jet collection
75  if (!jets.isValid()) {
76  ATH_MSG_ERROR("Failed to retrieve jet collection " << m_jetSGKey.key());
77  return StatusCode::FAILURE;
78  }
79 
80  // Get the jets that pass the selection
81  std::vector<const xAOD::Jet*> selectedJets;
82 
83  if (!m_selectionString.empty()) {
84  // Use the expression parser
85  std::vector<int> entries = m_parser->evaluateAsVector();
86  if (entries.size() != jets->size()) {
87  ATH_MSG_ERROR("Selection string evaluation size mismatch!");
88  return StatusCode::FAILURE;
89  }
90 
91  for (size_t i = 0; i < jets->size(); ++i) {
92  if (entries[i] == 1) {
93  selectedJets.push_back((*jets)[i]);
94  }
95  }
96  } else {
97  // Keep all jets
98  for (const auto* jet : *jets) {
99  selectedJets.push_back(jet);
100  }
101  }
102 
103  ATH_MSG_DEBUG("Number of selected jets: " << selectedJets.size()
104  << " out of " << jets->size());
105 
106  // Get thinning handle for the ghost container
108 
109  if (!ghostContainer.isValid()) {
110  ATH_MSG_WARNING("Ghost container " << m_ghostContainerKey.key() << " not valid, skipping");
111  return StatusCode::SUCCESS;
112  }
113 
114  size_t nObjects = ghostContainer->size();
115  std::vector<bool> mask(nObjects, false);
116  const int maskSize = static_cast<int>(mask.size());
117 
118  // Create accessor for the ghost association
120 
121  size_t nGhostLinks = 0;
122 
123  // Loop over selected jets and mark ghost objects to keep using their indices
124  for (const auto* jet : selectedJets) {
125  if (!jet) continue;
126 
127  // Check if this jet has the ghost association
128  if (!ghostAcc.isAvailable(*jet)) {
129  ATH_MSG_VERBOSE("Jet does not have ghost association: " << m_ghostName);
130  continue;
131  }
132 
133  // Get the ghost links
134  const std::vector<ElementLink<xAOD::IParticleContainer>>& ghostLinks = ghostAcc(*jet);
135 
136  ATH_MSG_VERBOSE("Jet has " << ghostLinks.size() << " ghost objects");
137 
138  // Mark all valid ghost objects using their indices
139  for (const auto& link : ghostLinks) {
140  if (!link.isValid()) continue;
141 
142  int index = link.index();
143  if (index < 0) {
144  ATH_MSG_VERBOSE(" Ghost link has negative index, skipping");
145  continue;
146  }
147 
148  if (index < maskSize) {
149  mask[index] = true;
150  nGhostLinks++;
151  const xAOD::IParticle* ghostObj = *link;
152  if (ghostObj) {
153  ATH_MSG_VERBOSE(" Ghost object at index " << index << ": pt=" << ghostObj->pt()
154  << ", eta=" << ghostObj->eta());
155  }
156  }
157  }
158  }
159 
160  size_t nKept = std::count(mask.begin(), mask.end(), true);
161  ATH_MSG_DEBUG("Found " << nGhostLinks << " ghost links from selected jets");
162  ATH_MSG_DEBUG("Ghost container " << m_ghostContainerKey.key() << ": keeping "
163  << nKept << " out of " << nObjects << " objects");
164 
165  ghostContainer.keep(mask);
166 
167  return StatusCode::SUCCESS;
168 }

◆ finalize()

StatusCode DerivationFramework::JetGhostThinning::finalize ( )
overridevirtual

Definition at line 64 of file JetGhostThinning.cxx.

64  {
65  ATH_MSG_VERBOSE("finalize() ...");
66  return StatusCode::SUCCESS;
67 }

◆ initialize()

StatusCode DerivationFramework::JetGhostThinning::initialize ( )
overridevirtual

Definition at line 23 of file JetGhostThinning.cxx.

23  {
24  ATH_MSG_VERBOSE("initialize() ...");
25 
26  // Check that we have a jet container
27  if (m_jetSGKey.empty()) {
28  ATH_MSG_FATAL("No jet collection provided!");
29  return StatusCode::FAILURE;
30  }
31 
33  ATH_MSG_INFO("Using " << m_jetSGKey.key() << " as the jet collection");
34 
35  // Initialize the selection string parser if provided
36  if (!m_selectionString.empty()) {
37  ATH_CHECK(initializeParser(m_selectionString));
38  ATH_MSG_INFO("Jet selection string: " << m_selectionString);
39  }
40 
41  // Check that we have a ghost name
42  if (m_ghostName.empty()) {
43  ATH_MSG_FATAL("No ghost name provided!");
44  return StatusCode::FAILURE;
45  }
46 
47  // Check that we have a ghost container name
48  if (m_ghostContainerName.empty()) {
49  ATH_MSG_FATAL("No ghost container name provided!");
50  return StatusCode::FAILURE;
51  }
52 
53  // Initialize thinning handle key
56 
57  ATH_MSG_INFO("Thinning ghost objects:");
58  ATH_MSG_INFO(" Ghost name: " << m_ghostName);
59  ATH_MSG_INFO(" Ghost container: " << m_ghostContainerName);
60 
61  return StatusCode::SUCCESS;
62 }

Member Data Documentation

◆ m_ghostContainerKey

SG::ThinningHandleKey<xAOD::IParticleContainer> DerivationFramework::JetGhostThinning::m_ghostContainerKey
private

Definition at line 52 of file JetGhostThinning.h.

◆ m_ghostContainerName

StringProperty DerivationFramework::JetGhostThinning::m_ghostContainerName
private
Initial value:
{
this, "GhostContainerName", "", "Name of the ghost object container (e.g., CaloCalFwdTopoTowers)"}

Definition at line 49 of file JetGhostThinning.h.

◆ m_ghostName

StringProperty DerivationFramework::JetGhostThinning::m_ghostName
private
Initial value:
{
this, "GhostName", "", "Name of the ghost association (e.g., GhostTower)"}

Definition at line 46 of file JetGhostThinning.h.

◆ m_jetSGKey

SG::ReadHandleKey<xAOD::JetContainer> DerivationFramework::JetGhostThinning::m_jetSGKey
private
Initial value:
{
this, "JetKey", "", "SG key for jet container"}

Definition at line 40 of file JetGhostThinning.h.

◆ m_selectionString

StringProperty DerivationFramework::JetGhostThinning::m_selectionString
private
Initial value:
{
this, "SelectionString", "", "Selection string for jets"}

Definition at line 43 of file JetGhostThinning.h.

◆ m_streamName

StringProperty DerivationFramework::JetGhostThinning::m_streamName
private
Initial value:
{this, "StreamName", "",
"Name of the stream being thinned"}

Definition at line 37 of file JetGhostThinning.h.


The documentation for this class was generated from the following files:
DerivationFramework::JetGhostThinning::m_ghostContainerKey
SG::ThinningHandleKey< xAOD::IParticleContainer > m_ghostContainerKey
Definition: JetGhostThinning.h:52
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DerivationFramework::JetGhostThinning::m_ghostName
StringProperty m_ghostName
Definition: JetGhostThinning.h:46
SG::ThinningHandleKey
HandleKey object for adding thinning to an object.
Definition: ThinningHandleKey.h:38
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
index
Definition: index.py:1
defineDB.jets
jets
Definition: JetTagCalibration/share/defineDB.py:24
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
XMLtoHeader.count
count
Definition: XMLtoHeader.py:84
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:459
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition: ThinningHandle.h:84
ROBbits::maskSize
const uint32_t maskSize
Definition: TrigMonROBData.cxx:17
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
DerivationFramework::JetGhostThinning::m_streamName
StringProperty m_streamName
Definition: JetGhostThinning.h:37
beamspotman.n
n
Definition: beamspotman.py:727
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
DerivationFramework::JetGhostThinning::m_selectionString
StringProperty m_selectionString
Definition: JetGhostThinning.h:43
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::IParticle::pt
virtual double pt() const =0
The transverse momentum ( ) of the particle.
DerivationFramework::JetGhostThinning::m_ghostContainerName
StringProperty m_ghostContainerName
Definition: JetGhostThinning.h:49
DerivationFramework::JetGhostThinning::m_jetSGKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetSGKey
Definition: JetGhostThinning.h:40
DeMoScan.index
string index
Definition: DeMoScan.py:362
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::IParticle::eta
virtual double eta() const =0
The pseudorapidity ( ) of the particle.
entries
double entries
Definition: listroot.cxx:49