ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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  :
25 base_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
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 }

◆ 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 }

◆ 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 }

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.

◆ m_inDetSGKey

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

Definition at line 43 of file VSITrackParticleThinning.h.

◆ m_npass

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

Definition at line 39 of file VSITrackParticleThinning.h.

◆ m_ntot

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

Definition at line 38 of file VSITrackParticleThinning.h.

◆ m_selectionString

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

Definition at line 45 of file VSITrackParticleThinning.h.

◆ m_streamName

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

Definition at line 41 of file VSITrackParticleThinning.h.

◆ m_trackSelectionString

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

Definition at line 47 of file VSITrackParticleThinning.h.


The documentation for this class was generated from the following files:
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
index
Definition: index.py:1
SG::ConstAccessor< char >
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition: ThinningHandle.h:84
DerivationFramework::kdvTrackThinning
@ kdvTrackThinning
Definition: VSITrackParticleThinning.h:28
DerivationFramework::VSITrackParticleThinning::m_selectionString
StringProperty m_selectionString
Definition: VSITrackParticleThinning.h:46
DerivationFramework::VSITrackParticleThinning::m_augVerStrings
StringArrayProperty m_augVerStrings
Definition: VSITrackParticleThinning.h:51
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
DerivationFramework::VSITrackParticleThinning::m_streamName
StringProperty m_streamName
Definition: VSITrackParticleThinning.h:42
beamspotman.n
n
Definition: beamspotman.py:731
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::VSITrackParticleThinning::m_npass
std::atomic< unsigned int > m_npass
Definition: VSITrackParticleThinning.h:39
DerivationFramework::VSITrackParticleThinning::m_ntot
std::atomic< unsigned int > m_ntot
Definition: VSITrackParticleThinning.h:38
DerivationFramework::VSITrackParticleThinning::m_inDetSGKey
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetSGKey
Definition: VSITrackParticleThinning.h:44
DeMoScan.index
string index
Definition: DeMoScan.py:364
DerivationFramework::VSITrackParticleThinning::m_trackSelectionString
StringProperty m_trackSelectionString
Definition: VSITrackParticleThinning.h:48
entries
double entries
Definition: listroot.cxx:49
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73