ATLAS Offline Software
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | List of all members
AFP_ProtonRecoAnalytical Class Reference

Tool for proton reconstruction by directly using transport parameterisation. More...

#include <AFP_ProtonRecoAnalytical.h>

Inheritance diagram for AFP_ProtonRecoAnalytical:
Collaboration diagram for AFP_ProtonRecoAnalytical:

Public Member Functions

 AFP_ProtonRecoAnalytical (const std::string &type, const std::string &name, const IInterface *parent)
 Default constructor. More...
 
 ~AFP_ProtonRecoAnalytical ()=default
 
StatusCode initialize () override
 Loads parameterization. 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...
 

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

Private Member Functions

StatusCode configInfo () const
 
virtual xAOD::AFPProtonreco (const xAOD::AFPTrack *trkNear, const xAOD::AFPTrack *trkFar, std::unique_ptr< xAOD::AFPProtonContainer > &outputContainer) const override
 Reconstructs single proton from pair of tracks. More...
 
virtual xAOD::AFPProtonreco (const xAOD::AFPTrack *trkFar, std::unique_ptr< xAOD::AFPProtonContainer > &outputContainer) const override
 Reconstructs single proton using only one track from far station. More...
 
virtual double chi2 (double energy, double sx, double sy, const Measurement &my_measAFP) const override
 Calculates chi2 for reconstructed proton. More...
 
double bisection (double(AFP_ProtonRecoAnalytical::*fun)(double, const Measurement &, std::vector< double > &, std::vector< double > &) const, const Measurement &my_measAFP, std::vector< double > &my_slopeCalculated, std::vector< double > &my_positionCalculated) const
 Calculates root of given function. More...
 
double bothStations (double energy, const Measurement &my_measAFP, std::vector< double > &my_slopeCalculated, std::vector< double > &my_positionCalculated) const
 Function obtained from parameterization equation. More...
 
double singleStation (double energy, const Measurement &my_measAFP, std::vector< double > &my_slopeCalculated, std::vector< double > &my_positionCalculated) const
 Function obtained from parameterization equation. More...
 
double calculateSlope (double energy, int XorY, std::vector< double > &my_slopeCalculated) const
 Calculates ininial slope based on measurements and reconstructed energy. More...
 
double calculateXslope (double energy, std::vector< double > &my_slopeCalculated) const
 Calculates initial horizontal slope Calls calculateSlope(energy, 0) More...
 
double calculateYslope (double energy, std::vector< double > &my_slopeCalculated) const
 Calculates initial vertical slope Calls calculateSlope(energy, 1) More...
 

Private Attributes

std::unique_ptr< AFP::Parameterizationm_parametrization
 Pointer to parameterization. More...
 
double m_distanceBetweenStations = 0.0
 Distance between near and far station. More...
 
Gaudi::Property< std::string > m_parametrizationFileName {this, "parametrizationFileName", "none.txt", "Name of the file containing parameterization"}
 Name of the file containing parameterization. More...
 
double m_parametrizationPosition = 0.0
 Position for which parameterization was performed. More...
 
double m_parametrizationEnergy = 0.0
 Parameterization energy. More...
 

Detailed Description

Tool for proton reconstruction by directly using transport parameterisation.

Definition at line 31 of file AFP_ProtonRecoAnalytical.h.

Member Typedef Documentation

◆ Momentum

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

3-momentum of reconstructed proton

Definition at line 83 of file AFP_ProtonRecoBase.h.

Constructor & Destructor Documentation

◆ AFP_ProtonRecoAnalytical()

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

Default constructor.

Definition at line 8 of file AFP_ProtonRecoAnalytical.cxx.

10 {
11  ATH_MSG_DEBUG("in AFP_ProtonRecoAnalytical constructor");
12 }

◆ ~AFP_ProtonRecoAnalytical()

AFP_ProtonRecoAnalytical::~AFP_ProtonRecoAnalytical ( )
default

Member Function Documentation

◆ bisection()

double AFP_ProtonRecoAnalytical::bisection ( double(AFP_ProtonRecoAnalytical::*)(double, const Measurement &, std::vector< double > &, std::vector< double > &) const  fun,
const Measurement my_measAFP,
std::vector< double > &  my_slopeCalculated,
std::vector< double > &  my_positionCalculated 
) const
private

Calculates root of given function.

Definition at line 92 of file AFP_ProtonRecoAnalytical.cxx.

92  {
93 
94  // Alias to minimized function
95  auto fn = [this, fun, my_slopeCalculated, my_positionCalculated](double x, const Measurement& m, std::vector<double>& s, std::vector<double>& p) { return (this->*fun)(x,m,s,p); };
96 
97  constexpr double tol = 1e-3; // 1 MeV
98  double eMin = m_parametrizationEnergy - 2000.; // ~30% xi
99  double eMax = m_parametrizationEnergy;
100 
101  if (fn(eMax, my_measAFP, my_slopeCalculated, my_positionCalculated) * fn(eMin, my_measAFP, my_slopeCalculated, my_positionCalculated) >= 0) { // Cannot use bisection method
102 
103  ATH_MSG_DEBUG("Cannot use bisection method");
104 
105  // Return value closest to zero
106  return (fn(eMin, my_measAFP, my_slopeCalculated, my_positionCalculated) < 0) ? std::max(fn(eMin, my_measAFP, my_slopeCalculated, my_positionCalculated), fn(eMax, my_measAFP, my_slopeCalculated, my_positionCalculated)) : std::min(fn(eMin, my_measAFP, my_slopeCalculated, my_positionCalculated), fn(eMax, my_measAFP, my_slopeCalculated, my_positionCalculated));
107  }
108 
109  ATH_MSG_VERBOSE("==== eMin\teMax\te\tfun(eMin)\tfun(eMax)\tfun(E) ====");
110 
111  double e = eMin;
112 
113  // Bisection method
114  while (eMax - eMin > tol) {
115  e = (eMin + eMax)/2.0;
116  ATH_MSG_VERBOSE("* " << eMin << "\t" << eMax << "\t" << e << "\t" << fn(e, my_measAFP, my_slopeCalculated, my_positionCalculated) << "\t" << fn(eMin, my_measAFP, my_slopeCalculated, my_positionCalculated) << "\t" << fn(eMax, my_measAFP, my_slopeCalculated, my_positionCalculated));
117  if (fn(eMax, my_measAFP, my_slopeCalculated, my_positionCalculated) * fn(e, my_measAFP, my_slopeCalculated, my_positionCalculated) < 0)
118  eMin = e;
119  else if (fn(eMin, my_measAFP, my_slopeCalculated, my_positionCalculated) * fn(e, my_measAFP, my_slopeCalculated, my_positionCalculated) < 0)
120  eMax = e;
121  else {
122  eMin = e;
123  eMax = e;
124  }
125  }
126 
127  ATH_MSG_DEBUG("Bisection energy: " << e);
128 
129  return e;
130 }

◆ bothStations()

double AFP_ProtonRecoAnalytical::bothStations ( double  energy,
const Measurement my_measAFP,
std::vector< double > &  my_slopeCalculated,
std::vector< double > &  my_positionCalculated 
) const
private

Function obtained from parameterization equation.

Used in bisection method.

Definition at line 178 of file AFP_ProtonRecoAnalytical.cxx.

178  {
179 
180  const double xi = 1.0 - energy / m_parametrizationEnergy;
181 
182  return
183  (my_positionCalculated.at(0)
184  - m_parametrization->getEquation(0)->getPolynomial(0)->Eval(xi)
185  - m_vertexIP.at(0)*m_parametrization->getEquation(0)->getPolynomial(1)->Eval(xi)
186  - m_vertexIP.at(2)*m_parametrization->getEquation(0)->getPolynomial(3)->Eval(xi)
187  )
188  *(
189  m_parametrization->getEquation(2)->getPolynomial(4)->Eval(xi)
190  + m_vertexIP.at(2)*m_parametrization->getEquation(2)->getPolynomial(6)->Eval(xi)
191  )
192  - (
193  my_slopeCalculated.at(0)
194  - m_parametrization->getEquation(2)->getPolynomial(0)->Eval(xi)
195  - m_vertexIP.at(0)*m_parametrization->getEquation(2)->getPolynomial(1)->Eval(xi)
196  - m_vertexIP.at(2)*m_parametrization->getEquation(2)->getPolynomial(3)->Eval(xi)
197  )
198  *(
199  m_parametrization->getEquation(0)->getPolynomial(4)->Eval(xi)
200  + m_vertexIP.at(2)*m_parametrization->getEquation(0)->getPolynomial(6)->Eval(xi)
201  );
202 }

◆ calculateSlope()

double AFP_ProtonRecoAnalytical::calculateSlope ( double  energy,
int  XorY,
std::vector< double > &  my_slopeCalculated 
) const
private

Calculates ininial slope based on measurements and reconstructed energy.

Definition at line 218 of file AFP_ProtonRecoAnalytical.cxx.

218  { // 0 - X, 1 - Y
219 
220  const double xi = 1.0 - energy / m_parametrizationEnergy;
221 
222  const double Ax = m_parametrization->getEquation(2 + XorY)->getPolynomial(0)->Eval(xi);
223  const double Bx = m_parametrization->getEquation(2 + XorY)->getPolynomial(4 + XorY)->Eval(xi);
224  const double Cx = m_parametrization->getEquation(2 + XorY)->getPolynomial(1 + XorY)->Eval(xi);
225  const double Dx = m_parametrization->getEquation(2 + XorY)->getPolynomial(6 + XorY)->Eval(xi);
226  const double Ex = m_parametrization->getEquation(2 + XorY)->getPolynomial(3)->Eval(xi);
227 
228  const double Fx = my_slopeCalculated.at(0 + XorY) - Ax - Cx*m_vertexIP.at(0 + XorY) - Ex*m_vertexIP.at(2);
229  const double Gx = Bx + m_vertexIP.at(2)*Dx;
230  const double slp = (Gx == 0) ? 0. : Fx/Gx;
231 
232  return slp;
233 }

◆ calculateXslope()

double AFP_ProtonRecoAnalytical::calculateXslope ( double  energy,
std::vector< double > &  my_slopeCalculated 
) const
private

Calculates initial horizontal slope Calls calculateSlope(energy, 0)

Definition at line 236 of file AFP_ProtonRecoAnalytical.cxx.

236  {
237 
238  return calculateSlope(energy, 0, my_slopeCalculated);
239 }

◆ calculateYslope()

double AFP_ProtonRecoAnalytical::calculateYslope ( double  energy,
std::vector< double > &  my_slopeCalculated 
) const
private

Calculates initial vertical slope Calls calculateSlope(energy, 1)

Definition at line 242 of file AFP_ProtonRecoAnalytical.cxx.

242  {
243 
244  return calculateSlope(energy, 1, my_slopeCalculated);
245 }

◆ chi2()

double AFP_ProtonRecoAnalytical::chi2 ( double  energy,
double  sx,
double  sy,
const Measurement my_measAFP 
) const
overrideprivatevirtual

Calculates chi2 for reconstructed proton.

Reimplemented from AFP_ProtonRecoBase.

Definition at line 248 of file AFP_ProtonRecoAnalytical.cxx.

248  {
249 
250  const double energy = sqrt(px*px + py*py + pz*pz);
251  const double sx = px/energy;
252  const double sy = py/energy;
253 
254  const double xNear = m_parametrization->x(m_vertexIP.at(0), m_vertexIP.at(1), m_vertexIP.at(2), sx, sy, energy);
255  const double yNear = m_parametrization->y(m_vertexIP.at(0), m_vertexIP.at(1), m_vertexIP.at(2), sx, sy, energy);
256  const double xFar = xNear + m_distanceBetweenStations * m_parametrization->sx(m_vertexIP.at(0), m_vertexIP.at(1), m_vertexIP.at(2), sx, sy, energy);
257  const double yFar = yNear + m_distanceBetweenStations * m_parametrization->sy(m_vertexIP.at(0), m_vertexIP.at(1), m_vertexIP.at(2), sx, sy, energy);
258 
259  if (m_allowSingleStationReco and my_measAFP.xN == 0 and my_measAFP.yN == 0) {
260  const double dx2 = my_measAFP.xF - xFar;
261  const double dy2 = my_measAFP.yF - yFar;
262 
263  const double chi2x2 = dx2 * dx2 / (m_xSigma * m_xSigma);
264  const double chi2y2 = (m_parametrization->yIsUsed()) ? dy2 * dy2 / (m_ySigma * m_ySigma) : 0.;
265 
266  return chi2x2 + chi2y2;
267  }
268 
269  const double dx1 = my_measAFP.xN - xNear;
270  const double dx2 = my_measAFP.xF - xFar;
271  const double dy1 = my_measAFP.yN - yNear;
272  const double dy2 = my_measAFP.yF - yFar;
273 
274  const double chi2x1 = dx1 * dx1 / (m_xSigma * m_xSigma);
275  const double chi2x2 = dx2 * dx2 / (m_xSigma * m_xSigma);
276  const double chi2y1 = (m_parametrization->yIsUsed()) ? dy1 * dy1 / (m_ySigma * m_ySigma) : 0.;
277  const double chi2y2 = (m_parametrization->yIsUsed()) ? dy2 * dy2 / (m_ySigma * m_ySigma) : 0.;
278 
279  return chi2x1 + chi2y1 + chi2x2 + chi2y2;
280 }

◆ configInfo()

StatusCode AFP_ProtonRecoAnalytical::configInfo ( ) const
private

Definition at line 15 of file AFP_ProtonRecoAnalytical.cxx.

16 {
17  ATH_MSG_INFO("----- AFP_ProtonRecoAnalytical -----");
18 
19  ATH_MSG_INFO("\tNear AFP position [m]: " << m_detectorPositionNear );
20  ATH_MSG_INFO("\tFar AFP position [m]: " << m_detectorPositionFar );
21  ATH_MSG_INFO("\tSingle station reconstruction: " << m_allowSingleStationReco );
22  ATH_MSG_INFO("\tCuts:\n");
23  ATH_MSG_INFO("\t\ttrackDistance [mm]: " << m_trackDistance );
24 
25  ATH_MSG_INFO("\tparametrizationFileName = " << m_parametrizationFileName);
26  ATH_MSG_INFO("\tparametrizationPosition = " << m_parametrizationPosition);
27  ATH_MSG_INFO("\tparametrizationEnergy = " << m_parametrizationEnergy);
28 
29  return StatusCode::SUCCESS;
30 }

◆ createProton()

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

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
overrideinherited

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 }

◆ initialize()

StatusCode AFP_ProtonRecoAnalytical::initialize ( )
override

Loads parameterization.

Definition at line 33 of file AFP_ProtonRecoAnalytical.cxx.

34 {
35 
36  CHECK( m_trackContainerKey.initialize() );
37 
38  if(m_detectorPositions.empty())
39  {
40  if(m_side==0)
41  {
42  m_detectorPositionNear=205.217;
43  m_detectorPositionFar=217.302;
44  }
45  else if(m_side==1)
46  {
47  m_detectorPositionNear=205.824;
48  m_detectorPositionFar=217.909;
49  }
50  else
51  {
52  ATH_MSG_ERROR("unknown side id "<<m_side<<", allowed values are 0 (for A) and 1 (for C)");
53  return StatusCode::FAILURE;
54  }
55  }
56  else if(m_detectorPositions.size()==2)
57  {
59  {
62  }
63  else
64  {
67  }
68  }
69  else
70  {
71  ATH_MSG_ERROR("there are "<<m_detectorPositions.size()<<" entries for m_detectorPositions, we have only 2 detectors on each side");
72  return StatusCode::FAILURE;
73  }
74 
75 
77  {
78  m_parametrizationFileName = (m_side) ? "param_mad_b1_def.txt" : "param_mad_b2_def.txt";
79  }
80 
82 
83  m_parametrization = std::make_unique<AFP::Parameterization>(parametrization);
84  m_parametrizationPosition = m_parametrization->parametrizationPosition();
87 
88  return StatusCode::SUCCESS;
89 }

◆ linkTracksToProton()

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

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
inlineoverrideinherited

Definition at line 41 of file AFP_ProtonRecoBase.h.

41 {return m_protonsContainerName;}

◆ reco() [1/2]

xAOD::AFPProton * AFP_ProtonRecoAnalytical::reco ( const xAOD::AFPTrack trkFar,
std::unique_ptr< xAOD::AFPProtonContainer > &  outputContainer 
) const
overrideprivatevirtual

Reconstructs single proton using only one track from far station.

Reimplemented from AFP_ProtonRecoBase.

Definition at line 162 of file AFP_ProtonRecoAnalytical.cxx.

162  {
163 
164  const Measurement my_measAFP = Measurement(0., 0., trackFar->xLocal(), trackFar->yLocal());
165 
166  ATH_MSG_DEBUG("Reconstructing proton with bisection method (single station)...");
167  ATH_MSG_DEBUG("Tracks (xFar, yFar): " << my_measAFP.xF << ", " << my_measAFP.yF);
168 
169  std::vector<double> my_slopeCalculated = {0, 0};
170  std::vector<double> my_positionCalculated = {0, 0};
171 
172  const double energy = bisection(&AFP_ProtonRecoAnalytical::singleStation, my_measAFP, my_slopeCalculated, my_positionCalculated);
173 
174  return createProton({0., 0., energy}, my_measAFP, xAOD::AFPProtonRecoAlgID::analytical, outputContainer);
175 }

◆ reco() [2/2]

xAOD::AFPProton * AFP_ProtonRecoAnalytical::reco ( const xAOD::AFPTrack trkNear,
const xAOD::AFPTrack trkFar,
std::unique_ptr< xAOD::AFPProtonContainer > &  outputContainer 
) const
overrideprivatevirtual

Reconstructs single proton from pair of tracks.

  • Sets up measurement and calculates slopes and postitions
  • Reconstructs energy of proton with bisection method
  • Calculates initial proton slopes
  • Adds proton to outputContainer and sets its properties
Returns
Pointer to reconstructed AFPProton

AFP measurement

Reimplemented from AFP_ProtonRecoBase.

Definition at line 133 of file AFP_ProtonRecoAnalytical.cxx.

133  {
134 
136  const Measurement my_measAFP = Measurement(trackNear->xLocal(), trackNear->yLocal(), trackFar->xLocal(), trackFar->yLocal());
137 
138  std::vector<double> my_slopeCalculated = {0, 0};
139  std::vector<double> my_positionCalculated = {0, 0};
140 
141  my_slopeCalculated.at(0) = (my_measAFP.xF - my_measAFP.xN)/m_distanceBetweenStations;
142  my_slopeCalculated.at(1) = (my_measAFP.yF - my_measAFP.yN)/m_distanceBetweenStations;
143  my_positionCalculated.at(0) = my_measAFP.xN + my_slopeCalculated.at(0)*(m_parametrizationPosition - m_detectorPositionNear);
144  my_positionCalculated.at(1) = my_measAFP.yN + my_slopeCalculated.at(1)*(m_parametrizationPosition - m_detectorPositionNear);
145 
146  ATH_MSG_DEBUG("Reconstructing proton with bisection method...");
147  ATH_MSG_DEBUG("Tracks (xNear, yNear; xFar, yFar): " << my_measAFP.xN << ", " << my_measAFP.yN << "; "
148  << my_measAFP.xF << ", " << my_measAFP.yF);
149 
150  const double energy = bisection(&AFP_ProtonRecoAnalytical::bothStations, my_measAFP, my_slopeCalculated, my_positionCalculated);
151  const double slopeX = calculateXslope(energy,my_slopeCalculated);
152  const double slopeY = calculateYslope(energy,my_slopeCalculated);
153 
154  const double px = energy * slopeX;
155  const double py = energy * slopeY;
156  const double pz = energy * sqrt(1. - slopeX*slopeX - slopeY*slopeY);
157 
158  return createProton({px, py, pz}, my_measAFP, xAOD::AFPProtonRecoAlgID::analytical, outputContainer);
159 }

◆ singleStation()

double AFP_ProtonRecoAnalytical::singleStation ( double  energy,
const Measurement my_measAFP,
std::vector< double > &  my_slopeCalculated,
std::vector< double > &  my_positionCalculated 
) const
private

Function obtained from parameterization equation.

Used in bisection method for single station reconstruction.

Definition at line 205 of file AFP_ProtonRecoAnalytical.cxx.

205  {
206 
207  const double xi = 1.0 - energy / m_parametrizationEnergy;
208  const double xNear = my_measAFP.xF - m_distanceBetweenStations * m_parametrization->sx(m_vertexIP.at(0), m_vertexIP.at(1), m_vertexIP.at(2), 0, 0, energy);
209 
210  const double Ax = m_parametrization->getEquation(0)->getPolynomial(0)->Eval(xi);
211  const double Bx = m_parametrization->getEquation(0)->getPolynomial(1)->Eval(xi);
212  const double Dx = m_parametrization->getEquation(0)->getPolynomial(3)->Eval(xi);
213 
214  return xNear - Ax - m_vertexIP.at(0)*Bx - m_vertexIP.at(2)*Dx;
215 }

Member Data Documentation

◆ m_allowSingleStationReco

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

Definition at line 76 of file AFP_ProtonRecoBase.h.

◆ m_detectorPositionFar

double AFP_ProtonRecoBase::m_detectorPositionFar = 0.0
protectedinherited

Default position of AFP far station.

Definition at line 95 of file AFP_ProtonRecoBase.h.

◆ m_detectorPositionNear

double AFP_ProtonRecoBase::m_detectorPositionNear = 0.0
protectedinherited

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"}
protectedinherited

Definition at line 70 of file AFP_ProtonRecoBase.h.

◆ m_distanceBetweenStations

double AFP_ProtonRecoAnalytical::m_distanceBetweenStations = 0.0
private

Distance between near and far station.

Definition at line 92 of file AFP_ProtonRecoAnalytical.h.

◆ m_parametrization

std::unique_ptr<AFP::Parameterization> AFP_ProtonRecoAnalytical::m_parametrization
private

Pointer to parameterization.

Definition at line 89 of file AFP_ProtonRecoAnalytical.h.

◆ m_parametrizationEnergy

double AFP_ProtonRecoAnalytical::m_parametrizationEnergy = 0.0
private

Parameterization energy.

Definition at line 101 of file AFP_ProtonRecoAnalytical.h.

◆ m_parametrizationFileName

Gaudi::Property<std::string> AFP_ProtonRecoAnalytical::m_parametrizationFileName {this, "parametrizationFileName", "none.txt", "Name of the file containing parameterization"}
private

Name of the file containing parameterization.

Definition at line 95 of file AFP_ProtonRecoAnalytical.h.

◆ m_parametrizationPosition

double AFP_ProtonRecoAnalytical::m_parametrizationPosition = 0.0
private

Position for which parameterization was performed.

Definition at line 98 of file AFP_ProtonRecoAnalytical.h.

◆ m_protonsContainerName

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

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"}
protectedinherited

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"}
protectedinherited

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"}
protectedinherited

Definition at line 74 of file AFP_ProtonRecoBase.h.

◆ m_vertexIP

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

Vertex position.

Definition at line 105 of file AFP_ProtonRecoBase.h.

◆ m_xSigma

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

x-Sigma value

Definition at line 98 of file AFP_ProtonRecoBase.h.

◆ m_ySigma

constexpr double AFP_ProtonRecoBase::m_ySigma = 30e-6
staticconstexprprotectedinherited

y-Sigma value

Definition at line 101 of file AFP_ProtonRecoBase.h.


The documentation for this class was generated from the following files:
AFP_ProtonRecoAnalytical::m_parametrization
std::unique_ptr< AFP::Parameterization > m_parametrization
Pointer to parameterization.
Definition: AFP_ProtonRecoAnalytical.h:89
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
AFP_ProtonRecoAnalytical::calculateYslope
double calculateYslope(double energy, std::vector< double > &my_slopeCalculated) const
Calculates initial vertical slope Calls calculateSlope(energy, 1)
Definition: AFP_ProtonRecoAnalytical.cxx:242
AFP_ProtonRecoAnalytical::m_parametrizationPosition
double m_parametrizationPosition
Position for which parameterization was performed.
Definition: AFP_ProtonRecoAnalytical.h:98
generateReferenceFile.fun
fun
Definition: generateReferenceFile.py:18
xAOD::AFPTrack_v2
Class representing a track reconstructed in AFP.
Definition: AFPTrack_v2.h:37
fitman.sy
sy
Definition: fitman.py:524
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
PathResolver::RecursiveSearch
@ RecursiveSearch
Definition: PathResolver.h:28
AFP_ProtonRecoAnalytical::calculateXslope
double calculateXslope(double energy, std::vector< double > &my_slopeCalculated) const
Calculates initial horizontal slope Calls calculateSlope(energy, 0)
Definition: AFP_ProtonRecoAnalytical.cxx:236
AFP_ProtonRecoAnalytical::bisection
double bisection(double(AFP_ProtonRecoAnalytical::*fun)(double, const Measurement &, std::vector< double > &, std::vector< double > &) const, const Measurement &my_measAFP, std::vector< double > &my_slopeCalculated, std::vector< double > &my_positionCalculated) const
Calculates root of given function.
Definition: AFP_ProtonRecoAnalytical.cxx:92
test_pyathena.px
px
Definition: test_pyathena.py:18
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
max
#define max(a, b)
Definition: cfImp.cxx:41
AFP_ProtonRecoBase::reco
virtual xAOD::AFPProton * reco(const xAOD::AFPTrack *, const xAOD::AFPTrack *, std::unique_ptr< xAOD::AFPProtonContainer > &) const
Definition: AFP_ProtonRecoBase.h:108
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
OfflineHitType::Measurement
@ Measurement
python.compressB64.sx
string sx
Definition: compressB64.py:96
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
AFP_ProtonRecoBase::AFP_ProtonRecoBase
AFP_ProtonRecoBase(const std::string &type, const std::string &name, const IInterface *parent)
Default constructor.
Definition: AFP_ProtonRecoBase.cxx:9
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AFP_ProtonRecoBase::m_trackDistance
Gaudi::Property< double > m_trackDistance
Definition: AFP_ProtonRecoBase.h:74
MCP::ScaleSmearParam::r2
@ r2
AFP_ProtonRecoAnalytical::bothStations
double bothStations(double energy, const Measurement &my_measAFP, std::vector< double > &my_slopeCalculated, std::vector< double > &my_positionCalculated) const
Function obtained from parameterization equation.
Definition: AFP_ProtonRecoAnalytical.cxx:178
x
#define x
LArGeo::Fx
GeoGenfun::FunctionNoop Fx(double r, GeoGenfun::GENFUNCTION G, const double Cenx[], const double Ceny[])
Definition: BarrelAuxFunctions.cxx:16
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
AFP_ProtonRecoAnalytical::m_parametrizationFileName
Gaudi::Property< std::string > m_parametrizationFileName
Name of the file containing parameterization.
Definition: AFP_ProtonRecoAnalytical.h:95
xAOD::AFPProtonRecoAlgID::analytical
static constexpr int analytical
analytical algorithm id=0
Definition: AFPProtonRecoAlgID.h:47
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
python.getCurrentFolderTag.fn
fn
Definition: getCurrentFolderTag.py:65
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
ParticleGun_EoverP_Config.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:63
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AFP_ProtonRecoBase::createProton
xAOD::AFPProton * createProton(const Momentum &momentum, const Measurement &my_measAFP, const int algID, std::unique_ptr< xAOD::AFPProtonContainer > &outputContainer) const
Creates and sets up a proton.
Definition: AFP_ProtonRecoBase.cxx:94
AFP_ProtonRecoBase::m_detectorPositionNear
double m_detectorPositionNear
Default position of AFP near station.
Definition: AFP_ProtonRecoBase.h:92
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_ProtonRecoAnalytical::calculateSlope
double calculateSlope(double energy, int XorY, std::vector< double > &my_slopeCalculated) const
Calculates ininial slope based on measurements and reconstructed energy.
Definition: AFP_ProtonRecoAnalytical.cxx:218
AFP_ProtonRecoAnalytical::m_distanceBetweenStations
double m_distanceBetweenStations
Distance between near and far station.
Definition: AFP_ProtonRecoAnalytical.h:92
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
AFP_ProtonRecoBase::m_allowSingleStationReco
Gaudi::Property< bool > m_allowSingleStationReco
Definition: AFP_ProtonRecoBase.h:76
AFP_ProtonRecoBase::m_detectorPositions
Gaudi::Property< std::vector< double > > m_detectorPositions
Definition: AFP_ProtonRecoBase.h:70
AFP_ProtonRecoAnalytical::m_parametrizationEnergy
double m_parametrizationEnergy
Parameterization energy.
Definition: AFP_ProtonRecoAnalytical.h:101
min
#define min(a, b)
Definition: cfImp.cxx:40
AFP_ProtonRecoBase::m_xSigma
static constexpr double m_xSigma
x-Sigma value
Definition: AFP_ProtonRecoBase.h:98
Amg::py
@ py
Definition: GeoPrimitives.h:39
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
AFP_ProtonRecoBase::m_side
Gaudi::Property< int > m_side
Definition: AFP_ProtonRecoBase.h:72
xAOD::proton
@ proton
Definition: TrackingPrimitives.h:198
AFP_ProtonRecoBase::m_ySigma
static constexpr double m_ySigma
y-Sigma value
Definition: AFP_ProtonRecoBase.h:101
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_ProtonRecoAnalytical::singleStation
double singleStation(double energy, const Measurement &my_measAFP, std::vector< double > &my_slopeCalculated, std::vector< double > &my_positionCalculated) const
Function obtained from parameterization equation.
Definition: AFP_ProtonRecoAnalytical.cxx:205
AFP_ProtonRecoBase::m_protonsContainerName
Gaudi::Property< std::string > m_protonsContainerName
Definition: AFP_ProtonRecoBase.h:80
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AFP_ProtonRecoBase::m_vertexIP
const std::vector< double > m_vertexIP
Vertex position.
Definition: AFP_ProtonRecoBase.h:105
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
LArG4GenerateShowerLib.parametrization
parametrization
Definition: LArG4GenerateShowerLib.py:19
AFP_ProtonRecoBase::m_detectorPositionFar
double m_detectorPositionFar
Default position of AFP far station.
Definition: AFP_ProtonRecoBase.h:95