ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
DerivationFramework::TauThinningTool Class Reference

#include <TauThinningTool.h>

Inheritance diagram for DerivationFramework::TauThinningTool:
Collaboration diagram for DerivationFramework::TauThinningTool:

Public Member Functions

 TauThinningTool (const std::string &t, const std::string &n, const IInterface *p)
 
virtual ~TauThinningTool ()=default
 
virtual StatusCode initialize () override
 
virtual StatusCode finalize () override
 
virtual StatusCode doThinning () const override
 

Private Attributes

std::atomic< unsigned int > m_ntot = 0
 
std::atomic< unsigned int > m_npass = 0
 
StringProperty m_streamName { this, "StreamName", "", "Name of the stream being thinned" }
 
Gaudi::Property< std::string > m_selectionString { this, "SelectionString", "", "" }
 
SG::ThinningHandleKey< xAOD::TauJetContainerm_taus { this, "Taus", "TauJets", "" }
 
SG::ThinningHandleKey< xAOD::TauTrackContainerm_tauTracks { this, "TauTracks", "TauTracks", "" }
 
SG::ThinningHandleKey< xAOD::TrackParticleContainerm_trackParticles { this, "TrackParticles", "InDetTrackParticles", "" }
 
SG::ThinningHandleKey< xAOD::PFOContainerm_neutralPFOs { this, "TauNeutralPFOs", "TauNeutralParticleFlowObjects", "" }
 
SG::ThinningHandleKey< xAOD::VertexContainerm_secondaryVertices { this, "TauSecondaryVertices", "TauSecondaryVertices", "" }
 

Detailed Description

Definition at line 25 of file TauThinningTool.h.

Constructor & Destructor Documentation

◆ TauThinningTool()

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

Definition at line 12 of file TauThinningTool.cxx.

14  :
15  base_class(t,n,p)
16 {
17 }

◆ ~TauThinningTool()

virtual DerivationFramework::TauThinningTool::~TauThinningTool ( )
virtualdefault

Member Function Documentation

◆ doThinning()

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

Definition at line 45 of file TauThinningTool.cxx.

46 {
47  const EventContext& ctx = Gaudi::Hive::currentContext();
48 
49  // retrieve containers and thin them
51  taus.thinAll();
52  size_t nTaus = taus->size();
53 
55  tauTracks.thinAll();
56 
58  trackParticles.thinAll();
59 
61  neutralPFOs.thinAll();
62 
64  secondaryVertices.thinAll();
65 
66 
67  std::vector<const xAOD::TauJet*> tausToKeep;
68 
69  // execute the text parser if requested
70  if (!m_selectionString.empty()) {
71  std::vector<int> entries = m_parser->evaluateAsVector();
72  size_t nEntries = entries.size();
73  if (nTaus != nEntries) {
74  ATH_MSG_ERROR("Incompatible sizes: " << nTaus << " vs " << nEntries << "! Please check your selection string uses the appropriate tau container.");
75  return StatusCode::FAILURE;
76  }
77  // identify which taus to keep
78  for (size_t i=0; i<nTaus; ++i) if (entries[i]==1) tausToKeep.push_back(taus->at(i));
79  }
80  // use all taus if no selection string is passed
81  else {
82  for (size_t i=0; i<nTaus; ++i) tausToKeep.push_back(taus->at(i));
83  }
84 
85 
86  if(tausToKeep.size() >0) {
87  for(size_t i=0; i < tausToKeep.size()-1; i++){
88  for (size_t j=i+1; j < tausToKeep.size(); j++){
89  if( (tausToKeep.at(i)->p4().DeltaR(tausToKeep.at(j)->p4())) < 0.01){
90  ATH_MSG_WARNING("Found duplicated tau with eta " << tausToKeep.at(j)->eta() << " phi " << tausToKeep.at(j)->phi() << " pt " << tausToKeep.at(j)->pt() << ". Removing it ...");
91  tausToKeep.erase( tausToKeep.begin()+j);
92  }
93  }
94  }
95  }
96 
97 
98  // keep the various tau-related objects for taus passing the selection
99  for (const auto* tau : tausToKeep) {
100  // tau
101  taus.keep(tau->index());
102 
103  // classifiedCharged tau tracks
104  for (const xAOD::TauTrack* track : tau->tracks()) {
105  tauTracks.keep(track->index());
106 
107  // associated ID track
108  trackParticles.keep(track->track()->index());
109  }
110 
111  // neutral PFOs
112  for (size_t i=0; i<tau->nNeutralPFOs(); i++) {
113  neutralPFOs.keep(tau->neutralPFO(i)->index());
114  }
115 
116  // secondary vertex
117  if (tau->secondaryVertex() != nullptr) {
118  secondaryVertices.keep(tau->secondaryVertex()->index());
119  }
120  }
121 
122  // increment counters
123  m_npass += tausToKeep.size();
124  m_ntot += nTaus;
125 
126  return StatusCode::SUCCESS;
127 }

◆ finalize()

StatusCode DerivationFramework::TauThinningTool::finalize ( )
overridevirtual

Definition at line 37 of file TauThinningTool.cxx.

38 {
39  ATH_MSG_INFO("Processed " << m_ntot << " taus, " << m_npass << " were kept");
40  ATH_CHECK( finalizeParser() );
41  return StatusCode::SUCCESS;
42 }

◆ initialize()

StatusCode DerivationFramework::TauThinningTool::initialize ( )
overridevirtual

Definition at line 20 of file TauThinningTool.cxx.

21 {
22  ATH_CHECK( m_taus.initialize(m_streamName) );
23  ATH_CHECK( m_tauTracks.initialize(m_streamName) );
25  ATH_CHECK( m_neutralPFOs.initialize(m_streamName) );
27 
28  // set up the text-parsing machinery for selecting taus according to user cuts
29  if (!m_selectionString.empty()) {
30  ATH_MSG_INFO("Selection string for " << m_taus.key() << ": " << m_selectionString);
31  ATH_CHECK( initializeParser(m_selectionString) );
32  }
33  return StatusCode::SUCCESS;
34 }

Member Data Documentation

◆ m_neutralPFOs

SG::ThinningHandleKey<xAOD::PFOContainer> DerivationFramework::TauThinningTool::m_neutralPFOs { this, "TauNeutralPFOs", "TauNeutralParticleFlowObjects", "" }
private

Definition at line 41 of file TauThinningTool.h.

◆ m_npass

std::atomic<unsigned int> DerivationFramework::TauThinningTool::m_npass = 0
mutableprivate

Definition at line 35 of file TauThinningTool.h.

◆ m_ntot

std::atomic<unsigned int> DerivationFramework::TauThinningTool::m_ntot = 0
mutableprivate

Definition at line 34 of file TauThinningTool.h.

◆ m_secondaryVertices

SG::ThinningHandleKey<xAOD::VertexContainer> DerivationFramework::TauThinningTool::m_secondaryVertices { this, "TauSecondaryVertices", "TauSecondaryVertices", "" }
private

Definition at line 42 of file TauThinningTool.h.

◆ m_selectionString

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

Definition at line 37 of file TauThinningTool.h.

◆ m_streamName

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

Definition at line 36 of file TauThinningTool.h.

◆ m_taus

SG::ThinningHandleKey<xAOD::TauJetContainer> DerivationFramework::TauThinningTool::m_taus { this, "Taus", "TauJets", "" }
private

Definition at line 38 of file TauThinningTool.h.

◆ m_tauTracks

SG::ThinningHandleKey<xAOD::TauTrackContainer> DerivationFramework::TauThinningTool::m_tauTracks { this, "TauTracks", "TauTracks", "" }
private

Definition at line 39 of file TauThinningTool.h.

◆ m_trackParticles

SG::ThinningHandleKey<xAOD::TrackParticleContainer> DerivationFramework::TauThinningTool::m_trackParticles { this, "TrackParticles", "InDetTrackParticles", "" }
private

Definition at line 40 of file TauThinningTool.h.


The documentation for this class was generated from the following files:
DerivationFramework::TauThinningTool::m_trackParticles
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_trackParticles
Definition: TauThinningTool.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DerivationFramework::TauThinningTool::m_selectionString
Gaudi::Property< std::string > m_selectionString
Definition: TauThinningTool.h:37
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::TauThinningTool::m_taus
SG::ThinningHandleKey< xAOD::TauJetContainer > m_taus
Definition: TauThinningTool.h:38
DerivationFramework::TauThinningTool::m_secondaryVertices
SG::ThinningHandleKey< xAOD::VertexContainer > m_secondaryVertices
Definition: TauThinningTool.h:42
DerivationFramework::TauThinningTool::m_npass
std::atomic< unsigned int > m_npass
Definition: TauThinningTool.h:35
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition: ThinningHandle.h:84
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::TauThinningTool::m_neutralPFOs
SG::ThinningHandleKey< xAOD::PFOContainer > m_neutralPFOs
Definition: TauThinningTool.h:41
lumiFormat.i
int i
Definition: lumiFormat.py:85
DerivationFramework::TauThinningTool::m_streamName
StringProperty m_streamName
Definition: TauThinningTool.h:36
beamspotman.n
n
Definition: beamspotman.py:731
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DerivationFramework::TauThinningTool::m_tauTracks
SG::ThinningHandleKey< xAOD::TauTrackContainer > m_tauTracks
Definition: TauThinningTool.h:39
xAOD::TauTrack_v1
Definition: TauTrack_v1.h:27
entries
double entries
Definition: listroot.cxx:49
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
DerivationFramework::TauThinningTool::m_ntot
std::atomic< unsigned int > m_ntot
Definition: TauThinningTool.h:34