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

#include <GenericObjectThinning.h>

Inheritance diagram for DerivationFramework::GenericObjectThinning:
Collaboration diagram for DerivationFramework::GenericObjectThinning:

Public Member Functions

 GenericObjectThinning (const std::string &t, const std::string &n, const IInterface *p)
 ~GenericObjectThinning ()
virtual StatusCode initialize () override
virtual StatusCode finalize () override
virtual StatusCode doThinning (const EventContext &ctx) const override

Private Attributes

StringProperty m_streamName { this, "StreamName", "", "Name of the stream being thinned" }
SG::ThinningHandleKey< xAOD::IParticleContainerm_SGKey { this, "ContainerName", "", "" }
std::string m_selectionString
std::atomic< unsigned int > m_ntot
std::atomic< unsigned int > m_npass

Detailed Description

Definition at line 26 of file GenericObjectThinning.h.

Constructor & Destructor Documentation

◆ GenericObjectThinning()

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

Definition at line 17 of file GenericObjectThinning.cxx.

19 :
20base_class(t,n,p),
22m_ntot(0),
23m_npass(0)
24{
25 declareProperty("SelectionString", m_selectionString);
26}

◆ ~GenericObjectThinning()

DerivationFramework::GenericObjectThinning::~GenericObjectThinning ( )

Definition at line 29 of file GenericObjectThinning.cxx.

29 {
30}

Member Function Documentation

◆ doThinning()

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

Definition at line 62 of file GenericObjectThinning.cxx.

63{
64
65 // Retrieve main object collection
66 SG::ThinningHandle<xAOD::IParticleContainer> particles (m_SGKey, ctx);
67
68 // Check the event contains objects
69 unsigned int nObjects = particles->size();
70 if (nObjects==0) return StatusCode::SUCCESS;
71
72 // Set up a mask with the same entries as the full collection
73 std::vector<bool> mask;
74 mask.assign(nObjects,false); // default: don't keep any tracks
75 m_ntot += nObjects;
76
77 // Execute the text parser and update the mask
78 if (m_parser) {
79 std::vector<int> entries = m_parser->evaluateAsVector();
80 unsigned int nEntries = entries.size();
81 // check the sizes are compatible
82 if (nObjects != nEntries ) {
83 ATH_MSG_ERROR("Sizes incompatible! Are you sure your selection string used the same collection as the input collection??");
84 return StatusCode::FAILURE;
85 } else {
86 // set mask
87 for (unsigned int i=0; i<nObjects; ++i) if (entries[i]==1) mask[i]=true;
88 }
89 }
90 // Count the mask
91 m_npass += std::count (mask.begin(), mask.end(), true);
92
93 // Execute the thinning based on the mask. Finish.
94 particles.keep (mask);
95
96 return StatusCode::SUCCESS;
97}
#define ATH_MSG_ERROR(x)
SG::ThinningHandleKey< xAOD::IParticleContainer > m_SGKey
double entries
Definition listroot.cxx:49

◆ finalize()

StatusCode DerivationFramework::GenericObjectThinning::finalize ( )
overridevirtual

Definition at line 53 of file GenericObjectThinning.cxx.

54{
55 ATH_MSG_VERBOSE("finalize() ...");
56 ATH_MSG_INFO("Processed "<< m_ntot <<" objects, "<< m_npass<< " were retained ");
57 ATH_CHECK(finalizeParser());
58 return StatusCode::SUCCESS;
59}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)

◆ initialize()

StatusCode DerivationFramework::GenericObjectThinning::initialize ( )
overridevirtual

Definition at line 33 of file GenericObjectThinning.cxx.

34{
35 ATH_MSG_VERBOSE("initialize() ...");
36 if (m_selectionString.empty()) {
37 ATH_MSG_FATAL("No selection string provided!");
38 return StatusCode::FAILURE;
39 } else {ATH_MSG_INFO("Selection string: " << m_selectionString);}
40
41 // Set up the text-parsing machinery for thinning the tracks directly according to user cuts
42 if (!m_selectionString.empty()) {
43 ATH_CHECK(initializeParser( m_selectionString) );
44 }
45
46 //check xAOD::InDetTrackParticle collection
47 ATH_CHECK( m_SGKey.initialize (m_streamName) );
48 ATH_MSG_INFO("Using " << m_SGKey << "as the source collection");
49
50 return StatusCode::SUCCESS;
51}
#define ATH_MSG_FATAL(x)

Member Data Documentation

◆ m_npass

std::atomic<unsigned int> DerivationFramework::GenericObjectThinning::m_npass
private

Definition at line 44 of file GenericObjectThinning.h.

◆ m_ntot

std::atomic<unsigned int> DerivationFramework::GenericObjectThinning::m_ntot
mutableprivate

Definition at line 44 of file GenericObjectThinning.h.

◆ m_selectionString

std::string DerivationFramework::GenericObjectThinning::m_selectionString
private

Definition at line 41 of file GenericObjectThinning.h.

◆ m_SGKey

SG::ThinningHandleKey<xAOD::IParticleContainer> DerivationFramework::GenericObjectThinning::m_SGKey { this, "ContainerName", "", "" }
private

Definition at line 37 of file GenericObjectThinning.h.

38{ this, "ContainerName", "", "" };

◆ m_streamName

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

Definition at line 35 of file GenericObjectThinning.h.

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

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