ATLAS Offline Software
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  declareInterface<DerivationFramework::IThinningTool>(this);
33  declareProperty("SelectionString", m_selectionString);
34 }

◆ ~JetCaloClusterThinning()

DerivationFramework::JetCaloClusterThinning::~JetCaloClusterThinning ( )
virtualdefault

Member Function Documentation

◆ doThinning()

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

Definition at line 86 of file JetCaloClusterThinning.cxx.

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

◆ finalize()

StatusCode DerivationFramework::JetCaloClusterThinning::finalize ( )
overridevirtual

Definition at line 75 of file JetCaloClusterThinning.cxx.

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

◆ initialize()

StatusCode DerivationFramework::JetCaloClusterThinning::initialize ( )
overridevirtual

Definition at line 41 of file JetCaloClusterThinning.cxx.

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

◆ 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:70
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
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
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