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::Thin_vtxDuplicates Class Reference

#include <Thin_vtxDuplicates.h>

Inheritance diagram for DerivationFramework::Thin_vtxDuplicates:
Collaboration diagram for DerivationFramework::Thin_vtxDuplicates:

Public Member Functions

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

Private Attributes

bool m_noFlags
 
StringProperty m_streamName { this, "StreamName", "", "Name of the stream being thinned" }
 
std::atomic< unsigned int > m_nVtxTot
 
std::atomic< unsigned int > m_nVtxPass
 
SG::ThinningHandleKey< xAOD::VertexContainerm_vertexContainerNames
 
SG::ReadDecorHandleKeyArray< xAOD::VertexContainerm_passFlags
 

Detailed Description

Definition at line 18 of file Thin_vtxDuplicates.h.

Constructor & Destructor Documentation

◆ Thin_vtxDuplicates()

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

Definition at line 22 of file Thin_vtxDuplicates.cxx.

22  :
23  base_class(t,n,p),
24  // m_acceptanceR(-1.),
25  m_noFlags(false),
26  m_nVtxTot(0),
27  m_nVtxPass(0)
28 {
29  declareProperty("VertexContainerName" , m_vertexContainerNames);
30  declareProperty("PassFlags" , m_passFlags);
31  //declareProperty("AcceptanceRadius" , m_acceptanceR);
32  declareProperty("IgnoreFlags" , m_noFlags);
33  //declareProperty("ApplyAndForTracks" , m_trackAnd = false);
34  //declareProperty("ThinTracks" , m_thinTracks = true);
35 }

◆ ~Thin_vtxDuplicates()

DerivationFramework::Thin_vtxDuplicates::~Thin_vtxDuplicates ( )
default

Member Function Documentation

◆ doThinning()

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

Definition at line 73 of file Thin_vtxDuplicates.cxx.

74 {
75  // retieve vertex
76  const EventContext& ctx = Gaudi::Hive::currentContext();
78  std::vector<bool> vtxMask(vertexContainer->size(), true); // default: keep all vertices
79  int vtxTot = 0;
80  int nVtxPass = 0;
81  // loop over vertices
82  int k = 0;
83  std::vector<SG::ReadDecorHandle<xAOD::VertexContainer, Char_t>> handles;
84  handles.reserve(m_passFlags.size());
85  for(const auto &key : m_passFlags){
86  handles.emplace_back(key, ctx);
87  if(!handles.back().isPresent()) return StatusCode::FAILURE;
88  }
89  for(auto vtxItr = vertexContainer->cbegin(); vtxItr!=vertexContainer->cend(); ++vtxItr, ++k) {
90  const xAOD::Vertex* vtx = *vtxItr;
91  // check if the vertex passed the required selections criteria (is run when the vertex is already excluded, because the counter needs the info)
92  bool passed = false;
93  if(m_noFlags){passed = true; vtxTot++; }
94  else{
95  for(auto &flagAcc : handles) {
96  if(flagAcc(*vtx) != 0) {
97  passed = true;
98  vtxTot++;//Have to count the ones which are accepted to start with
99  break;
100  }
101  } // end of loop over flags
102  }
103 
104  // Skip if it has already been identified as duplicate
105  if(vtxMask[k] == false)continue; //After the flag-check to have the total-passed work correctly
106 
107  if(!passed)vtxMask[k]= false;
108 
109  if(passed) {
110  // vertex passed the selection
111  nVtxPass++;
112 
113  // determine the sum of the tracks at vertex as centre for the cone
114  std::vector<const xAOD::TrackParticle*> presentVertex, compareVertex;
115 
116  //Fill in the present vertex, for later comparison against other vertices
117  presentVertex.clear();
118  for(uint j=0; j<vtx->nTrackParticles(); ++j) {
119  presentVertex.push_back(vtx->trackParticle(j));
120  }
121  sort( presentVertex.begin(), presentVertex.end() ); //Sort the trackparticles BY POINTER ADDRESS
122 
123  //Loop over the remaining vertices and remove them if needed
124  int loop_k = k+1;
125  for(auto vtxLoopItr = vtxItr+1; vtxLoopItr!=vertexContainer->cend(); vtxLoopItr++, loop_k++){
126 
127  const xAOD::Vertex* loop_vtx = *vtxLoopItr;
128 
129  //Vertices are distinct if have different size
130  if(vtx->nTrackParticles() != loop_vtx->nTrackParticles())continue;
131 
132  //If the vertex is still active load and compare
133  if(vtxMask[loop_k]){
134 
135  compareVertex.clear();
136  for(uint j=0; j<loop_vtx->nTrackParticles(); ++j) {
137  compareVertex.push_back(loop_vtx->trackParticle(j));
138  }
139 
140  std::sort( compareVertex.begin(), compareVertex.end());
141 
142  vtxMask[loop_k] = false;
143 
144  ATH_MSG_DEBUG("Compared tracks: ");
145  ATH_MSG_DEBUG(std::setw(14)<<compareVertex[0]<<std::setw(14) << compareVertex[1]<<std::setw(14)<<compareVertex[2]);
146  ATH_MSG_DEBUG(std::setw(14)<<presentVertex[0]<<std::setw(14) << presentVertex[1]<<std::setw(14)<<presentVertex[2]);
147 
148  for(uint j=0; j<loop_vtx->nTrackParticles(); ++j) {
149  if( compareVertex[j] != presentVertex[j] ){vtxMask[loop_k] = true; break;}
150  }
151  ATH_MSG_DEBUG("Verdict:"<<(vtxMask[loop_k]? "keep": "erase") );
152  }
153 
154  } // Endo of extra loop over remaining vertices
155 
156  } // if( passed )
157  } // end of loop over vertices
158 
159  // Execute the thinning service based on the vtxMask.
160  vertexContainer.keep(vtxMask);
161 
162  m_nVtxTot.fetch_add( vtxTot, std::memory_order_relaxed);
163  m_nVtxPass.fetch_add( nVtxPass, std::memory_order_relaxed);
164 
165 
166 
167  return StatusCode::SUCCESS;
168 }

◆ finalize()

StatusCode DerivationFramework::Thin_vtxDuplicates::finalize ( )
virtual

Definition at line 64 of file Thin_vtxDuplicates.cxx.

65 {
66  ATH_MSG_VERBOSE("finalize() ...");
67  ATH_MSG_INFO("Processed "<< m_nVtxTot <<" vertices, "<< m_nVtxPass<< " were retained ");
68 
69  return StatusCode::SUCCESS;
70 }

◆ initialize()

StatusCode DerivationFramework::Thin_vtxDuplicates::initialize ( )
virtual

Definition at line 41 of file Thin_vtxDuplicates.cxx.

42 {
43  // Decide which collections need to be checked for ID TrackParticles
44  ATH_MSG_VERBOSE("initialize() ...");
46 
47 
48  if (m_passFlags.empty()) {
49  ATH_MSG_FATAL("No pass flags provided for thinning.");
50  return StatusCode::FAILURE;
51  } else {
52  for(auto itr = m_passFlags.cbegin(); itr!=m_passFlags.cend(); ++itr) {
53  ATH_MSG_INFO("Vertices must pass the \"" << itr->key() << "\" selection");
54  }
55  }
56 
57  for(auto &key : m_passFlags){
58  key = m_vertexContainerNames.key() + '.' + key.key();
59  }
60  ATH_CHECK(m_passFlags.initialize());
61  return StatusCode::SUCCESS;
62 }

Member Data Documentation

◆ m_noFlags

bool DerivationFramework::Thin_vtxDuplicates::m_noFlags
private

Definition at line 27 of file Thin_vtxDuplicates.h.

◆ m_nVtxPass

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

Definition at line 29 of file Thin_vtxDuplicates.h.

◆ m_nVtxTot

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

Definition at line 29 of file Thin_vtxDuplicates.h.

◆ m_passFlags

SG::ReadDecorHandleKeyArray<xAOD::VertexContainer> DerivationFramework::Thin_vtxDuplicates::m_passFlags
private

Definition at line 32 of file Thin_vtxDuplicates.h.

◆ m_streamName

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

Definition at line 28 of file Thin_vtxDuplicates.h.

◆ m_vertexContainerNames

SG::ThinningHandleKey< xAOD::VertexContainer > DerivationFramework::Thin_vtxDuplicates::m_vertexContainerNames
private

Definition at line 31 of file Thin_vtxDuplicates.h.


The documentation for this class was generated from the following files:
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
xAOD::Vertex_v1::nTrackParticles
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
Definition: Vertex_v1.cxx:270
TrigCompositeUtils::passed
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
Definition: TrigCompositeUtilsRoot.cxx:117
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DerivationFramework::Thin_vtxDuplicates::m_nVtxTot
std::atomic< unsigned int > m_nVtxTot
Definition: Thin_vtxDuplicates.h:29
DerivationFramework::Thin_vtxDuplicates::m_passFlags
SG::ReadDecorHandleKeyArray< xAOD::VertexContainer > m_passFlags
Definition: Thin_vtxDuplicates.h:32
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::Thin_vtxDuplicates::m_nVtxPass
std::atomic< unsigned int > m_nVtxPass
Definition: Thin_vtxDuplicates.h:29
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:554
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition: ThinningHandle.h:84
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
DerivationFramework::Thin_vtxDuplicates::m_vertexContainerNames
SG::ThinningHandleKey< xAOD::VertexContainer > m_vertexContainerNames
Definition: Thin_vtxDuplicates.h:31
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::Vertex_v1::trackParticle
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
Definition: Vertex_v1.cxx:249
DerivationFramework::Thin_vtxDuplicates::m_noFlags
bool m_noFlags
Definition: Thin_vtxDuplicates.h:27
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
DerivationFramework::Thin_vtxDuplicates::m_streamName
StringProperty m_streamName
Definition: Thin_vtxDuplicates.h:28
fitman.k
k
Definition: fitman.py:528
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37