32 #include <sys/types.h>
42 declareInterface<ICalibrationIOTool>(
this);
49 system((
"mkdir -p " +
m_calib_dir +
"/t0s").c_str());
53 db_file = fopen(t0_dbfile_name.c_str(),
"w");
56 return StatusCode::FAILURE;
63 return StatusCode::SUCCESS;
70 std::shared_ptr<const IRtRelation> new_rt = rt_relation->
rt();
71 std::unique_ptr<RtDataFromFile::RtRelation> rt = std::make_unique<RtDataFromFile::RtRelation>();
74 rt_data.
addRt(rt_region_id, rt.get(), rt_relation->
fullInfo().get());
77 std::string location =
"location";
79 std::string mdt_rt_map_t_id =
"mdt_rt_map_t_id";
80 int mdt_rt_map_r_id = 99;
81 int mdt_rt_map_s_id = 99;
82 system((
"mkdir -p " +
m_calib_dir +
"/rts").c_str());
88 db_rt_file = fopen(rt_dbfile_name.c_str(),
"w");
90 db_rtt_file = fopen(rtt_dbfile_name.c_str(),
"w");
92 db_rtr_file = fopen(rtr_dbfile_name.c_str(),
"w");
94 db_rts_file = fopen(rts_dbfile_name.c_str(),
"w");
95 if (db_rt_file ==
nullptr || db_rtt_file ==
nullptr || db_rtr_file ==
nullptr || db_rts_file ==
nullptr) {
97 if (db_rt_file) fclose(db_rt_file);
98 if (db_rtt_file) fclose(db_rtt_file);
99 if (db_rtr_file) fclose(db_rtr_file);
100 if (db_rts_file) fclose(db_rts_file);
101 return StatusCode::FAILURE;
103 ATH_MSG_INFO(
"Writing out r-t relationships in the files for calibration db.");
108 fprintf(db_rt_file,
" %d,%d,%d,%d,%d,%s,", mdt_rt_id, station_id.
FixedId(), -9999,
iov_start,
iov_end, location.c_str());
109 fprintf(db_rtt_file,
" %s,%d,%d,", mdt_rt_map_t_id.c_str(), mdt_rt_id, mdt_rt_id);
110 fprintf(db_rtr_file,
" %d,%d,%s,", mdt_rt_map_r_id, mdt_rt_id, mdt_rt_map_t_id.c_str());
111 fprintf(db_rts_file,
" %d,%d,", mdt_rt_map_s_id, mdt_rt_id);
112 rt_data.
write_forDB(db_rt_file, db_rtt_file, db_rtr_file, db_rts_file, rt_region_id);
113 ATH_MSG_INFO(
"r-t relationships wrote in the files for calibration db.");
118 return StatusCode::SUCCESS;
122 const std::shared_ptr<const MuonCalib::IRtResolution>& resolut) {
128 std::shared_ptr<const RtChebyshev> rt_Chebyshev = std::dynamic_pointer_cast<const RtChebyshev>(new_rt);
129 std::shared_ptr<const RtRelationLookUp> rt_lookup = std::dynamic_pointer_cast<const RtRelationLookUp>(new_rt);
137 unsigned int nb_points(100);
138 double t_length(rt_Chebyshev->tUpper() - rt_Chebyshev->tLower());
139 double bin_size(t_length /
static_cast<double>(nb_points - 1));
140 for (
unsigned int k = 0;
k < nb_points;
k++) {
141 double time(rt_Chebyshev->tLower() +
k * bin_size);
142 double radius(rt_Chebyshev->radius(time));
145 if (std::isnan(time) || std::isnan(
radius) || std::isnan(resol)) {
149 rt->addEntry(time,
radius, resol);
155 double t_min(rt_param[0]);
156 double bin_size = rt_param[1];
157 unsigned int nb_points(rt_lookup->nPar() - 2);
158 for (
unsigned int k = 0;
k < nb_points;
k++) {
159 double radius(rt_param[
k + 2]);
163 if (std::isnan(
radius) || std::isnan(resol)) {
167 rt->addEntry(t_min + bin_size *
k, rt_param[
k + 2], resol);