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

#include <SV1TrackThinning.h>

Inheritance diagram for DerivationFramework::SV1TrackThinning:
Collaboration diagram for DerivationFramework::SV1TrackThinning:

Public Member Functions

 SV1TrackThinning (const std::string &t, const std::string &n, const IInterface *p)
 
 ~SV1TrackThinning ()
 
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", "" }
 
std::string m_jetSGKey
 
std::string m_selectionString
 

Detailed Description

Definition at line 25 of file SV1TrackThinning.h.

Constructor & Destructor Documentation

◆ SV1TrackThinning()

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

Definition at line 20 of file SV1TrackThinning.cxx.

22  :
23  base_class(t,n,p),
24  m_ntot(0),
25  m_npass(0),
26  m_jetSGKey(""),
28 {
29  declareProperty("JetKey", m_jetSGKey);
30  declareProperty("SelectionString", m_selectionString);
31 }

◆ ~SV1TrackThinning()

DerivationFramework::SV1TrackThinning::~SV1TrackThinning ( )

Definition at line 34 of file SV1TrackThinning.cxx.

34  {
35 }

Member Function Documentation

◆ doThinning()

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

Definition at line 65 of file SV1TrackThinning.cxx.

66 {
67  const EventContext& ctx = Gaudi::Hive::currentContext();
68 
69  // Retrieve main TrackParticle collection
71  (m_inDetSGKey, ctx);
72 
73  // Check the event contains tracks
74  unsigned int nTracks = importedTrackParticles->size();
75  if (nTracks==0) return StatusCode::SUCCESS;
76 
77  // Set up a mask with the same entries as the full TrackParticle collection
78  std::vector<bool> mask;
79  mask.assign(nTracks, false); // default: don't keep any tracks
80  m_ntot += nTracks;
81 
82  const xAOD::JetContainer* importedJets(0);
83  if (evtStore()->retrieve(importedJets,m_jetSGKey).isFailure()) {
84  ATH_MSG_ERROR("No jet collection with name " << m_jetSGKey << " found in StoreGate!");
85  return StatusCode::FAILURE;
86  }
87 
88  unsigned int nJets(importedJets->size());
89  std::vector<const xAOD::Jet*> jetToCheck; jetToCheck.clear();
90 
91  // Execute the text parser if requested
92  if (!m_selectionString.empty()) {
93  std::vector<int> entries = m_parser->evaluateAsVector();
94  unsigned int nEntries = entries.size();
95  // check the sizes are compatible
96  if (nJets != nEntries ) {
97  ATH_MSG_ERROR("Sizes incompatible! Are you sure your selection string used jets??");
98  return StatusCode::FAILURE;
99  } else {
100  // identify which jets to keep for the thinning check
101  for (unsigned int i=0; i<nJets; ++i) if (entries[i]==1) jetToCheck.push_back((*importedJets)[i]);
102  }
103  }
104 
105  // Retrieve containers
106  // ... jets
107  if (m_selectionString=="") { // check all jets as user didn't provide a selection string
108  for (xAOD::JetContainer::const_iterator jetIt=importedJets->begin(); jetIt!=importedJets->end(); ++jetIt) {
109  const xAOD::BTagging* btag = xAOD::BTaggingUtilities::getBTagging( **jetIt );
110  const std::vector< ElementLink<xAOD::TrackParticleContainer> >& SV1_trackParticleLinks =
111  btag->SV1_TrackParticleLinks();
112 
113 
114  for (const ElementLink<xAOD::TrackParticleContainer> &tp : SV1_trackParticleLinks) {
115  int index = (*tp)->index();
116  mask[index] = true;
117  }
118  }
119  } else { // check only jets passing user selection string
120  for (std::vector<const xAOD::Jet*>::iterator jetIt = jetToCheck.begin(); jetIt!=jetToCheck.end(); ++jetIt) {
121  const xAOD::BTagging* btag = xAOD::BTaggingUtilities::getBTagging( **jetIt );
122  const std::vector< ElementLink<xAOD::TrackParticleContainer> >& SV1_trackParticleLinks =
123  btag->SV1_TrackParticleLinks();
124 
125 
126  for (const ElementLink<xAOD::TrackParticleContainer> &tp : SV1_trackParticleLinks) {
127  int index = (*tp)->index();
128  mask[index] = true;
129  }
130  }
131  }
132 
133  // Count up the mask contents
134  for (unsigned int i=0; i<nTracks; ++i) {
135  if (mask[i]) ++m_npass;
136  }
137 
138  // Execute the thinning service based on the mask. Finish.
139  importedTrackParticles.keep (mask);
140 
141  return StatusCode::SUCCESS;
142 }

◆ finalize()

StatusCode DerivationFramework::SV1TrackThinning::finalize ( )
overridevirtual

Definition at line 56 of file SV1TrackThinning.cxx.

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

◆ initialize()

StatusCode DerivationFramework::SV1TrackThinning::initialize ( )
overridevirtual

Definition at line 38 of file SV1TrackThinning.cxx.

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

Member Data Documentation

◆ m_inDetSGKey

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

Definition at line 37 of file SV1TrackThinning.h.

◆ m_jetSGKey

std::string DerivationFramework::SV1TrackThinning::m_jetSGKey
private

Definition at line 39 of file SV1TrackThinning.h.

◆ m_npass

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

Definition at line 34 of file SV1TrackThinning.h.

◆ m_ntot

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

Definition at line 34 of file SV1TrackThinning.h.

◆ m_selectionString

std::string DerivationFramework::SV1TrackThinning::m_selectionString
private

Definition at line 39 of file SV1TrackThinning.h.

◆ m_streamName

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

Definition at line 35 of file SV1TrackThinning.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
DerivationFramework::SV1TrackThinning::m_inDetSGKey
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_inDetSGKey
Definition: SV1TrackThinning.h:38
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
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
index
Definition: index.py:1
ParticleTest.tp
tp
Definition: ParticleTest.py:25
DerivationFramework::SV1TrackThinning::m_jetSGKey
std::string m_jetSGKey
Definition: SV1TrackThinning.h:39
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::SV1TrackThinning::m_npass
std::atomic< unsigned int > m_npass
Definition: SV1TrackThinning.h:34
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
DerivationFramework::SV1TrackThinning::m_streamName
StringProperty m_streamName
Definition: SV1TrackThinning.h:36
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
DerivationFramework::SV1TrackThinning::m_ntot
std::atomic< unsigned int > m_ntot
Definition: SV1TrackThinning.h:34
xAOD::BTagging_v1::SV1_TrackParticleLinks
const TPELVec_t & SV1_TrackParticleLinks() const
get vector of SV1 TrackParticle ElementLinks
Definition: BTagging_v1.cxx:106
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::BTagging_v1
Definition: BTagging_v1.h:39
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::BTaggingUtilities::getBTagging
const BTagging * getBTagging(const SG::AuxElement &part)
Access the default xAOD::BTagging object associated to an object.
Definition: BTaggingUtilities.cxx:37
DeMoScan.index
string index
Definition: DeMoScan.py:362
entries
double entries
Definition: listroot.cxx:49
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
DerivationFramework::SV1TrackThinning::m_selectionString
std::string m_selectionString
Definition: SV1TrackThinning.h:39