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

Algorithm reconstructing tracks from hits clusters. More...

#include <AFP_SIDLocRecoTool.h>

Inheritance diagram for AFP_SIDLocRecoTool:
Collaboration diagram for AFP_SIDLocRecoTool:

Public Member Functions

 AFP_SIDLocRecoTool (const std::string &type, const std::string &name, const IInterface *parent)
 
 ~AFP_SIDLocRecoTool () override
 Does nothing. More...
 
StatusCode initialize () override
 
StatusCode execute (const EventContext &ctx) const override
 Run pixel clustering tool and next run track reconstruction tools. More...
 
StatusCode finalize () override
 Does nothing. More...
 

Private Attributes

ToolHandleArray< IAFPSiDLocRecoTrackAlgToolm_recoToolsList {this,"RecoToolsList",{},"List of AFP track reconstruction tools"}
 Vector of tool handles to be used for tracks reconstruction. More...
 
SG::WriteHandleKeyArray< xAOD::AFPTrackContainerm_arrayOfWriteHandleKeys {this, "AFPTrackContainerList", {"AFPTrackContainer"}, "List of output containers"}
 Array of unique write handle keys for track output containers. More...
 
ToolHandle< GenericMonitoringToolm_monTool {this, "MonTool", "", "Monitoring tool"}
 @ brief Monitoring tool More...
 

Detailed Description

Algorithm reconstructing tracks from hits clusters.

Definition at line 30 of file AFP_SIDLocRecoTool.h.

Constructor & Destructor Documentation

◆ AFP_SIDLocRecoTool()

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

Definition at line 9 of file AFP_SIDLocRecoTool.cxx.

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

◆ ~AFP_SIDLocRecoTool()

AFP_SIDLocRecoTool::~AFP_SIDLocRecoTool ( )
inlineoverride

Does nothing.

Definition at line 37 of file AFP_SIDLocRecoTool.h.

37 {}

Member Function Documentation

◆ execute()

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

Run pixel clustering tool and next run track reconstruction tools.

Definition at line 110 of file AFP_SIDLocRecoTool.cxx.

111 {
112  ATH_MSG_DEBUG("in AFP_SIDLocRecoTool::execute()");
113 
114 
115  auto trkSize = Monitored::Scalar("TrkSize", 0.0);
116 
117  for(const auto &whk : m_arrayOfWriteHandleKeys)
118  {
119  // reconstruct tracks
120  auto afpTrk=std::make_unique<xAOD::AFPTrackContainer>();
121  auto afpTrkAux=std::make_unique<xAOD::AFPTrackAuxContainer>();
122  afpTrk->setStore(afpTrkAux.get());
123 
124  for(const auto &recoTool : m_recoToolsList)
125  {
126  if(recoTool->outputContainerName() != whk.key()) continue;
127 
128  if( recoTool->reconstructTracks(afpTrk, ctx).isFailure() )
129  {
130  ATH_MSG_WARNING ("Failed to reconstruct tracks with algorithm = "<<recoTool->name());
131  }
132  }
133 
134  trkSize += afpTrk->size();
135  ATH_MSG_DEBUG("Number of AFP SID tracks = " << trkSize);
136 
137  SG::WriteHandle<xAOD::AFPTrackContainer> trackContainer(whk, ctx);
138  ATH_CHECK( trackContainer.record(std::move(afpTrk), std::move(afpTrkAux)) );
139  }
140 
141  Monitored::Group( m_monTool, trkSize);
142 
143  return StatusCode::SUCCESS;
144 }

◆ finalize()

StatusCode AFP_SIDLocRecoTool::finalize ( )
override

Does nothing.

Definition at line 146 of file AFP_SIDLocRecoTool.cxx.

147 {
148  return StatusCode::SUCCESS;
149 }

◆ initialize()

StatusCode AFP_SIDLocRecoTool::initialize ( )
override

Definition at line 18 of file AFP_SIDLocRecoTool.cxx.

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

Member Data Documentation

◆ m_arrayOfWriteHandleKeys

SG::WriteHandleKeyArray<xAOD::AFPTrackContainer> AFP_SIDLocRecoTool::m_arrayOfWriteHandleKeys {this, "AFPTrackContainerList", {"AFPTrackContainer"}, "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_LocReco/AFP_LocReco.py) and let the python script pick unique names.

Definition at line 57 of file AFP_SIDLocRecoTool.h.

◆ m_monTool

ToolHandle<GenericMonitoringTool> AFP_SIDLocRecoTool::m_monTool {this, "MonTool", "", "Monitoring tool"}
private

@ brief Monitoring tool

Definition at line 60 of file AFP_SIDLocRecoTool.h.

◆ m_recoToolsList

ToolHandleArray<IAFPSiDLocRecoTrackAlgTool> AFP_SIDLocRecoTool::m_recoToolsList {this,"RecoToolsList",{},"List of AFP track reconstruction tools"}
private

Vector of tool handles to be used for tracks reconstruction.

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

Definition at line 52 of file AFP_SIDLocRecoTool.h.


The documentation for this class was generated from the following files:
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
AFP_SIDLocRecoTool::m_arrayOfWriteHandleKeys
SG::WriteHandleKeyArray< xAOD::AFPTrackContainer > m_arrayOfWriteHandleKeys
Array of unique write handle keys for track output containers.
Definition: AFP_SIDLocRecoTool.h:57
AFP_SIDLocRecoTool::m_recoToolsList
ToolHandleArray< IAFPSiDLocRecoTrackAlgTool > m_recoToolsList
Vector of tool handles to be used for tracks reconstruction.
Definition: AFP_SIDLocRecoTool.h:52
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_SIDLocRecoTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
@ brief Monitoring tool
Definition: AFP_SIDLocRecoTool.h:60
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
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34