ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::TauJets_LepRMParticleThinning Class Reference

#include <TauJets_LepRMParticleThinning.h>

Inheritance diagram for DerivationFramework::TauJets_LepRMParticleThinning:
Collaboration diagram for DerivationFramework::TauJets_LepRMParticleThinning:

Public Member Functions

 TauJets_LepRMParticleThinning (const std::string &t, const std::string &n, const IInterface *p)
virtual StatusCode initialize () override
virtual StatusCode finalize () override
virtual StatusCode doThinning (const EventContext &ctx) const override

Private Attributes

std::atomic< unsigned int > m_ntot_taus {0}
std::atomic< unsigned int > m_ntot_trks {0}
std::atomic< unsigned int > m_ntot_ID_trks {0}
std::atomic< unsigned int > m_npass_taus {0}
std::atomic< unsigned int > m_npass_trks {0}
std::atomic< unsigned int > m_npass_ID_trks {0}
StringProperty m_streamName { this, "StreamName", "", "Name of the stream being thinned" }
SG::ReadHandleKey< xAOD::TauJetContainerm_originalTauKey { this, "originalTauKey", "", ""}
SG::ThinningHandleKey< xAOD::TauJetContainerm_LepRMTauKey { this, "LepRMTauKey", "TauJets_LepRM", "where Lep can be Muon or Elec" }
SG::ThinningHandleKey< xAOD::TrackParticleContainerm_inDetSGKey { this, "InDetTrackParticlesKey", "InDetTrackParticles", "" }
SG::ThinningHandleKey< xAOD::TauTrackContainerm_tauTracksSGKey { this, "TauTracksKey", "TauTracks_LepRM", "where Lep can be Muon or Elec" }
Gaudi::Property< std::string > m_selectionString { this, "SelectionString", "",""}

Detailed Description

Definition at line 28 of file TauJets_LepRMParticleThinning.h.

Constructor & Destructor Documentation

◆ TauJets_LepRMParticleThinning()

DerivationFramework::TauJets_LepRMParticleThinning::TauJets_LepRMParticleThinning ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 18 of file TauJets_LepRMParticleThinning.cxx.

20 :
21base_class(t,n,p) {}

Member Function Documentation

◆ doThinning()

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

Definition at line 71 of file TauJets_LepRMParticleThinning.cxx.

72{
73 // Retrieve main TrackParticle collection
74 SG::ThinningHandle<xAOD::TrackParticleContainer> TrackParticles(m_inDetSGKey, ctx);
75 if (!TrackParticles.isValid()) {
76 ATH_MSG_ERROR("No tau collection with name " << m_inDetSGKey.key() << " found in StoreGate!");
77 return StatusCode::FAILURE;
78 }
79 SG::ThinningHandle<xAOD::TauTrackContainer> TauTracks(m_tauTracksSGKey, ctx);
80 if (!TauTracks.isValid()) {
81 ATH_MSG_ERROR("No tau collection with name " << m_tauTracksSGKey.key() << " found in StoreGate!");
82 return StatusCode::FAILURE;
83 }
84 SG::ThinningHandle<xAOD::TauJetContainer> LepRMTaus(m_LepRMTauKey,ctx);
85 if (!LepRMTaus.isValid()) {
86 ATH_MSG_ERROR("No tau collection with name " << m_LepRMTauKey.key() << " found in StoreGate!");
87 return StatusCode::FAILURE;
88 }
89 SG::ReadHandle<xAOD::TauJetContainer> OriTaus(m_originalTauKey,ctx);
90 if (!OriTaus.isValid()) {
91 ATH_MSG_ERROR("No tau collection with name " << m_originalTauKey.key() << " found in StoreGate!");
92 return StatusCode::FAILURE;
93 }
94
95 //Thin tauJets_LepRM
96 std::vector<int> tau_kine_mask = m_parser->evaluateAsVector();
97 std::vector<bool> tau_lep_remove_mask(OriTaus->size(), false);
98 static const SG::AuxElement::ConstAccessor<char> acc_modified("ModifiedInAOD");
99 std::transform(LepRMTaus->cbegin(), LepRMTaus->cend(), tau_lep_remove_mask.begin(),
100 [&](auto lep_remove_tau) -> bool {
101 return static_cast<bool>(acc_modified(*lep_remove_tau));
102 }
103 );
104 std::vector<bool> tau_mask(OriTaus->size(),false);
105 std::transform(tau_lep_remove_mask.cbegin(), tau_lep_remove_mask.cend(), tau_kine_mask.cbegin(), tau_mask.begin(),
106 [](auto tau_lep_remove_pass, auto tau_kine_pass) -> bool
107 {
108 return tau_lep_remove_pass == 1 && tau_kine_pass == 1;
109 }
110 );
111
112 std::vector<const xAOD::TauJet*> LepRMTausAfterThinning;
113 std::transform(tau_mask.cbegin(), tau_mask.cend(), LepRMTaus->cbegin(), std::back_inserter(LepRMTausAfterThinning),
114 [](bool mask, auto tau) -> const xAOD::TauJet*
115 {
116 return mask ? tau : nullptr;
117 }
118 );
119 LepRMTausAfterThinning.erase(std::remove(LepRMTausAfterThinning.begin(), LepRMTausAfterThinning.end(), nullptr), LepRMTausAfterThinning.end());
120
121 //Thin TauTrack_LepRM
122 std::vector<bool> tau_track_mask(TauTracks->size(), false);
123 std::vector<bool> id_track_mask(TrackParticles->size(), false);
124 std::for_each(LepRMTausAfterThinning.cbegin(), LepRMTausAfterThinning.cend(),
125 [&](auto tau)
126 {
127 auto tau_track_links = tau->tauTrackLinks();
128 std::for_each(tau_track_links.cbegin(), tau_track_links.cend(),
129 [&](auto link)
130 {
131 if (link.isValid())
132 {
133 tau_track_mask[link.index()] = 1;
134 if (auto id_track_link = (*link)->trackLinks().at(0); id_track_link.isValid())
135 {
136 id_track_mask[id_track_link.index()] = 1;
137 }
138 }
139 }
140 );
141 }
142 );
143
144 LepRMTaus.keep(tau_mask);
145 TauTracks.keep(tau_track_mask);
146 TrackParticles.keep(id_track_mask);
147
148 m_ntot_taus += OriTaus->size();
149 m_ntot_trks += TauTracks->size();
150 m_ntot_ID_trks += TrackParticles->size();
151 m_npass_taus += std::accumulate(tau_mask.begin(), tau_mask.end(),0);
152 m_npass_trks += std::accumulate(tau_track_mask.begin(), tau_track_mask.end(),0);
153 m_npass_ID_trks += std::accumulate(id_track_mask.begin(), id_track_mask.end(),0);
154 ATH_MSG_DEBUG(std::accumulate(tau_mask.begin(), tau_mask.end(),0) << " / " << OriTaus->size() << " taus were retained");
155
156 return StatusCode::SUCCESS;
157
158}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
SG::ThinningHandleKey< xAOD::TauTrackContainer > m_tauTracksSGKey
SG::ThinningHandleKey< xAOD::TauJetContainer > m_LepRMTauKey
SG::ReadHandleKey< xAOD::TauJetContainer > m_originalTauKey
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetSGKey
DataModel_detail::iterator< DVL > remove(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, const T &value)
Specialization of remove for DataVector/List.
TauJet_v3 TauJet
Definition of the current "tau version".

◆ finalize()

StatusCode DerivationFramework::TauJets_LepRMParticleThinning::finalize ( )
overridevirtual

Definition at line 60 of file TauJets_LepRMParticleThinning.cxx.

61{
62 ATH_MSG_VERBOSE("finalize() ...");
63 ATH_MSG_INFO("Processed "<< m_ntot_trks <<" tau tracks, "<< m_npass_trks<< " were retained ");
64 ATH_MSG_INFO("Processed "<< m_ntot_ID_trks <<" ID tracks, "<< m_npass_ID_trks<< " were retained ");
65 ATH_MSG_INFO("Processed "<< m_ntot_taus <<" taus, "<< m_npass_taus<< " were retained ");
66 ATH_CHECK( finalizeParser() );
67 return StatusCode::SUCCESS;
68}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)

◆ initialize()

StatusCode DerivationFramework::TauJets_LepRMParticleThinning::initialize ( )
overridevirtual

Definition at line 24 of file TauJets_LepRMParticleThinning.cxx.

25{
26 // Decide which collections need to be checked for ID TrackParticles
27 ATH_MSG_VERBOSE("initialize() ...");
28 ATH_CHECK( m_inDetSGKey.initialize (m_streamName) );
29 ATH_MSG_INFO("Using " << m_inDetSGKey << " as the source collection for inner detector track particles");
30
31 if (m_LepRMTauKey.key().empty())
32 {
33 ATH_MSG_FATAL("No tau collection provided for thinning.");
34 return StatusCode::FAILURE;
35 }
36 else
37 {
38 ATH_MSG_INFO("Inner detector track particles associated with objects in " << m_LepRMTauKey.key() << " will be retained in this format with the rest being thinned away");
39 }
41
42 //tautracks
43 if (m_tauTracksSGKey.key().empty()) {
44 ATH_MSG_FATAL("No tau tracks collection provided for thinning.");
45 return StatusCode::FAILURE;
46 } else {
47 ATH_MSG_INFO("Tau track thinning requested; tau tracks with the SG key " << m_tauTracksSGKey.key() << " will be thinned if not associated with objects in " << m_LepRMTauKey.key());
49 }
50
51 // Set up the text-parsing machinery for selectiong the tau directly according to user cuts
52 if (!m_selectionString.empty()) {
53 ATH_CHECK(initializeParser(m_selectionString) );
54 }
55
56 ATH_CHECK(m_originalTauKey.initialize());
57 return StatusCode::SUCCESS;
58}
#define ATH_MSG_FATAL(x)

Member Data Documentation

◆ m_inDetSGKey

SG::ThinningHandleKey<xAOD::TrackParticleContainer> DerivationFramework::TauJets_LepRMParticleThinning::m_inDetSGKey { this, "InDetTrackParticlesKey", "InDetTrackParticles", "" }
private

Definition at line 49 of file TauJets_LepRMParticleThinning.h.

49{ this, "InDetTrackParticlesKey", "InDetTrackParticles", "" };

◆ m_LepRMTauKey

SG::ThinningHandleKey<xAOD::TauJetContainer> DerivationFramework::TauJets_LepRMParticleThinning::m_LepRMTauKey { this, "LepRMTauKey", "TauJets_LepRM", "where Lep can be Muon or Elec" }
private

Definition at line 47 of file TauJets_LepRMParticleThinning.h.

47{ this, "LepRMTauKey", "TauJets_LepRM", "where Lep can be Muon or Elec" };

◆ m_npass_ID_trks

std::atomic<unsigned int> DerivationFramework::TauJets_LepRMParticleThinning::m_npass_ID_trks {0}
mutableprivate

Definition at line 41 of file TauJets_LepRMParticleThinning.h.

41{0};

◆ m_npass_taus

std::atomic<unsigned int> DerivationFramework::TauJets_LepRMParticleThinning::m_npass_taus {0}
mutableprivate

Definition at line 39 of file TauJets_LepRMParticleThinning.h.

39{0};

◆ m_npass_trks

std::atomic<unsigned int> DerivationFramework::TauJets_LepRMParticleThinning::m_npass_trks {0}
mutableprivate

Definition at line 40 of file TauJets_LepRMParticleThinning.h.

40{0};

◆ m_ntot_ID_trks

std::atomic<unsigned int> DerivationFramework::TauJets_LepRMParticleThinning::m_ntot_ID_trks {0}
mutableprivate

Definition at line 38 of file TauJets_LepRMParticleThinning.h.

38{0};

◆ m_ntot_taus

std::atomic<unsigned int> DerivationFramework::TauJets_LepRMParticleThinning::m_ntot_taus {0}
mutableprivate

Definition at line 36 of file TauJets_LepRMParticleThinning.h.

36{0};

◆ m_ntot_trks

std::atomic<unsigned int> DerivationFramework::TauJets_LepRMParticleThinning::m_ntot_trks {0}
mutableprivate

Definition at line 37 of file TauJets_LepRMParticleThinning.h.

37{0};

◆ m_originalTauKey

SG::ReadHandleKey<xAOD::TauJetContainer> DerivationFramework::TauJets_LepRMParticleThinning::m_originalTauKey { this, "originalTauKey", "", ""}
private

Definition at line 45 of file TauJets_LepRMParticleThinning.h.

45{ this, "originalTauKey", "", ""};

◆ m_selectionString

Gaudi::Property<std::string> DerivationFramework::TauJets_LepRMParticleThinning::m_selectionString { this, "SelectionString", "",""}
private

Definition at line 53 of file TauJets_LepRMParticleThinning.h.

53{ this, "SelectionString", "",""};

◆ m_streamName

StringProperty DerivationFramework::TauJets_LepRMParticleThinning::m_streamName { this, "StreamName", "", "Name of the stream being thinned" }
private

Definition at line 43 of file TauJets_LepRMParticleThinning.h.

43{ this, "StreamName", "", "Name of the stream being thinned" };

◆ m_tauTracksSGKey

SG::ThinningHandleKey<xAOD::TauTrackContainer> DerivationFramework::TauJets_LepRMParticleThinning::m_tauTracksSGKey { this, "TauTracksKey", "TauTracks_LepRM", "where Lep can be Muon or Elec" }
private

Definition at line 51 of file TauJets_LepRMParticleThinning.h.

51{ this, "TauTracksKey", "TauTracks_LepRM", "where Lep can be Muon or Elec" };

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