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

#include <DiTauTrackParticleThinning.h>

Inheritance diagram for DerivationFramework::DiTauTrackParticleThinning:
Collaboration diagram for DerivationFramework::DiTauTrackParticleThinning:

Public Member Functions

 DiTauTrackParticleThinning (const std::string &t, const std::string &n, const IInterface *p)
 
virtual ~DiTauTrackParticleThinning ()
 
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::ReadHandleKey< xAOD::DiTauJetContainerm_ditauKey { this, "DiTauKey","",""}
 
SG::ThinningHandleKey< xAOD::TrackParticleContainerm_inDetSGKey { this, "InDetTrackParticlesKey", "InDetTrackParticles", "" }
 
Gaudi::Property< std::string > m_selectionString { this, "SelectionString", "", ""}
 

Detailed Description

Definition at line 29 of file DiTauTrackParticleThinning.h.

Constructor & Destructor Documentation

◆ DiTauTrackParticleThinning()

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

Definition at line 20 of file DiTauTrackParticleThinning.cxx.

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

◆ ~DiTauTrackParticleThinning()

DerivationFramework::DiTauTrackParticleThinning::~DiTauTrackParticleThinning ( )
virtualdefault

Member Function Documentation

◆ doThinning()

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

Definition at line 55 of file DiTauTrackParticleThinning.cxx.

56 {
57 
58  const EventContext& ctx = Gaudi::Hive::currentContext();
59 
60  // Retrieve main TrackParticle collection
62  (m_inDetSGKey, ctx);
63 
64  // Check the event contains tracks
65  unsigned int nTracks = importedTrackParticles->size();
66  if (nTracks==0) return StatusCode::SUCCESS;
67 
68  // Set up a mask with the same entries as the full TrackParticle collection
69  std::vector<bool> mask;
70  mask.assign(nTracks,false); // default: don't keep any tracks
71  m_ntot += nTracks;
72 
73  // Retrieve containers
74  // ... ditaus
76  if (!importedDiTaus.isValid()) {
77  ATH_MSG_ERROR("No ditau collection with name " << m_ditauKey.key() << " found in StoreGate!");
78  return StatusCode::FAILURE;
79  }
80  unsigned int nDiTaus(importedDiTaus->size());
81  std::vector<const xAOD::DiTauJet*> ditauToCheck; ditauToCheck.clear();
82 
83  // Execute the text parser if requested
84  if (!m_selectionString.empty()) {
85  std::vector<int> entries = m_parser->evaluateAsVector();
86  unsigned int nEntries = entries.size();
87  // check the sizes are compatible
88  if (nDiTaus != nEntries ) {
89  ATH_MSG_ERROR("Sizes incompatible! Are you sure your selection string used ditaus??");
90  return StatusCode::FAILURE;
91  } else {
92  // identify which ditaus to keep for the thinning check
93  for (unsigned int i=0; i<nDiTaus; ++i) if (entries[i]==1) ditauToCheck.push_back((*importedDiTaus)[i]);
94  }
95  }
96 
97  // Set elements in the mask to true if there is a corresponding ElementLink from a reconstructed object
98  // ... ditaus
99  if (m_selectionString=="") { // check all ditaus as user didn't provide a selection string
100  for (const auto *ditauIt : *importedDiTaus) {
101  for (unsigned int i=0; i<ditauIt->nTracks(); ++i) {
102  int index = ditauIt->trackLinks().at(i).index();
103  mask[index] = true;
104  }
105  for (unsigned int i=0; i<ditauIt->nIsoTracks(); ++i) {
106  int index = ditauIt->isoTrackLinks().at(i).index();
107  mask[index] = true;
108  }
109  }
110  } else { // check only ditaus passing user selection string
111  for (auto & ditauIt : ditauToCheck) {
112  for (unsigned int i=0; i<ditauIt->nTracks(); ++i) {
113  int index = ditauIt->trackLinks().at(i).index();
114  mask[index] = true;
115  }
116  for (unsigned int i=0; i<ditauIt->nIsoTracks(); ++i) {
117  int index = ditauIt->isoTrackLinks().at(i).index();
118  mask[index] = true;
119  }
120  }
121  }
122 
123  // Count up the mask contents
124  unsigned int n_pass=0;
125  for (unsigned int i=0; i<nTracks; ++i) {
126  if (mask[i]) ++n_pass;
127  }
128  m_npass += n_pass;
129 
130  // Execute the thinning service based on the mask. Finish.
131  importedTrackParticles.keep (mask);
132 
133  return StatusCode::SUCCESS;
134 }

◆ finalize()

StatusCode DerivationFramework::DiTauTrackParticleThinning::finalize ( )
overridevirtual

Definition at line 46 of file DiTauTrackParticleThinning.cxx.

47 {
48  ATH_MSG_VERBOSE("finalize() ...");
49  ATH_MSG_INFO("Processed "<< m_ntot <<" tracks, "<< m_npass<< " were retained ");
50  ATH_CHECK( finalizeParser() );
51  return StatusCode::SUCCESS;
52 }

◆ initialize()

StatusCode DerivationFramework::DiTauTrackParticleThinning::initialize ( )
overridevirtual

Definition at line 30 of file DiTauTrackParticleThinning.cxx.

31 {
32  // Decide which collections need to be checked for ID TrackParticles
33  ATH_MSG_VERBOSE("initialize() ...");
34  ATH_CHECK( m_ditauKey.initialize () );
35  ATH_CHECK( m_inDetSGKey.initialize (m_streamName) );
36  ATH_MSG_INFO("Using " << m_inDetSGKey.key() << "as the source collection for inner detector track particles");
37  ATH_MSG_INFO("Inner detector track particles associated with objects in " << m_ditauKey.key() << " will be retained in this format with the rest being thinned away");
38 
39  // Set up the text-parsing machinery for selectiong the ditau directly according to user cuts
40  if (!m_selectionString.empty()) {
41  ATH_CHECK(initializeParser(m_selectionString));
42  }
43  return StatusCode::SUCCESS;
44 }

Member Data Documentation

◆ m_ditauKey

SG::ReadHandleKey<xAOD::DiTauJetContainer> DerivationFramework::DiTauTrackParticleThinning::m_ditauKey { this, "DiTauKey","",""}
private

Definition at line 42 of file DiTauTrackParticleThinning.h.

◆ m_inDetSGKey

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

Definition at line 44 of file DiTauTrackParticleThinning.h.

◆ m_npass

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

Definition at line 39 of file DiTauTrackParticleThinning.h.

◆ m_ntot

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

Definition at line 38 of file DiTauTrackParticleThinning.h.

◆ m_selectionString

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

Definition at line 46 of file DiTauTrackParticleThinning.h.

◆ m_streamName

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

Definition at line 40 of file DiTauTrackParticleThinning.h.


The documentation for this class was generated from the following files:
DerivationFramework::DiTauTrackParticleThinning::m_ditauKey
SG::ReadHandleKey< xAOD::DiTauJetContainer > m_ditauKey
Definition: DiTauTrackParticleThinning.h:43
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
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::DiTauTrackParticleThinning::m_inDetSGKey
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetSGKey
Definition: DiTauTrackParticleThinning.h:45
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
DerivationFramework::DiTauTrackParticleThinning::m_selectionString
Gaudi::Property< std::string > m_selectionString
Definition: DiTauTrackParticleThinning.h:47
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
DerivationFramework::DiTauTrackParticleThinning::m_ntot
std::atomic< unsigned int > m_ntot
Definition: DiTauTrackParticleThinning.h:38
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DeMoScan.index
string index
Definition: DeMoScan.py:364
entries
double entries
Definition: listroot.cxx:49
DerivationFramework::DiTauTrackParticleThinning::m_npass
std::atomic< unsigned int > m_npass
Definition: DiTauTrackParticleThinning.h:39
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
DerivationFramework::DiTauTrackParticleThinning::m_streamName
StringProperty m_streamName
Definition: DiTauTrackParticleThinning.h:41