Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
DerivationFramework::JetCaloClusterThinning Class Reference

#include <JetCaloClusterThinning.h>

Inheritance diagram for DerivationFramework::JetCaloClusterThinning:
Collaboration diagram for DerivationFramework::JetCaloClusterThinning:

Public Member Functions

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

Private Member Functions

void setJetClustersMask (std::vector< bool > &, const xAOD::JetContainer *&) const
 
void setJetClustersMask (std::vector< bool > &, std::vector< const xAOD::Jet * > &) const
 

Private Attributes

std::atomic< unsigned int > m_ntotTopo
 
std::atomic< unsigned int > m_npassTopo
 
StringProperty m_streamName
 
SG::ThinningHandleKey< xAOD::CaloClusterContainerm_TopoClSGKey { this, "TopoClCollectionSGKey", "CaloCalTopoCluster", "" }
 
SG::ReadHandleKey< xAOD::JetContainerm_sgKey { this, "SGKey", "", "SG key of jet container to thin" }
 
Gaudi::Property< std::vector< std::string > > m_addClusterSGKey { this, "AdditionalClustersKey", {}, ""}
 
SG::ThinningHandleKey< xAOD::CaloClusterContainerm_tmpAddClusterKey { this, "TmpAddClustersKey","LCOriginTopoClusters",""}
 
std::vector< SG::ThinningHandleKey< xAOD::CaloClusterContainer > > m_addClusterKeys
 
std::string m_selectionString
 

Detailed Description

Definition at line 28 of file JetCaloClusterThinning.h.

Constructor & Destructor Documentation

◆ JetCaloClusterThinning()

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

Definition at line 23 of file JetCaloClusterThinning.cxx.

27  : base_class(t, n, p)
28  , m_ntotTopo(0)
29  , m_npassTopo(0)
30  , m_selectionString("")
31 {
32  declareProperty("SelectionString", m_selectionString);
33 }

◆ ~JetCaloClusterThinning()

DerivationFramework::JetCaloClusterThinning::~JetCaloClusterThinning ( )
virtualdefault

Member Function Documentation

◆ doThinning()

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

Definition at line 85 of file JetCaloClusterThinning.cxx.

86 {
87  const EventContext& ctx = Gaudi::Hive::currentContext();
88 
89  // Retrieve CalCaloTopo collection if required
90  SG::ThinningHandle<xAOD::CaloClusterContainer> importedTopoCaloCluster(
91  m_TopoClSGKey, ctx);
92 
93  // Check the event contains tracks
94  unsigned int nTopoClusters = importedTopoCaloCluster->size();
95  if (nTopoClusters == 0)
96  return StatusCode::SUCCESS;
97 
98  // Set up a mask with the same entries as the full CaloCalTopoClusters collection(s)
99  std::vector<bool> topomask;
100  topomask.assign(nTopoClusters, false);
101  m_ntotTopo += nTopoClusters;
102 
103  // Retrieve jet container
104  const xAOD::JetContainer* importedJets(nullptr);
105  SG::ReadHandle<xAOD::JetContainer> importedJetsHandle{ m_sgKey, ctx };
106  importedJets = importedJetsHandle.ptr();
107  if (importedJets == nullptr) {
108  ATH_MSG_ERROR("No jet collection with name " << m_sgKey.key()
109  << " found in StoreGate!");
110  return StatusCode::FAILURE;
111  }
112  unsigned int nJets(importedJets->size());
113  if (nJets == 0)
114  return StatusCode::SUCCESS;
115  std::vector<const xAOD::Jet*> jetToCheck;
116  jetToCheck.clear();
117 
118  // Execute the text parsers if requested
119  if (!m_selectionString.empty()) {
120  std::vector<int> entries = m_parser->evaluateAsVector();
121  unsigned int nEntries = entries.size();
122  // check the sizes are compatible
123  if (nJets != nEntries) {
124  ATH_MSG_ERROR("Sizes incompatible! Are you sure your selection string "
125  "used jets objects??");
126  return StatusCode::FAILURE;
127  } else {
128  // identify which e-gammas to keep for the thinning check
129  for (unsigned int i = 0; i < nJets; ++i)
130  if (entries[i] == 1)
131  jetToCheck.push_back((*importedJets)[i]);
132  }
133 
134  if(jetToCheck.empty())
135  return StatusCode::SUCCESS;
136 
137  for( const xAOD::Jet* jet : jetToCheck){
138  const auto& links = jet->constituentLinks();
139  for( const auto& link : links ) {
140  // Check that the link is valid:
141  if( ! link.isValid() ) {
142  continue;
143  }
144  topomask.at( link.index() ) = true;
145  }
146  }
147  }
148  else{
149  for( const xAOD::Jet* jet : *importedJets){
150  const auto& links = jet->constituentLinks();
151  for( const auto& link : links ) {
152  // Check that the link is valid:
153  if( ! link.isValid() ) {
154  continue;
155  }
156  topomask.at( link.index() ) = true;
157  }
158  }
159  }
160 
161  // Count up the mask contents
162  for (unsigned int i = 0; i < nTopoClusters; ++i) {
163  if (topomask[i])
164  ++m_npassTopo;
165  }
166 
167  // Execute the thinning service based on the mask. Finish.
168  importedTopoCaloCluster.keep(topomask);
169 
170  for(const auto & addClusterKey : m_addClusterKeys){
171  SG::ThinningHandle<xAOD::CaloClusterContainer> tempClusters(addClusterKey);
172  tempClusters.keep(topomask);
173  }
174 
175  return StatusCode::SUCCESS;
176 }

◆ finalize()

StatusCode DerivationFramework::JetCaloClusterThinning::finalize ( )
overridevirtual

Definition at line 74 of file JetCaloClusterThinning.cxx.

75 {
76  ATH_MSG_VERBOSE("finalize() ...");
77  ATH_MSG_INFO("Processed " << m_ntotTopo << " topo clusters, of which "
78  << m_npassTopo << " were retained ");
79  ATH_CHECK(finalizeParser());
80  return StatusCode::SUCCESS;
81 }

◆ initialize()

StatusCode DerivationFramework::JetCaloClusterThinning::initialize ( )
overridevirtual

Definition at line 40 of file JetCaloClusterThinning.cxx.

41 {
42  // Decide which collections need to be checked for ID TrackParticles
43  ATH_MSG_VERBOSE("initialize() ...");
45  ATH_MSG_INFO("Using " << m_TopoClSGKey.key()
46  << "as the source collection for topo calo clusters");
47  if (m_sgKey.empty()) {
48  ATH_MSG_FATAL("No jet collection provided for thinning.");
49  return StatusCode::FAILURE;
50  } else {
52  "Calo clusters associated with objects in "
53  << m_sgKey.key()
54  << " will be retained in this format with the rest being thinned away");
56  }
57 
58  for(unsigned int i=0; i < m_addClusterSGKey.size(); i++){
62  }
63 
64  // Set up the text-parsing machinery for selectiong the photon directly
65  // according to user cuts
66  if (!m_selectionString.empty()) {
67  ATH_CHECK(initializeParser(m_selectionString));
68  }
69 
70  return StatusCode::SUCCESS;
71 }

◆ setJetClustersMask() [1/2]

void DerivationFramework::JetCaloClusterThinning::setJetClustersMask ( std::vector< bool > &  ,
const xAOD::JetContainer *&   
) const
private

◆ setJetClustersMask() [2/2]

void DerivationFramework::JetCaloClusterThinning::setJetClustersMask ( std::vector< bool > &  ,
std::vector< const xAOD::Jet * > &   
) const
private

Member Data Documentation

◆ m_addClusterKeys

std::vector<SG::ThinningHandleKey<xAOD::CaloClusterContainer> > DerivationFramework::JetCaloClusterThinning::m_addClusterKeys
private

Definition at line 55 of file JetCaloClusterThinning.h.

◆ m_addClusterSGKey

Gaudi::Property<std::vector<std::string> > DerivationFramework::JetCaloClusterThinning::m_addClusterSGKey { this, "AdditionalClustersKey", {}, ""}
private

Definition at line 53 of file JetCaloClusterThinning.h.

◆ m_npassTopo

std::atomic<unsigned int> DerivationFramework::JetCaloClusterThinning::m_npassTopo
private

Definition at line 42 of file JetCaloClusterThinning.h.

◆ m_ntotTopo

std::atomic<unsigned int> DerivationFramework::JetCaloClusterThinning::m_ntotTopo
mutableprivate

Definition at line 41 of file JetCaloClusterThinning.h.

◆ m_selectionString

std::string DerivationFramework::JetCaloClusterThinning::m_selectionString
private

Definition at line 57 of file JetCaloClusterThinning.h.

◆ m_sgKey

SG::ReadHandleKey<xAOD::JetContainer> DerivationFramework::JetCaloClusterThinning::m_sgKey { this, "SGKey", "", "SG key of jet container to thin" }
private

Definition at line 51 of file JetCaloClusterThinning.h.

◆ m_streamName

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

Definition at line 44 of file JetCaloClusterThinning.h.

◆ m_tmpAddClusterKey

SG::ThinningHandleKey<xAOD::CaloClusterContainer> DerivationFramework::JetCaloClusterThinning::m_tmpAddClusterKey { this, "TmpAddClustersKey","LCOriginTopoClusters",""}
private

Definition at line 54 of file JetCaloClusterThinning.h.

◆ m_TopoClSGKey

SG::ThinningHandleKey<xAOD::CaloClusterContainer> DerivationFramework::JetCaloClusterThinning::m_TopoClSGKey { this, "TopoClCollectionSGKey", "CaloCalTopoCluster", "" }
private

Definition at line 49 of file JetCaloClusterThinning.h.


The documentation for this class was generated from the following files:
DerivationFramework::JetCaloClusterThinning::m_addClusterSGKey
Gaudi::Property< std::vector< std::string > > m_addClusterSGKey
Definition: JetCaloClusterThinning.h:53
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
DerivationFramework::JetCaloClusterThinning::m_addClusterKeys
std::vector< SG::ThinningHandleKey< xAOD::CaloClusterContainer > > m_addClusterKeys
Definition: JetCaloClusterThinning.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
DerivationFramework::JetCaloClusterThinning::m_tmpAddClusterKey
SG::ThinningHandleKey< xAOD::CaloClusterContainer > m_tmpAddClusterKey
Definition: JetCaloClusterThinning.h:54
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition: ThinningHandle.h:84
DerivationFramework::JetCaloClusterThinning::m_sgKey
SG::ReadHandleKey< xAOD::JetContainer > m_sgKey
Definition: JetCaloClusterThinning.h:51
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
DerivationFramework::JetCaloClusterThinning::m_selectionString
std::string m_selectionString
Definition: JetCaloClusterThinning.h:57
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
DMTest::links
links
Definition: CLinks_v1.cxx:22
DerivationFramework::JetCaloClusterThinning::m_TopoClSGKey
SG::ThinningHandleKey< xAOD::CaloClusterContainer > m_TopoClSGKey
Definition: JetCaloClusterThinning.h:49
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
DerivationFramework::JetCaloClusterThinning::m_ntotTopo
std::atomic< unsigned int > m_ntotTopo
Definition: JetCaloClusterThinning.h:41
DerivationFramework::JetCaloClusterThinning::m_npassTopo
std::atomic< unsigned int > m_npassTopo
Definition: JetCaloClusterThinning.h:42
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
entries
double entries
Definition: listroot.cxx:49
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
DerivationFramework::JetCaloClusterThinning::m_streamName
StringProperty m_streamName
Definition: JetCaloClusterThinning.h:44