ATLAS Offline Software
Loading...
Searching...
No Matches
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.
 ~BPhysPVThinningTool ()
 Destructor.
virtual StatusCode initialize () override
virtual StatusCode finalize () override
virtual StatusCode doThinning () const override
 Check that the current event passes this filter.

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),
34{
35 declareProperty("CandidateCollections" , m_BPhyCandList);
36 declareProperty("KeepPVTracks", m_keepTracks);
37 declareProperty("TrackParticleContainerName", m_TrackContainerName);
38 declareProperty("PrimaryVertexContainerName", m_PVContainerName);
39}
SG::ReadHandleKeyArray< xAOD::VertexContainer > m_BPhyCandList
SG::ThinningHandleKey< xAOD::VertexContainer > m_PVContainerName
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_TrackContainerName

◆ ~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
68 SG::ThinningHandle<xAOD::VertexContainer> PV_col(m_PVContainerName, ctx);
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
81
82
83
84 for(auto &str : m_BPhyCandList) {
85 SG::ReadHandle<xAOD::VertexContainer> Container(str, ctx);
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){
109 SG::ThinningHandle<xAOD::TrackParticleContainer> importedTrackParticles(m_TrackContainerName, ctx);
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define x
pv_type
: Enum type of the PV
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ 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}
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)

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

40{ this, "StreamName", "", "Name of the stream being thinned" };

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