ATLAS Offline Software
Loading...
Searching...
No Matches
AFP_VertexRecoBasic Class Reference

Tool for vertex reconstruction by basic algorithm. More...

#include <AFP_VertexRecoBasic.h>

Inheritance diagram for AFP_VertexRecoBasic:
Collaboration diagram for AFP_VertexRecoBasic:

Public Member Functions

 AFP_VertexRecoBasic (const std::string &type, const std::string &name, const IInterface *parent)
 Default constructor.
virtual ~AFP_VertexRecoBasic ()=default
virtual StatusCode initialize () override
 Loads parameterization.
const std::string & outputContainerName () const override
StatusCode doVertexReco (std::unique_ptr< xAOD::AFPVertexContainer > &outputContainer, const EventContext &ctx) const override

Private Member Functions

StatusCode configInfo () const
xAOD::AFPVertexreco (const double distA, const double distC, const xAOD::AFPToFTrack *toFTrackA, const xAOD::AFPToFTrack *toFTrackC, const xAOD::AFPProton *protonA, const xAOD::AFPProton *protonC, const AFP::ToFVtxParamData &TVP_A, const AFP::ToFVtxParamData &TVP_C, std::unique_ptr< xAOD::AFPVertexContainer > &outputContainer) const
 Reconstructs single vertex from pair of ToFTracks and a pair of protons.
xAOD::AFPVertexcreateVertex (const double position, const double distA, const double distC, std::unique_ptr< xAOD::AFPVertexContainer > &outputContainer) const
 Creates and sets up a vertex.
void linkToFTracksToVertex (const xAOD::AFPToFTrack *toFTrack, SG::ReadHandle< xAOD::AFPToFTrackContainer > &tofTrackContainer, xAOD::AFPVertex *vertex) const
 Links ToF track pair to reconstructed vertex.
void linkProtonsToVertex (const xAOD::AFPProton *proton, SG::ReadHandle< xAOD::AFPProtonContainer > &protonContainer, xAOD::AFPVertex *vertex) const
 Links proton pair to reconstructed vertex.

Private Attributes

ToolHandle< AFP::IToFVtxParamDBToolm_tofVtxParamDBTool {this, "tofVtxParamDBTool", "AFP__ToFLocParamDBTool", "Tool to access DB to get the vertex ToF parameters"}
 @ brief Tool for accessing DB to get the vertex ToF parameters
Gaudi::Property< double > m_trackDistance {this, "TrackDistance", 0.5, "Maximum distance between ToF train edge and proton"}
SG::ReadHandleKey< xAOD::AFPToFTrackContainerm_tofTrackContainerKey {this, "AFPToFTrackContainerKey", "AFPToFTrackContainer", "Name of the container with ToF tracks from which vertices are to be reconstructed"}
SG::ReadHandleKey< xAOD::AFPProtonContainerm_protonContainerKey {this, "AFPProtonContainerKey", "AFPProtonContainer", "Name of the container with protons from which vertices are to be reconstructed"}
Gaudi::Property< std::string > m_vertexContainerName {this, "verticesContainerName", "AFPVertexContainer", "Name of the container in which vertices are saved"}

Detailed Description

Tool for vertex reconstruction by basic algorithm.

Definition at line 39 of file AFP_VertexRecoBasic.h.

Constructor & Destructor Documentation

◆ AFP_VertexRecoBasic()

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

Default constructor.

Definition at line 9 of file AFP_VertexRecoBasic.cxx.

10 : base_class(type, name, parent)
11{
12 ATH_MSG_DEBUG("in AFP_VertexRecoBasic constructor");
13}
#define ATH_MSG_DEBUG(x)

◆ ~AFP_VertexRecoBasic()

virtual AFP_VertexRecoBasic::~AFP_VertexRecoBasic ( )
virtualdefault

Member Function Documentation

◆ configInfo()

StatusCode AFP_VertexRecoBasic::configInfo ( ) const
private

Definition at line 16 of file AFP_VertexRecoBasic.cxx.

17{
18 ATH_MSG_INFO("----- AFP_VertexRecoBasic -----");
19
20 ATH_MSG_INFO("\tCuts:\n");
21 ATH_MSG_INFO("\t\ttrackDistance [mm]: " << m_trackDistance );
22
23 CHECK( m_tofVtxParamDBTool.retrieve() );
24
25 return StatusCode::SUCCESS;
26}
#define ATH_MSG_INFO(x)
#define CHECK(...)
Evaluate an expression and check for errors.
ToolHandle< AFP::IToFVtxParamDBTool > m_tofVtxParamDBTool
@ brief Tool for accessing DB to get the vertex ToF parameters
Gaudi::Property< double > m_trackDistance

◆ createVertex()

xAOD::AFPVertex * AFP_VertexRecoBasic::createVertex ( const double position,
const double distA,
const double distC,
std::unique_ptr< xAOD::AFPVertexContainer > & outputContainer ) const
private

Creates and sets up a vertex.

Definition at line 158 of file AFP_VertexRecoBasic.cxx.

159{
160
161 auto * vertex = outputContainer->push_back(std::make_unique<xAOD::AFPVertex>());
162
163 // Set vertex properties
164
165 vertex->setPosition(position);
166 vertex->setDistA(distA);
167 vertex->setDistC(distC);
168 vertex->setAlgID(0);
169
170 ATH_MSG_DEBUG("Reconstructed AFP vertex (position): " << vertex->position() <<", distA "<<vertex->distA()<<", distC "<<vertex->distC());
171
172 return vertex;
173}

◆ doVertexReco()

StatusCode AFP_VertexRecoBasic::doVertexReco ( std::unique_ptr< xAOD::AFPVertexContainer > & outputContainer,
const EventContext & ctx ) const
override

Definition at line 38 of file AFP_VertexRecoBasic.cxx.

39{
40
41 SG::ReadHandle<xAOD::AFPToFTrackContainer> tofTrackContainer( m_tofTrackContainerKey, ctx );
42 if(!tofTrackContainer.isValid())
43 {
44 // this is allowed, there might be no AFP data in the input
45 return StatusCode::SUCCESS;
46 }
47
48
49 SG::ReadHandle<xAOD::AFPProtonContainer> protonContainer( m_protonContainerKey, ctx );
50 if(!protonContainer.isValid())
51 {
52 // this is allowed, there might be no AFP data in the input
53 return StatusCode::SUCCESS;
54 }
55
56
57 // Select ToF tracks on side A
58 std::vector<const xAOD::AFPToFTrack*> tofTrackSideAContainer;
59 std::copy_if(tofTrackContainer->begin(), tofTrackContainer->end(), std::back_inserter(tofTrackSideAContainer),
60 [](auto track) { return track->stationID() == 0; });
61 if(tofTrackSideAContainer.empty()) return StatusCode::SUCCESS;
62
63 // Select ToF tracks on side C
64 std::vector<const xAOD::AFPToFTrack*> tofTrackSideCContainer;
65 std::copy_if(tofTrackContainer->begin(), tofTrackContainer->end(), std::back_inserter(tofTrackSideCContainer),
66 [](auto track) { return track->stationID() == 3; });
67 if(tofTrackSideCContainer.empty()) return StatusCode::SUCCESS;
68
69 // Select protons on side A
70 std::vector<const xAOD::AFPProton*> protonSideAContainer;
71 std::copy_if(protonContainer->begin(), protonContainer->end(), std::back_inserter(protonSideAContainer),
72 [](auto proton) { return proton->side() == 0; });
73 if(protonSideAContainer.empty()) return StatusCode::SUCCESS;
74
75 // Select protons on side C
76 std::vector<const xAOD::AFPProton*> protonSideCContainer;
77 std::copy_if(protonContainer->begin(), protonContainer->end(), std::back_inserter(protonSideCContainer),
78 [](auto proton) { return proton->side() == 1; });
79 if(protonSideCContainer.empty()) return StatusCode::SUCCESS;
80
81 ATH_MSG_DEBUG("tofTrackSideAContainer size: " << tofTrackSideAContainer.size());
82 ATH_MSG_DEBUG("tofTrackSideCContainer size: " << tofTrackSideCContainer.size());
83 ATH_MSG_DEBUG("protonSideAContainer size: " << protonSideAContainer.size());
84 ATH_MSG_DEBUG("protonSideCContainer size: " << protonSideCContainer.size());
85
86
87 nlohmann::json dataTVP=m_tofVtxParamDBTool->parametersData(ctx);
88 const AFP::ToFVtxParamData TVP_A=m_tofVtxParamDBTool->parameters(dataTVP, 0);
89 const AFP::ToFVtxParamData TVP_C=m_tofVtxParamDBTool->parameters(dataTVP, 3);
90
91 // Loop over four containers
92 for (const xAOD::AFPToFTrack* tofTrackSideA : tofTrackSideAContainer) {
93
94 for (const xAOD::AFPProton* protonSideA : protonSideAContainer) {
95 // Apply cuts
96
97 double protonXPositionFar = protonSideA->track(0)->xLocal();
98 if(protonSideA->nTracks()==2 && protonSideA->track(1)->stationID()==0)
99 protonXPositionFar = protonSideA->track(1)->xLocal();
100
101 double dx = std::min(std::abs(protonXPositionFar-TVP_A.trainEdge(tofTrackSideA->trainID())),std::abs(protonXPositionFar-TVP_A.trainEdge(tofTrackSideA->trainID()+1)));
102 double distA = dx;
103 if( protonXPositionFar > TVP_A.trainEdge(tofTrackSideA->trainID()) && protonXPositionFar < TVP_A.trainEdge(tofTrackSideA->trainID()+1) ) distA = -dx;
104
105 if (distA > m_trackDistance) {
107 "Tracks too far away from each other (xProton, xLeftPositionSideA; xRightPositionSideA; distance) [mm]: "
108 << protonXPositionFar << ", " << TVP_A.trainEdge(tofTrackSideA->trainID()) << "; "
109 << TVP_A.trainEdge(tofTrackSideA->trainID()+1) << ", " << distA << "; " << distA);
110
111 continue;
112 }
113
114
115
116 for (const xAOD::AFPToFTrack* tofTrackSideC : tofTrackSideCContainer) {
117
118 for (const xAOD::AFPProton* protonSideC : protonSideCContainer) {
119 // Apply cuts
120
121 double protonXPositionFar = protonSideC->track(0)->xLocal();
122 if(protonSideC->nTracks()==2 && protonSideC->track(1)->stationID()==3)
123 protonXPositionFar = protonSideC->track(1)->xLocal();
124 double dx = std::min(std::abs(protonXPositionFar-TVP_C.trainEdge(tofTrackSideC->trainID())),std::abs(protonXPositionFar-TVP_C.trainEdge(tofTrackSideC->trainID()+1)));
125 double distC = dx;
126 if( protonXPositionFar > TVP_C.trainEdge(tofTrackSideC->trainID()) && protonXPositionFar < TVP_C.trainEdge(tofTrackSideC->trainID()+1) ) distC = -dx;
127
128 if (distC > m_trackDistance) {
130 "Tracks too far away from each other (xProton, xLeftPositionSideC; xRightPositionSideC; distance) [mm]: "
131 << protonXPositionFar << ", " << TVP_C.trainEdge(tofTrackSideC->trainID()) << "; "
132 << TVP_C.trainEdge(tofTrackSideC->trainID()+1) << ", " << distC << "; " << distC);
133
134 continue;
135 }
136
137 // Reconstruct vertex and add it to the container
138 xAOD::AFPVertex * vertex = reco(distA, distC, tofTrackSideA, tofTrackSideC, protonSideA, protonSideC, TVP_A, TVP_C, outputContainer);
139
140 if (!vertex)
141 continue;
142
143
144 // Create link to tracks
145 linkToFTracksToVertex(tofTrackSideA, tofTrackContainer, vertex);
146 linkToFTracksToVertex(tofTrackSideC, tofTrackContainer, vertex);
147 linkProtonsToVertex(protonSideA, protonContainer,vertex);
148 linkProtonsToVertex(protonSideC, protonContainer,vertex);
149 }
150 }
151 }
152 }
153
154 return StatusCode::SUCCESS;
155}
const std::vector< double > & trainEdge() const
Train edges; the end of n-th train is also the beginning of the (n+1)-th train.
void linkProtonsToVertex(const xAOD::AFPProton *proton, SG::ReadHandle< xAOD::AFPProtonContainer > &protonContainer, xAOD::AFPVertex *vertex) const
Links proton pair to reconstructed vertex.
SG::ReadHandleKey< xAOD::AFPProtonContainer > m_protonContainerKey
xAOD::AFPVertex * reco(const double distA, const double distC, const xAOD::AFPToFTrack *toFTrackA, const xAOD::AFPToFTrack *toFTrackC, const xAOD::AFPProton *protonA, const xAOD::AFPProton *protonC, const AFP::ToFVtxParamData &TVP_A, const AFP::ToFVtxParamData &TVP_C, std::unique_ptr< xAOD::AFPVertexContainer > &outputContainer) const
Reconstructs single vertex from pair of ToFTracks and a pair of protons.
SG::ReadHandleKey< xAOD::AFPToFTrackContainer > m_tofTrackContainerKey
void linkToFTracksToVertex(const xAOD::AFPToFTrack *toFTrack, SG::ReadHandle< xAOD::AFPToFTrackContainer > &tofTrackContainer, xAOD::AFPVertex *vertex) const
Links ToF track pair to reconstructed vertex.
AFPToFTrack_v1 AFPToFTrack
Definition AFPToFTrack.h:12
AFPProton_v1 AFPProton
Definition AFPProton.h:11
AFPVertex_v1 AFPVertex
Definition AFPVertex.h:12

◆ initialize()

StatusCode AFP_VertexRecoBasic::initialize ( )
overridevirtual

Loads parameterization.

Definition at line 29 of file AFP_VertexRecoBasic.cxx.

30{
31
32 CHECK( m_tofTrackContainerKey.initialize() );
33 CHECK( m_protonContainerKey.initialize() );
34
35 return StatusCode::SUCCESS;
36}

◆ linkProtonsToVertex()

void AFP_VertexRecoBasic::linkProtonsToVertex ( const xAOD::AFPProton * proton,
SG::ReadHandle< xAOD::AFPProtonContainer > & protonContainer,
xAOD::AFPVertex * vertex ) const
private

Links proton pair to reconstructed vertex.

Definition at line 185 of file AFP_VertexRecoBasic.cxx.

186 {
187
188 ElementLink<xAOD::AFPProtonContainer> protonLink;
189
190 protonLink.toContainedElement(*protonContainer, proton);
191 vertex->addProton(protonLink);
192}

◆ linkToFTracksToVertex()

void AFP_VertexRecoBasic::linkToFTracksToVertex ( const xAOD::AFPToFTrack * toFTrack,
SG::ReadHandle< xAOD::AFPToFTrackContainer > & tofTrackContainer,
xAOD::AFPVertex * vertex ) const
private

Links ToF track pair to reconstructed vertex.

Definition at line 176 of file AFP_VertexRecoBasic.cxx.

177 {
178
179 ElementLink<xAOD::AFPToFTrackContainer> tofTrackLink;
180
181 tofTrackLink.toContainedElement(*tofTrackContainer, tofTrack);
182 vertex->addToFTrack(tofTrackLink);
183}

◆ outputContainerName()

const std::string & AFP_VertexRecoBasic::outputContainerName ( ) const
inlineoverride

Definition at line 51 of file AFP_VertexRecoBasic.h.

Gaudi::Property< std::string > m_vertexContainerName

◆ reco()

xAOD::AFPVertex * AFP_VertexRecoBasic::reco ( const double distA,
const double distC,
const xAOD::AFPToFTrack * toFTrackA,
const xAOD::AFPToFTrack * toFTrackC,
const xAOD::AFPProton * protonA,
const xAOD::AFPProton * protonC,
const AFP::ToFVtxParamData & TVP_A,
const AFP::ToFVtxParamData & TVP_C,
std::unique_ptr< xAOD::AFPVertexContainer > & outputContainer ) const
private

Reconstructs single vertex from pair of ToFTracks and a pair of protons.

  • Sets up measurement and calculates distances and times
  • Reconstucts vertex using basic algorithm
  • Calculates initial matching quality
  • Adds vertex to outputContainer and sets it's properties
Returns
Poiner to reconstucted AFPVertex

Definition at line 197 of file AFP_VertexRecoBasic.cxx.

202{
203 int trainID = tofTrackSideA->trainID();
204 double protonYPositionFar = protonSideA->track(0)->yLocal();
205 if(protonSideA->nTracks()==2 && protonSideA->track(1)->stationID()==0)
206 protonYPositionFar = protonSideA->track(1)->yLocal();
207 double timeA = tofTrackSideA->trainTime() - (TVP_A.timeOffset(trainID)+TVP_A.timeSlope(trainID)*protonYPositionFar);
208
209 trainID = tofTrackSideC->trainID();
210 protonYPositionFar = protonSideC->track(0)->yLocal();
211 if(protonSideC->nTracks()==2 && protonSideC->track(1)->stationID()==3)
212 protonYPositionFar = protonSideC->track(1)->yLocal();
213
214 double timeC = tofTrackSideC->trainTime() - (TVP_C.timeOffset(trainID)+TVP_C.timeSlope(trainID)*protonYPositionFar);
215
216 double position = ( (timeC*1000.-TVP_C.timeGlobalOffset()) - (timeA*1000.-TVP_A.timeGlobalOffset()))/2.*0.299792458 ;
217
218 return createVertex(position, distA, distC, outputContainer);
219}
const std::vector< double > & timeOffset() const
Time offsets for the trains.
const std::vector< double > & timeSlope() const
Time slopes for the trains.
double timeGlobalOffset() const
Global offset of the whole station.
xAOD::AFPVertex * createVertex(const double position, const double distA, const double distC, std::unique_ptr< xAOD::AFPVertexContainer > &outputContainer) const
Creates and sets up a vertex.

Member Data Documentation

◆ m_protonContainerKey

SG::ReadHandleKey<xAOD::AFPProtonContainer> AFP_VertexRecoBasic::m_protonContainerKey {this, "AFPProtonContainerKey", "AFPProtonContainer", "Name of the container with protons from which vertices are to be reconstructed"}
private

Definition at line 81 of file AFP_VertexRecoBasic.h.

81{this, "AFPProtonContainerKey", "AFPProtonContainer", "Name of the container with protons from which vertices are to be reconstructed"};

◆ m_tofTrackContainerKey

SG::ReadHandleKey<xAOD::AFPToFTrackContainer> AFP_VertexRecoBasic::m_tofTrackContainerKey {this, "AFPToFTrackContainerKey", "AFPToFTrackContainer", "Name of the container with ToF tracks from which vertices are to be reconstructed"}
private

Definition at line 79 of file AFP_VertexRecoBasic.h.

79{this, "AFPToFTrackContainerKey", "AFPToFTrackContainer", "Name of the container with ToF tracks from which vertices are to be reconstructed"};

◆ m_tofVtxParamDBTool

ToolHandle<AFP::IToFVtxParamDBTool> AFP_VertexRecoBasic::m_tofVtxParamDBTool {this, "tofVtxParamDBTool", "AFP__ToFLocParamDBTool", "Tool to access DB to get the vertex ToF parameters"}
private

@ brief Tool for accessing DB to get the vertex ToF parameters

Definition at line 75 of file AFP_VertexRecoBasic.h.

75{this, "tofVtxParamDBTool", "AFP__ToFLocParamDBTool", "Tool to access DB to get the vertex ToF parameters"};

◆ m_trackDistance

Gaudi::Property<double> AFP_VertexRecoBasic::m_trackDistance {this, "TrackDistance", 0.5, "Maximum distance between ToF train edge and proton"}
private

Definition at line 77 of file AFP_VertexRecoBasic.h.

77{this, "TrackDistance", 0.5, "Maximum distance between ToF train edge and proton"};

◆ m_vertexContainerName

Gaudi::Property<std::string> AFP_VertexRecoBasic::m_vertexContainerName {this, "verticesContainerName", "AFPVertexContainer", "Name of the container in which vertices are saved"}
private

Definition at line 83 of file AFP_VertexRecoBasic.h.

83{this, "verticesContainerName", "AFPVertexContainer", "Name of the container in which vertices are saved"};

The documentation for this class was generated from the following files: