ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
DerivationFramework::Reco_Vertex Class Reference

#include <Reco_Vertex.h>

Inheritance diagram for DerivationFramework::Reco_Vertex:
Collaboration diagram for DerivationFramework::Reco_Vertex:

Public Member Functions

 Reco_Vertex (const std::string &t, const std::string &n, const IInterface *p)
 
virtual StatusCode initialize ()
 
virtual StatusCode addBranches () const
 

Private Attributes

ToolHandle< Trk::V0Toolsm_v0Tools
 tools More...
 
ToolHandle< Analysis::ICandidateSearchm_SearchTool
 
ToolHandle< Analysis::PrimaryVertexRefitterm_pvRefitter
 
SG::ReadHandleKey< xAOD::EventInfom_eventInfo_key {this, "EventInfo", "EventInfo", "Input event information"}
 
SG::WriteHandleKey< xAOD::VertexContainerm_outputVtxContainerName
 job options More...
 
SG::ReadHandleKey< xAOD::VertexContainerm_pvContainerName
 
SG::WriteHandleKey< xAOD::VertexContainerm_refPVContainerName
 
bool m_refitPV
 
int m_PV_max
 
int m_DoVertexType
 
size_t m_PV_minNTracks
 
bool m_do3d
 
bool m_checkCollections
 
SG::ReadHandleKeyArray< xAOD::VertexContainerm_CollectionsToCheck
 
SG::ReadHandleKeyArray< xAOD::TrackParticleContainerm_RelinkContainers {this, "RelinkTracks", {}, "Track Containers if they need to be relinked through indirect use" }
 
SG::ReadHandleKeyArray< xAOD::MuonContainerm_RelinkMuons {this, "RelinkMuons", {}, "Muon Containers if they need to be relinked through indirect use" }
 

Detailed Description

Definition at line 25 of file Reco_Vertex.h.

Constructor & Destructor Documentation

◆ Reco_Vertex()

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

Definition at line 21 of file Reco_Vertex.cxx.

23  :
24  base_class(t,n,p),
25  m_v0Tools("Trk::V0Tools", this),
26  m_SearchTool("",this),
27  m_pvRefitter("Analysis::PrimaryVertexRefitter", this)
28  {
29 
30  // Declare tools
31  declareProperty("V0Tools" , m_v0Tools);
32  declareProperty("VertexSearchTool", m_SearchTool);
33  declareProperty("PVRefitter", m_pvRefitter);
34 
35  // Declare user-defined properties
36  declareProperty("OutputVtxContainerName", m_outputVtxContainerName = "OniaCandidates");
37  declareProperty("PVContainerName" , m_pvContainerName = "PrimaryVertices");
38  declareProperty("RefPVContainerName" , m_refPVContainerName = "RefittedPrimaryVertices");
39  declareProperty("RefitPV" , m_refitPV = false);
40  declareProperty("MaxPVrefit" , m_PV_max = 1000);
41  declareProperty("DoVertexType" , m_DoVertexType = 7);
42  // minimum number of tracks for PV to be considered for PV association
43  declareProperty("MinNTracksInPV" , m_PV_minNTracks = 0);
44  declareProperty("Do3d" , m_do3d = false);
45  declareProperty("CheckCollections" , m_checkCollections = false);
46  declareProperty("CheckVertexContainers" , m_CollectionsToCheck);
47  }

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::Reco_Vertex::addBranches ( ) const
virtual

Definition at line 81 of file Reco_Vertex.cxx.

82  {
83  bool callTool = true;
84  const EventContext& ctx = Gaudi::Hive::currentContext();
85  if(m_checkCollections) {
86  for(const auto &str : m_CollectionsToCheck){
88  ATH_CHECK(handle.isValid());
89  if(handle->size() == 0) {
90  callTool = false;
91  ATH_MSG_DEBUG("Container VertexContainer (" << str << ") is empty");
92  break;//No point checking other containers
93  }
94  }
95  }
96 
97  // Vertex container and its auxilliary store
98  std::unique_ptr<xAOD::VertexContainer> vtxContainer = std::make_unique<xAOD::VertexContainer>();
99  std::unique_ptr<xAOD::VertexAuxContainer> vtxAuxContainer = std::make_unique<xAOD::VertexAuxContainer>();
100  vtxContainer->setStore(vtxAuxContainer.get());
101 
102  if(callTool) {
103  //----------------------------------------------------
104  // call Tool
105  //----------------------------------------------------
106  if( !m_SearchTool->performSearch(ctx,*vtxContainer).isSuccess() ) {
107  ATH_MSG_FATAL("Tool (" << m_SearchTool << ") failed.");
108  return StatusCode::FAILURE;
109  }
110 
111  //----------------------------------------------------
112  // retrieve primary vertices
113  //----------------------------------------------------
115 
116  //----------------------------------------------------
117  // Try to retrieve refitted primary vertices
118  //----------------------------------------------------
119  std::unique_ptr<xAOD::VertexContainer> refPvContainer;
120  std::unique_ptr<xAOD::VertexAuxContainer> refPvAuxContainer;
121  if(m_refitPV) {
122  // refitted PV container does not exist. Create a new one.
123  refPvContainer = std::make_unique<xAOD::VertexContainer>();
124  refPvAuxContainer = std::make_unique<xAOD::VertexAuxContainer>();
125  refPvContainer->setStore(refPvAuxContainer.get());
126  }
127 
128  // Give the helper class the ptr to v0tools and beamSpotsSvc to use
130  if(not evt.isValid()) ATH_MSG_ERROR("Cannot Retrieve " << evt.key() );
131  BPhysPVTools helper(&(*m_v0Tools), evt.cptr());
132  helper.SetMinNTracksInPV(m_PV_minNTracks);
133  helper.SetSave3d(m_do3d);
134 
135  if(m_refitPV){
136  if(vtxContainer->size() >0){
137  if(vtxContainer->size() > 10000){
138  ATH_MSG_WARNING("Number of candidates is very high N=" << vtxContainer->size() << " this may crash the sharedwriter");
139  }
140  StatusCode SC = helper.FillCandwithRefittedVertices(vtxContainer.get(), pvContainer.cptr(), refPvContainer.get(), &(*m_pvRefitter) , m_PV_max, m_DoVertexType);
141  if(SC.isFailure()){
142  ATH_MSG_FATAL("refitting failed - check the vertices you passed");
143  return SC;
144  }
145  if(refPvContainer->size() > 10000){
146  ATH_MSG_WARNING("Number of refitted vertices is very high N=" << refPvContainer->size() << " this may crash the sharedwriter");
147  }
148  }
149  }else{
150  if(vtxContainer->size() >0)CHECK(helper.FillCandExistingVertices(vtxContainer.get(), pvContainer.cptr(), m_DoVertexType));
151  }
152 
154 
155  std::vector<const xAOD::TrackParticleContainer*> trackCols;
156  for(const auto &str : m_RelinkContainers){
158  trackCols.push_back(handle.cptr());
159  }
160  if(not trackCols.empty()){
161  for(xAOD::Vertex* vtx : *vtxContainer.get()){
162  try{
164  }catch(std::runtime_error const& e){
165  ATH_MSG_ERROR(e.what());
166  return StatusCode::FAILURE;
167  }
168  }
169  }
170  std::vector<const xAOD::MuonContainer*> muCols;
171  for(const auto &str : m_RelinkMuons){
173  muCols.push_back(handle.cptr());
174  }
175  if(not muCols.empty()){
176  for(xAOD::Vertex* vtx : *vtxContainer.get()){
177  try{
179  }catch(std::runtime_error const& e){
180  ATH_MSG_ERROR(e.what());
181  return StatusCode::FAILURE;
182  }
183  }
184  }
185  //----------------------------------------------------
186  // save in the StoreGate
187  //----------------------------------------------------
189  ATH_CHECK(handle.record(std::move(vtxContainer), std::move(vtxAuxContainer)));
190 
191  if(m_refitPV) {
193  ATH_CHECK(handle.record(std::move(refPvContainer), std::move(refPvAuxContainer)));
194  }
195  }
196 
197  if (!callTool) { //Fill with empty containers
199  ATH_CHECK(handle.record(std::unique_ptr<xAOD::VertexContainer>(new xAOD::VertexContainer ),
200  std::unique_ptr<xAOD::VertexAuxContainer>(new xAOD::VertexAuxContainer )));
201  }
202 
203  return StatusCode::SUCCESS;
204  }

◆ initialize()

StatusCode DerivationFramework::Reco_Vertex::initialize ( )
virtual

Definition at line 51 of file Reco_Vertex.cxx.

52  {
53 
54  ATH_MSG_DEBUG("in initialize()");
55 
56  // retrieve V0 tools
57  CHECK( m_v0Tools.retrieve() );
58 
59  // get the Search tool
60  CHECK( m_SearchTool.retrieve() );
61 
62  // get the PrimaryVertexRefitter tool
63  CHECK( m_pvRefitter.retrieve() );
64 
65  // Get the beam spot service
67 
68 
69  ATH_CHECK(m_outputVtxContainerName.initialize());
70  ATH_CHECK(m_pvContainerName.initialize());
71  ATH_CHECK(m_refPVContainerName.initialize());
72  ATH_CHECK(m_RelinkContainers.initialize());
73  ATH_CHECK(m_RelinkMuons.initialize());
75  return StatusCode::SUCCESS;
76 
77  }

Member Data Documentation

◆ m_checkCollections

bool DerivationFramework::Reco_Vertex::m_checkCollections
private

Definition at line 50 of file Reco_Vertex.h.

◆ m_CollectionsToCheck

SG::ReadHandleKeyArray<xAOD::VertexContainer> DerivationFramework::Reco_Vertex::m_CollectionsToCheck
private

Definition at line 51 of file Reco_Vertex.h.

◆ m_do3d

bool DerivationFramework::Reco_Vertex::m_do3d
private

Definition at line 49 of file Reco_Vertex.h.

◆ m_DoVertexType

int DerivationFramework::Reco_Vertex::m_DoVertexType
private

Definition at line 47 of file Reco_Vertex.h.

◆ m_eventInfo_key

SG::ReadHandleKey<xAOD::EventInfo> DerivationFramework::Reco_Vertex::m_eventInfo_key {this, "EventInfo", "EventInfo", "Input event information"}
private

Definition at line 39 of file Reco_Vertex.h.

◆ m_outputVtxContainerName

SG::WriteHandleKey<xAOD::VertexContainer> DerivationFramework::Reco_Vertex::m_outputVtxContainerName
private

job options

Definition at line 42 of file Reco_Vertex.h.

◆ m_PV_max

int DerivationFramework::Reco_Vertex::m_PV_max
private

Definition at line 46 of file Reco_Vertex.h.

◆ m_PV_minNTracks

size_t DerivationFramework::Reco_Vertex::m_PV_minNTracks
private

Definition at line 48 of file Reco_Vertex.h.

◆ m_pvContainerName

SG::ReadHandleKey<xAOD::VertexContainer> DerivationFramework::Reco_Vertex::m_pvContainerName
private

Definition at line 43 of file Reco_Vertex.h.

◆ m_pvRefitter

ToolHandle<Analysis::PrimaryVertexRefitter> DerivationFramework::Reco_Vertex::m_pvRefitter
private

Definition at line 38 of file Reco_Vertex.h.

◆ m_refitPV

bool DerivationFramework::Reco_Vertex::m_refitPV
private

Definition at line 45 of file Reco_Vertex.h.

◆ m_refPVContainerName

SG::WriteHandleKey<xAOD::VertexContainer> DerivationFramework::Reco_Vertex::m_refPVContainerName
private

Definition at line 44 of file Reco_Vertex.h.

◆ m_RelinkContainers

SG::ReadHandleKeyArray<xAOD::TrackParticleContainer> DerivationFramework::Reco_Vertex::m_RelinkContainers {this, "RelinkTracks", {}, "Track Containers if they need to be relinked through indirect use" }
private

Definition at line 52 of file Reco_Vertex.h.

◆ m_RelinkMuons

SG::ReadHandleKeyArray<xAOD::MuonContainer> DerivationFramework::Reco_Vertex::m_RelinkMuons {this, "RelinkMuons", {}, "Muon Containers if they need to be relinked through indirect use" }
private

Definition at line 53 of file Reco_Vertex.h.

◆ m_SearchTool

ToolHandle<Analysis::ICandidateSearch> DerivationFramework::Reco_Vertex::m_SearchTool
private

Definition at line 37 of file Reco_Vertex.h.

◆ m_v0Tools

ToolHandle<Trk::V0Tools> DerivationFramework::Reco_Vertex::m_v0Tools
private

tools

Definition at line 36 of file Reco_Vertex.h.


The documentation for this class was generated from the following files:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
xAOD::VertexAuxContainer_v1
Temporary container used until we have I/O for AuxStoreInternal.
Definition: VertexAuxContainer_v1.h:32
DerivationFramework::Reco_Vertex::m_eventInfo_key
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo_key
Definition: Reco_Vertex.h:39
Analysis::JpsiUpsilonCommon::RelinkVertexMuons
static void RelinkVertexMuons(const std::vector< const xAOD::MuonContainer * > &muoncols, xAOD::Vertex *vtx)
Definition: JpsiUpsilonCommon.cxx:148
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
DerivationFramework::Reco_Vertex::m_checkCollections
bool m_checkCollections
Definition: Reco_Vertex.h:50
DerivationFramework::Reco_Vertex::m_RelinkContainers
SG::ReadHandleKeyArray< xAOD::TrackParticleContainer > m_RelinkContainers
Definition: Reco_Vertex.h:52
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
DerivationFramework::Reco_Vertex::m_SearchTool
ToolHandle< Analysis::ICandidateSearch > m_SearchTool
Definition: Reco_Vertex.h:37
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::Reco_Vertex::m_outputVtxContainerName
SG::WriteHandleKey< xAOD::VertexContainer > m_outputVtxContainerName
job options
Definition: Reco_Vertex.h:42
DerivationFramework::Reco_Vertex::m_v0Tools
ToolHandle< Trk::V0Tools > m_v0Tools
tools
Definition: Reco_Vertex.h:36
DerivationFramework::Reco_Vertex::m_PV_minNTracks
size_t m_PV_minNTracks
Definition: Reco_Vertex.h:48
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
DerivationFramework::Reco_Vertex::m_pvContainerName
SG::ReadHandleKey< xAOD::VertexContainer > m_pvContainerName
Definition: Reco_Vertex.h:43
DerivationFramework::Reco_Vertex::m_CollectionsToCheck
SG::ReadHandleKeyArray< xAOD::VertexContainer > m_CollectionsToCheck
Definition: Reco_Vertex.h:51
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::Reco_Vertex::m_refitPV
bool m_refitPV
Definition: Reco_Vertex.h:45
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::Reco_Vertex::m_DoVertexType
int m_DoVertexType
Definition: Reco_Vertex.h:47
TRT_PAI_gasdata::SC
const float SC[NC]
Cross sections for Carbon.
Definition: TRT_PAI_gasdata.h:255
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
Analysis::JpsiUpsilonCommon::RelinkVertexTracks
static void RelinkVertexTracks(const std::vector< const xAOD::TrackParticleContainer * > &trkcols, xAOD::Vertex *vtx)
Definition: JpsiUpsilonCommon.cxx:126
DerivationFramework::Reco_Vertex::m_do3d
bool m_do3d
Definition: Reco_Vertex.h:49
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DerivationFramework::Reco_Vertex::m_RelinkMuons
SG::ReadHandleKeyArray< xAOD::MuonContainer > m_RelinkMuons
Definition: Reco_Vertex.h:53
Analysis::JpsiUpsilonCommon
Definition: JpsiUpsilonCommon.h:39
DerivationFramework::Reco_Vertex::m_PV_max
int m_PV_max
Definition: Reco_Vertex.h:46
DerivationFramework::Reco_Vertex::m_pvRefitter
ToolHandle< Analysis::PrimaryVertexRefitter > m_pvRefitter
Definition: Reco_Vertex.h:38
DerivationFramework::Reco_Vertex::m_refPVContainerName
SG::WriteHandleKey< xAOD::VertexContainer > m_refPVContainerName
Definition: Reco_Vertex.h:44
str
Definition: BTagTrackIpAccessor.cxx:11
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.