ATLAS Offline Software
Loading...
Searching...
No Matches
AFPProtonTransportTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4
7#include <fstream>
8#include <math.h>
9
10AFPProtonTransportTool::AFPProtonTransportTool(const std::string & type, const std::string & name, const IInterface* parent) : AthAlgTool(type, name, parent) {
11
12 declareInterface<IAFPProtonTransportTool>(this);
13
14}
15
17
18 ATH_MSG_INFO("AFPProtonTransportTool::initialize Initializing transport tool");
19
20 return StatusCode::SUCCESS;
21}
22
24
26 std::ifstream file;
27 file.open(m_filename);
28 ATH_MSG_INFO("AFPProtonTransportTool::load "<<m_filename);
29 if (!file.is_open()) return StatusCode::FAILURE;
30
31 std::unique_ptr<AFPProtonTransportPolynomial> pol[4][8];
32
33 while (file.peek() == '#') {
34 char ch;
35 std::string name;
36 file >> ch >> name;
37
38 //Fetching variable values from the txt file
39 if (name == "m_xPositionInitIP") {
40 double value;
41 file >> value;
42 m_xPositionInitIP = value;
43 }
44 else if (name == "m_yPositionInitIP") {
45 double value;
46 file >> value;
47 m_yPositionInitIP = value;
48 }
49 else if (name == "m_zPositionInitIP") {
50 double value;
51 file >> value;
52 m_zPositionInitIP = value;
53 }
54 else if (name == "m_xSlopeInitIP") {
55 double value;
56 file >> value;
57 m_xSlopeInitIP = value;
58 }
59 else if (name == "m_ySlopeInitIP") {
60 double value;
61 file >> value;
62 m_ySlopeInitIP = value;
63 }
64 else if (name == "m_detectorPosition") {
65 double value;
66 file >> value;
68 }
69 else if (name == "m_nominalEnergy") {
70 double value;
71 file >> value;
72 m_energy = value;
73 }
74
75 file.ignore(1000, '\n');
76 }
77
78 //Fetching the polynomial coeficients
79 for (int iEqu = 0; iEqu < 4; iEqu++) {
80 file.ignore(1000, '\n');
81 for (int iPoly = 0; iPoly < 8; iPoly++) {
82 int N = 0;
83 file >> N;
84 double ch[10];
85 for (int i = 0; i < 10; i++) {
86 if (i <= N) file >> ch[i];
87 else ch[i] = 0;
88 }
89 file.ignore(1000, '\n');
90
91 //Create polynomial object with the coeficients loaded from the file
92 pol[iEqu][iPoly] =
93 std::make_unique<AFPProtonTransportPolynomial>(N, ch[0], ch[1], ch[2], ch[3], ch[4], ch[5], ch[6], ch[7], ch[8], ch[9]);
94 }
95 }
96 file.close();
97
98 //Creating the Parameterization objects with the polynomials created
99 m_x_position = std::make_unique<AFPProtonTransportParam>(m_energy, pol[0]);
100 m_y_position = std::make_unique<AFPProtonTransportParam>(m_energy, pol[1]);
101 m_x_slope = std::make_unique<AFPProtonTransportParam>(m_energy, pol[2]);
102 m_y_slope = std::make_unique<AFPProtonTransportParam>(m_energy, pol[3]);
103
104 return StatusCode::SUCCESS;
105}
#define ATH_MSG_INFO(x)
Gaudi::Property< double > m_yPositionInitIP
Proton's initial y position at the interaction point.
std::unique_ptr< AFPProtonTransportParam > m_y_slope
AFPProtonTransportParam object used for the y slope.
Gaudi::Property< double > m_xPositionInitIP
Proton's initial x position at the interaction point.
Gaudi::Property< double > m_energy
Nominal beam energy.
Gaudi::Property< double > m_xSlopeInitIP
Beam crossing angle from x axis at the interaction point.
std::unique_ptr< AFPProtonTransportParam > m_x_slope
AFPProtonTransportParam object used for the x slope.
virtual StatusCode initialize() override
Gaudi::Property< double > m_ySlopeInitIP
Beam crossing angle from y axis at the interaction point.
std::unique_ptr< AFPProtonTransportParam > m_y_position
AFPProtonTransportParam object used for the y position evaluation.
AFPProtonTransportTool(const std::string &type, const std::string &name, const IInterface *parent)
std::unique_ptr< AFPProtonTransportParam > m_x_position
AFPProtonTransportParam object used for the x position evaluation.
Gaudi::Property< double > m_parametrisationPosition
Detector position for which the parameterisation has been done.
Gaudi::Property< std::string > m_filename
Gaudi::Property< double > m_zPositionInitIP
Proton's initial z position at the interaction point.
virtual StatusCode load() override
Loads parametrization file and gets the value of positions, slopes and nominal energy....
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
TFile * file