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

#include <VSITrackParticleThinning.h>

Inheritance diagram for DerivationFramework::VSITrackParticleThinning:
Collaboration diagram for DerivationFramework::VSITrackParticleThinning:

Public Member Functions

 VSITrackParticleThinning (const std::string &t, const std::string &n, const IInterface *p)
virtual ~VSITrackParticleThinning ()
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", "" }
StringProperty m_selectionString { this, "SelectionString", "", "" }
StringProperty m_trackSelectionString { this, "TrackSelectionString", "", "" }
StringArrayProperty m_augVerStrings { this, "AugVerStrings", {""}, "List of augVerStrings to consider" }

Detailed Description

Definition at line 29 of file VSITrackParticleThinning.h.

Constructor & Destructor Documentation

◆ VSITrackParticleThinning()

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

Definition at line 22 of file VSITrackParticleThinning.cxx.

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

◆ ~VSITrackParticleThinning()

DerivationFramework::VSITrackParticleThinning::~VSITrackParticleThinning ( )
virtual

Definition at line 30 of file VSITrackParticleThinning.cxx.

30 {
31}

Member Function Documentation

◆ doThinning()

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

Definition at line 58 of file VSITrackParticleThinning.cxx.

59{
60
61 const EventContext& ctx = Gaudi::Hive::currentContext();
62
63 // Retrieve main TrackParticle collection
64 SG::ThinningHandle<xAOD::TrackParticleContainer> importedTrackParticles
65 (m_inDetSGKey, ctx);
66
67 // Check the event contains tracks
68 unsigned int nTracks = importedTrackParticles->size();
69 if (nTracks==0) return StatusCode::SUCCESS;
70
71 // Set up a mask with the same entries as the full TrackParticle collection
72 std::vector<bool> mask;
73 mask.assign(nTracks,false); // default: don't keep any tracks
74 m_ntot += nTracks;
75
76 // Set elements in the mask to true if associated with a DV
77 for ( const auto trkIt: *importedTrackParticles ) {
78 for ( const auto &augVerString: m_augVerStrings) {
79 SG::ConstAccessor<char> acc("is_svtrk_final" + augVerString);
80 if (acc.withDefault (*trkIt, false)) {
81 int index = trkIt->index();
82 mask[index] = true;
83 }
84 }
85 }
86
87 // Apply a track selection string.
88 if (!m_trackSelectionString.empty()) {
89 std::vector<int> entries = m_parser[kdvTrackThinning]->evaluateAsVector();
90 unsigned int nEntries = entries.size();
91 // check the sizes are compatible
92 if (nTracks != nEntries ) {
93 ATH_MSG_ERROR("Sizes incompatible! Are you sure your track selection string used tracks??");
94 return StatusCode::FAILURE;
95 }
96 else {
97 // identify which dvs to keep for the thinning check
98 for (unsigned int i=0; i<nEntries; ++i) {
99 if (!mask[i]) continue;
100 if (!entries[i]) mask[i] = false;
101 }
102 }
103 }
104
105
106 // Count up the mask contents
107 unsigned int n_pass=0;
108 for (unsigned int i=0; i<nTracks; ++i) {
109 if (mask[i]) ++n_pass;
110 }
111 m_npass += n_pass;
112
113
114 // Execute the thinning service based on the mask. Finish.
115 importedTrackParticles.keep (mask);
116
117
118 return StatusCode::SUCCESS;
119
120}
#define ATH_MSG_ERROR(x)
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetSGKey
double entries
Definition listroot.cxx:49
str index
Definition DeMoScan.py:362

◆ finalize()

StatusCode DerivationFramework::VSITrackParticleThinning::finalize ( )
overridevirtual

Definition at line 50 of file VSITrackParticleThinning.cxx.

51{
52 ATH_MSG_VERBOSE("finalize() ...");
53 ATH_MSG_INFO("Processed "<< m_ntot <<" tracks, "<< m_npass<< " were retained ");
54 return StatusCode::SUCCESS;
55}
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)

◆ initialize()

StatusCode DerivationFramework::VSITrackParticleThinning::initialize ( )
overridevirtual

Definition at line 34 of file VSITrackParticleThinning.cxx.

35{
36
37 // Decide which collections need to be checked for ID TrackParticles
38 ATH_MSG_VERBOSE("initialize() ...");
39 ATH_CHECK( m_inDetSGKey.initialize (m_streamName) );
40
41 // Set up the text-parsing machinery for selectiong the dv directly according to user cuts
42 if (!m_trackSelectionString.empty()) {
43 // order must match enum order EJetTrPThinningParser
44 ATH_CHECK( initializeParser( { m_selectionString, m_trackSelectionString } ));
45 }
46
47 return StatusCode::SUCCESS;
48}
#define ATH_CHECK
Evaluate an expression and check for errors.

Member Data Documentation

◆ m_augVerStrings

StringArrayProperty DerivationFramework::VSITrackParticleThinning::m_augVerStrings { this, "AugVerStrings", {""}, "List of augVerStrings to consider" }
private

Definition at line 50 of file VSITrackParticleThinning.h.

51{ this, "AugVerStrings", {""}, "List of augVerStrings to consider" };

◆ m_inDetSGKey

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

Definition at line 43 of file VSITrackParticleThinning.h.

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

◆ m_npass

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

Definition at line 39 of file VSITrackParticleThinning.h.

39{};

◆ m_ntot

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

Definition at line 38 of file VSITrackParticleThinning.h.

38{};

◆ m_selectionString

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

Definition at line 45 of file VSITrackParticleThinning.h.

46{ this, "SelectionString", "", "" };

◆ m_streamName

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

Definition at line 41 of file VSITrackParticleThinning.h.

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

◆ m_trackSelectionString

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

Definition at line 47 of file VSITrackParticleThinning.h.

48{ this, "TrackSelectionString", "", "" };

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