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

#include <JetLargeD0TrackParticleThinning.h>

Inheritance diagram for DerivationFramework::JetLargeD0TrackParticleThinning:
Collaboration diagram for DerivationFramework::JetLargeD0TrackParticleThinning:

Public Member Functions

 JetLargeD0TrackParticleThinning (const std::string &t, const std::string &n, const IInterface *p)
virtual ~JetLargeD0TrackParticleThinning ()
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 {}
SG::ReadHandleKey< xAOD::JetContainerm_jetKey { this, "JetKey", "", ""}
StringProperty m_streamName { this, "StreamName", "", "Name of the stream being thinned" }
SG::ThinningHandleKey< xAOD::TrackParticleContainerm_inDetSGKey { this, "InDetTrackParticlesKey", "InDetTrackParticles", "" }
StringProperty m_selectionString { this, "SelectionString", "", "" }
StringProperty m_trackSelectionString { this, "TrackSelectionString", "", "" }

Detailed Description

Definition at line 28 of file JetLargeD0TrackParticleThinning.h.

Constructor & Destructor Documentation

◆ JetLargeD0TrackParticleThinning()

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

Definition at line 27 of file JetLargeD0TrackParticleThinning.cxx.

29 :
30base_class(t,n,p)
31{
32}

◆ ~JetLargeD0TrackParticleThinning()

DerivationFramework::JetLargeD0TrackParticleThinning::~JetLargeD0TrackParticleThinning ( )
virtual

Definition at line 35 of file JetLargeD0TrackParticleThinning.cxx.

35 {
36}

Member Function Documentation

◆ doThinning()

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

Definition at line 68 of file JetLargeD0TrackParticleThinning.cxx.

69{
70 const EventContext& ctx = Gaudi::Hive::currentContext();
71
72 // Retrieve main TrackParticle collection
73 SG::ThinningHandle<xAOD::TrackParticleContainer> importedTrackParticles
74 (m_inDetSGKey, ctx);
75 SG::ReadHandle<xAOD::TrackParticleContainer> tracks(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 // ... jets
88 SG::ReadHandle<xAOD::JetContainer> importedJets(m_jetKey,ctx);
89 if (!importedJets.isValid()) {
90 ATH_MSG_ERROR("No jet collection with name " << m_jetKey.key() << " found in StoreGate!");
91 return StatusCode::FAILURE;
92 }
93 unsigned int nJets(importedJets->size());
94 std::vector<const xAOD::Jet*> jetToCheck; jetToCheck.clear();
95
96 // Execute the text parser if requested
97 if (!m_selectionString.empty()) {
98 std::vector<int> entries = m_parser[kJetSelection]->evaluateAsVector();
99 unsigned int nEntries = entries.size();
100 // check the sizes are compatible
101 if (nJets != nEntries ) {
102 ATH_MSG_ERROR("Sizes incompatible! Are you sure your selection string used jets??");
103 return StatusCode::FAILURE;
104 } else {
105 // identify which jets to keep for the thinning check
106 for (unsigned int i=0; i<nJets; ++i) if (entries[i]==1) jetToCheck.push_back((*importedJets)[i]);
107 }
108 }
109
110 // Set elements in the mask to true if they are matched to a reconstructed object
111 // ... jets
112 static const SG::AuxElement::ConstAccessor<std::vector<ElementLink<DataVector<xAOD::IParticle> > > > ghostTrackLRT ("GhostTrackLRT");
113
114 if (m_selectionString.empty()) { // check all jets as user didn't provide a selection string
115 for (xAOD::JetContainer::const_iterator jetIt=importedJets->begin(); jetIt!=importedJets->end(); ++jetIt) {
116 const std::vector< ElementLink<DataVector<xAOD::IParticle> > > &jetTrackLinks = ghostTrackLRT( **jetIt );
117 for (const auto &jetTrkIt : jetTrackLinks) {
118 const xAOD::TrackParticle* trackPart = dynamic_cast<const xAOD::TrackParticle*>(*jetTrkIt);
119 int index = trackPart->index();
120 mask[index] = true;
121 }
122 }
123 } else { // check only jets passing user selection string
124 for (std::vector<const xAOD::Jet*>::const_iterator jetIt=jetToCheck.begin(); jetIt!=jetToCheck.end(); ++jetIt) {
125 const std::vector< ElementLink<DataVector<xAOD::IParticle> > > &jetTrackLinks = ghostTrackLRT( **jetIt );
126 for (const auto &jetTrkIt : jetTrackLinks) {
127 const xAOD::TrackParticle* trackPart = dynamic_cast<const xAOD::TrackParticle*>(*jetTrkIt);
128 int index = trackPart->index();
129 mask[index] = true;
130 }
131 }
132 }
133
134 // Apply a track selection string.
135 if (!m_trackSelectionString.empty()) {
136 std::vector<int> entries = m_parser[kTrackThinning]->evaluateAsVector();
137 unsigned int nEntries = entries.size();
138 // check the sizes are compatible
139 if (nTracks != nEntries ) {
140 ATH_MSG_ERROR("Sizes incompatible! Are you sure your track selection string used tracks??");
141 return StatusCode::FAILURE;
142 } else {
143 // identify which jets to keep for the thinning check
144 for (unsigned int i=0; i<nEntries; ++i) {
145 if (!entries[i]) mask[i] = false;
146 }
147 }
148 }
149
150 // Count up the mask contents
151 unsigned int n_pass=0;
152 for (unsigned int i=0; i<nTracks; ++i) {
153 if (mask[i]) ++n_pass;
154 }
155 m_npass += n_pass;
156
157 // Execute the thinning service based on the mask. Finish.
158 importedTrackParticles.keep (mask);
159
160 return StatusCode::SUCCESS;
161}
#define ATH_MSG_ERROR(x)
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetSGKey
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
size_t index() const
Return the index of this element within its container.
double entries
Definition listroot.cxx:49
str index
Definition DeMoScan.py:362
TrackParticle_v1 TrackParticle
Reference the current persistent version:

◆ finalize()

StatusCode DerivationFramework::JetLargeD0TrackParticleThinning::finalize ( )
overridevirtual

Definition at line 60 of file JetLargeD0TrackParticleThinning.cxx.

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

◆ initialize()

StatusCode DerivationFramework::JetLargeD0TrackParticleThinning::initialize ( )
overridevirtual

Definition at line 39 of file JetLargeD0TrackParticleThinning.cxx.

40{
41 // Decide which collections need to be checked for ID TrackParticles
42 ATH_MSG_VERBOSE("initialize() ...");
43 ATH_CHECK( m_inDetSGKey.initialize (m_streamName) );
44 ATH_MSG_INFO("Using " << m_inDetSGKey << "as the source collection for inner detector track particles");
45 if (m_jetKey.key().empty()) {
46 ATH_MSG_FATAL("No jet collection provided for thinning.");
47 return StatusCode::FAILURE;
48 }
49 ATH_CHECK( m_jetKey.initialize() );
50 ATH_MSG_INFO("Inner detector track particles associated with objects in " << m_jetKey.key() << " will be retained in this format with the rest being thinned away");
51
52 // Set up the text-parsing machinery for selectiong the jet directly according to user cuts
53 if (!m_selectionString.empty() || !m_trackSelectionString.empty()) {
54 // order must match enum order EJetTrPThinningParser
55 ATH_CHECK( initializeParser( {m_selectionString, m_trackSelectionString } ));
56 }
57 return StatusCode::SUCCESS;
58}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)

Member Data Documentation

◆ m_inDetSGKey

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

Definition at line 44 of file JetLargeD0TrackParticleThinning.h.

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

◆ m_jetKey

SG::ReadHandleKey<xAOD::JetContainer> DerivationFramework::JetLargeD0TrackParticleThinning::m_jetKey { this, "JetKey", "", ""}
private

Definition at line 39 of file JetLargeD0TrackParticleThinning.h.

40{ this, "JetKey", "", ""};

◆ m_npass

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

Definition at line 38 of file JetLargeD0TrackParticleThinning.h.

38{};

◆ m_ntot

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

Definition at line 37 of file JetLargeD0TrackParticleThinning.h.

37{};

◆ m_selectionString

StringProperty DerivationFramework::JetLargeD0TrackParticleThinning::m_selectionString { this, "SelectionString", "", "" }
private

Definition at line 46 of file JetLargeD0TrackParticleThinning.h.

47{ this, "SelectionString", "", "" };

◆ m_streamName

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

Definition at line 42 of file JetLargeD0TrackParticleThinning.h.

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

◆ m_trackSelectionString

StringProperty DerivationFramework::JetLargeD0TrackParticleThinning::m_trackSelectionString { this, "TrackSelectionString", "", "" }
private

Definition at line 48 of file JetLargeD0TrackParticleThinning.h.

49{ this, "TrackSelectionString", "", "" };

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