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

#include <CalibrationFileIOTool.h>

Inheritance diagram for MuonCalib::CalibrationFileIOTool:
Collaboration diagram for MuonCalib::CalibrationFileIOTool:

Public Member Functions

 CalibrationFileIOTool (const std::string &t, const std::string &n, const IInterface *p)
 constructor More...
 
StatusCode WriteT0 (const MdtTubeFitContainer *t0_output, const NtupleStationId &station_id, int, int) override
 write out t0 More...
 
StatusCode WriteRt (const RtCalibrationOutput *rt_relation, std::shared_ptr< const IRtResolution > resolution, const NtupleStationId &station_id, int, int, bool, bool) override
 write rt More...
 
StatusCode LoadT0 (std::map< NtupleStationId, MdtStationT0Container * > &t0s, int) override
 load t0s More...
 
StatusCode LoadRt (std::map< NtupleStationId, IRtRelation * > &rts, std::map< NtupleStationId, IRtResolution * > &res, int) override
 load rts More...
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 interface method More...
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
 
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

bool fill_rt (std::unique_ptr< RtDataFromFile::RtRelation > &rt, const std::shared_ptr< const IRtRelation > &new_rt, const std::shared_ptr< const MuonCalib::IRtResolution > &resolut)
 fill rt relation More...
 
void read_rt_relation (const std::string &fname, std::map< NtupleStationId, IRtRelation * > &rts, std::map< NtupleStationId, IRtResolution * > &res, const MuonCalib::NtupleStationId &id)
 create the rt relation and resolution More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Static Private Member Functions

static bool interpret_chamber_name (const std::string &nm, const char *prefix, std::string &station, int &eta, int &phi, int &ml)
 extract station identifier from file name More...
 

Private Attributes

std::string m_calib_dir
 path to calibration directory - job option More...
 
bool m_use_fixed_id
 use fixed identifier if set tot true - job option More...
 
bool m_rt_lookup
 create rt relation as lookup table if set tot true - job option More...
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

Definition at line 17 of file CalibrationFileIOTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ CalibrationFileIOTool()

MuonCalib::CalibrationFileIOTool::CalibrationFileIOTool ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

constructor

Definition at line 43 of file CalibrationFileIOTool.cxx.

43  :
44  AthAlgTool(t, n, p), m_calib_dir("calibration"), m_use_fixed_id(false), m_rt_lookup(true) {
45  declareInterface<ICalibrationIOTool>(this);
46  declareProperty("outputLocation", m_calib_dir);
47  declareProperty("UseFixedId", m_use_fixed_id);
48  declareProperty("RtRelationLookup", m_rt_lookup);
49  }

Member Function Documentation

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKeyArray>

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleBase>

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( ) const
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase &  ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ fill_rt()

bool MuonCalib::CalibrationFileIOTool::fill_rt ( std::unique_ptr< RtDataFromFile::RtRelation > &  rt,
const std::shared_ptr< const IRtRelation > &  new_rt,
const std::shared_ptr< const MuonCalib::IRtResolution > &  resolut 
)
private

fill rt relation

Definition at line 153 of file CalibrationFileIOTool.cxx.

154  {
156  // VARIABLES //
158  const CalibFunc::ParVec &rt_param = new_rt->parameters();
159  // parameters of the r-t relationship to be copied
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);
162 
164  // FILL THE r-t CLASS //
166 
167  // case 1: r-t relationship is stored in the class RtChebyshev //
168  if (rt_Chebyshev) {
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);
174  double radius(rt_Chebyshev->radius(time));
175  double resol(0.0);
176  resol = resolut->resolution(time);
177  if (std::isnan(time) || std::isnan(radius) || std::isnan(resol)) {
178  ATH_MSG_FATAL("Filling nan into rt relation!");
179  // return false;
180  }
181  rt->addEntry(time, radius, resol);
182  }
183  }
184 
185  // case 2: r-t relationship is stored in the class RtRelationLookUp //
186  if (rt_lookup) {
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]);
192  double resol(0.0);
193 
194  resol = resolut->resolution(t_min + bin_size * k);
195  if (std::isnan(radius) || std::isnan(resol)) {
196  ATH_MSG_FATAL("Filling nan into rt relation!");
197  // return false;
198  }
199  rt->addEntry(t_min + bin_size * k, rt_param[k + 2], resol);
200  }
201  }
202 
204  // DECLARE THE NEW r-t RELATIONSHIP VALID //
206  if (new_rt->HasTmaxDiff()) rt->addEntry(new_rt->GetTmaxDiff(), -9999, 0);
207  rt->isValid(1);
208 
209  return true;
210  } // end CalibrationFileIOTool::fill_rt

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

static const InterfaceID& MuonCalib::ICalibrationIOTool::interfaceID ( )
inlinestaticinherited

interface method

Definition at line 35 of file ICalibrationIOTool.h.

35  {
36  static const InterfaceID IID_CalibrationIOTool("MuonCalib::ICalibrationIOTool", 1, 0);
37  return IID_CalibrationIOTool;
38  }

◆ interpret_chamber_name()

bool MuonCalib::CalibrationFileIOTool::interpret_chamber_name ( const std::string &  nm,
const char *  prefix,
std::string &  station,
int &  eta,
int &  phi,
int &  ml 
)
inlinestaticprivate

extract station identifier from file name

Definition at line 212 of file CalibrationFileIOTool.cxx.

213  {
214  // check if name begins with the prefix
215  std::string prefix_st(prefix);
216  if (!nm.starts_with( prefix_st)) return false;
217  // check if filename ends in .dat
218  if (!CxxUtils::ends_with (nm, ".dat")) return false;
219  // cut prefix and suffix from filename
220  std::string cutout(nm, prefix_st.size(), nm.size() - 4 - prefix_st.size());
221  // extract station name
222  int uscore_pos(cutout.find('_'));
223  if (uscore_pos <= 0) return false;
224  station = std::string(cutout, 0, uscore_pos);
225  // get eta, phi, and multilayer
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;
230  return true;
231  }

◆ LoadRt()

StatusCode MuonCalib::CalibrationFileIOTool::LoadRt ( std::map< NtupleStationId, IRtRelation * > &  rts,
std::map< NtupleStationId, IRtResolution * > &  res,
int   
)
overridevirtual

load rts

Implements MuonCalib::ICalibrationIOTool.

Definition at line 126 of file CalibrationFileIOTool.cxx.

127  {
128  rts.clear();
129  res.clear();
130  DIR *directory(opendir((m_calib_dir + "/rts").c_str()));
131  if (directory == nullptr) return StatusCode::SUCCESS;
132  // According to `man readdir` this is thread-safe in "modern glibc" if
133  // used on different directory streams, which would be the case here:
134  struct dirent *dent ATLAS_THREAD_SAFE;
135  // loop on all files in directory
136  while ((dent = readdir(directory)) != nullptr) {
137  std::string nm(dent->d_name);
138  std::string station_str;
139  int eta, phi, ml;
140  // interpret filename and check if it is an t0 file
141  if (!interpret_chamber_name(nm, "Rt_", station_str, eta, phi, ml)) continue;
143  if (!id.Initialize(station_str, eta, phi, ml)) continue;
144  ATH_MSG_INFO("Reading rt for " << station_str << "_" << eta << "_" << phi << "_" << ml);
145  // read rt ralation
146  read_rt_relation((m_calib_dir + "/rts/" + nm), rts, res, id);
147  ATH_MSG_INFO("Read rt for " << id.regionId());
148  }
149  closedir(directory);
150  return StatusCode::SUCCESS;
151  }

◆ LoadT0()

StatusCode MuonCalib::CalibrationFileIOTool::LoadT0 ( std::map< NtupleStationId, MdtStationT0Container * > &  t0s,
int   
)
overridevirtual

load t0s

Implements MuonCalib::ICalibrationIOTool.

Definition at line 94 of file CalibrationFileIOTool.cxx.

94  {
95  ATH_MSG_INFO("Reading calibration from '" << (m_calib_dir + "/t0s") << "'");
96  t0s.clear();
97  DIR *directory(opendir((m_calib_dir + "/t0s").c_str()));
98  if (directory == nullptr) return StatusCode::SUCCESS;
99  // According to `man readdir` this is thread-safe in "modern glibc" if
100  // used on different directory streams, which would be the case here:
101  struct dirent *dent ATLAS_THREAD_SAFE;
102  // loop on all files in directory
103  while ((dent = readdir(directory)) != nullptr) {
104  std::string nm(dent->d_name);
105  std::string station_str;
106  int eta, phi, ml;
107  // interpret filename and check if it is an t0 file
108  if (!interpret_chamber_name(nm, "T0", station_str, eta, phi, ml)) continue;
109  // store
111  if (!id.Initialize(station_str, eta, phi, ml)) continue;
112  ATH_MSG_INFO("Reading t0 for " << station_str << "_" << eta << "_" << phi);
113  MuonCalib::MdtStationT0Container *t0_container = new MuonCalib::MdtStationT0Container((m_calib_dir + "/t0s/" + nm).c_str());
114  if (t0_container->t0_loaded()) {
115  t0s[id] = t0_container;
116  ATH_MSG_INFO("Read t0 for " << id.regionId());
117  } else {
118  ATH_MSG_ERROR("t0 file for " << id.regionId() << " is corrupted!");
119  delete t0_container;
120  }
121  }
122  closedir(directory);
123  return StatusCode::SUCCESS;
124  }

◆ msg() [1/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ outputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ read_rt_relation()

void MuonCalib::CalibrationFileIOTool::read_rt_relation ( const std::string &  fname,
std::map< NtupleStationId, IRtRelation * > &  rts,
std::map< NtupleStationId, IRtResolution * > &  res,
const MuonCalib::NtupleStationId id 
)
inlineprivate

create the rt relation and resolution

Definition at line 233 of file CalibrationFileIOTool.cxx.

235  {
236  // open file
237  std::ifstream infile(fname.c_str());
238  if (infile.fail()) {
239  ATH_MSG_ERROR("Cannot open file '" << fname << "' for reading!");
240  return;
241  }
242  // sample points
243  std::vector<double> r, t, res;
244  std::string sdummy;
245  double dummy;
246  // ignore the first line
247  getline(infile, sdummy);
248  // read table
249  float multilayer_diff(9e9);
250  while (!(infile.eof() || infile.fail())) {
251  infile >> dummy;
252  if (infile.eof() || infile.fail() || dummy > 15.0) break;
253  if (dummy < -9998) {
254  infile >> multilayer_diff;
255  infile >> dummy;
256  } else {
257  r.push_back(dummy);
258  infile >> dummy;
259  t.push_back(dummy);
260  infile >> dummy;
261  res.push_back(dummy);
262  }
263  }
264  if (r.size() < 3) {
265  ATH_MSG_WARNING("Not enough good rt points for " << id.regionId() << "!");
266  return;
267  }
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);
273  }
274  // convert rt relation
275  MuonCalib::RtFromPoints rt_from_points;
276  if (m_rt_lookup) {
278  } else {
280  }
281  if (multilayer_diff < 8e8) rts[id]->SetTmaxDiff(multilayer_diff);
282  // create resolution function
283  MuonCalib::RtResolutionFromPoints res_from_points;
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);
288  }
290  } // end CalibrationFileIOTool::read_rt_relation

◆ renounce()

std::enable_if_t<std::is_void_v<std::result_of_t<decltype(&T::renounce)(T)> > && !std::is_base_of_v<SG::VarHandleKeyArray, T> && std::is_base_of_v<Gaudi::DataHandle, T>, void> AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase &  )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

◆ WriteRt()

StatusCode MuonCalib::CalibrationFileIOTool::WriteRt ( const RtCalibrationOutput rt_relation,
std::shared_ptr< const IRtResolution resolution,
const NtupleStationId station_id,
int  ,
int  ,
bool  ,
bool   
)
overridevirtual

write rt

Implements MuonCalib::ICalibrationIOTool.

Definition at line 70 of file CalibrationFileIOTool.cxx.

72  {
73  RtDataFromFile rt_data;
74  std::shared_ptr<const IRtRelation> new_rt = rt_relation->rt();
75  std::unique_ptr<RtDataFromFile::RtRelation> rt = std::make_unique<RtDataFromFile::RtRelation>();
76  if (m_use_fixed_id) {
77  rt->setRegionId(station_id.FixedId());
78  rt_data.setVersion(2, 0);
79  } else {
80  if (station_id.RegionHash() != 0) { rt->setRegionId(station_id.RegionHash()); }
81  }
82  int rt_region_id(0);
83  rt_data.setNRts(1);
84  rt_data.addRt(rt_region_id, rt.get(), rt_relation->fullInfo().get());
85  if (!fill_rt(rt, new_rt, resolution)) return StatusCode::FAILURE;
86  // write out the r-t relationship //
87  system(("mkdir -p " + m_calib_dir + "/rts").c_str());
88  std::string rt_file_name(m_calib_dir + "/rts/Rt_" + station_id.regionId() + ".dat");
89  std::ofstream output_file(rt_file_name.c_str());
90  rt_data.write(output_file, rt_region_id);
91  return StatusCode::SUCCESS;
92  }

◆ WriteT0()

StatusCode MuonCalib::CalibrationFileIOTool::WriteT0 ( const MdtTubeFitContainer t0_output,
const NtupleStationId station_id,
int  ,
int   
)
overridevirtual

write out t0

Implements MuonCalib::ICalibrationIOTool.

Definition at line 51 of file CalibrationFileIOTool.cxx.

52  {
53  // create directory
54  system(("mkdir -p " + m_calib_dir + "/t0s").c_str());
55  // open file
56  std::string t0_file_name(m_calib_dir + "/t0s/T0" + station_id.regionId() + ".dat");
57  std::ofstream output_file(t0_file_name.c_str());
58  if (output_file.fail()) {
59  ATH_MSG_ERROR("Could not open t0 file " << t0_file_name << "!");
60  return StatusCode::FAILURE;
61  }
62  // write
63  TubeDataFromFile t0_file;
64  t0_file.setNRegions(1);
65  t0_file.addTubes(0, t0_output);
66  t0_file.write(output_file);
67  return StatusCode::SUCCESS;
68  }

Member Data Documentation

◆ m_calib_dir

std::string MuonCalib::CalibrationFileIOTool::m_calib_dir
private

path to calibration directory - job option

Definition at line 35 of file CalibrationFileIOTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_rt_lookup

bool MuonCalib::CalibrationFileIOTool::m_rt_lookup
private

create rt relation as lookup table if set tot true - job option

Definition at line 39 of file CalibrationFileIOTool.h.

◆ m_use_fixed_id

bool MuonCalib::CalibrationFileIOTool::m_use_fixed_id
private

use fixed identifier if set tot true - job option

Definition at line 37 of file CalibrationFileIOTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files:
MuonCalib::CalibrationFileIOTool::fill_rt
bool fill_rt(std::unique_ptr< RtDataFromFile::RtRelation > &rt, const std::shared_ptr< const IRtRelation > &new_rt, const std::shared_ptr< const MuonCalib::IRtResolution > &resolut)
fill rt relation
Definition: CalibrationFileIOTool.cxx:153
beamspotman.r
def r
Definition: beamspotman.py:676
MuonCalib::CalibrationFileIOTool::read_rt_relation
void read_rt_relation(const std::string &fname, std::map< NtupleStationId, IRtRelation * > &rts, std::map< NtupleStationId, IRtResolution * > &res, const MuonCalib::NtupleStationId &id)
create the rt relation and resolution
Definition: CalibrationFileIOTool.cxx:233
MuonCalib::IRtResolution::resolution
virtual double resolution(double t, double bgRate=0.0) const =0
returns resolution for a give time and background rate
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
run.infile
string infile
Definition: run.py:13
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
MuonCalib::CalibrationFileIOTool::m_use_fixed_id
bool m_use_fixed_id
use fixed identifier if set tot true - job option
Definition: CalibrationFileIOTool.h:37
CxxUtils::ends_with
bool ends_with(const char *s, const char *suffix)
Test whether one null-terminated byte string ends with another.
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
MuonCalib::RtResolutionFromPoints::getRtResolutionChebyshev
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 ...
Definition: RtResolutionFromPoints.cxx:38
MuonCalib::NtupleStationId
Definition: NtupleStationId.h:36
MuonCalib::MdtStationT0Container
Definition: MdtStationT0Container.h:24
MuonCalib::RtChebyshev
Definition: RtChebyshev.h:52
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
MuonCalib::RtRelationLookUp
Equidistant look up table for rt-relations with the time as key.
Definition: RtRelationLookUp.h:24
Dedxcorrection::resolution
double resolution[nGasTypes][nParametersResolution]
Definition: TRT_ToT_Corrections.h:46
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
MuonCalib::RtFromPoints::getRtRelationLookUp
static RtRelationLookUp getRtRelationLookUp(const std::vector< SamplePoint > &sample_points)
Definition: RtFromPoints.cxx:78
MuonCalib::CalibFunc::ParVec
std::vector< double > ParVec
Definition: CalibFunc.h:36
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DeMoScan.directory
string directory
Definition: DeMoScan.py:80
beamspotman.n
n
Definition: beamspotman.py:731
MuonCalib::CalibrationFileIOTool::m_calib_dir
std::string m_calib_dir
path to calibration directory - job option
Definition: CalibrationFileIOTool.h:35
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
MuonCalib::RtFromPoints::getRtChebyshev
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...
Definition: RtFromPoints.cxx:39
python.xAODType.dummy
dummy
Definition: xAODType.py:4
mergePhysValFiles.output_file
output_file
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:27
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
MuonCalib::RtFromPoints
Definition: RtFromPoints.h:30
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:191
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
MuonCalib::MdtStationT0Container::t0_loaded
bool t0_loaded() const
Definition: MdtStationT0Container.h:64
jobOptions.Initialize
Initialize
Definition: jobOptions.pA.py:28
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
MuonCalib::RtResolutionChebyshev
Definition: RtResolutionChebyshev.h:50
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
a
TList * a
Definition: liststreamerinfos.cxx:10
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
h
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
MuonCalib::RtResolutionFromPoints
Definition: RtResolutionFromPoints.h:30
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
calibdata.rts
rts
Definition: calibdata.py:414
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:616
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
MuonCalib::CalibrationFileIOTool::interpret_chamber_name
static bool interpret_chamber_name(const std::string &nm, const char *prefix, std::string &station, int &eta, int &phi, int &ml)
extract station identifier from file name
Definition: CalibrationFileIOTool.cxx:212
fitman.k
k
Definition: fitman.py:528
MuonCalib::CalibrationFileIOTool::m_rt_lookup
bool m_rt_lookup
create rt relation as lookup table if set tot true - job option
Definition: CalibrationFileIOTool.h:39