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

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

◆ ~VSITrackParticleThinning()

DerivationFramework::VSITrackParticleThinning::~VSITrackParticleThinning ( )
virtual

Definition at line 29 of file VSITrackParticleThinning.cxx.

29 {
30}

Member Function Documentation

◆ doThinning()

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

Definition at line 57 of file VSITrackParticleThinning.cxx.

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

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

◆ initialize()

StatusCode DerivationFramework::VSITrackParticleThinning::initialize ( )
overridevirtual

Definition at line 33 of file VSITrackParticleThinning.cxx.

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