ATLAS Offline Software
Loading...
Searching...
No Matches
TauLRTThinningTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration.
3*/
4
7#include <vector>
8#include <string>
9
11 const std::string& n,
12 const IInterface* p) :
13 base_class(t,n,p)
14{
15}
16
17
19{
20 ATH_CHECK( m_taus.initialize(m_streamName) );
21 ATH_CHECK( m_tauTracks.initialize(m_streamName) );
26
27 // set up the text-parsing machinery for selecting taus according to user cuts
28 if (!m_selectionString.empty()) {
29 ATH_MSG_INFO("Selection string for " << m_taus.key() << ": " << m_selectionString);
30 ATH_CHECK( initializeParser(m_selectionString) );
31 }
32 return StatusCode::SUCCESS;
33}
34
35
37{
38 ATH_MSG_INFO("Processed " << m_ntot << " taus, " << m_npass << " were kept");
39 ATH_CHECK( finalizeParser() );
40 return StatusCode::SUCCESS;
41}
42
43
44StatusCode DerivationFramework::TauLRTThinningTool::doThinning(const EventContext& ctx) const
45{
46
47 // retrieve containers and thin them
49 taus.thinAll();
50 size_t nTaus = taus->size();
51
53 tauTracks.thinAll();
54
56 trackParticles.thinAll();
57
59 trackLargeD0Particles.thinAll();
60
62 neutralPFOs.thinAll();
63
65 secondaryVertices.thinAll();
66
67
68 std::vector<const xAOD::TauJet*> tausToKeep;
69
70 // execute the text parser if requested
71 if (!m_selectionString.empty()) {
72 std::vector<int> entries = m_parser->evaluateAsVector();
73 size_t nEntries = entries.size();
74 if (nTaus != nEntries) {
75 ATH_MSG_ERROR("Incompatible sizes: " << nTaus << " vs " << nEntries << "! Please check your selection string uses the appropriate tau container.");
76 return StatusCode::FAILURE;
77 }
78 // identify which taus to keep
79 for (size_t i=0; i<nTaus; ++i) if (entries[i]==1) tausToKeep.push_back(taus->at(i));
80 }
81 // use all taus if no selection string is passed
82 else {
83 for (size_t i=0; i<nTaus; ++i) tausToKeep.push_back(taus->at(i));
84 }
85
86 // protection against duplicate taus -- built from different seed jets, but end up having same (eta,phi)
87 if( tausToKeep.size() > 0){
88 for(size_t i=0; i < tausToKeep.size()-1; i++){
89 const auto* aTau=tausToKeep[i];
90 auto it = std::remove_if(tausToKeep.begin()+i+1,tausToKeep.end(),[aTau](const xAOD::TauJet* bTau) {return aTau->p4().DeltaR(bTau->p4()) < 0.01;});
91 tausToKeep.erase (it, tausToKeep.end());
92 }
93 }
94
95 // keep the various tau-related objects for taus passing the selection
96 for (const auto* tau : tausToKeep) {
97 // tau
98 taus.keep(tau->index());
99
100 // classifiedCharged tau tracks
101 for (const xAOD::TauTrack* track : tau->tracks()) {
102 tauTracks.keep(track->index());
103
104 // associated ID track
105 bool isTrackLRT = track->flag(xAOD::TauJetParameters::TauTrackFlag::LargeRadiusTrack);
106 if (!isTrackLRT) {
107 trackParticles.keep(track->track()->index());
108 } else {
109 trackLargeD0Particles.keep(track->track()->index());
110 }
111 }
112
113 // neutral PFOs
114 for (size_t i=0; i<tau->nNeutralPFOs(); i++) {
115 neutralPFOs.keep(tau->neutralPFO(i)->index());
116 }
117
118 // secondary vertex
119 if (tau->secondaryVertex() != nullptr) {
120 secondaryVertices.keep(tau->secondaryVertex()->index());
121 }
122 }
123
124 // increment counters
125 m_npass += tausToKeep.size();
126 m_ntot += nTaus;
127
128 return StatusCode::SUCCESS;
129}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
static Double_t taus
Handle for requesting thinning for a data object.
SG::ThinningHandleKey< xAOD::VertexContainer > m_secondaryVertices
SG::ThinningHandleKey< xAOD::PFOContainer > m_neutralPFOs
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_trackLargeD0Particles
virtual StatusCode initialize() override
SG::ThinningHandleKey< xAOD::TauJetContainer > m_taus
TauLRTThinningTool(const std::string &t, const std::string &n, const IInterface *p)
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_trackParticles
SG::ThinningHandleKey< xAOD::TauTrackContainer > m_tauTracks
virtual StatusCode doThinning(const EventContext &ctx) const override
Gaudi::Property< std::string > m_selectionString
void thinAll()
Mark that all elements should be thinned away.
void keep(size_t ndx)
Mark that index ndx in the container should be kept (not thinned away).
Handle for requesting thinning for a data object.
double entries
Definition listroot.cxx:49
DataModel_detail::iterator< DVL > remove_if(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, Predicate pred)
Specialization of remove_if for DataVector/List.
TauTrack_v1 TauTrack
Definition of the current version.
Definition TauTrack.h:16
TauJet_v3 TauJet
Definition of the current "tau version".