ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
DerivationFramework::JetLargeD0TrackParticleThinning Class Reference

#include <JetLargeD0TrackParticleThinning.h>

Inheritance diagram for DerivationFramework::JetLargeD0TrackParticleThinning:
Collaboration diagram for DerivationFramework::JetLargeD0TrackParticleThinning:

Public Member Functions

 JetLargeD0TrackParticleThinning (const std::string &t, const std::string &n, const IInterface *p)
 
virtual ~JetLargeD0TrackParticleThinning ()
 
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 {}
 
SG::ReadHandleKey< xAOD::JetContainerm_jetKey { this, "JetKey", "", ""}
 
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", "", "" }
 

Detailed Description

Definition at line 28 of file JetLargeD0TrackParticleThinning.h.

Constructor & Destructor Documentation

◆ JetLargeD0TrackParticleThinning()

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

Definition at line 27 of file JetLargeD0TrackParticleThinning.cxx.

29  :
30 base_class(t,n,p)
31 {
32 }

◆ ~JetLargeD0TrackParticleThinning()

DerivationFramework::JetLargeD0TrackParticleThinning::~JetLargeD0TrackParticleThinning ( )
virtual

Definition at line 35 of file JetLargeD0TrackParticleThinning.cxx.

35  {
36 }

Member Function Documentation

◆ doThinning()

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

Definition at line 68 of file JetLargeD0TrackParticleThinning.cxx.

69 {
70  const EventContext& ctx = Gaudi::Hive::currentContext();
71 
72  // Retrieve main TrackParticle collection
74  (m_inDetSGKey, ctx);
76 
77  // Check the event contains tracks
78  unsigned int nTracks = importedTrackParticles->size();
79  if (nTracks==0) return StatusCode::SUCCESS;
80 
81  // Set up a mask with the same entries as the full TrackParticle collection
82  std::vector<bool> mask;
83  mask.assign(nTracks,false); // default: don't keep any tracks
84  m_ntot += nTracks;
85 
86  // Retrieve containers
87  // ... jets
89  if (!importedJets.isValid()) {
90  ATH_MSG_ERROR("No jet collection with name " << m_jetKey.key() << " found in StoreGate!");
91  return StatusCode::FAILURE;
92  }
93  unsigned int nJets(importedJets->size());
94  std::vector<const xAOD::Jet*> jetToCheck; jetToCheck.clear();
95 
96  // Execute the text parser if requested
97  if (!m_selectionString.empty()) {
98  std::vector<int> entries = m_parser[kJetSelection]->evaluateAsVector();
99  unsigned int nEntries = entries.size();
100  // check the sizes are compatible
101  if (nJets != nEntries ) {
102  ATH_MSG_ERROR("Sizes incompatible! Are you sure your selection string used jets??");
103  return StatusCode::FAILURE;
104  } else {
105  // identify which jets to keep for the thinning check
106  for (unsigned int i=0; i<nJets; ++i) if (entries[i]==1) jetToCheck.push_back((*importedJets)[i]);
107  }
108  }
109 
110  // Set elements in the mask to true if they are matched to a reconstructed object
111  // ... jets
112  static const SG::AuxElement::ConstAccessor<std::vector<ElementLink<DataVector<xAOD::IParticle> > > > ghostTrackLRT ("GhostTrackLRT");
113 
114  if (m_selectionString.empty()) { // check all jets as user didn't provide a selection string
115  for (xAOD::JetContainer::const_iterator jetIt=importedJets->begin(); jetIt!=importedJets->end(); ++jetIt) {
116  const std::vector< ElementLink<DataVector<xAOD::IParticle> > > &jetTrackLinks = ghostTrackLRT( **jetIt );
117  for (const auto &jetTrkIt : jetTrackLinks) {
118  const xAOD::TrackParticle* trackPart = dynamic_cast<const xAOD::TrackParticle*>(*jetTrkIt);
119  int index = trackPart->index();
120  mask[index] = true;
121  }
122  }
123  } else { // check only jets passing user selection string
124  for (std::vector<const xAOD::Jet*>::const_iterator jetIt=jetToCheck.begin(); jetIt!=jetToCheck.end(); ++jetIt) {
125  const std::vector< ElementLink<DataVector<xAOD::IParticle> > > &jetTrackLinks = ghostTrackLRT( **jetIt );
126  for (const auto &jetTrkIt : jetTrackLinks) {
127  const xAOD::TrackParticle* trackPart = dynamic_cast<const xAOD::TrackParticle*>(*jetTrkIt);
128  int index = trackPart->index();
129  mask[index] = true;
130  }
131  }
132  }
133 
134  // Apply a track selection string.
135  if (!m_trackSelectionString.empty()) {
136  std::vector<int> entries = m_parser[kTrackThinning]->evaluateAsVector();
137  unsigned int nEntries = entries.size();
138  // check the sizes are compatible
139  if (nTracks != nEntries ) {
140  ATH_MSG_ERROR("Sizes incompatible! Are you sure your track selection string used tracks??");
141  return StatusCode::FAILURE;
142  } else {
143  // identify which jets to keep for the thinning check
144  for (unsigned int i=0; i<nEntries; ++i) {
145  if (!entries[i]) mask[i] = false;
146  }
147  }
148  }
149 
150  // Count up the mask contents
151  unsigned int n_pass=0;
152  for (unsigned int i=0; i<nTracks; ++i) {
153  if (mask[i]) ++n_pass;
154  }
155  m_npass += n_pass;
156 
157  // Execute the thinning service based on the mask. Finish.
158  importedTrackParticles.keep (mask);
159 
160  return StatusCode::SUCCESS;
161 }

◆ finalize()

StatusCode DerivationFramework::JetLargeD0TrackParticleThinning::finalize ( )
overridevirtual

Definition at line 60 of file JetLargeD0TrackParticleThinning.cxx.

61 {
62  ATH_MSG_VERBOSE("finalize() ...");
63  ATH_MSG_INFO("Processed "<< m_ntot <<" tracks, "<< m_npass<< " were retained ");
64  return StatusCode::SUCCESS;
65 }

◆ initialize()

StatusCode DerivationFramework::JetLargeD0TrackParticleThinning::initialize ( )
overridevirtual

Definition at line 39 of file JetLargeD0TrackParticleThinning.cxx.

40 {
41  // Decide which collections need to be checked for ID TrackParticles
42  ATH_MSG_VERBOSE("initialize() ...");
43  ATH_CHECK( m_inDetSGKey.initialize (m_streamName) );
44  ATH_MSG_INFO("Using " << m_inDetSGKey << "as the source collection for inner detector track particles");
45  if (m_jetKey.key().empty()) {
46  ATH_MSG_FATAL("No jet collection provided for thinning.");
47  return StatusCode::FAILURE;
48  }
49  ATH_CHECK( m_jetKey.initialize() );
50  ATH_MSG_INFO("Inner detector track particles associated with objects in " << m_jetKey.key() << " will be retained in this format with the rest being thinned away");
51 
52  // Set up the text-parsing machinery for selectiong the jet directly according to user cuts
53  if (!m_selectionString.empty() || !m_trackSelectionString.empty()) {
54  // order must match enum order EJetTrPThinningParser
55  ATH_CHECK( initializeParser( {m_selectionString, m_trackSelectionString } ));
56  }
57  return StatusCode::SUCCESS;
58 }

Member Data Documentation

◆ m_inDetSGKey

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

Definition at line 44 of file JetLargeD0TrackParticleThinning.h.

◆ m_jetKey

SG::ReadHandleKey<xAOD::JetContainer> DerivationFramework::JetLargeD0TrackParticleThinning::m_jetKey { this, "JetKey", "", ""}
private

Definition at line 39 of file JetLargeD0TrackParticleThinning.h.

◆ m_npass

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

Definition at line 38 of file JetLargeD0TrackParticleThinning.h.

◆ m_ntot

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

Definition at line 37 of file JetLargeD0TrackParticleThinning.h.

◆ m_selectionString

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

Definition at line 46 of file JetLargeD0TrackParticleThinning.h.

◆ m_streamName

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

Definition at line 42 of file JetLargeD0TrackParticleThinning.h.

◆ m_trackSelectionString

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

Definition at line 48 of file JetLargeD0TrackParticleThinning.h.


The documentation for this class was generated from the following files:
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DerivationFramework::JetLargeD0TrackParticleThinning::m_npass
std::atomic< unsigned int > m_npass
Definition: JetLargeD0TrackParticleThinning.h:38
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
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
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
beamspotman.n
n
Definition: beamspotman.py:731
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
DerivationFramework::JetLargeD0TrackParticleThinning::m_jetKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetKey
Definition: JetLargeD0TrackParticleThinning.h:40
DerivationFramework::kTrackThinning
@ kTrackThinning
Definition: JetTrackParticleThinning.h:27
DerivationFramework::JetLargeD0TrackParticleThinning::m_inDetSGKey
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetSGKey
Definition: JetLargeD0TrackParticleThinning.h:45
DerivationFramework::kJetSelection
@ kJetSelection
Definition: JetTrackParticleThinning.h:27
DerivationFramework::JetLargeD0TrackParticleThinning::m_streamName
StringProperty m_streamName
Definition: JetLargeD0TrackParticleThinning.h:43
DerivationFramework::JetLargeD0TrackParticleThinning::m_trackSelectionString
StringProperty m_trackSelectionString
Definition: JetLargeD0TrackParticleThinning.h:49
DerivationFramework::JetLargeD0TrackParticleThinning::m_ntot
std::atomic< unsigned int > m_ntot
Definition: JetLargeD0TrackParticleThinning.h:37
DeMoScan.index
string index
Definition: DeMoScan.py:364
entries
double entries
Definition: listroot.cxx:49
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
DerivationFramework::JetLargeD0TrackParticleThinning::m_selectionString
StringProperty m_selectionString
Definition: JetLargeD0TrackParticleThinning.h:47