ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::Thin_vtxTrk Class Reference

#include <Thin_vtxTrk.h>

Inheritance diagram for DerivationFramework::Thin_vtxTrk:
Collaboration diagram for DerivationFramework::Thin_vtxTrk:

Public Member Functions

 Thin_vtxTrk (const std::string &t, const std::string &n, const IInterface *p)
 ~Thin_vtxTrk ()
StatusCode initialize ()
StatusCode finalize ()
virtual StatusCode doThinning () const

Private Attributes

StringProperty m_streamName { this, "StreamName", "", "Name of the stream being thinned" }
std::atomic< unsigned int > m_ntot
std::atomic< unsigned int > m_npass
double m_acceptanceR
std::atomic< unsigned int > m_nVtxTot
std::atomic< unsigned int > m_nVtxPass
SG::ThinningHandleKey< xAOD::TrackParticleContainerm_trackParticleContainerName
SG::ThinningHandleKeyArray< xAOD::VertexContainerm_vertexContainerName
std::vector< std::string > m_passFlags
SG::ReadDecorHandleKeyArray< xAOD::VertexContainerm_passArray {this, "INTERNALARRAY", {}}
bool m_thinTracks
bool m_noFlags

Detailed Description

Definition at line 29 of file Thin_vtxTrk.h.

Constructor & Destructor Documentation

◆ Thin_vtxTrk()

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

Definition at line 19 of file Thin_vtxTrk.cxx.

19 :
20 base_class(t,n,p),
21 m_ntot(0),
22 m_npass(0),
23 m_acceptanceR(-1.), // Do not add tracks within a cone from the vertex by default
24 m_nVtxTot(0),
25 m_nVtxPass(0),
26 m_noFlags(false)
27{
28 declareProperty("TrackParticleContainerName", m_trackParticleContainerName = "InDetTrackParticles");
29 declareProperty("VertexContainerNames" , m_vertexContainerName);
30 declareProperty("PassFlags" , m_passFlags);
31 declareProperty("AcceptanceRadius" , m_acceptanceR);
32 declareProperty("IgnoreFlags" , m_noFlags);
33 declareProperty("ThinTracks" , m_thinTracks = true);
34}
std::atomic< unsigned int > m_nVtxTot
Definition Thin_vtxTrk.h:41
std::atomic< unsigned int > m_npass
Definition Thin_vtxTrk.h:39
std::atomic< unsigned int > m_nVtxPass
Definition Thin_vtxTrk.h:41
std::vector< std::string > m_passFlags
Definition Thin_vtxTrk.h:45
std::atomic< unsigned int > m_ntot
Definition Thin_vtxTrk.h:39
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_trackParticleContainerName
Definition Thin_vtxTrk.h:43
SG::ThinningHandleKeyArray< xAOD::VertexContainer > m_vertexContainerName
Definition Thin_vtxTrk.h:44

◆ ~Thin_vtxTrk()

DerivationFramework::Thin_vtxTrk::~Thin_vtxTrk ( )
default

Member Function Documentation

◆ doThinning()

StatusCode DerivationFramework::Thin_vtxTrk::doThinning ( ) const
virtual

Definition at line 88 of file Thin_vtxTrk.cxx.

89{
90 const EventContext& ctx = Gaudi::Hive::currentContext();
91 // Retrieve main TrackParticle collection
92 SG::ThinningHandle<xAOD::TrackParticleContainer> importedTrackParticles(m_trackParticleContainerName, ctx);
93
94 // Check the event contains tracks
95 unsigned int nTracks = importedTrackParticles->size();
96 if (nTracks==0) return StatusCode::SUCCESS;
97
98 // Set up a trackMask with the same entries as the full TrackParticle collection
99 std::vector<bool> trackMask(nTracks,false); // default: don't keep any tracks
100 m_ntot += nTracks;
101 int nVtxTot =0;
102 int nVtxPass=0;
103
104 std::unordered_map<std::string, SG::ReadDecorHandle<xAOD::VertexContainer, Char_t>> handles;
105 handles.reserve(m_passArray.size());
106 for(const auto &key : m_passArray){
107 auto it = handles.emplace(std::piecewise_construct, std::forward_as_tuple(key.key()), std::forward_as_tuple(key, ctx));
108 if(!(*it.first).second.isPresent()) return StatusCode::FAILURE;
109 }
110
111 // retieve vertex
112 for(const auto& name : m_vertexContainerName){
113 SG::ThinningHandle<xAOD::VertexContainer> vertexContainer(name, ctx);
114 std::vector<bool> vtxMask(vertexContainer->size(), false); // default: don't keep any vertices
115
116 // loop over vertices
117 int k = 0;
118 for(auto vtxItr = vertexContainer->begin(); vtxItr!=vertexContainer->end(); ++vtxItr, ++k) {
119 const xAOD::Vertex* vtx = *vtxItr;
120 nVtxTot++;
121
122 // check if the vertex passed the required selections criteria
123 bool passed = false;
124 for(std::vector<std::string>::const_iterator flagItr = m_passFlags.begin(); flagItr!=m_passFlags.end(); ++flagItr) {
125 std::string lookupstr = name.key() + '.' + (*flagItr);
126 const auto& handle = handles.at(lookupstr);
127 if(handle(*vtx) != 0) {
128 passed = true;
129 break;
130 }
131 } // end of loop over flags
132
133 if(passed || m_noFlags) {
134 // vertex passed the selection
135 vtxMask[k] = true;
136 nVtxPass++;
137
138 // Add tracks according to DR selection
139 if(m_acceptanceR > 0.){
140
141 // determine the sum of the tracks at vertex as centre for the cone
142 TLorentzVector centreCandidate;
143 for(uint j=0; j<vtx->nTrackParticles(); ++j) {
144 centreCandidate += vtx->trackParticle(j)->p4();
145 }
146
147 for(uint i=0; i<nTracks; ++i) {
148 if(!trackMask[i]) { // do this only for tracks that haven't been selected, yet
149 const xAOD::TrackParticle* track = (*importedTrackParticles)[i];
150 if(centreCandidate.DeltaR(track->p4()) < m_acceptanceR) trackMask[i]= true;
151 }
152 }
153 }// end adding tracks according to DR selection
154
155 if(m_thinTracks) {
156 // loop over all tracks
157 for(uint i=0; i<nTracks; ++i) {
158 if(!trackMask[i]) { // do this only for tracks that haven't been selected, yet
159 const xAOD::TrackParticle* track = (*importedTrackParticles)[i];
160 // loop over tracks at vertex
161 for(uint j=0; j<vtx->nTrackParticles(); ++j) {
162 if(vtx->trackParticle(j) == track) {
163 trackMask[i] = true; // accept track
164 }
165 } // end of loop over tracks at vertex
166 }
167 } // end of loop over all tracks
168 }
169 }
170 } // end of loop over vertices
171
172 // Execute the thinning service based on the vtxMask.
173 vertexContainer.keep(vtxMask);
174 }
175
176 // Count up the trackMask contents
177 m_npass += std::accumulate(trackMask.begin(), trackMask.end(), 0);
178 m_nVtxTot += nVtxTot;
179 m_nVtxPass+= nVtxPass;
180 if(m_thinTracks || m_acceptanceR > 0.) {
181 // Execute the thinning service based on the trackMask. Finish.
182 importedTrackParticles.keep(trackMask);
183 }
184
185 return StatusCode::SUCCESS;
186}
bool passed(DecisionID id, const DecisionIDContainer &)
checks if required decision ID is in the set of IDs in the container
unsigned int uint
SG::ReadDecorHandleKeyArray< xAOD::VertexContainer > m_passArray
Definition Thin_vtxTrk.h:46
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ finalize()

StatusCode DerivationFramework::Thin_vtxTrk::finalize ( )

Definition at line 78 of file Thin_vtxTrk.cxx.

79{
80 ATH_MSG_VERBOSE("finalize() ...");
81 ATH_MSG_INFO("Processed "<< m_ntot <<" tracks, "<< m_npass<< " were retained ");
82 ATH_MSG_INFO("Processed "<< m_nVtxTot <<" vertices, "<< m_nVtxPass<< " were retained ");
83
84 return StatusCode::SUCCESS;
85}
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)

◆ initialize()

StatusCode DerivationFramework::Thin_vtxTrk::initialize ( )

Definition at line 40 of file Thin_vtxTrk.cxx.

41{
42 // Decide which collections need to be checked for ID TrackParticles
43 ATH_MSG_VERBOSE("initialize() ...");
45
46
47 if( m_noFlags){
48 ATH_MSG_INFO("IgnoreFlags is set, all vertices in the container will be kept");
49 }
50
51 if( ! m_noFlags){
52 if (m_passFlags.empty()) {
53 ATH_MSG_FATAL("No pass flags provided for thinning.");
54 return StatusCode::FAILURE;
55 } else {
56 for(auto itr = m_passFlags.begin(); itr!=m_passFlags.end(); ++itr) {
57 ATH_MSG_INFO("Vertices must pass the \"" << *itr << "\" selection");
58 }
59 }
60 }
61
62 if (m_acceptanceR > 0.) {
63 ATH_MSG_INFO("Extra tracks must be within cone of "<<m_acceptanceR<<" from vertex candidate.");
64 }
65
66 for(auto &handle : m_vertexContainerName){
67 ATH_CHECK(handle.initialize(m_streamName));
68 }
69 for(const auto &tracknames : m_vertexContainerName){
70 for(const auto &str : m_passFlags){
71 m_passArray.emplace_back(tracknames.key() + '.' + str);
72 }
73 }
74 ATH_CHECK(m_passArray.initialize());
75 return StatusCode::SUCCESS;
76}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)

Member Data Documentation

◆ m_acceptanceR

double DerivationFramework::Thin_vtxTrk::m_acceptanceR
private

Definition at line 40 of file Thin_vtxTrk.h.

◆ m_noFlags

bool DerivationFramework::Thin_vtxTrk::m_noFlags
private

Definition at line 48 of file Thin_vtxTrk.h.

◆ m_npass

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

Definition at line 39 of file Thin_vtxTrk.h.

◆ m_ntot

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

Definition at line 39 of file Thin_vtxTrk.h.

◆ m_nVtxPass

std::atomic<unsigned int> DerivationFramework::Thin_vtxTrk::m_nVtxPass
private

Definition at line 41 of file Thin_vtxTrk.h.

◆ m_nVtxTot

std::atomic<unsigned int> DerivationFramework::Thin_vtxTrk::m_nVtxTot
mutableprivate

Definition at line 41 of file Thin_vtxTrk.h.

◆ m_passArray

SG::ReadDecorHandleKeyArray<xAOD::VertexContainer> DerivationFramework::Thin_vtxTrk::m_passArray {this, "INTERNALARRAY", {}}
private

Definition at line 46 of file Thin_vtxTrk.h.

46{this, "INTERNALARRAY", {}};

◆ m_passFlags

std::vector<std::string> DerivationFramework::Thin_vtxTrk::m_passFlags
private

Definition at line 45 of file Thin_vtxTrk.h.

◆ m_streamName

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

Definition at line 38 of file Thin_vtxTrk.h.

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

◆ m_thinTracks

bool DerivationFramework::Thin_vtxTrk::m_thinTracks
private

Definition at line 47 of file Thin_vtxTrk.h.

◆ m_trackParticleContainerName

SG::ThinningHandleKey<xAOD::TrackParticleContainer> DerivationFramework::Thin_vtxTrk::m_trackParticleContainerName
private

Definition at line 43 of file Thin_vtxTrk.h.

◆ m_vertexContainerName

SG::ThinningHandleKeyArray<xAOD::VertexContainer> DerivationFramework::Thin_vtxTrk::m_vertexContainerName
private

Definition at line 44 of file Thin_vtxTrk.h.


The documentation for this class was generated from the following files: