ATLAS Offline Software
Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
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. More...
 
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 More...
 

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. More...
 
void linkTracksToProton (const xAOD::AFPTrack *track, SG::ReadHandle< xAOD::AFPTrackContainer > &trackContainer, xAOD::AFPProton *proton) const
 Links track pair to reconstructed proton. More...
 
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. More...
 
double m_detectorPositionFar = 0.0
 Default position of AFP far station. More...
 
const std::vector< double > m_vertexIP = {0, 0, 0}
 Vertex position. More...
 

Static Protected Attributes

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

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 }

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  }

◆ 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 }

◆ 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 
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 }

◆ 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 
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.

41 {return 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ m_xSigma

constexpr double AFP_ProtonRecoBase::m_xSigma = 10e-6
staticconstexprprotected

x-Sigma value

Definition at line 98 of file AFP_ProtonRecoBase.h.

◆ m_ySigma

constexpr 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:
xAOD::AFPTrack_v2
Class representing a track reconstructed in AFP.
Definition: AFPTrack_v2.h:37
test_pyathena.px
px
Definition: test_pyathena.py:18
AFP_ProtonRecoBase::reco
virtual xAOD::AFPProton * reco(const xAOD::AFPTrack *, const xAOD::AFPTrack *, std::unique_ptr< xAOD::AFPProtonContainer > &) const
Definition: AFP_ProtonRecoBase.h:108
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
AFP_ProtonRecoBase::m_trackDistance
Gaudi::Property< double > m_trackDistance
Definition: AFP_ProtonRecoBase.h:74
MCP::ScaleSmearParam::r2
@ r2
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
AFP_ProtonRecoBase::m_trackContainerKey
SG::ReadHandleKey< xAOD::AFPTrackContainer > m_trackContainerKey
Definition: AFP_ProtonRecoBase.h:78
AFP_ProtonRecoBase::chi2
virtual double chi2(double, double, double, const Measurement &) const
Definition: AFP_ProtonRecoBase.h:120
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ParticleGun_EoverP_Config.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:63
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Amg::pz
@ pz
Definition: GeoPrimitives.h:40
test_pyathena.parent
parent
Definition: test_pyathena.py:15
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
AnalysisUtils::copy_if
Out copy_if(In first, const In &last, Out res, const Pred &p)
Definition: IFilterUtils.h:30
AFP_ProtonRecoBase::m_allowSingleStationReco
Gaudi::Property< bool > m_allowSingleStationReco
Definition: AFP_ProtonRecoBase.h:76
Amg::py
@ py
Definition: GeoPrimitives.h:39
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AFP_ProtonRecoBase::m_side
Gaudi::Property< int > m_side
Definition: AFP_ProtonRecoBase.h:72
xAOD::proton
@ proton
Definition: TrackingPrimitives.h:198
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
makeTRTBarrelCans.dy
tuple dy
Definition: makeTRTBarrelCans.py:21
AFP_ProtonRecoBase::m_protonsContainerName
Gaudi::Property< std::string > m_protonsContainerName
Definition: AFP_ProtonRecoBase.h:80
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
AFP_ProtonRecoBase::linkTracksToProton
void linkTracksToProton(const xAOD::AFPTrack *track, SG::ReadHandle< xAOD::AFPTrackContainer > &trackContainer, xAOD::AFPProton *proton) const
Links track pair to reconstructed proton.
Definition: AFP_ProtonRecoBase.cxx:120
xAOD::AFPProton_v1
Class representing a proton reconstructed in AFP.
Definition: AFPProton_v1.h:36
xAOD::track
@ track
Definition: TrackingPrimitives.h:512