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 EventContext &ctx) 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 26 of file JetLargeD0TrackParticleThinning.cxx.

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

◆ ~JetLargeD0TrackParticleThinning()

DerivationFramework::JetLargeD0TrackParticleThinning::~JetLargeD0TrackParticleThinning ( )
virtual

Definition at line 34 of file JetLargeD0TrackParticleThinning.cxx.

34 {
35}

Member Function Documentation

◆ doThinning()

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

Definition at line 67 of file JetLargeD0TrackParticleThinning.cxx.

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

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

◆ initialize()

StatusCode DerivationFramework::JetLargeD0TrackParticleThinning::initialize ( )
overridevirtual

Definition at line 38 of file JetLargeD0TrackParticleThinning.cxx.

39{
40 // Decide which collections need to be checked for ID TrackParticles
41 ATH_MSG_VERBOSE("initialize() ...");
42 ATH_CHECK( m_inDetSGKey.initialize (m_streamName) );
43 ATH_MSG_INFO("Using " << m_inDetSGKey << "as the source collection for inner detector track particles");
44 if (m_jetKey.key().empty()) {
45 ATH_MSG_FATAL("No jet collection provided for thinning.");
46 return StatusCode::FAILURE;
47 }
48 ATH_CHECK( m_jetKey.initialize() );
49 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");
50
51 // Set up the text-parsing machinery for selectiong the jet directly according to user cuts
52 if (!m_selectionString.empty() || !m_trackSelectionString.empty()) {
53 // order must match enum order EJetTrPThinningParser
54 ATH_CHECK( initializeParser( {m_selectionString, m_trackSelectionString } ));
55 }
56 return StatusCode::SUCCESS;
57}
#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: