|
ATLAS Offline Software
|
Go to the documentation of this file.
35 #include <sys/types.h>
44 AthAlgTool(
t,
n,
p), m_calib_dir(
"calibration"), m_use_fixed_id(false), m_rt_lookup(true) {
45 declareInterface<ICalibrationIOTool>(
this);
54 system((
"mkdir -p " +
m_calib_dir +
"/t0s").c_str());
59 ATH_MSG_ERROR(
"Could not open t0 file " << t0_file_name <<
"!");
60 return StatusCode::FAILURE;
67 return StatusCode::SUCCESS;
74 std::shared_ptr<const IRtRelation> new_rt = rt_relation->
rt();
75 std::unique_ptr<RtDataFromFile::RtRelation> rt = std::make_unique<RtDataFromFile::RtRelation>();
77 rt->setRegionId(station_id.
FixedId());
84 rt_data.
addRt(rt_region_id, rt.get(), rt_relation->
fullInfo().get());
87 system((
"mkdir -p " +
m_calib_dir +
"/rts").c_str());
91 return StatusCode::SUCCESS;
98 if (
directory ==
nullptr)
return StatusCode::SUCCESS;
103 while ((dent = readdir(
directory)) !=
nullptr) {
104 std::string
nm(dent->d_name);
105 std::string station_str;
115 t0s[
id] = t0_container;
118 ATH_MSG_ERROR(
"t0 file for " <<
id.regionId() <<
" is corrupted!");
123 return StatusCode::SUCCESS;
131 if (
directory ==
nullptr)
return StatusCode::SUCCESS;
136 while ((dent = readdir(
directory)) !=
nullptr) {
137 std::string
nm(dent->d_name);
138 std::string station_str;
144 ATH_MSG_INFO(
"Reading rt for " << station_str <<
"_" <<
eta <<
"_" <<
phi <<
"_" << ml);
150 return StatusCode::SUCCESS;
154 const std::shared_ptr<const MuonCalib::IRtResolution>& resolut) {
160 std::shared_ptr<const RtChebyshev> rt_Chebyshev = std::dynamic_pointer_cast<const RtChebyshev>(new_rt);
161 std::shared_ptr<const RtRelationLookUp> rt_lookup = std::dynamic_pointer_cast<const RtRelationLookUp>(new_rt);
169 unsigned int nb_points(100);
170 double t_length(rt_Chebyshev->tUpper() - rt_Chebyshev->tLower());
171 double bin_size(t_length /
static_cast<double>(nb_points - 1));
172 for (
unsigned int k = 0;
k < nb_points;
k++) {
173 double time(rt_Chebyshev->tLower() +
k * bin_size);
177 if (std::isnan(
time) || std::isnan(
radius) || std::isnan(resol)) {
187 double t_min(rt_param[0]);
188 double bin_size = rt_param[1];
189 unsigned int nb_points(rt_lookup->nPar() - 2);
190 for (
unsigned int k = 0;
k < nb_points;
k++) {
191 double radius(rt_param[
k + 2]);
195 if (std::isnan(
radius) || std::isnan(resol)) {
199 rt->addEntry(t_min + bin_size *
k, rt_param[
k + 2], resol);
206 if (new_rt->HasTmaxDiff()) rt->addEntry(new_rt->GetTmaxDiff(), -9999, 0);
215 std::string prefix_st(
prefix);
216 if (!
nm.starts_with( prefix_st))
return false;
218 if (!
nm.ends_with(
".dat"))
return false;
220 std::string cutout(
nm, prefix_st.size(),
nm.size() - 4 - prefix_st.size());
222 int uscore_pos(cutout.find(
'_'));
223 if (uscore_pos <= 0)
return false;
224 station = std::string(cutout, 0, uscore_pos);
226 std::string cutout2(cutout, uscore_pos + 1);
227 int count_items(sscanf(cutout2.c_str(),
"%80d_%80d_%80d", &
phi, &
eta, &ml));
228 if (count_items < 2)
return false;
229 if (count_items != 3) ml = 0;
234 std::map<NtupleStationId, IRtResolution *> &res_map,
243 std::vector<double>
r,
t,
res;
249 float multilayer_diff(9e9);
254 infile >> multilayer_diff;
265 ATH_MSG_WARNING(
"Not enough good rt points for " <<
id.regionId() <<
"!");
268 std::vector<MuonCalib::SamplePoint> point(
r.size());
269 for (
unsigned int k = 0;
k < point.size();
k++) {
270 point[
k].set_x1(
t[
k]);
271 point[
k].set_x2(
r[
k]);
272 point[
k].set_error(1.0);
281 if (multilayer_diff < 8e8)
rts[
id]->SetTmaxDiff(multilayer_diff);
284 for (
unsigned int k = 0;
k < point.size();
k++) {
285 point[
k].set_x1(
t[
k]);
286 point[
k].set_x2(
res[
k]);
287 point[
k].set_error(1.0);
virtual double resolution(double t, double bgRate=0.0) const =0
returns resolution for a give time and background rate
Scalar phi() const
phi method
std::string regionId() const
return the region id string
Scalar eta() const
pseudorapidity method
std::ostream & write(std::ostream &os, int region) const
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
static RtResolutionChebyshev getRtResolutionChebyshev(const std::vector< SamplePoint > &sample_points, const unsigned int &order)
< get an RtResolutionChebyshev resembling the sigma(t) function as described by the sample points in ...
Manages the I/O of the Rt realtions from/to file.
Equidistant look up table for rt-relations with the time as key.
double resolution[nGasTypes][nParametersResolution]
void setNRegions(unsigned int n)
set total number of regions
static RtRelationLookUp getRtRelationLookUp(const std::vector< SamplePoint > &sample_points)
std::ostream & write(std::ostream &os) const
::StatusCode StatusCode
StatusCode definition for legacy code.
std::pair< std::vector< unsigned int >, bool > res
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
std::vector< double > ParVec
static RtChebyshev getRtChebyshev(const std::vector< SamplePoint > &sample_points, const unsigned int &order)
< get an RtChebyshev resembling the r(t) function as described by the sample points in the vector "sa...
bool addRt(int regionId, RtRelation *rt)
RtDataFromFile takes ownership of rt.
void setNRts(unsigned int nrts)
set total number of regions
std::shared_ptr< const IRtRelation > rt() const
access to private attributes
bool addTubes(int regionId, const MdtTubeFitContainer *tubes)
TubeDataFromFile takes ownership of the MdtTubeFitContainer.
void setVersion(int major, int minor)
def time(flags, cells_name, *args, **kw)
#define ATH_MSG_WARNING(x)
Holds single-tube full calibration information of one chamber.
std::shared_ptr< const RtFullInfo > fullInfo() const
#define ATLAS_THREAD_SAFE
Define macros for attributes used to control the static checker.