13 #include "GaudiKernel/ThreadLocalContext.h"
40 , m_selectionString(
"")
57 if (!m_CaloClSGKey.empty()) {
58 ATH_CHECK(m_CaloClSGKey.initialize(m_streamName));
61 <<
"as the source collection for calo clusters");
63 if (!m_TopoClSGKey.empty()) {
64 ATH_CHECK(m_TopoClSGKey.initialize(m_streamName));
67 <<
"as the source collection for topo calo clusters");
69 if (m_CaloClSGKey.empty() && m_TopoClSGKey.empty()) {
71 "No CalCaloTopoCluster or CaloCluster collection provided for thinning.");
72 return StatusCode::FAILURE;
75 if (m_sgKey.empty()) {
76 ATH_MSG_FATAL(
"No particle collection provided for thinning.");
77 return StatusCode::FAILURE;
80 "Calo clusters associated with objects in "
82 <<
" will be retained in this format with the rest being thinned away");
88 if (!m_selectionString.empty()) {
89 ATH_CHECK(initializeParser(m_selectionString));
92 return StatusCode::SUCCESS;
99 ATH_MSG_INFO(
"Processed " << m_ntot <<
" clusters, of which " << m_npass
100 <<
" were retained ");
101 ATH_MSG_INFO(
"Processed " << m_ntotTopo <<
" topo clusters, of which "
102 << m_npassTopo <<
" were retained ");
104 return StatusCode::SUCCESS;
111 const EventContext& ctx = Gaudi::Hive::currentContext();
113 bool is_muons =
false;
114 bool is_egamma =
false;
116 bool is_track =
false;
121 importedCaloCluster =
128 importedTopoCaloCluster =
132 unsigned int nClusters = 0;
134 nClusters = importedCaloCluster->
size();
136 unsigned int nTopoClusters = 0;
138 nTopoClusters = importedTopoCaloCluster->
size();
140 if (nClusters == 0 && nTopoClusters == 0) {
141 return StatusCode::SUCCESS;
145 std::vector<bool>
mask(nClusters,
false), topomask(nTopoClusters,
false);
147 m_ntotTopo += nTopoClusters;
153 importedParticlesHandle.ptr();
156 unsigned int nParticles(importedParticles->
size());
157 if (nParticles == 0) {
166 return StatusCode::SUCCESS;
197 if (!(is_egamma || is_muons || is_tau || is_track)) {
198 ATH_MSG_ERROR(
"This tool only works with Egamma, Muons, Taus and Tracks "
199 << m_sgKey.key() <<
" is not a compatible collection");
200 return StatusCode::FAILURE;
205 if (!m_selectionString.empty()) {
206 std::vector<int>
entries = m_parser->evaluateAsVector();
210 ATH_MSG_ERROR(
"Sizes incompatible! Are you sure your selection string "
211 "used e-gamma objects??");
212 return StatusCode::FAILURE;
214 std::vector<const xAOD::IParticle*> particlesToCheck = {};
216 for (
unsigned int i = 0;
i < nParticles; ++
i) {
217 if (
static_cast<bool>(
entries[
i])) {
218 particlesToCheck.push_back((*importedParticles)[
i]);
222 for (
const auto*
particle : particlesToCheck) {
225 if (particleCluster(
mask,
227 importedCaloCluster.
cptr(),
230 is_tau) != StatusCode::SUCCESS) {
231 return StatusCode::FAILURE;
233 if (setClustersMask(
mask,
235 importedCaloCluster.
cptr(),
238 is_track) != StatusCode::SUCCESS) {
239 return StatusCode::FAILURE;
243 if (particleCluster(topomask,
245 importedTopoCaloCluster.
cptr(),
248 is_tau) != StatusCode::SUCCESS) {
249 return StatusCode::FAILURE;
251 if (setClustersMask(topomask,
253 importedTopoCaloCluster.
cptr(),
256 is_track) != StatusCode::SUCCESS) {
257 return StatusCode::FAILURE;
262 for (
const auto*
particle : *importedParticles) {
264 if (particleCluster(
mask,
266 importedCaloCluster.
cptr(),
269 is_tau) != StatusCode::SUCCESS) {
270 return StatusCode::FAILURE;
272 if (setClustersMask(
mask,
274 importedCaloCluster.
cptr(),
277 is_track) != StatusCode::SUCCESS) {
278 return StatusCode::FAILURE;
282 if (particleCluster(topomask,
284 importedTopoCaloCluster.
cptr(),
287 is_tau) != StatusCode::SUCCESS) {
288 return StatusCode::FAILURE;
290 if (setClustersMask(topomask,
292 importedTopoCaloCluster.
cptr(),
295 is_track) != StatusCode::SUCCESS) {
296 return StatusCode::FAILURE;
303 for (
unsigned int i = 0;
i < nClusters; ++
i) {
307 for (
unsigned int i = 0;
i < nTopoClusters; ++
i) {
321 return StatusCode::SUCCESS;
326 std::vector<bool>&
mask,
335 return StatusCode::FAILURE;
342 return StatusCode::FAILURE;
350 return StatusCode::FAILURE;
358 return StatusCode::FAILURE;
362 return StatusCode::SUCCESS;
367 std::vector<bool>&
mask,
376 return StatusCode::FAILURE;
383 return StatusCode::FAILURE;
386 if (
it != cps->
end()) {
388 mask[ItsCluster] =
true;
396 return StatusCode::FAILURE;
399 if (
it != cps->
end()) {
401 mask[ItsCluster] =
true;
409 return StatusCode::FAILURE;
413 for (
const auto * pJetConstituent :
vec) {
414 TLorentzVector cluster_P4;
415 cluster_P4.SetPtEtaPhiM(1, pJetConstituent->Eta(), pJetConstituent->Phi(), 1);
416 if (LC_P4.DeltaR(cluster_P4) > 0.2)
421 if (it_cps != cps->
end()) {
423 mask[ItsCluster] =
true;
428 return StatusCode::SUCCESS;