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 EventContext &ctx) 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 EventContext & ctx) const
overridevirtual

Check that the current event passes this filter.

Definition at line 64 of file BPhysPVThinningTool.cxx.

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