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

Algorithm reconstructing tracks from hits. More...

#include <AFP_TDLocRecoTool.h>

Inheritance diagram for AFP_TDLocRecoTool:
Collaboration diagram for AFP_TDLocRecoTool:

Public Member Functions

 AFP_TDLocRecoTool (const std::string &type, const std::string &name, const IInterface *parent)
 
 ~AFP_TDLocRecoTool () 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< IAFPTDLocRecoTrackAlgToolm_recoToolsList {this,"RecoToolsList",{},"List of AFP ToF track reconstruction tools"}
 Vector of tool handles to be used for tracks reconstruction. More...
 
SG::WriteHandleKeyArray< xAOD::AFPToFTrackContainerm_arrayOfWriteHandleKeys {this, "AFPToFTrackContainerList", {"AFPToFTrackContainer"}, "List of output containers"}
 Array of unique write handle keys for track output containers. More...
 

Detailed Description

Algorithm reconstructing tracks from hits.

Definition at line 27 of file AFP_TDLocRecoTool.h.

Constructor & Destructor Documentation

◆ AFP_TDLocRecoTool()

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

Definition at line 9 of file AFP_TDLocRecoTool.cxx.

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

◆ ~AFP_TDLocRecoTool()

AFP_TDLocRecoTool::~AFP_TDLocRecoTool ( )
inlineoverride

Does nothing.

Definition at line 34 of file AFP_TDLocRecoTool.h.

34 {}

Member Function Documentation

◆ execute()

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

Run pixel clustering tool and next run track reconstruction tools.

Definition at line 104 of file AFP_TDLocRecoTool.cxx.

105 {
106  ATH_MSG_DEBUG("begin AFP_TDLocRecoTool::execute()");
107 
108  for(const auto &whk : m_arrayOfWriteHandleKeys)
109  {
110  // reconstruct tracks
111  auto afpTrk=std::make_unique<xAOD::AFPToFTrackContainer>();
112  auto afpTrkAux=std::make_unique<xAOD::AFPToFTrackAuxContainer>();
113  afpTrk->setStore(afpTrkAux.get());
114 
115  ATH_MSG_DEBUG("Number of AFP ToF tracks = " <<afpTrk->size());
116 
117  for(const auto &recoTool : m_recoToolsList)
118  {
119  if(recoTool->outputContainerName() != whk.key()) continue;
120 
121  if( recoTool->reconstructTracks(afpTrk, ctx).isFailure() )
122  {
123  ATH_MSG_WARNING ("Failed to reconstruct tracks with algorithm = "<<recoTool->name());
124  }
125  }
126 
127  SG::WriteHandle<xAOD::AFPToFTrackContainer> trackContainer(whk, ctx);
128  ATH_CHECK( trackContainer.record(std::move(afpTrk), std::move(afpTrkAux)) );
129  }
130 
131  ATH_MSG_DEBUG("end AFP_TDLocRecoTool::execute()");
132  return StatusCode::SUCCESS;
133 }

◆ finalize()

StatusCode AFP_TDLocRecoTool::finalize ( )
override

Does nothing.

Definition at line 135 of file AFP_TDLocRecoTool.cxx.

136 {
137  return StatusCode::SUCCESS;
138 }

◆ initialize()

StatusCode AFP_TDLocRecoTool::initialize ( )
override

Definition at line 18 of file AFP_TDLocRecoTool.cxx.

19 {
20  ATH_MSG_DEBUG("begin AFP_TDLocRecoTool::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  // 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
45  // case (c) wouldn't necessarily break things but it's not a sign of a good configuration and thus it's forbidden as well
46  // first, get names from write handle keys
47  std::vector<std::string> listOfWHKeys;
48  for(const auto &whk : m_arrayOfWriteHandleKeys)
49  {
50  ATH_MSG_DEBUG("have WHKey "<<whk.key());
51  listOfWHKeys.push_back(whk.key());
52  }
53  unsigned int all_WHkeys=listOfWHKeys.size();
54  // remove duplicities, there shouldn't be any
55  std::sort(listOfWHKeys.begin(), listOfWHKeys.end());
56  listOfWHKeys.erase(std::unique(listOfWHKeys.begin(),listOfWHKeys.end()), listOfWHKeys.end());
57  if(listOfWHKeys.size() != all_WHkeys)
58  {
59  ATH_MSG_ERROR("It seems write handle keys do not have unique values, check settings in AFP_LocReco/AFP_LocReco.py. Aborting.");
60  return StatusCode::FAILURE;
61  }
62  // get names from track reco tools
63  std::vector<std::string> listOfOutputContainers;
64  for(const auto &recoTool : m_recoToolsList)
65  {
66  ATH_MSG_DEBUG("have ouput container "<<recoTool->outputContainerName());
67  listOfOutputContainers.push_back(recoTool->outputContainerName());
68  }
69  // remove duplicities, they are allowed
70  std::sort(listOfOutputContainers.begin(), listOfOutputContainers.end());
71  listOfOutputContainers.erase(std::unique(listOfOutputContainers.begin(),listOfOutputContainers.end()), listOfOutputContainers.end());
72  // write handle keys and names from track reco tools should have the same size
73  if(listOfWHKeys.size() != listOfOutputContainers.size())
74  {
75  ATH_MSG_ERROR("There is different number of unique write handle keys ("<<listOfWHKeys.size()<<") and unique output containers ("<<listOfOutputContainers.size()<<"). Aborting");
76  return StatusCode::FAILURE;
77  }
78  // check they are the same; one of these loops are not strictly neccessary, but they will print outstanding names
79  bool doAbort=false;
80  for(const auto &trkOutCont : listOfOutputContainers)
81  {
82  if(std::find(listOfWHKeys.begin(),listOfWHKeys.end(),trkOutCont) == listOfWHKeys.end())
83  {
84  ATH_MSG_ERROR("Cannot find track reconstruction output container "<<trkOutCont<<" in write handle keys. Aborting");
85  doAbort=true;
86  }
87  }
88  for(const auto &whk : listOfWHKeys)
89  {
90  if(std::find(listOfOutputContainers.begin(),listOfOutputContainers.end(),whk) == listOfOutputContainers.end())
91  {
92  ATH_MSG_ERROR("Cannot find write handle key "<<whk<<" in track reconstruction output containers. Aborting");
93  doAbort=true;
94  }
95  }
96  if(doAbort) return StatusCode::FAILURE;
97  // Now, we are sure it's setup correctly
98 
99 
100  ATH_MSG_DEBUG("end AFP_TDLocRecoTool::initialize()");
101  return StatusCode::SUCCESS;
102 }

Member Data Documentation

◆ m_arrayOfWriteHandleKeys

SG::WriteHandleKeyArray<xAOD::AFPToFTrackContainer> AFP_TDLocRecoTool::m_arrayOfWriteHandleKeys {this, "AFPToFTrackContainerList", {"AFPToFTrackContainer"}, "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 53 of file AFP_TDLocRecoTool.h.

◆ m_recoToolsList

ToolHandleArray<IAFPTDLocRecoTrackAlgTool> AFP_TDLocRecoTool::m_recoToolsList {this,"RecoToolsList",{},"List of AFP ToF 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 48 of file AFP_TDLocRecoTool.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
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
AFP_TDLocRecoTool::m_recoToolsList
ToolHandleArray< IAFPTDLocRecoTrackAlgTool > m_recoToolsList
Vector of tool handles to be used for tracks reconstruction.
Definition: AFP_TDLocRecoTool.h:48
AFP_TDLocRecoTool::m_arrayOfWriteHandleKeys
SG::WriteHandleKeyArray< xAOD::AFPToFTrackContainer > m_arrayOfWriteHandleKeys
Array of unique write handle keys for track output containers.
Definition: AFP_TDLocRecoTool.h:53
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