Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Private Attributes | List of all members
DerivationFramework::BPhysPVThinningTool Class Reference

#include <BPhysPVThinningTool.h>

Inheritance diagram for DerivationFramework::BPhysPVThinningTool:
Collaboration diagram for DerivationFramework::BPhysPVThinningTool:

Public Member Functions

 BPhysPVThinningTool (const std::string &t, const std::string &n, const IInterface *p)
 Constructor with parameters. More...
 
 ~BPhysPVThinningTool ()
 Destructor. More...
 
virtual StatusCode initialize () override
 
virtual StatusCode finalize () override
 
virtual StatusCode doThinning () const override
 Check that the current event passes this filter. More...
 

Private Attributes

StringProperty m_streamName { this, "StreamName", "", "Name of the stream being thinned" }
 
SG::ReadHandleKeyArray< xAOD::VertexContainerm_BPhyCandList
 
SG::ThinningHandleKey< xAOD::TrackParticleContainerm_TrackContainerName
 
SG::ThinningHandleKey< xAOD::VertexContainerm_PVContainerName
 
std::atomic< unsigned int > m_ntot
 
std::atomic< unsigned int > m_npass
 
std::atomic< unsigned int > m_tracks_kept
 
bool m_keepTracks
 

Detailed Description

Definition at line 23 of file BPhysPVThinningTool.h.

Constructor & Destructor Documentation

◆ BPhysPVThinningTool()

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

Constructor with parameters.

Definition at line 26 of file BPhysPVThinningTool.cxx.

28  :
29  base_class(t,n,p),
30  m_TrackContainerName("InDetTrackParticles"),
31  m_PVContainerName("PrimaryVertices"),
32  m_ntot(0),
33  m_npass(0), m_tracks_kept(0), m_keepTracks(false)
34 {
35  declareProperty("CandidateCollections" , m_BPhyCandList);
36  declareProperty("KeepPVTracks", m_keepTracks);
37  declareProperty("TrackParticleContainerName", m_TrackContainerName);
38  declareProperty("PrimaryVertexContainerName", m_PVContainerName);
39 }

◆ ~BPhysPVThinningTool()

DerivationFramework::BPhysPVThinningTool::~BPhysPVThinningTool ( )

Destructor.

Definition at line 42 of file BPhysPVThinningTool.cxx.

42  {
43 }

Member Function Documentation

◆ doThinning()

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

Check that the current event passes this filter.

Definition at line 64 of file BPhysPVThinningTool.cxx.

65 {
66  const EventContext& ctx = Gaudi::Hive::currentContext();
67  // Get the track container
69  if(!PV_col.isValid()) {
70  ATH_MSG_ERROR ("Couldn't retrieve VertexContainer with key PrimaryVertices");
71  return StatusCode::FAILURE;
72  }
73  m_ntot+=PV_col->size();
74  // Loop over tracks, see if they pass, set mask
75  std::vector<bool> mask(PV_col->size(), false);
76 
77  BPhysHelper::pv_type pvtypes[] = {BPhysHelper::PV_MAX_SUM_PT2,
78  BPhysHelper::PV_MIN_A0,
79  BPhysHelper::PV_MIN_Z0,
80  BPhysHelper::PV_MIN_Z0_BA};
81 
82 
83 
84  for(auto &str : m_BPhyCandList) {
86  ATH_CHECK(Container.isValid());
87  size_t s = Container->size();
88  for(size_t i = 0; i<s; i++) {
89  xAOD::BPhysHelper vtx(Container->at(i));
90 
91  for(size_t i =0; i < 4; i++) {
92  const xAOD::Vertex* origPv = vtx.origPv(pvtypes[i]);
93  if(origPv==nullptr) continue;
94  auto pvit = std::find (PV_col->begin(), PV_col->end(), origPv);
95  if(pvit == PV_col->end()) {
96  ATH_MSG_WARNING("PV not found in container");
97  continue;
98  }
99  size_t x = std::distance(PV_col->begin(), pvit);
100  mask.at(x) = true;
101  }
102 
103  }
104  }
105 
106  m_npass += std::accumulate(mask.begin(), mask.end(), 0);
107 
108  if(m_keepTracks){
110  std::vector<bool> trackmask(importedTrackParticles->size(), false);
111  size_t pvnum = mask.size();
112  for(size_t i =0; i<pvnum;i++){
113  if(mask[i] == false) continue;
114  auto vtx = PV_col->at(i);
115  size_t s = vtx->nTrackParticles();
116  for(size_t j=0;j<s;j++){
117  auto trackit = std::find(importedTrackParticles->begin(), importedTrackParticles->end(), vtx->trackParticle(j));
118  if(trackit == importedTrackParticles->end()){
119  ATH_MSG_WARNING("track not found in container");
120  continue;
121  }
122  size_t x = std::distance(importedTrackParticles->begin(), trackit);
123  trackmask.at(x) = true;
124  }
125  }
126  importedTrackParticles.keep(trackmask);
127  m_tracks_kept += std::accumulate(trackmask.begin(), trackmask.end(), 0);
128  }
129  PV_col.keep(mask);
130 
131  return StatusCode::SUCCESS;
132 }

◆ finalize()

StatusCode DerivationFramework::BPhysPVThinningTool::finalize ( )
overridevirtual

Definition at line 55 of file BPhysPVThinningTool.cxx.

56 {
57  ATH_MSG_VERBOSE("finalize() ...");
58  ATH_MSG_INFO("Processed "<< m_ntot <<" PV, "<< m_npass<< " were retained ");
59  if(m_keepTracks) ATH_MSG_INFO("Additional tracks kept " << m_tracks_kept);
60  return StatusCode::SUCCESS;
61 }

◆ initialize()

StatusCode DerivationFramework::BPhysPVThinningTool::initialize ( )
overridevirtual

Definition at line 46 of file BPhysPVThinningTool.cxx.

47 {
48  ATH_MSG_VERBOSE("initialize() ...");
49  ATH_CHECK(m_BPhyCandList.initialize());
50  if(not m_TrackContainerName.key().empty()) ATH_CHECK(m_TrackContainerName.initialize(m_streamName));
52 
53  return StatusCode::SUCCESS;
54 }

Member Data Documentation

◆ m_BPhyCandList

SG::ReadHandleKeyArray<xAOD::VertexContainer> DerivationFramework::BPhysPVThinningTool::m_BPhyCandList
private

Definition at line 41 of file BPhysPVThinningTool.h.

◆ m_keepTracks

bool DerivationFramework::BPhysPVThinningTool::m_keepTracks
private

Definition at line 47 of file BPhysPVThinningTool.h.

◆ m_npass

std::atomic<unsigned int> DerivationFramework::BPhysPVThinningTool::m_npass
mutableprivate

Definition at line 45 of file BPhysPVThinningTool.h.

◆ m_ntot

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

Definition at line 44 of file BPhysPVThinningTool.h.

◆ m_PVContainerName

SG::ThinningHandleKey<xAOD::VertexContainer> DerivationFramework::BPhysPVThinningTool::m_PVContainerName
private

Definition at line 43 of file BPhysPVThinningTool.h.

◆ m_streamName

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

Definition at line 40 of file BPhysPVThinningTool.h.

◆ m_TrackContainerName

SG::ThinningHandleKey<xAOD::TrackParticleContainer> DerivationFramework::BPhysPVThinningTool::m_TrackContainerName
private

Definition at line 42 of file BPhysPVThinningTool.h.

◆ m_tracks_kept

std::atomic<unsigned int> DerivationFramework::BPhysPVThinningTool::m_tracks_kept
mutableprivate

Definition at line 46 of file BPhysPVThinningTool.h.


The documentation for this class was generated from the following files:
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
DerivationFramework::BPhysPVThinningTool::m_keepTracks
bool m_keepTracks
Definition: BPhysPVThinningTool.h:47
xAOD::BPhysHelper
Definition: BPhysHelper.h:71
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
DerivationFramework::BPhysPVThinningTool::m_streamName
StringProperty m_streamName
Definition: BPhysPVThinningTool.h:40
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::BPhysPVThinningTool::m_npass
std::atomic< unsigned int > m_npass
Definition: BPhysPVThinningTool.h:45
DerivationFramework::BPhysPVThinningTool::m_PVContainerName
SG::ThinningHandleKey< xAOD::VertexContainer > m_PVContainerName
Definition: BPhysPVThinningTool.h:43
x
#define x
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::BPhysPVThinningTool::m_tracks_kept
std::atomic< unsigned int > m_tracks_kept
Definition: BPhysPVThinningTool.h:46
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
xAOD::BPhysHelper::pv_type
pv_type
: Enum type of the PV
Definition: BPhysHelper.h:475
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
runIDAlign.accumulate
accumulate
Update flags based on parser line args.
Definition: runIDAlign.py:63
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
DerivationFramework::BPhysPVThinningTool::m_ntot
std::atomic< unsigned int > m_ntot
Definition: BPhysPVThinningTool.h:44
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DerivationFramework::BPhysPVThinningTool::m_BPhyCandList
SG::ReadHandleKeyArray< xAOD::VertexContainer > m_BPhyCandList
Definition: BPhysPVThinningTool.h:41
str
Definition: BTagTrackIpAccessor.cxx:11
DerivationFramework::BPhysPVThinningTool::m_TrackContainerName
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_TrackContainerName
Definition: BPhysPVThinningTool.h:42
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54