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

Algorithm reconstructing protons from tracks. More...

#include <AFP_GlobRecoTool.h>

Inheritance diagram for AFP_GlobRecoTool:
Collaboration diagram for AFP_GlobRecoTool:

Public Member Functions

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

Private Attributes

ToolHandleArray< IAFP_ProtonRecoToolm_recoToolsList {this,"RecoToolsList",{},"List of AFP proton reconstruction tools"}
 Vector of tool handles to be used for proton reconstruction. More...
 
SG::WriteHandleKeyArray< xAOD::AFPProtonContainerm_arrayOfWriteHandleKeys {this, "AFPProtonContainerList", {"AFPProtonContainer"}, "List of output containers"}
 Array of unique write handle keys for track output containers. More...
 

Detailed Description

Algorithm reconstructing protons from tracks.

Definition at line 30 of file AFP_GlobRecoTool.h.

Constructor & Destructor Documentation

◆ AFP_GlobRecoTool()

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

Definition at line 9 of file AFP_GlobRecoTool.cxx.

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

◆ ~AFP_GlobRecoTool()

AFP_GlobRecoTool::~AFP_GlobRecoTool ( )
default

Does nothing.

Member Function Documentation

◆ execute()

StatusCode AFP_GlobRecoTool::execute ( const EventContext &  ctx) const
override

Run proton reco tool.

Definition at line 113 of file AFP_GlobRecoTool.cxx.

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

◆ initialize()

StatusCode AFP_GlobRecoTool::initialize ( )
override

Definition at line 18 of file AFP_GlobRecoTool.cxx.

19 {
20  ATH_MSG_DEBUG("in AFP_GlobRecoTool::initialize()");
21 
22  // proton reconstruction tools
23  if(m_recoToolsList.empty())
24  {
25  ATH_MSG_ERROR("No proton reconstruction tools set, check settings in AFP_GlobReco/AFP_GlobReco.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 proton reconstruction tools
35  if(m_arrayOfWriteHandleKeys.empty())
36  {
37  ATH_MSG_ERROR("No output proton containers provided, check settings in AFP_GlobReco/AFP_GlobReco.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 proton reco tools are also in WriteHandleKeyArray; and moreover (c) that there are no extra WriteHandleKeys that are not present in any proton 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_GlobReco/AFP_GlobReco.py. Aborting.");
63  return StatusCode::FAILURE;
64  }
65  // get names from proton 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 proton 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 proton 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 proton 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::AFPProtonContainer> AFP_GlobRecoTool::m_arrayOfWriteHandleKeys {this, "AFPProtonContainerList", {"AFPProtonContainer"}, "List of output containers"}
private

Array of unique write handle keys for track output containers.

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

Definition at line 53 of file AFP_GlobRecoTool.h.

◆ m_recoToolsList

ToolHandleArray<IAFP_ProtonRecoTool> AFP_GlobRecoTool::m_recoToolsList {this,"RecoToolsList",{},"List of AFP proton reconstruction tools"}
private

Vector of tool handles to be used for proton reconstruction.

Each station has its own track reco algorithm. This array contains all of them

Definition at line 48 of file AFP_GlobRecoTool.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
AFP_GlobRecoTool::m_recoToolsList
ToolHandleArray< IAFP_ProtonRecoTool > m_recoToolsList
Vector of tool handles to be used for proton reconstruction.
Definition: AFP_GlobRecoTool.h:48
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
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:221
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
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
AFP_GlobRecoTool::m_arrayOfWriteHandleKeys
SG::WriteHandleKeyArray< xAOD::AFPProtonContainer > m_arrayOfWriteHandleKeys
Array of unique write handle keys for track output containers.
Definition: AFP_GlobRecoTool.h:53