ATLAS Offline Software
Loading...
Searching...
No Matches
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)
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}
#define ATH_MSG_ERROR(x)
SG::ReadHandleKey< xAOD::JetContainer > m_sgKey
SG::ThinningHandleKey< xAOD::CaloClusterContainer > m_TopoClSGKey
std::vector< SG::ThinningHandleKey< xAOD::CaloClusterContainer > > m_addClusterKeys
const_pointer_type ptr()
Dereference the pointer.
double entries
Definition listroot.cxx:49
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".

◆ 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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)

◆ 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");
55 ATH_CHECK(m_sgKey.initialize());
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}
#define ATH_MSG_FATAL(x)
Gaudi::Property< std::vector< std::string > > m_addClusterSGKey
SG::ThinningHandleKey< xAOD::CaloClusterContainer > m_tmpAddClusterKey

◆ 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.

53{ this, "AdditionalClustersKey", {}, ""};

◆ 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.

51{ this, "SGKey", "", "SG key of jet container to thin" };

◆ 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.

44 { this,
45 "StreamName",
46 "",
47 "Name of the stream being thinned" };

◆ m_tmpAddClusterKey

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

Definition at line 54 of file JetCaloClusterThinning.h.

54{ this, "TmpAddClustersKey","LCOriginTopoClusters",""};

◆ m_TopoClSGKey

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

Definition at line 49 of file JetCaloClusterThinning.h.

49{ this, "TopoClCollectionSGKey", "CaloCalTopoCluster", "" };

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