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

#include <MdtCalibInputSvc.h>

Inheritance diagram for MdtCalibInputSvc:
Collaboration diagram for MdtCalibInputSvc:

Public Member Functions

 MdtCalibInputSvc (const std::string &name, ISvcLocator *svc_locator)
 Service constructor. More...
 
virtual ~MdtCalibInputSvc ()
 destructor More...
 
virtual StatusCode initialize () override
 service initalizer - reads files More...
 
const MuonCalib::MdtStationT0ContainerGetT0 (const MuonCalib::NtupleStationId &id) const
 Get t0 container for Station. More...
 
const MuonCalib::IRtRelationGetRtRelation (const MuonCalib::NtupleStationId &id) const
 Get rt relation container. More...
 
const MuonCalib::BFieldCorFuncGetBCorr (const MuonCalib::NtupleStationId &id)
 Get B field correction. More...
 
const MuonCalib::IRtResolutionGetResolution (const MuonCalib::NtupleStationId &id) const
 Get Resolution. More...
 
const MuonCalib::IRtRelationGetRtRelation () const
 Get rt-Relation for calibration region. More...
 
const MuonCalib::BFieldCorFuncGetBCorr ()
 Get b-field correction for calibratino region. More...
 
const MuonCalib::IRtResolutionGetResolution () const
 Get resolution for calibration region. More...
 
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 ()
 

Private Member Functions

bool create_b_field_correction (const MuonCalib::NtupleStationId &id)
 create the b-field correction More...
 
const MuonCalib::BFieldCorFuncfindbfieldfun (const MuonCalib::NtupleStationId &id)
 
void create_mean_rts ()
 create mean rt relations, and resolutions for the selected calibration region More...
 
StatusCode read_calib_input ()
 

Private Attributes

ToolHandle< MuonCalib::ICalibrationIOToolm_calib_input_tool {this, "CalibrationInputTool", "MuonCalib::CalibrationDummyIOTool"}
 calibration io tool to be used More...
 
std::map< MuonCalib::NtupleStationId, MuonCalib::MdtStationT0Container * > m_t0
 calibration data sorted by station id More...
 
std::map< MuonCalib::NtupleStationId, MuonCalib::IRtRelation * > m_rt_relation
 
std::map< MuonCalib::NtupleStationId, MuonCalib::BFieldCorFunc * > m_B_corr
 
std::map< MuonCalib::NtupleStationId, MuonCalib::IRtResolution * > m_spat_res
 
ServiceHandle< RegionSelectionSvcm_reg_sel_svc
 pointer to region selection service More...
 
const MuonCalib::IRtRelationm_sel_region_rt {nullptr}
 rt relation - resolution - and correction function for the selected region - is average of all matching rt relations More...
 
const MuonCalib::BFieldCorFuncm_sel_region_b {nullptr}
 
const MuonCalib::IRtResolutionm_sel_region_res {nullptr}
 
MuonCalib::NtupleStationId m_mean_station_id
 station id for mean rt More...
 
std::set< MuonCalib::NtupleStationId > m_t0_warned ATLAS_THREAD_SAFE
 give warnings about missing calibration only once per chamber More...
 
std::set< MuonCalib::NtupleStationId > m_rt_warned ATLAS_THREAD_SAFE
 

Detailed Description

Athena service which read calibration from text files and sorts them by station id

Author
rausc.nosp@m.her@.nosp@m.cern..nosp@m.ch

Definition at line 30 of file MdtCalibInputSvc.h.

Constructor & Destructor Documentation

◆ MdtCalibInputSvc()

MdtCalibInputSvc::MdtCalibInputSvc ( const std::string &  name,
ISvcLocator *  svc_locator 
)

Service constructor.

Definition at line 22 of file MdtCalibInputSvc.cxx.

22  :
23  AthService(name, svc_locator), m_reg_sel_svc("RegionSelectionSvc", name) {
24  declareProperty("RegionSelectionSvc", m_reg_sel_svc);
25 }

◆ ~MdtCalibInputSvc()

MdtCalibInputSvc::~MdtCalibInputSvc ( )
virtual

destructor

Definition at line 27 of file MdtCalibInputSvc.cxx.

27  {
29  for (it1 = m_t0.begin(); it1 != m_t0.end(); ++it1) delete it1->second;
31  for (it2 = m_rt_relation.begin(); it2 != m_rt_relation.end(); ++it2) delete it2->second;
33  for (it3 = m_B_corr.begin(); it3 != m_B_corr.end(); ++it3) delete it3->second;
35  for (it4 = m_spat_res.begin(); it4 != m_spat_res.end(); ++it4) delete it4->second;
36 }

Member Function Documentation

◆ create_b_field_correction()

bool MdtCalibInputSvc::create_b_field_correction ( const MuonCalib::NtupleStationId id)
private

create the b-field correction

Definition at line 114 of file MdtCalibInputSvc.cxx.

114  {
115  std::map<MuonCalib::NtupleStationId, MuonCalib::IRtRelation *>::const_iterator it(m_rt_relation.find(id));
116  if (it == m_rt_relation.end()) return false;
117  ATH_MSG_INFO("Initiailizing B-Field correction for " << id.regionId());
118  const MuonCalib::IRtRelation *rt_rel(it->second);
119  // create magnetic field correction
120  std::vector<double> corr_params(2);
121  corr_params[0] = 3080.0; // high voltage
122  corr_params[1] = 0.11; // epsilon parameter
123  m_B_corr[id] = new MuonCalib::BFieldCorFunc(corr_params, rt_rel);
124  return true;
125 }

◆ create_mean_rts()

void MdtCalibInputSvc::create_mean_rts ( )
private

create mean rt relations, and resolutions for the selected calibration region

Definition at line 127 of file MdtCalibInputSvc.cxx.

127  {
128  ATH_MSG_INFO("MdtCalibInputSvc::create_mean_rts()");
129  std::list<const MuonCalib::IRtRelation *> matching_relations;
130  std::list<MuonCalib::NtupleStationId> matching_ids;
131  // loop over all rts
132  for (std::map<MuonCalib::NtupleStationId, MuonCalib::IRtRelation *>::const_iterator it = m_rt_relation.begin();
133  it != m_rt_relation.end(); ++it) {
135  // if the rt relation is stored per chamber, check both multilayers
136  if (it->first.GetMl() == 0) {
137  id.set_mdt();
138  for (int i = 1; i <= 2; i++) {
139  id.setStationName(it->first.GetStation());
140  id.setStationEta(it->first.GetEta());
141  id.setStationPhi(it->first.GetPhi());
142  id.setMdtMultilayer(i);
143  if (m_reg_sel_svc->isInRegion(id)) {
144  matching_relations.push_back(it->second);
145  matching_ids.push_back(it->first);
146  break;
147  }
148  }
149  } else {
150  id.setStationName(it->first.GetStation());
151  id.setStationEta(it->first.GetEta());
152  id.setStationPhi(it->first.GetPhi());
153  id.setMdtMultilayer(it->first.GetMl());
154  if (m_reg_sel_svc->isInRegion(id)) {
155  matching_relations.push_back(it->second);
156  matching_ids.push_back(it->first);
157  }
158  }
159  }
160 
161  ATH_MSG_INFO("Found " << matching_relations.size() << " rt-relations for calibration region");
162  if (matching_relations.empty()) return;
163  // averageing over rt relations is not yet implemented - take the first found
164  if (matching_relations.size() > 1) { ATH_MSG_WARNING("More than one rt relation for this region loaded! Taking first!"); }
165  m_sel_region_rt = *(matching_relations.begin());
166  m_mean_station_id = *(matching_ids.begin());
167  m_sel_region_res = GetResolution(*(matching_ids.begin()));
168 } // end MdtCalibInputSvc::create_mean_rts

◆ findbfieldfun()

const MuonCalib::BFieldCorFunc * MdtCalibInputSvc::findbfieldfun ( const MuonCalib::NtupleStationId id)
private

Definition at line 170 of file MdtCalibInputSvc.cxx.

170  {
171  std::map<MuonCalib::NtupleStationId, MuonCalib::BFieldCorFunc *>::const_iterator it(m_B_corr.find(id));
172  if (it == m_B_corr.end()) {
173  if (!create_b_field_correction(id)) return nullptr;
174  return findbfieldfun(id);
175  }
176  return it->second;
177 }

◆ GetBCorr() [1/2]

const MuonCalib::BFieldCorFunc* MdtCalibInputSvc::GetBCorr ( )
inline

Get b-field correction for calibratino region.

Definition at line 56 of file MdtCalibInputSvc.h.

56  {
58  return m_sel_region_b;
59  }

◆ GetBCorr() [2/2]

const MuonCalib::BFieldCorFunc * MdtCalibInputSvc::GetBCorr ( const MuonCalib::NtupleStationId id)

Get B field correction.

Definition at line 83 of file MdtCalibInputSvc.cxx.

83  {
85  if ((fun = findbfieldfun(id)) != nullptr) return fun;
87  chamber_id.SetMultilayer(0);
88  return findbfieldfun(chamber_id);
89 }

◆ GetResolution() [1/2]

const MuonCalib::IRtResolution* MdtCalibInputSvc::GetResolution ( ) const
inline

Get resolution for calibration region.

Definition at line 61 of file MdtCalibInputSvc.h.

61 { return m_sel_region_res; }

◆ GetResolution() [2/2]

const MuonCalib::IRtResolution * MdtCalibInputSvc::GetResolution ( const MuonCalib::NtupleStationId id) const

Get Resolution.

Definition at line 91 of file MdtCalibInputSvc.cxx.

91  {
92  std::map<MuonCalib::NtupleStationId, MuonCalib::IRtResolution *>::const_iterator it;
93  if ((it = m_spat_res.find(id)) == m_spat_res.end()) {
95  chamber_id.SetMultilayer(0);
96  if ((it = m_spat_res.find(chamber_id)) == m_spat_res.end()) {
97  if (m_rt_warned.find(chamber_id) == m_rt_warned.end()) {
98  ATH_MSG_FATAL("Rt relation not loaded for station");
99  m_rt_warned.insert(chamber_id);
100  }
101  return nullptr;
102  }
103  }
104  return it->second;
105 }

◆ GetRtRelation() [1/2]

const MuonCalib::IRtRelation* MdtCalibInputSvc::GetRtRelation ( ) const
inline

Get rt-Relation for calibration region.

Definition at line 54 of file MdtCalibInputSvc.h.

54 { return m_sel_region_rt; }

◆ GetRtRelation() [2/2]

const MuonCalib::IRtRelation * MdtCalibInputSvc::GetRtRelation ( const MuonCalib::NtupleStationId id) const

Get rt relation container.

Definition at line 65 of file MdtCalibInputSvc.cxx.

65  {
66  static std::mutex warn_mutex;
67  std::map<MuonCalib::NtupleStationId, MuonCalib::IRtRelation *>::const_iterator it;
68  if ((it = m_rt_relation.find(id)) == m_rt_relation.end()) {
70  chamber_id.SetMultilayer(0);
71  if ((it = m_rt_relation.find(chamber_id)) == m_rt_relation.end()) {
72  std::lock_guard<std::mutex> guard(warn_mutex);
73  if (m_rt_warned.find(chamber_id) == m_rt_warned.end()) {
74  ATH_MSG_WARNING("Rt relation not loaded for station" << chamber_id.regionId());
75  m_rt_warned.insert(chamber_id);
76  }
77  return nullptr;
78  }
79  }
80  return it->second;
81 }

◆ GetT0()

const MuonCalib::MdtStationT0Container * MdtCalibInputSvc::GetT0 ( const MuonCalib::NtupleStationId id) const

Get t0 container for Station.

Definition at line 47 of file MdtCalibInputSvc.cxx.

47  {
48  static std::mutex warn_mutex;
49  std::map<MuonCalib::NtupleStationId, MuonCalib::MdtStationT0Container *>::const_iterator it;
50  if ((it = m_t0.find(id)) == m_t0.end()) {
52  chamber_id.SetMultilayer(0);
53  if ((it = m_t0.find(chamber_id)) == m_t0.end()) {
54  std::lock_guard<std::mutex> guard(warn_mutex);
55  if (m_t0_warned.find(chamber_id) == m_t0_warned.end()) {
56  ATH_MSG_WARNING("T0 not loaded for station " << id.regionId());
57  m_t0_warned.insert(chamber_id);
58  }
59  return nullptr;
60  }
61  }
62  return it->second;
63 }

◆ initialize()

StatusCode MdtCalibInputSvc::initialize ( )
overridevirtual

service initalizer - reads files

Definition at line 38 of file MdtCalibInputSvc.cxx.

38  {
39  ATH_MSG_INFO("initialize()");
40  // get region selection service
41  ATH_CHECK(m_reg_sel_svc.retrieve());
42  ATH_CHECK(m_calib_input_tool.retrieve());
44  return StatusCode::SUCCESS;
45 }

◆ interfaceID()

static const InterfaceID& MdtCalibInputSvc::interfaceID ( )
inlinestatic

Definition at line 37 of file MdtCalibInputSvc.h.

37  {
38  // interface to enable retrieving of a pointer to the singleton //
39  static const InterfaceID IID_IMdtCalibInputSvc("MdtCalibInputSvc", 1, 0);
40  return IID_IMdtCalibInputSvc;
41  }

◆ msg() [1/2]

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msg() [2/2]

MsgStream& AthCommonMsg< Service >::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< Service >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

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

◆ read_calib_input()

StatusCode MdtCalibInputSvc::read_calib_input ( )
private

Definition at line 107 of file MdtCalibInputSvc.cxx.

107  {
108  ATH_CHECK(m_calib_input_tool->LoadT0(m_t0, -1));
110  create_mean_rts();
111  return StatusCode::SUCCESS;
112 }

Member Data Documentation

◆ ATLAS_THREAD_SAFE [1/2]

std::set<MuonCalib::NtupleStationId> m_t0_warned MdtCalibInputSvc::ATLAS_THREAD_SAFE
mutableprivate

give warnings about missing calibration only once per chamber

Definition at line 86 of file MdtCalibInputSvc.h.

◆ ATLAS_THREAD_SAFE [2/2]

std::set<MuonCalib::NtupleStationId> m_rt_warned MdtCalibInputSvc::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 87 of file MdtCalibInputSvc.h.

◆ m_B_corr

std::map<MuonCalib::NtupleStationId, MuonCalib::BFieldCorFunc *> MdtCalibInputSvc::m_B_corr
private

Definition at line 69 of file MdtCalibInputSvc.h.

◆ m_calib_input_tool

ToolHandle<MuonCalib::ICalibrationIOTool> MdtCalibInputSvc::m_calib_input_tool {this, "CalibrationInputTool", "MuonCalib::CalibrationDummyIOTool"}
private

calibration io tool to be used

Definition at line 65 of file MdtCalibInputSvc.h.

◆ m_mean_station_id

MuonCalib::NtupleStationId MdtCalibInputSvc::m_mean_station_id
private

station id for mean rt

Definition at line 84 of file MdtCalibInputSvc.h.

◆ m_reg_sel_svc

ServiceHandle<RegionSelectionSvc> MdtCalibInputSvc::m_reg_sel_svc
private

pointer to region selection service

Definition at line 72 of file MdtCalibInputSvc.h.

◆ m_rt_relation

std::map<MuonCalib::NtupleStationId, MuonCalib::IRtRelation *> MdtCalibInputSvc::m_rt_relation
private

Definition at line 68 of file MdtCalibInputSvc.h.

◆ m_sel_region_b

const MuonCalib::BFieldCorFunc* MdtCalibInputSvc::m_sel_region_b {nullptr}
private

Definition at line 81 of file MdtCalibInputSvc.h.

◆ m_sel_region_res

const MuonCalib::IRtResolution* MdtCalibInputSvc::m_sel_region_res {nullptr}
private

Definition at line 82 of file MdtCalibInputSvc.h.

◆ m_sel_region_rt

const MuonCalib::IRtRelation* MdtCalibInputSvc::m_sel_region_rt {nullptr}
private

rt relation - resolution - and correction function for the selected region - is average of all matching rt relations

Definition at line 80 of file MdtCalibInputSvc.h.

◆ m_spat_res

std::map<MuonCalib::NtupleStationId, MuonCalib::IRtResolution *> MdtCalibInputSvc::m_spat_res
private

Definition at line 70 of file MdtCalibInputSvc.h.

◆ m_t0

std::map<MuonCalib::NtupleStationId, MuonCalib::MdtStationT0Container *> MdtCalibInputSvc::m_t0
private

calibration data sorted by station id

Definition at line 67 of file MdtCalibInputSvc.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AthService::AthService
AthService()
MdtCalibInputSvc::read_calib_input
StatusCode read_calib_input()
Definition: MdtCalibInputSvc.cxx:107
generateReferenceFile.fun
fun
Definition: generateReferenceFile.py:18
MdtCalibInputSvc::create_mean_rts
void create_mean_rts()
create mean rt relations, and resolutions for the selected calibration region
Definition: MdtCalibInputSvc.cxx:127
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
MdtCalibInputSvc::m_sel_region_b
const MuonCalib::BFieldCorFunc * m_sel_region_b
Definition: MdtCalibInputSvc.h:81
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
MuonCalib::NtupleStationId
Definition: NtupleStationId.h:36
skel.it
it
Definition: skel.GENtoEVGEN.py:396
MdtCalibInputSvc::m_mean_station_id
MuonCalib::NtupleStationId m_mean_station_id
station id for mean rt
Definition: MdtCalibInputSvc.h:84
MdtCalibInputSvc::m_B_corr
std::map< MuonCalib::NtupleStationId, MuonCalib::BFieldCorFunc * > m_B_corr
Definition: MdtCalibInputSvc.h:69
MdtCalibInputSvc::m_sel_region_rt
const MuonCalib::IRtRelation * m_sel_region_rt
rt relation - resolution - and correction function for the selected region - is average of all matchi...
Definition: MdtCalibInputSvc.h:80
MuonCalib::BFieldCorFunc
Definition: BFieldCorFunc.h:47
MdtCalibInputSvc::m_sel_region_res
const MuonCalib::IRtResolution * m_sel_region_res
Definition: MdtCalibInputSvc.h:82
MdtCalibInputSvc::m_reg_sel_svc
ServiceHandle< RegionSelectionSvc > m_reg_sel_svc
pointer to region selection service
Definition: MdtCalibInputSvc.h:72
MdtCalibInputSvc::GetResolution
const MuonCalib::IRtResolution * GetResolution() const
Get resolution for calibration region.
Definition: MdtCalibInputSvc.h:61
MdtCalibInputSvc::GetBCorr
const MuonCalib::BFieldCorFunc * GetBCorr()
Get b-field correction for calibratino region.
Definition: MdtCalibInputSvc.h:56
MdtCalibInputSvc::findbfieldfun
const MuonCalib::BFieldCorFunc * findbfieldfun(const MuonCalib::NtupleStationId &id)
Definition: MdtCalibInputSvc.cxx:170
lumiFormat.i
int i
Definition: lumiFormat.py:85
DetDescrDictionaryDict::it1
std::vector< HWIdentifier >::iterator it1
Definition: DetDescrDictionaryDict.h:17
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
calibdata.chamber_id
chamber_id
Definition: calibdata.py:536
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MuonCalib::MuonFixedId
Definition: MuonFixedId.h:50
MdtCalibInputSvc::m_t0
std::map< MuonCalib::NtupleStationId, MuonCalib::MdtStationT0Container * > m_t0
calibration data sorted by station id
Definition: MdtCalibInputSvc.h:67
MdtCalibInputSvc::create_b_field_correction
bool create_b_field_correction(const MuonCalib::NtupleStationId &id)
create the b-field correction
Definition: MdtCalibInputSvc.cxx:114
MdtCalibInputSvc::m_calib_input_tool
ToolHandle< MuonCalib::ICalibrationIOTool > m_calib_input_tool
calibration io tool to be used
Definition: MdtCalibInputSvc.h:65
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MdtCalibInputSvc::m_rt_relation
std::map< MuonCalib::NtupleStationId, MuonCalib::IRtRelation * > m_rt_relation
Definition: MdtCalibInputSvc.h:68
MdtCalibInputSvc::m_spat_res
std::map< MuonCalib::NtupleStationId, MuonCalib::IRtResolution * > m_spat_res
Definition: MdtCalibInputSvc.h:70
MuonCalib::IRtRelation
generic interface for a rt-relation
Definition: IRtRelation.h:15