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

Base class for all proton reconstruction tools. More...

#include <AFP_ProtonRecoBase.h>

Inheritance diagram for AFP_ProtonRecoBase:
Collaboration diagram for AFP_ProtonRecoBase:

Classes

struct  Measurement
 Local class for storing tracks positions. More...

Public Member Functions

 AFP_ProtonRecoBase (const std::string &type, const std::string &name, const IInterface *parent)
 Default constructor.
const std::string & outputContainerName () const override
StatusCode doProtonReco (std::unique_ptr< xAOD::AFPProtonContainer > &outputContainer, const EventContext &ctx) const override

Protected Types

using Momentum = std::array<double, 3>
 3-momentum of reconstructed proton

Protected Member Functions

xAOD::AFPProtoncreateProton (const Momentum &momentum, const Measurement &my_measAFP, const int algID, std::unique_ptr< xAOD::AFPProtonContainer > &outputContainer) const
 Creates and sets up a proton.
void linkTracksToProton (const xAOD::AFPTrack *track, SG::ReadHandle< xAOD::AFPTrackContainer > &trackContainer, xAOD::AFPProton *proton) const
 Links track pair to reconstructed proton.
virtual xAOD::AFPProtonreco (const xAOD::AFPTrack *, const xAOD::AFPTrack *, std::unique_ptr< xAOD::AFPProtonContainer > &) const
virtual xAOD::AFPProtonreco (const xAOD::AFPTrack *, std::unique_ptr< xAOD::AFPProtonContainer > &) const
virtual double chi2 (double, double, double, const Measurement &) const

Protected Attributes

Gaudi::Property< std::vector< double > > m_detectorPositions {this, "detectorPositions", {}, "absolute values of detector positions for each station on one side"}
Gaudi::Property< int > m_side {this, "side", 0, "side id, A=0, C=1"}
Gaudi::Property< double > m_trackDistance {this, "trackDistance", 2.0, "Maximum distance between tracks in the near and the far station on xy-plane"}
Gaudi::Property< bool > m_allowSingleStationReco {this, "allowSingleStationReco", false, "Switch for allowing proton reconstruction using only far station"}
SG::ReadHandleKey< xAOD::AFPTrackContainerm_trackContainerKey {this, "AFPTrackContainerKey", "AFPTrackContainer", "Name of the container with tracks of hits from which protons are to be reconstructed"}
Gaudi::Property< std::string > m_protonsContainerName {this, "protonsContainerName", "AFPProtonContainer", "Name of the container in which protons are saved"}
double m_detectorPositionNear = 0.0
 Default position of AFP near station.
double m_detectorPositionFar = 0.0
 Default position of AFP far station.
const std::vector< double > m_vertexIP = {0, 0, 0}
 Vertex position.

Static Protected Attributes

static constexpr double m_xSigma = 10e-6
 x-Sigma value
static constexpr double m_ySigma = 30e-6
 y-Sigma value

Detailed Description

Base class for all proton reconstruction tools.

Definition at line 34 of file AFP_ProtonRecoBase.h.

Member Typedef Documentation

◆ Momentum

using AFP_ProtonRecoBase::Momentum = std::array<double, 3>
protected

3-momentum of reconstructed proton

Definition at line 83 of file AFP_ProtonRecoBase.h.

Constructor & Destructor Documentation

◆ AFP_ProtonRecoBase()

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

Default constructor.

Definition at line 9 of file AFP_ProtonRecoBase.cxx.

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

Member Function Documentation

◆ chi2()

virtual double AFP_ProtonRecoBase::chi2 ( double ,
double ,
double ,
const Measurement &  ) const
inlineprotectedvirtual

Reimplemented in AFP_ProtonRecoAnalytical.

Definition at line 120 of file AFP_ProtonRecoBase.h.

121 {
122 ATH_MSG_ERROR("this is chi2(energy, sx, sy, sz, my_measAFP) in AFP_ProtonRecoBase, shall not be used, returning 0");
123 return 0.;
124 }
#define ATH_MSG_ERROR(x)

◆ createProton()

xAOD::AFPProton * AFP_ProtonRecoBase::createProton ( const Momentum & momentum,
const Measurement & my_measAFP,
const int algID,
std::unique_ptr< xAOD::AFPProtonContainer > & outputContainer ) const
protected

Creates and sets up a proton.

Definition at line 94 of file AFP_ProtonRecoBase.cxx.

95{
96
97 // Return nullptr if any of momentum components is not a number
98 if ( std::any_of(begin(momentum), end(momentum), [](auto& el) { return !std::isfinite(el); }) )
99 return nullptr;
100
101 const auto [px, py, pz] = momentum;
102
103 auto * proton = outputContainer->push_back(std::make_unique<xAOD::AFPProton>());
104
105 // Set proton properties
106 constexpr double protonMass = 0.938; // in GeV
107
108 proton->setPxPyPzE(px, py, pz, sqrt(px*px + py*py + pz*pz + protonMass*protonMass));
109 proton->setChi2(chi2(px, py, pz, my_measAFP));
110 proton->setSide(m_side);
111 proton->setMethodID(algID);
112
113 ATH_MSG_DEBUG("Reconstructed proton (px, py, pz): " << proton->px() << ", " << proton->py() << ", " << proton->pz()<<", chi2 "<<proton->chi2()<<", side "<<proton->side());
114
115 return proton;
116}
Gaudi::Property< int > m_side
virtual double chi2(double, double, double, const Measurement &) const

◆ doProtonReco()

StatusCode AFP_ProtonRecoBase::doProtonReco ( std::unique_ptr< xAOD::AFPProtonContainer > & outputContainer,
const EventContext & ctx ) const
override

Definition at line 16 of file AFP_ProtonRecoBase.cxx.

17{
18
19 SG::ReadHandle<xAOD::AFPTrackContainer> trackContainer( m_trackContainerKey, ctx );
20 if(!trackContainer.isValid())
21 {
22 // this is allowed, there might be no AFP data in the input
23 return StatusCode::SUCCESS;
24 }
25
26 const double trackDistanceRadiusSq = m_trackDistance*m_trackDistance;
27
28 // Select tracks in near station
29 std::vector<const xAOD::AFPTrack*> trackNearContainer;
30 const int nearId = m_side + 1;
31 std::copy_if(trackContainer->begin(), trackContainer->end(), std::back_inserter(trackNearContainer),
32 [&nearId](auto track) { return track->stationID() == nearId; });
33
34 // Select tracks in far station
35 std::vector<const xAOD::AFPTrack*> trackFarContainer;
36 const int farId = 3 * m_side;
37 std::copy_if(trackContainer->begin(), trackContainer->end(), std::back_inserter(trackFarContainer),
38 [&farId](auto track) { return track->stationID() == farId; });
39
40 ATH_MSG_DEBUG("trackNearContainer size: " << trackNearContainer.size()<<", side "<<m_side);
41 ATH_MSG_DEBUG("trackFarContainer size: " << trackFarContainer.size()<<", side "<<m_side);
42
43 // Loop over both containers
44 for (const xAOD::AFPTrack* trackFar : trackFarContainer) {
45 bool foundMatchingTrack = false;
46
47 for (const xAOD::AFPTrack* trackNear : trackNearContainer) {
48 // Apply cuts
49 const double dx = trackFar->xLocal() - trackNear->xLocal();
50 const double dy = trackFar->yLocal() - trackNear->yLocal();
51 const double r2 = dx*dx + dy*dy;
52
53 if (r2 > trackDistanceRadiusSq) {
55 "Tracks too far away from each other (xNear, yNear; xFar, yFar; distance) [mm]: "
56 << trackNear->xLocal() << ", " << trackNear->yLocal() << "; "
57 << trackFar->xLocal() << ", " << trackFar->yLocal() << "; " << r2);
58
59 continue;
60 }
61
62 // Reconstruct proton and add it to the container
63 xAOD::AFPProton * proton = reco(trackNear, trackFar, outputContainer);
64
65 if (!proton)
66 continue;
67
68 foundMatchingTrack = true;
69
70 // Create link to tracks
71 linkTracksToProton(trackNear, trackContainer, proton);
72 linkTracksToProton(trackFar, trackContainer, proton);
73 }
74
75 // Reconstuct proton using only FAR station if
76 // no matching track on NEAR station was found
77 if (m_allowSingleStationReco and !foundMatchingTrack) {
78 // Apply cuts
79 // none
80
81 xAOD::AFPProton * proton = reco(trackFar, outputContainer);
82
83 if (!proton)
84 continue;
85
86 linkTracksToProton(trackFar, trackContainer, proton);
87 }
88 }
89
90 return StatusCode::SUCCESS;
91}
void linkTracksToProton(const xAOD::AFPTrack *track, SG::ReadHandle< xAOD::AFPTrackContainer > &trackContainer, xAOD::AFPProton *proton) const
Links track pair to reconstructed proton.
Gaudi::Property< double > m_trackDistance
Gaudi::Property< bool > m_allowSingleStationReco
virtual xAOD::AFPProton * reco(const xAOD::AFPTrack *, const xAOD::AFPTrack *, std::unique_ptr< xAOD::AFPProtonContainer > &) const
SG::ReadHandleKey< xAOD::AFPTrackContainer > m_trackContainerKey
AFPTrack_v2 AFPTrack
Definition AFPTrack.h:12
AFPProton_v1 AFPProton
Definition AFPProton.h:11

◆ linkTracksToProton()

void AFP_ProtonRecoBase::linkTracksToProton ( const xAOD::AFPTrack * track,
SG::ReadHandle< xAOD::AFPTrackContainer > & trackContainer,
xAOD::AFPProton * proton ) const
protected

Links track pair to reconstructed proton.

Definition at line 119 of file AFP_ProtonRecoBase.cxx.

120 {
121
122 ElementLink<xAOD::AFPTrackContainer> trackLink;
123
124 trackLink.toContainedElement(*trackContainer, track);
125 proton->addAFPTrackLink(trackLink);
126}

◆ outputContainerName()

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

Definition at line 41 of file AFP_ProtonRecoBase.h.

Gaudi::Property< std::string > m_protonsContainerName

◆ reco() [1/2]

virtual xAOD::AFPProton * AFP_ProtonRecoBase::reco ( const xAOD::AFPTrack * ,
const xAOD::AFPTrack * ,
std::unique_ptr< xAOD::AFPProtonContainer > &  ) const
inlineprotectedvirtual

Reimplemented in AFP_ProtonRecoAnalytical.

Definition at line 108 of file AFP_ProtonRecoBase.h.

109 {
110 ATH_MSG_ERROR("this is reco(trkNear, trkFar, outputContainer) in AFP_ProtonRecoBase, shall not be used, returning 0");
111 return 0;
112 }

◆ reco() [2/2]

virtual xAOD::AFPProton * AFP_ProtonRecoBase::reco ( const xAOD::AFPTrack * ,
std::unique_ptr< xAOD::AFPProtonContainer > &  ) const
inlineprotectedvirtual

Reimplemented in AFP_ProtonRecoAnalytical.

Definition at line 113 of file AFP_ProtonRecoBase.h.

114 {
115 ATH_MSG_ERROR("this is reco(trkFar, outputContainer) in AFP_ProtonRecoBase, shall not be used, returning 0");
116 return 0;
117 }

Member Data Documentation

◆ m_allowSingleStationReco

Gaudi::Property<bool> AFP_ProtonRecoBase::m_allowSingleStationReco {this, "allowSingleStationReco", false, "Switch for allowing proton reconstruction using only far station"}
protected

Definition at line 76 of file AFP_ProtonRecoBase.h.

76{this, "allowSingleStationReco", false, "Switch for allowing proton reconstruction using only far station"};

◆ m_detectorPositionFar

double AFP_ProtonRecoBase::m_detectorPositionFar = 0.0
protected

Default position of AFP far station.

Definition at line 95 of file AFP_ProtonRecoBase.h.

◆ m_detectorPositionNear

double AFP_ProtonRecoBase::m_detectorPositionNear = 0.0
protected

Default position of AFP near station.

Definition at line 92 of file AFP_ProtonRecoBase.h.

◆ m_detectorPositions

Gaudi::Property<std::vector<double> > AFP_ProtonRecoBase::m_detectorPositions {this, "detectorPositions", {}, "absolute values of detector positions for each station on one side"}
protected

Definition at line 70 of file AFP_ProtonRecoBase.h.

70{this, "detectorPositions", {}, "absolute values of detector positions for each station on one side"};

◆ m_protonsContainerName

Gaudi::Property<std::string> AFP_ProtonRecoBase::m_protonsContainerName {this, "protonsContainerName", "AFPProtonContainer", "Name of the container in which protons are saved"}
protected

Definition at line 80 of file AFP_ProtonRecoBase.h.

80{this, "protonsContainerName", "AFPProtonContainer", "Name of the container in which protons are saved"};

◆ m_side

Gaudi::Property<int> AFP_ProtonRecoBase::m_side {this, "side", 0, "side id, A=0, C=1"}
protected

Definition at line 72 of file AFP_ProtonRecoBase.h.

72{this, "side", 0, "side id, A=0, C=1"};

◆ m_trackContainerKey

SG::ReadHandleKey<xAOD::AFPTrackContainer> AFP_ProtonRecoBase::m_trackContainerKey {this, "AFPTrackContainerKey", "AFPTrackContainer", "Name of the container with tracks of hits from which protons are to be reconstructed"}
protected

Definition at line 78 of file AFP_ProtonRecoBase.h.

78{this, "AFPTrackContainerKey", "AFPTrackContainer", "Name of the container with tracks of hits from which protons are to be reconstructed"};

◆ m_trackDistance

Gaudi::Property<double> AFP_ProtonRecoBase::m_trackDistance {this, "trackDistance", 2.0, "Maximum distance between tracks in the near and the far station on xy-plane"}
protected

Definition at line 74 of file AFP_ProtonRecoBase.h.

74{this, "trackDistance", 2.0, "Maximum distance between tracks in the near and the far station on xy-plane"};

◆ m_vertexIP

const std::vector<double> AFP_ProtonRecoBase::m_vertexIP = {0, 0, 0}
protected

Vertex position.

Definition at line 105 of file AFP_ProtonRecoBase.h.

105{0, 0, 0};

◆ m_xSigma

double AFP_ProtonRecoBase::m_xSigma = 10e-6
staticconstexprprotected

x-Sigma value

Definition at line 98 of file AFP_ProtonRecoBase.h.

◆ m_ySigma

double AFP_ProtonRecoBase::m_ySigma = 30e-6
staticconstexprprotected

y-Sigma value

Definition at line 101 of file AFP_ProtonRecoBase.h.


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