ATLAS Offline Software
Classes | 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
MuonAlign::AlignmentErrorTool Class Reference

#include <AlignmentErrorTool.h>

Inheritance diagram for MuonAlign::AlignmentErrorTool:
Collaboration diagram for MuonAlign::AlignmentErrorTool:

Classes

struct  deviationSummary_t
 

Public Member Functions

 AlignmentErrorTool (const std::string &, const std::string &, const IInterface *)
 
 ~AlignmentErrorTool () override=default
 
StatusCode initialize () override
 
void makeAlignmentDeviations (const Trk::Track &track, std::vector< Trk::AlignmentDeviation * > &deviations) const override
 Compute alignment deviations, given a track as input. 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 ()
 

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

std::string hardwareName (MuonCalib::MuonFixedLongId calibId) const
 
std::string sectorString (MuonCalib::MuonFixedLongId calibId) const
 
int sector (MuonCalib::MuonFixedLongId calibId) const
 
int hardwareEta (MuonCalib::MuonFixedLongId calibId) const
 
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 std::string_view side (MuonCalib::MuonFixedLongId calibId)
 
static bool isSmallSector (MuonCalib::MuonFixedLongId calibId)
 

Private Attributes

ToolHandle< MuonCalib::IIdToFixedIdToolm_idTool {this, "idTool", "MuonCalib::IdToFixedIdTool"}
 
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
 
SG::ReadCondHandleKey< MuonAlignmentErrorDatam_readKey {this, "ReadKey", "MuonAlignmentErrorData", "Key of MuonAlignmentErrorData"}
 
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 29 of file AlignmentErrorTool.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

◆ AlignmentErrorTool()

MuonAlign::AlignmentErrorTool::AlignmentErrorTool ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Definition at line 27 of file AlignmentErrorTool.cxx.

27  : AthAlgTool(t, n, p) {
28  declareInterface<Trk::ITrkAlignmentDeviationTool>(this);
29 }

◆ ~AlignmentErrorTool()

MuonAlign::AlignmentErrorTool::~AlignmentErrorTool ( )
overridedefault

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

◆ hardwareEta()

int MuonAlign::AlignmentErrorTool::hardwareEta ( MuonCalib::MuonFixedLongId  calibId) const
inlineprivate

Definition at line 361 of file AlignmentErrorTool.cxx.

361  {
362  using StationName = MuonCalib::MuonFixedLongId::StationName;
363  switch (calibId.stationName()) {
364  case StationName::BML:
365  {
366  if (sector(calibId)==13) {
367  switch (calibId.eta()) {
368  case 4: return 5;
369  case 5: return 6;
370  case 6: return 7;
371  case -4: return -5;
372  case -5: return -6;
373  case -6: return -7;
374  }
375  }
376  return calibId.eta();
377  }
378  case StationName::BOL:
379  {
380  if (sector(calibId)==13) {
381  if (calibId.eta()== 7) return 1; // BOE1A13 not BOL7A13
382  if (calibId.eta()==-7) return -1; // BOE1C13 not BOL7C13
383  }
384  return calibId.eta();
385  }
386  case StationName::BOF:
387  return calibId.eta()>0 ? calibId.eta()*2-1 : calibId.eta()*2+1;
388  case StationName::BOG:
389  return calibId.eta()*2;
390  case StationName::EIL:
391  {
392  if ((sector(calibId) == 1) || (sector(calibId) == 9)) {
393  switch (calibId.eta()) {
394  case 4: return 5;
395  case 5: return 4;
396  case -4: return -5;
397  case -5: return -4;
398  }
399  }
400  return calibId.eta();
401  }
402  case StationName::EEL:
403  {
404  if ((sector(calibId) == 5) && (calibId.eta() == 1)) return 2;
405  if ((sector(calibId) == 5) && (calibId.eta() == -1)) return -2;
406  return calibId.eta();
407  }
408  default: return calibId.eta();
409  }
410 }

◆ hardwareName()

std::string MuonAlign::AlignmentErrorTool::hardwareName ( MuonCalib::MuonFixedLongId  calibId) const
inlineprivate

Definition at line 295 of file AlignmentErrorTool.cxx.

295  {
296  using StationName = MuonCalib::MuonFixedLongId::StationName;
297 
298  // The only exception that cannot be caught by hardwareEta() above
299  if (sector(calibId)==13) {
300  if (calibId.eta()== 7 && calibId.stationName()==StationName::BOL) return "BOE1A13"; // BOE1A13 not BOL7A13
301  if (calibId.eta()==-7 && calibId.stationName()==StationName::BOL) return "BOE1C13"; // BOE1C13 not BOL7C13
302  if (calibId.eta()== 8 && calibId.stationName()==StationName::BOL) return "BOE2A13"; // BOE2A13 not BOL8A13
303  if (calibId.eta()==-8 && calibId.stationName()==StationName::BOL) return "BOE2C13"; // BOE2C13 not BOL8C13
304  }
305 
306  std::string ret { calibId.stationNameString() };
307  ret.push_back(static_cast<char>('0'+std::abs(hardwareEta(calibId))));
308  ret.append(side(calibId)).append(sectorString(calibId));
309 
310  return ret;
311 }

◆ initialize()

StatusCode MuonAlign::AlignmentErrorTool::initialize ( )
override

Definition at line 31 of file AlignmentErrorTool.cxx.

31  {
32  ATH_MSG_INFO("*****************************************");
33  ATH_MSG_INFO("AlignmentErrorTool::initialize()");
34 
35  ATH_CHECK(m_idTool.retrieve());
36  ATH_CHECK(m_idHelperSvc.retrieve());
38 
39  return StatusCode::SUCCESS;
40 }

◆ 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()

const InterfaceID & Trk::ITrkAlignmentDeviationTool::interfaceID ( )
inlinestaticinherited

Definition at line 37 of file ITrkAlignmentDeviationTool.h.

38 {
39  return IID_ITrkAlignmentDeviationTool;
40 }

◆ isSmallSector()

bool MuonAlign::AlignmentErrorTool::isSmallSector ( MuonCalib::MuonFixedLongId  calibId)
inlinestaticprivate

Definition at line 337 of file AlignmentErrorTool.cxx.

337  {
338  using StationName = MuonCalib::MuonFixedLongId::StationName;
339  switch (calibId.stationName()) {
340  case StationName::BIS:
341  case StationName::BMS:
342  case StationName::BOS:
343  case StationName::BEE:
344  case StationName::BMF:
345  case StationName::BOF:
346  case StationName::BOG:
347  case StationName::EES:
348  case StationName::EMS:
349  case StationName::EOS:
350  case StationName::EIS:
351  case StationName::CSS:
352  case StationName::BMG:
353  case StationName::MMS:
354  case StationName::STS:
355  return true;
356  default:
357  return false;
358  }
359 }

◆ makeAlignmentDeviations()

void MuonAlign::AlignmentErrorTool::makeAlignmentDeviations ( const Trk::Track track,
std::vector< Trk::AlignmentDeviation * > &  deviations 
) const
overridevirtual

Compute alignment deviations, given a track as input.

Implements Trk::ITrkAlignmentDeviationTool.

Definition at line 42 of file AlignmentErrorTool.cxx.

42  {
43  ATH_MSG_DEBUG("AlignmentErrorTool::makeAlignmentDeviations()");
44 
46  const MuonAlignmentErrorData* readCdo{*readHandle};
47  if (!readCdo) {
48  ATH_MSG_ERROR("nullptr to the read conditions object");
49  return;
50  }
51  const auto& deviationVec = readCdo->getDeviations();
52  std::vector<deviationSummary_t> devSumVec;
53  devSumVec.reserve(deviationVec.size());
54  deviationSummary_t aDevSumm;
55  for (const auto & i : deviationVec) {
56  aDevSumm.translation = i.translation;
57  aDevSumm.rotation = i.rotation;
58  aDevSumm.stationName = i.stationName;
59  aDevSumm.multilayer = i.multilayer;
60  devSumVec.emplace_back(std::move(aDevSumm));
61  }
62 
63  typedef Trk::TrackStates tsosc_t;
64  const tsosc_t* tsosc = track.trackStateOnSurfaces();
65 
66  // LOOP ON HITS ON TRACK //
67  unsigned int nPrecisionHits = 0;
68  for (const auto *tsos : *tsosc) {
69  if (!tsos->type(Trk::TrackStateOnSurface::Measurement)) {
70  continue;
71  }
72  const Trk::MeasurementBase* meas = tsos->measurementOnTrack();
73  const auto* rot = dynamic_cast<const Trk::RIO_OnTrack*>(meas);
74 
75  if (!rot) {
76  const auto* crot = dynamic_cast<const Trk::CompetingRIOsOnTrack*>(meas);
77  if (crot) {
78  unsigned int index = crot->indexOfMaxAssignProb();
79  rot = &(crot->rioOnTrack(index));
80  }
81  }
82  if (!rot) continue;
83 
84  Identifier channelId = rot->identify();
85  if (!m_idHelperSvc->isMuon(channelId)) {
86  // the RIO_OnTrack Identifiers could also come from ID or Calo, but this tool is only interested in MS hits
87  ATH_MSG_VERBOSE("Given Identifier " << channelId.get_compact() << " is not a muon Identifier, continuing");
88  continue;
89  }
90 
91  // Keep only the precision coordinate hits
92  if (m_idHelperSvc->isRpc(channelId)
93  || m_idHelperSvc->isTgc(channelId)
94  || (m_idHelperSvc->isCsc(channelId) && m_idHelperSvc->cscIdHelper().measuresPhi(channelId) == 1)
95  || (m_idHelperSvc->issTgc(channelId) && m_idHelperSvc->stgcIdHelper().channelType(channelId) != sTgcIdHelper::sTgcChannelTypes::Strip)) {
96  continue;
97  }
98 
99  // To maintain backward compatibility with the old error CLOBs, activate
100  // the NSW hits only if specified in the CLOB, else disccard them
101  if (!readCdo->hasNswHits()
102  && (m_idHelperSvc->issTgc(channelId) || m_idHelperSvc->isMM(channelId))) {
103  continue;
104  }
105 
106  MuonCalib::MuonFixedLongId calibId = m_idTool->idToFixedLongId(channelId);
107  if (!calibId.isValid()) continue;
108 
109  // GATHERING INFORMATION TO PUT TOGETHER THE STATION NAME //
110  std::string alignStationName = hardwareName(calibId);
111  int multilayer = 1;
112  if (calibId.is_mdt()) {
113  multilayer = calibId.mdtMultilayer();
114  } else if (calibId.is_mmg()) {
115  multilayer = calibId.mmgMultilayer();
116  } else if (calibId.is_stg()) {
117  multilayer = calibId.stgMultilayer();
118  }
119  std::string multilayerName = std::to_string(multilayer);
120 
121  ATH_MSG_DEBUG("Hit is in station " << alignStationName << " multilayer " << multilayerName);
122  ++nPrecisionHits;
123 
124  // Compute deviationSummary_t building blocks
125  const Trk::PrepRawData* prd = rot->prepRawData();
126  const Trk::Surface& sur = prd->detectorElement()->surface(prd->identify());
127 
128  double w2 = 1.0 / (rot->localCovariance()(Trk::loc1, Trk::loc1));
129  Amg::Vector3D hitP = tsos->trackParameters()->position();
130  Amg::Vector3D hitU = tsos->trackParameters()->momentum().unit();
131 
132  // Wire direction for MDT, strip direction for MM or sTGC
133  int icol = (calibId.is_mdt()||calibId.is_csc()) ? 2 : 1;
134  Amg::Vector3D hitV = sur.transform().rotation().col(icol);
135 
136  // Enforce orientation of the V vectors
137  static const Amg::Vector3D zATLAS(0., 0., 1.);
138  if (hitP.cross(zATLAS).dot(hitV)<0.0) {
139  hitV *= -1.0;
140  }
141 
142  // FOR CROSS-CHECK
143  bool is_matched = false;
144 
145  // LOOP ON STATION DEVIATIONS EXTRACTED FROM INPUT FILE //
146  for (auto & iDev : devSumVec) {
147  // try to regexp-match the station name and the multilayer name
148  if (!boost::regex_match(alignStationName, iDev.stationName)) {
149  continue;
150  }
151  if (!boost::regex_match(multilayerName, iDev.multilayer)) {
152  continue;
153  }
154 
155  // ASSOCIATE EACH NUISANCE TO A LIST OF HITS
156  iDev.hits.push_back(rot);
157 
158  iDev.sumW2 += w2;
159  iDev.sumP += w2 * hitP;
160  iDev.sumU += w2 * hitU;
161  iDev.sumV += w2 * hitV;
162 
163  // FOR CROSS-CHECK
164  is_matched = true;
165 
166 
167  } // LOOP ON DEVIATIONS
168 
169  if (!is_matched) {
170  ATH_MSG_WARNING("The hits in the station " << alignStationName << ", multilayer " << multilayerName
171  << " couldn't be matched to any deviation regexp in the list.");
172  }
173 
174  } // LOOP ON TSOS
175 
176  // Nuisance parameters covering the complete track are not wanted. (MS/ID
177  // error treated differently for now). Removing the deviations covering the
178  // full track in further processing.
179  for (auto& dev : devSumVec) {
180  if (dev.hits.size() == nPrecisionHits) {
181  dev.hits.clear();
182  }
183  }
184 
185  // GET RID OF PERFECT OVERLAPS BY COMBINING ERRORS
186  std::vector<const Trk::RIO_OnTrack*> v1, v2;
187  for (auto iti = devSumVec.begin(); iti != devSumVec.end(); ++iti) {
188 
189  v1 = iti->hits;
190  if (v1.empty()) {
191  continue;
192  }
193 
194  std::stable_sort(v1.begin(), v1.end());
195 
196  for (auto itj = iti+1; itj != devSumVec.end(); ++itj) {
197 
198  if (iti->hits.size() != itj->hits.size()) {
199  continue;
200  }
201 
202  v2 = itj->hits;
203  std::stable_sort(v2.begin(), v2.end());
204 
205  if (v1 == v2) {
206  auto iDev = std::distance(devSumVec.begin(), iti);
207  auto jDev = std::distance(devSumVec.begin(), itj);
208  ATH_MSG_DEBUG("Found deviations " << iDev << " and " << jDev << " related to the same list of hits. Merging...");
209  ATH_MSG_DEBUG("old (translation, rotation) systematic uncertainties for "
210  << iDev << ": " << iti->translation << ", " << iti->rotation);
211  ATH_MSG_DEBUG("old (translation, rotation) systematic uncertainties for "
212  << jDev << ": " << itj->translation << ", " << itj->rotation);
213 
214  // MERGE THE TWO DEVIATIONS ASSOCIATED TO THE SAME LIST OF HITS //
215  double new_translation = std::hypot(iti->translation, itj->translation);
216  double new_rotation = std::hypot(iti->rotation, itj->rotation);
217 
218  // NOW PREPARE TO ERASE ONE OF THE TWO COPIES //
219  itj->hits.clear();
220 
221  // ASSIGN NEW TRASLATION/ROTATION TO THE REMAINING COPY //
222  iti->translation = new_translation;
223  iti->rotation = new_rotation;
224  ATH_MSG_DEBUG("New combined (translation, rotation) systematic uncertainties: " << new_translation << ", " << new_rotation);
225 
226  } // FIND AN OVERLAP IN THE HITS LISTS
227  } // SECOND LOOP ON DEVIATIONS
228  } // FIRST LOOP ON DEVIATIONS
229 
230 
231  // NOW BUILD THE DEVIATIONS
232  deviations.clear();
233  ATH_MSG_DEBUG("************************************");
234  ATH_MSG_DEBUG("FINAL LIST OF DEVIATIONS");
235  for (const auto & iDev : devSumVec) {
236  if (iDev.hits.empty()) {
237  continue;
238  }
239 
240  double rotation = iDev.rotation;
241  double translation = iDev.translation;
242 
243  Amg::Vector3D sumP = iDev.sumP;
244  Amg::Vector3D sumU = iDev.sumU;
245  Amg::Vector3D sumV = iDev.sumV;
246  double sumW2 = iDev.sumW2;
247 
248  sumP *= (1. / sumW2);
249  sumU *= (1. / sumW2);
250  sumV *= (1. / sumW2);
251 
252  if (translation >= 0.001 * Gaudi::Units::mm) {
253  std::size_t hitshash = 0;
254  for (const auto *it : iDev.hits) {
255  boost::hash_combine(hitshash, (it->identify()).get_compact());
256  }
257  deviations.push_back(
258  new AlignmentTranslationDeviation(sumU.cross(sumV), translation * Gaudi::Units::mm, iDev.hits));
259  deviations.back()->setHashOfHits(hitshash);
260 
261  ATH_MSG_DEBUG("A translation along ("
262  << sumU.x() << ", " << sumU.y() << ", " << sumU.z() << ") with sigma=" << translation * Gaudi::Units::mm
263  << " mm was applied to " << iDev.hits.size()
264  << " hits matching the station: " << iDev.stationName.str() << " and the multilayer "
265  << iDev.multilayer.str());
266  }
267  if (rotation >= 0.000001 * Gaudi::Units::rad) {
268  std::size_t hitshash = 0;
269  for (const auto *it : iDev.hits) {
270  boost::hash_combine(hitshash, (it->identify()).get_compact());
271  }
272  deviations.push_back(new AlignmentRotationDeviation(sumP, sumV, rotation * Gaudi::Units::rad, iDev.hits));
273  deviations.back()->setHashOfHits(hitshash);
274 
275  ATH_MSG_DEBUG("A rotation around the center = (" << sumP.x() << ", " << sumP.y() << ", " << sumP.z() << ") and axis = ("
276  << sumV.x() << ", " << sumV.y() << ", " << sumV.z()
277  << ") with sigma=" << rotation / Gaudi::Units::mrad << " mrad was applied to "
278  << iDev.hits.size() << " hits matching the station "
279  << iDev.stationName.str() << " and the multilayer "
280  << iDev.multilayer.str());
281  }
282 
283  } // LOOP ON NUISANCES
284 
285  ATH_MSG_DEBUG("******************************");
286  ATH_MSG_DEBUG("FINAL CHECKUP");
287  ATH_MSG_DEBUG("Found " << deviations.size() << " nuisances after duplicates merging");
288  ATH_MSG_DEBUG("******************************");
289 }

◆ 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.

◆ 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  }

◆ sector()

int MuonAlign::AlignmentErrorTool::sector ( MuonCalib::MuonFixedLongId  calibId) const
inlineprivate

Definition at line 328 of file AlignmentErrorTool.cxx.

328  {
329  if (calibId.is_tgc()) {
330  // TGC sector convention is special
331  return calibId.phi();
332  } else {
333  return isSmallSector(calibId) ? 2*calibId.phi() : 2*calibId.phi()-1;
334  }
335 }

◆ sectorString()

std::string MuonAlign::AlignmentErrorTool::sectorString ( MuonCalib::MuonFixedLongId  calibId) const
inlineprivate

Definition at line 317 of file AlignmentErrorTool.cxx.

317  {
318  int sec = sector(calibId);
319  if (sec<0 || sec > 99) {
320  throw std::runtime_error("Unhandled sector number");
321  }
322  std::string ret = "00";
323  ret[0] += (sec/10);
324  ret[1] += (sec%10);
325  return ret;
326 }

◆ side()

std::string_view MuonAlign::AlignmentErrorTool::side ( MuonCalib::MuonFixedLongId  calibId)
inlinestaticprivate

Definition at line 313 of file AlignmentErrorTool.cxx.

313  {
314  return calibId.eta()>0 ? "A" : calibId.eta()<0 ? "C" : "B";
315 }

◆ 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  }

Member Data Documentation

◆ 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_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> MuonAlign::AlignmentErrorTool::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Definition at line 43 of file AlignmentErrorTool.h.

◆ m_idTool

ToolHandle<MuonCalib::IIdToFixedIdTool> MuonAlign::AlignmentErrorTool::m_idTool {this, "idTool", "MuonCalib::IdToFixedIdTool"}
private

Definition at line 42 of file AlignmentErrorTool.h.

◆ m_readKey

SG::ReadCondHandleKey<MuonAlignmentErrorData> MuonAlign::AlignmentErrorTool::m_readKey {this, "ReadKey", "MuonAlignmentErrorData", "Key of MuonAlignmentErrorData"}
private

Definition at line 72 of file AlignmentErrorTool.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:
BIS
@ BIS
Definition: RegSelEnums.h:11
MuonCalib::MuonFixedLongId::mmgMultilayer
int mmgMultilayer() const
Mmg specific:
Definition: MuonFixedLongId.h:1451
MuonCalib::MuonFixedLongId::phi
int phi() const
Definition: MuonFixedLongId.h:935
MuonCalib::MuonFixedLongId::is_tgc
bool is_tgc() const
Definition: MuonFixedLongId.h:778
MuonCalib::MuonFixedLongId::is_mdt
bool is_mdt() const
Definition: MuonFixedLongId.h:774
CSS
@ CSS
Definition: ParabolaCscClusterFitter.h:25
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
BOG
@ BOG
Definition: RegSelEnums.h:19
index
Definition: index.py:1
AthCommonDataStore::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
MuonCalib::MuonFixedLongId::StationName
StationName
an enum with the station names
Definition: MuonFixedLongId.h:64
xAOD::L2MuonParameters::BEE
@ BEE
BEE measurement point.
Definition: TrigMuonDefs.h:24
skel.it
it
Definition: skel.GENtoEVGEN.py:423
MuonCalib::MuonFixedLongId::isValid
bool isValid() const
check validity of the identifier.
Definition: MuonFixedLongId.h:770
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
MuonCalib::MuonFixedLongId::is_mmg
bool is_mmg() const
Definition: MuonFixedLongId.h:790
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
BMF
@ BMF
Definition: RegSelEnums.h:16
MuonAlign::AlignmentErrorTool::m_idTool
ToolHandle< MuonCalib::IIdToFixedIdTool > m_idTool
Definition: AlignmentErrorTool.h:42
MuonCalib::MuonFixedLongId::is_stg
bool is_stg() const
Definition: MuonFixedLongId.h:794
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
BOL
@ BOL
Definition: RegSelEnums.h:14
python.SystemOfUnits.mrad
int mrad
Definition: SystemOfUnits.py:112
MuonAlign::AlignmentErrorTool::sector
int sector(MuonCalib::MuonFixedLongId calibId) const
Definition: AlignmentErrorTool.cxx:328
std::stable_sort
void stable_sort(std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, std::reverse_iterator< DataModel_detail::iterator< DVL > > end, Compare comp)
Specialization of stable_sort for DataVector/List.
Definition: DVL_algorithms.h:711
atlasStyleMacro.icol
int icol
Definition: atlasStyleMacro.py:13
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
MuonAlign::AlignmentErrorTool::m_readKey
SG::ReadCondHandleKey< MuonAlignmentErrorData > m_readKey
Definition: AlignmentErrorTool.h:72
MuonCalib::MuonFixedLongId::stgMultilayer
int stgMultilayer() const
Stg specific:
Definition: MuonFixedLongId.h:1516
BOF
@ BOF
Definition: RegSelEnums.h:18
MuonCalib::MuonFixedLongId
Definition: MuonFixedLongId.h:50
MuonCalib::MuonFixedLongId::stationNameString
std::string_view stationNameString() const
Definition: MuonFixedLongId.h:886
MuonAlignmentErrorData
MuonAlignmentErrorData is condition data which is derived and recorded by MuonAlignmentErrorDbAlg.
Definition: MuonAlignmentErrorData.h:20
AthCommonDataStore
Definition: AthCommonDataStore.h:52
MuonAlign::AlignmentErrorTool::hardwareName
std::string hardwareName(MuonCalib::MuonFixedLongId calibId) const
Definition: AlignmentErrorTool.cxx:295
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
ret
T ret(T t)
Definition: rootspy.cxx:260
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::rotation
rotation
Definition: TrackSurface_v1.cxx:15
Trk::CompetingRIOsOnTrack
Base class for all CompetingRIOsOnTack implementations, extends the common MeasurementBase.
Definition: CompetingRIOsOnTrack.h:64
Trk::TrkDetElementBase::surface
virtual const Surface & surface() const =0
Return surface associated with this detector element.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonAlign::AlignmentErrorTool::hardwareEta
int hardwareEta(MuonCalib::MuonFixedLongId calibId) const
Definition: AlignmentErrorTool.cxx:361
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
MuonCalib::MuonFixedLongId::eta
int eta() const
Definition: MuonFixedLongId.h:912
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
DataVector< const Trk::TrackStateOnSurface >
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
MuonCalib::MuonFixedLongId::is_csc
bool is_csc() const
Definition: MuonFixedLongId.h:782
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
MuonAlign::AlignmentErrorTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: AlignmentErrorTool.h:43
Trk::PrepRawData
Definition: PrepRawData.h:62
Trk::MeasurementBase
Definition: MeasurementBase.h:58
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonAlign::AlignmentErrorTool::sectorString
std::string sectorString(MuonCalib::MuonFixedLongId calibId) const
Definition: AlignmentErrorTool.cxx:317
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
ReadCellNoiseFromCoolCompare.v2
v2
Definition: ReadCellNoiseFromCoolCompare.py:364
a
TList * a
Definition: liststreamerinfos.cxx:10
h
BML
@ BML
Definition: RegSelEnums.h:12
MuonCalib::MuonFixedLongId::stationName
StationName stationName() const
Definition: MuonFixedLongId.h:882
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
BMS
@ BMS
Definition: RegSelEnums.h:13
MuonCalib::MuonFixedLongId::mdtMultilayer
int mdtMultilayer() const
Mdt specific:
Definition: MuonFixedLongId.h:1070
MuonAlign::AlignmentErrorTool::isSmallSector
static bool isSmallSector(MuonCalib::MuonFixedLongId calibId)
Definition: AlignmentErrorTool.cxx:337
MuonAlign::AlignmentErrorTool::side
static std::string_view side(MuonCalib::MuonFixedLongId calibId)
Definition: AlignmentErrorTool.cxx:313
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
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
Trk::loc1
@ loc1
Definition: ParamDefs.h:40
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
BOS
@ BOS
Definition: RegSelEnums.h:15
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
Trk::Surface::transform
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
Trk::TrackStateOnSurface::Measurement
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
Definition: TrackStateOnSurface.h:101
python.SystemOfUnits.rad
int rad
Definition: SystemOfUnits.py:111
fitman.k
k
Definition: fitman.py:528
Trk::PrepRawData::detectorElement
virtual const TrkDetElementBase * detectorElement() const =0
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...