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

#include <TauTrackParticleThinning.h>

Inheritance diagram for DerivationFramework::TauTrackParticleThinning:
Collaboration diagram for DerivationFramework::TauTrackParticleThinning:

Public Member Functions

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

Private Attributes

std::atomic< unsigned int > m_ntot {}
 
std::atomic< unsigned int > m_npass {}
 
StringProperty m_streamName { this, "StreamName", "", "Name of the stream being thinned" }
 
SG::ThinningHandleKey< xAOD::TrackParticleContainerm_inDetSGKey { this, "InDetTrackParticlesKey", "InDetTrackParticles", "" }
 
SG::ReadHandleKey< xAOD::TauJetContainerm_tauKey { this, "TauKey", "", ""}
 
Gaudi::Property< bool > m_doTauTracksThinning { this, "DoTauTracksThinning", false, "Apply thinning to tau tracks in addition to ID tracks"}
 
SG::ThinningHandleKey< xAOD::TauTrackContainerm_tauTracksSGKey { this, "TauTracksKey", "TauTracks", "StoreGate key of the tau track container" }
 
Gaudi::Property< std::string > m_selectionString { this, "SelectionString", "",""}
 
Gaudi::Property< float > m_coneSize { this, "ConeSize", -1.0, ""}
 

Detailed Description

Definition at line 29 of file TauTrackParticleThinning.h.

Constructor & Destructor Documentation

◆ TauTrackParticleThinning()

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

Definition at line 21 of file TauTrackParticleThinning.cxx.

23  :
24 base_class(t,n,p)
25 {
26 }

◆ ~TauTrackParticleThinning()

DerivationFramework::TauTrackParticleThinning::~TauTrackParticleThinning ( )
virtualdefault

Member Function Documentation

◆ doThinning()

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

Definition at line 69 of file TauTrackParticleThinning.cxx.

70 {
71  const EventContext& ctx = Gaudi::Hive::currentContext();
72 
73  // Retrieve main TrackParticle collection
75  (m_inDetSGKey, ctx);
76 
77  // Check the event contains tracks
78  unsigned int nTracks = importedTrackParticles->size();
79  if (nTracks==0) return StatusCode::SUCCESS;
80 
81  // Set up a mask with the same entries as the full TrackParticle collection
82  std::vector<bool> mask;
83  mask.assign(nTracks,false); // default: don't keep any tracks
84  m_ntot += nTracks;
85 
86  // Retrieve containers
87  // ... taus
89  if (!importedTaus.isValid()) {
90  ATH_MSG_ERROR("No tau collection with name " << m_tauKey.key() << " found in StoreGate!");
91  return StatusCode::FAILURE;
92  }
93  unsigned int nTaus(importedTaus->size());
94  std::vector<const xAOD::TauJet*> tauToCheck; tauToCheck.clear();
95 
96  // Execute the text parser if requested
97  if (!m_selectionString.empty()) {
98  std::vector<int> entries = m_parser->evaluateAsVector();
99  unsigned int nEntries = entries.size();
100  // check the sizes are compatible
101  if (nTaus != nEntries ) {
102  ATH_MSG_ERROR("Sizes incompatible! Are you sure your selection string used taus??");
103  return StatusCode::FAILURE;
104  } else {
105  // identify which taus to keep for the thinning check
106  for (unsigned int i=0; i<nTaus; ++i) if (entries[i]==1) tauToCheck.push_back((*importedTaus)[i]);
107  }
108  } else {
109  // use all taus if no selection string is passed
110  for (unsigned int i=0; i<nTaus; ++i) tauToCheck.push_back((*importedTaus)[i]);
111  }
112 
113  // Set elements in the mask to true if there is a corresponding ElementLink from a reconstructed object
114  // ... taus
116  if (m_selectionString=="") { // check all taus as user didn't provide a selection string
117  for (const auto *tauIt : *importedTaus) {
118  if (m_coneSize>0.0) trIC.select(tauIt,m_coneSize,importedTrackParticles.cptr(),mask); // check tracks in a cone around the tau if req'd
119  for (unsigned int i=0; i<tauIt->nTracks(); ++i) {
121  mask[index] = true;
122  }
123  }
124  } else { // check only taus passing user selection string
125  for (auto & tauIt : tauToCheck) {
126  if (m_coneSize>0.0) trIC.select(tauIt,m_coneSize,importedTrackParticles.cptr(),mask); // check tracks in a cone around the tau if req'd
127  for (unsigned int i=0; i<tauIt->nTracks(); ++i) {
129  mask[index] = true;
130  }
131  }
132  }
133 
134  // Count up the mask contents
135  unsigned int n_pass=0;
136  for (unsigned int i=0; i<nTracks; ++i) {
137  if (mask[i]) ++n_pass;
138  }
139  m_npass += n_pass;
140 
141  // Execute the thinning service based on the mask.
142  importedTrackParticles.keep (mask);
143 
144  // Apply thinning to tau track collection if requested
145  if( m_doTauTracksThinning ) {
147  (m_tauTracksSGKey, ctx);
148  if( importedTauTracks->empty() ) {
149  return StatusCode::SUCCESS;
150  }
151  std::vector< bool > mask_tautracks( importedTauTracks->size(), false );
152 
153  for( const xAOD::TauJet* tau : tauToCheck ) {
154  // Get all the associated charged tau tracks:
155  auto ttLinks = tau->tauTrackLinks(xAOD::TauJetParameters::TauTrackFlag::classifiedCharged );
156  // Process the links:
157  for( const auto& ttLink : ttLinks ) {
158  if( ! ttLink.isValid() ) {
159  continue;
160  }
161  if( ttLink.dataID() != m_tauTracksSGKey.key() ) {
162  ATH_MSG_FATAL( "Charged tau track does not come from "
163  "container \"" << m_tauTracksSGKey << "\"" );
164  return StatusCode::FAILURE;
165  }
166  // If it is, set the mask for it:
167  mask_tautracks.at( ttLink.index() ) = true;
168  }
169  // Select the tau tracks in a cone if it was requested (NOT RECOMMENDED):
170  if( m_coneSize > 0.0 ) {
171  trIC.select( tau, m_coneSize, importedTauTracks.cptr(), mask_tautracks );
172  }
173  }
174 
175  importedTauTracks.keep(mask_tautracks);
176 
177  }
178 
179  return StatusCode::SUCCESS;
180 
181 }

◆ finalize()

StatusCode DerivationFramework::TauTrackParticleThinning::finalize ( )
overridevirtual

Definition at line 60 of file TauTrackParticleThinning.cxx.

61 {
62  ATH_MSG_VERBOSE("finalize() ...");
63  ATH_MSG_INFO("Processed "<< m_ntot <<" tracks, "<< m_npass<< " were retained ");
64  ATH_CHECK( finalizeParser() );
65  return StatusCode::SUCCESS;
66 }

◆ initialize()

StatusCode DerivationFramework::TauTrackParticleThinning::initialize ( )
overridevirtual

Definition at line 32 of file TauTrackParticleThinning.cxx.

33 {
34  // Decide which collections need to be checked for ID TrackParticles
35  ATH_MSG_VERBOSE("initialize() ...");
36  ATH_CHECK( m_inDetSGKey.initialize (m_streamName) );
37  ATH_MSG_INFO("Using " << m_inDetSGKey << "as the source collection for inner detector track particles");
38  if (m_tauKey.key().empty()) {
39  ATH_MSG_FATAL("No tau collection provided for thinning.");
40  return StatusCode::FAILURE;
41  } else { ATH_MSG_INFO("Inner detector track particles associated with objects in " << m_tauKey.key() << " will be retained in this format with the rest being thinned away");}
42  ATH_CHECK(m_tauKey.initialize());
44  if (m_tauTracksSGKey.key().empty()) {
45  ATH_MSG_FATAL("No tau tracks collection provided for thinning, despite this option being requested.");
46  return StatusCode::FAILURE;
47  } else {
48  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_tauKey.key());
49  ATH_CHECK( m_tauTracksSGKey.initialize (m_streamName) );
50  }
51  }
52 
53  // Set up the text-parsing machinery for selectiong the tau directly according to user cuts
54  if (!m_selectionString.empty()) {
55  ATH_CHECK(initializeParser(m_selectionString) );
56  }
57  return StatusCode::SUCCESS;
58 }

Member Data Documentation

◆ m_coneSize

Gaudi::Property<float> DerivationFramework::TauTrackParticleThinning::m_coneSize { this, "ConeSize", -1.0, ""}
private

Definition at line 52 of file TauTrackParticleThinning.h.

◆ m_doTauTracksThinning

Gaudi::Property<bool> DerivationFramework::TauTrackParticleThinning::m_doTauTracksThinning { this, "DoTauTracksThinning", false, "Apply thinning to tau tracks in addition to ID tracks"}
private

Definition at line 46 of file TauTrackParticleThinning.h.

◆ m_inDetSGKey

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

Definition at line 42 of file TauTrackParticleThinning.h.

◆ m_npass

std::atomic<unsigned int> DerivationFramework::TauTrackParticleThinning::m_npass {}
mutableprivate

Definition at line 39 of file TauTrackParticleThinning.h.

◆ m_ntot

std::atomic<unsigned int> DerivationFramework::TauTrackParticleThinning::m_ntot {}
mutableprivate

Definition at line 38 of file TauTrackParticleThinning.h.

◆ m_selectionString

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

Definition at line 50 of file TauTrackParticleThinning.h.

◆ m_streamName

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

Definition at line 40 of file TauTrackParticleThinning.h.

◆ m_tauKey

SG::ReadHandleKey<xAOD::TauJetContainer> DerivationFramework::TauTrackParticleThinning::m_tauKey { this, "TauKey", "", ""}
private

Definition at line 44 of file TauTrackParticleThinning.h.

◆ m_tauTracksSGKey

SG::ThinningHandleKey<xAOD::TauTrackContainer> DerivationFramework::TauTrackParticleThinning::m_tauTracksSGKey { this, "TauTracksKey", "TauTracks", "StoreGate key of the tau track container" }
private

Definition at line 48 of file TauTrackParticleThinning.h.


The documentation for this class was generated from the following files:
DerivationFramework::TauTrackParticleThinning::m_inDetSGKey
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetSGKey
Definition: TauTrackParticleThinning.h:43
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DerivationFramework::TauTrackParticleThinning::m_streamName
StringProperty m_streamName
Definition: TauTrackParticleThinning.h:41
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
DerivationFramework::TauTrackParticleThinning::m_ntot
std::atomic< unsigned int > m_ntot
Definition: TauTrackParticleThinning.h:38
xAOD::TauJetParameters::classifiedCharged
@ classifiedCharged
Definition: TauDefs.h:406
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
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
lumiFormat.i
int i
Definition: lumiFormat.py:85
DerivationFramework::TauTrackParticleThinning::m_coneSize
Gaudi::Property< float > m_coneSize
Definition: TauTrackParticleThinning.h:53
beamspotman.n
n
Definition: beamspotman.py:731
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
DerivationFramework::TauTrackParticleThinning::m_tauKey
SG::ReadHandleKey< xAOD::TauJetContainer > m_tauKey
Definition: TauTrackParticleThinning.h:45
xAOD::TauHelpers::trackParticleLinks
std::vector< ElementLink< xAOD::TrackParticleContainer > > trackParticleLinks(const xAOD::TauJet *tau, xAOD::TauJetParameters::TauTrackFlag flag=xAOD::TauJetParameters::TauTrackFlag::classifiedCharged)
Definition: TauxAODHelpers.cxx:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::TauTrackParticleThinning::m_selectionString
Gaudi::Property< std::string > m_selectionString
Definition: TauTrackParticleThinning.h:51
DerivationFramework::TauTrackParticleThinning::m_doTauTracksThinning
Gaudi::Property< bool > m_doTauTracksThinning
Definition: TauTrackParticleThinning.h:47
DeMoScan.index
string index
Definition: DeMoScan.py:364
DerivationFramework::TauTrackParticleThinning::m_tauTracksSGKey
SG::ThinningHandleKey< xAOD::TauTrackContainer > m_tauTracksSGKey
Definition: TauTrackParticleThinning.h:49
entries
double entries
Definition: listroot.cxx:49
DerivationFramework::TracksInCone
Definition: TracksInCone.h:19
DerivationFramework::TracksInCone::select
void select(const xAOD::IParticle *particle, float coneSize, const xAOD::TrackParticleContainer *tracks, std::vector< bool > &mask)
Definition: TracksInCone.h:21
DerivationFramework::TauTrackParticleThinning::m_npass
std::atomic< unsigned int > m_npass
Definition: TauTrackParticleThinning.h:39
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73