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 EventContext &ctx) 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 22 of file JetCaloClusterThinning.cxx.

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

◆ ~JetCaloClusterThinning()

DerivationFramework::JetCaloClusterThinning::~JetCaloClusterThinning ( )
virtualdefault

Member Function Documentation

◆ doThinning()

StatusCode DerivationFramework::JetCaloClusterThinning::doThinning ( const EventContext & ctx) const
overridevirtual

Definition at line 84 of file JetCaloClusterThinning.cxx.

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

74{
75 ATH_MSG_VERBOSE("finalize() ...");
76 ATH_MSG_INFO("Processed " << m_ntotTopo << " topo clusters, of which "
77 << m_npassTopo << " were retained ");
78 ATH_CHECK(finalizeParser());
79 return StatusCode::SUCCESS;
80}
#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 39 of file JetCaloClusterThinning.cxx.

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