ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
AFP_VertexRecoTool Class Reference

Algorithm reconstructing vertices from protons. More...

#include <AFP_VertexRecoTool.h>

Inheritance diagram for AFP_VertexRecoTool:
Collaboration diagram for AFP_VertexRecoTool:

Public Member Functions

 AFP_VertexRecoTool (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual ~AFP_VertexRecoTool ()=default
 Does nothing. More...
 
virtual StatusCode initialize () override
 
virtual StatusCode execute (const EventContext &ctx) const override
 Run vertex reco tool. More...
 

Private Attributes

ToolHandleArray< IAFP_TimeRecoToolm_recoToolsList {this,"RecoToolsList",{},"List of AFP vertex reconstruction tools"}
 Vector of tool handles to be used for vertex reconstruction. More...
 
SG::WriteHandleKeyArray< xAOD::AFPVertexContainerm_arrayOfWriteHandleKeys {this, "AFPVertexContainerList", {"AFPVertexContainer"}, "List of output containers"}
 Array of unique write handle keys for vertex output container. More...
 

Detailed Description

Algorithm reconstructing vertices from protons.

Definition at line 30 of file AFP_VertexRecoTool.h.

Constructor & Destructor Documentation

◆ AFP_VertexRecoTool()

AFP_VertexRecoTool::AFP_VertexRecoTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 9 of file AFP_VertexRecoTool.cxx.

12  : base_class(type, name, parent)
13 {
14  ATH_MSG_DEBUG("in AFP_VertexRecoTool constructor");
15 }

◆ ~AFP_VertexRecoTool()

virtual AFP_VertexRecoTool::~AFP_VertexRecoTool ( )
virtualdefault

Does nothing.

Member Function Documentation

◆ execute()

StatusCode AFP_VertexRecoTool::execute ( const EventContext &  ctx) const
overridevirtual

Run vertex reco tool.

Definition at line 113 of file AFP_VertexRecoTool.cxx.

114 {
115  ATH_MSG_DEBUG("in AFP_VertexRecoTool::execute()");
116 
117 
118  for(const auto &whk : m_arrayOfWriteHandleKeys)
119  {
120  // reconstruct vertices
121  auto afpVertex=std::make_unique<xAOD::AFPVertexContainer>();
122  auto afpVertexAux=std::make_unique<xAOD::AFPVertexAuxContainer>();
123  afpVertex->setStore(afpVertexAux.get());
124 
125  for(const auto &recoTool : m_recoToolsList)
126  {
127  if(recoTool->outputContainerName() != whk.key()) continue;
128 
129  if( recoTool->doVertexReco(afpVertex, ctx).isFailure() )
130  {
131  ATH_MSG_WARNING ("Failed to reconstruct vertices with algorithm = "<<recoTool->name());
132  }
133  }
134 
135  ATH_MSG_DEBUG("write handle key "<<whk<<", have "<<afpVertex->size()<<" reconstructed vertices");
136 
137 
138  SG::WriteHandle<xAOD::AFPVertexContainer> vertexContainer(whk, ctx);
139  ATH_CHECK( vertexContainer.record(std::move(afpVertex), std::move(afpVertexAux)) );
140  }
141 
142  return StatusCode::SUCCESS;
143 }

◆ initialize()

StatusCode AFP_VertexRecoTool::initialize ( )
overridevirtual

Definition at line 18 of file AFP_VertexRecoTool.cxx.

19 {
20  ATH_MSG_DEBUG("in AFP_VertexRecoTool::initialize()");
21 
22  // vertex reconstruction tools
23  if(m_recoToolsList.empty())
24  {
25  ATH_MSG_ERROR("No vertex reconstruction tools set, check settings in AFP_VertexReco/AFP_VertexReco.py. Aborting.");
26  return StatusCode::FAILURE;
27  }
28  else
29  {
30  ATH_MSG_DEBUG("There are these tools in m_recoToolsList: "<<m_recoToolsList<<", will retrieve");
31  CHECK( m_recoToolsList.retrieve() );
32  }
33 
34  // output containers for the vertex reconstruction tools
35  if(m_arrayOfWriteHandleKeys.empty())
36  {
37  ATH_MSG_ERROR("No output vertex containers provided, check settings in AFP_VertexReco/AFP_VertexReco.py. Aborting.");
38  return StatusCode::FAILURE;
39  }
40  else
41  {
42  ATH_MSG_DEBUG("There are these write handle keys in m_arrayOfWriteHandleKeys: "<<m_arrayOfWriteHandleKeys<<", will initialize");
43  CHECK( m_arrayOfWriteHandleKeys.initialize() );
44  }
45 
46 
47  // the code in execute relies on the facts that (a) the keys in WriteHandleKeyArray are unique; (b) all output container names from vertex reco tools are also in WriteHandleKeyArray; and moreover (c) that there are no extra WriteHandleKeys that are not present in any vertex reco tools
48  // case (c) wouldn't necessarily break things but it's not a sign of a good configuration and thus it's forbidden as well
49  // first, get names from write handle keys
50  std::vector<std::string> listOfWHKeys;
51  for(const auto &whk : m_arrayOfWriteHandleKeys)
52  {
53  ATH_MSG_DEBUG("have WHKey "<<whk.key());
54  listOfWHKeys.push_back(whk.key());
55  }
56  unsigned int all_WHkeys=listOfWHKeys.size();
57  // remove duplicities, there shouldn't be any
58  std::sort(listOfWHKeys.begin(), listOfWHKeys.end());
59  listOfWHKeys.erase(std::unique(listOfWHKeys.begin(),listOfWHKeys.end()), listOfWHKeys.end());
60  if(listOfWHKeys.size() != all_WHkeys)
61  {
62  ATH_MSG_ERROR("It seems write handle keys do not have unique values, check settings in AFP_VertexReco/AFP_VertexReco.py. Aborting.");
63  return StatusCode::FAILURE;
64  }
65  // get names from vertex reco tools
66  std::vector<std::string> listOfOutputContainers;
67  for(const auto &recoTool : m_recoToolsList)
68  {
69  ATH_MSG_DEBUG("have ouput container "<<recoTool->outputContainerName());
70  listOfOutputContainers.push_back(recoTool->outputContainerName());
71  }
72  // remove duplicities, they are allowed
73  std::sort(listOfOutputContainers.begin(), listOfOutputContainers.end());
74  listOfOutputContainers.erase(std::unique(listOfOutputContainers.begin(),listOfOutputContainers.end()), listOfOutputContainers.end());
75  // write handle keys and names from vertex reco tools should have the same size
76  if(listOfWHKeys.size() != listOfOutputContainers.size())
77  {
78  ATH_MSG_ERROR("There is different number of unique write handle keys ("<<listOfWHKeys.size()<<") and unique output containers ("<<listOfOutputContainers.size()<<"). Aborting");
79  return StatusCode::FAILURE;
80  }
81  // check they are the same; one of these loops are not strictly neccessary, but they will print outstanding names
82  bool doAbort=false;
83  for(const auto &trkOutCont : listOfOutputContainers)
84  {
85  if(std::find(listOfWHKeys.begin(),listOfWHKeys.end(),trkOutCont) == listOfWHKeys.end())
86  {
87  ATH_MSG_ERROR("Cannot find vertex reconstruction output container "<<trkOutCont<<" in write handle keys. Aborting");
88  doAbort=true;
89  }
90  }
91  for(const auto &whk : listOfWHKeys)
92  {
93  if(std::find(listOfOutputContainers.begin(),listOfOutputContainers.end(),whk) == listOfOutputContainers.end())
94  {
95  ATH_MSG_ERROR("Cannot find write handle key "<<whk<<" in vertex reconstruction output containers. Aborting");
96  doAbort=true;
97  }
98  }
99  if(doAbort) return StatusCode::FAILURE;
100  // Now, we are sure it's setup correctly
101 
102 
103 // monitoring tool to be added soon
104  // monitoring
105 // if (!(m_monTool.name().empty())) {
106 // CHECK( m_monTool.retrieve() );
107 // ATH_MSG_DEBUG("m_monTool name: " << m_monTool);
108 // }
109 
110  return StatusCode::SUCCESS;
111 }

Member Data Documentation

◆ m_arrayOfWriteHandleKeys

SG::WriteHandleKeyArray<xAOD::AFPVertexContainer> AFP_VertexRecoTool::m_arrayOfWriteHandleKeys {this, "AFPVertexContainerList", {"AFPVertexContainer"}, "List of output containers"}
private

Array of unique write handle keys for vertex output container.

Each write handle key has to be unique and in sync with m_recoToolsList. It's possible for several time reco algorithms contributing to the common container. Ideally, one should setup vertex reco containers (in AFP_VertexReco/AFP_VertexReco.py) and let the python script pick unique names.

Definition at line 53 of file AFP_VertexRecoTool.h.

◆ m_recoToolsList

ToolHandleArray<IAFP_TimeRecoTool> AFP_VertexRecoTool::m_recoToolsList {this,"RecoToolsList",{},"List of AFP vertex reconstruction tools"}
private

Vector of tool handles to be used for vertex reconstruction.

Several time reco algorithms will be implemented. This array contains all of them

Definition at line 48 of file AFP_VertexRecoTool.h.


The documentation for this class was generated from the following files:
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AFP_VertexRecoTool::m_recoToolsList
ToolHandleArray< IAFP_TimeRecoTool > m_recoToolsList
Vector of tool handles to be used for vertex reconstruction.
Definition: AFP_VertexRecoTool.h:48
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
AFP_VertexRecoTool::m_arrayOfWriteHandleKeys
SG::WriteHandleKeyArray< xAOD::AFPVertexContainer > m_arrayOfWriteHandleKeys
Array of unique write handle keys for vertex output container.
Definition: AFP_VertexRecoTool.h:53
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
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78