ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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 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 18 of file GenericObjectThinning.cxx.

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

◆ ~GenericObjectThinning()

DerivationFramework::GenericObjectThinning::~GenericObjectThinning ( )

Definition at line 30 of file GenericObjectThinning.cxx.

30  {
31 }

Member Function Documentation

◆ doThinning()

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

Definition at line 63 of file GenericObjectThinning.cxx.

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

◆ finalize()

StatusCode DerivationFramework::GenericObjectThinning::finalize ( )
overridevirtual

Definition at line 54 of file GenericObjectThinning.cxx.

55 {
56  ATH_MSG_VERBOSE("finalize() ...");
57  ATH_MSG_INFO("Processed "<< m_ntot <<" objects, "<< m_npass<< " were retained ");
58  ATH_CHECK(finalizeParser());
59  return StatusCode::SUCCESS;
60 }

◆ initialize()

StatusCode DerivationFramework::GenericObjectThinning::initialize ( )
overridevirtual

Definition at line 34 of file GenericObjectThinning.cxx.

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

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.

◆ m_streamName

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

Definition at line 35 of file GenericObjectThinning.h.


The documentation for this class was generated from the following files:
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DerivationFramework::GenericObjectThinning::m_SGKey
SG::ThinningHandleKey< xAOD::IParticleContainer > m_SGKey
Definition: GenericObjectThinning.h:38
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition: ThinningHandle.h:84
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::GenericObjectThinning::m_ntot
std::atomic< unsigned int > m_ntot
Definition: GenericObjectThinning.h:44
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
entries
double entries
Definition: listroot.cxx:49
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
DerivationFramework::GenericObjectThinning::m_streamName
StringProperty m_streamName
Definition: GenericObjectThinning.h:36
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
DerivationFramework::GenericObjectThinning::m_selectionString
std::string m_selectionString
Definition: GenericObjectThinning.h:41
DerivationFramework::GenericObjectThinning::m_npass
std::atomic< unsigned int > m_npass
Definition: GenericObjectThinning.h:44