ATLAS Offline Software
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Rec::MuSAVtxFitterTool Class Reference

#include <MuSAVtxFitterTool.h>

Inheritance diagram for Rec::MuSAVtxFitterTool:
Collaboration diagram for Rec::MuSAVtxFitterTool:

Classes

struct  WrkVrt
 Represents a working vertex structure used in VKalVrt fitting. More...
 

Public Member Functions

 MuSAVtxFitterTool (const std::string &type, const std::string &name, const IInterface *parent)
 
 ~MuSAVtxFitterTool ()
 
virtual StatusCode initialize () override
 
std::unique_ptr< xAOD::TrackParticleextrapolateMuSA (const xAOD::TrackParticle &trk, const xAOD::EventInfo &eventInfo, const EventContext &ctx) const
 
StatusCode doMuSAVtxFit (std::vector< MuSAVtxFitterTool::WrkVrt > &workVerticesContainer, const xAOD::MuonContainer &muonContainer, const xAOD::EventInfo &eventInfo, const EventContext &ctx) const
 
StatusCode doPostFitSelections (std::vector< MuSAVtxFitterTool::WrkVrt > &workVerticesContainer) const
 
StatusCode selectBestVertices (std::vector< MuSAVtxFitterTool::WrkVrt > &workVerticesContainer) const
 
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, V, H > &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

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

ToolHandle< Trk::ITrkVKalVrtFitterm_vertexFitter
 
ToolHandle< Trk::IExtrapolatorm_extrapolator
 
DoubleProperty m_etaCutMSTP {this, "etaCutMSTP", 2.5, "Maximum |eta| of input MSTPs"}
 
DoubleProperty m_baseChi2Cut {this, "baseChi2Cut", 50., "Maximum allowed chi2 of saved vertices"}
 
Gaudi::Property< bool > m_doValidation {this, "doValidation", false, "Vertex every MSTP in input as part of validation process"}
 
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 23 of file MuSAVtxFitterTool.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

◆ MuSAVtxFitterTool()

Rec::MuSAVtxFitterTool::MuSAVtxFitterTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 19 of file MuSAVtxFitterTool.cxx.

19  :
21 {
22  declareInterface<MuSAVtxFitterTool>(this);
23 }

◆ ~MuSAVtxFitterTool()

Rec::MuSAVtxFitterTool::~MuSAVtxFitterTool ( )
default

Member Function Documentation

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > &  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, V, H > &  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, V, H > &  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, V, H > &  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, V, H > &  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; }

◆ doMuSAVtxFit()

StatusCode Rec::MuSAVtxFitterTool::doMuSAVtxFit ( std::vector< MuSAVtxFitterTool::WrkVrt > &  workVerticesContainer,
const xAOD::MuonContainer muonContainer,
const xAOD::EventInfo eventInfo,
const EventContext &  ctx 
) const

Definition at line 69 of file MuSAVtxFitterTool.cxx.

73 {
74  ATH_MSG_DEBUG("MuSAVtxFitterTool::doMuSAVtxFit");
75 
76  // first gather all SA muons that pass basic checks
77  std::vector<const xAOD::Muon*> candidateSAmuons;
78  for (const auto muon : muonContainer) {
79  bool isSA = (muon->muonType() == xAOD::Muon::MuonStandAlone);
80  bool isCalo = (muon->muonType() == xAOD::Muon::CaloTagged);
81  bool isSegment = (muon->muonType() == xAOD::Muon::SegmentTagged);
82  bool isSiForward = (muon->muonType() == xAOD::Muon::SiliconAssociatedForwardMuon);
83 
84  if (!isSA && !m_doValidation) {
85  continue;
86  }
87 
88  const xAOD::TrackParticle* MuSAMSTP = muon->trackParticle(xAOD::Muon::MuonSpectrometerTrackParticle);
89  if (!MuSAMSTP) {
90  if (isCalo || isSegment || isSiForward) {
91  ATH_MSG_VERBOSE("Skipping non-SA, non-Combined muon type in validation mode!");
92  } else {
93  ATH_MSG_WARNING("Muon has no MSTP, check your input!");
94  }
95  continue;
96  }
97 
98  // pre-fit cuts at "seeding" level go here
99  if (std::abs(MuSAMSTP->eta()) > m_etaCutMSTP) {
100  ATH_MSG_VERBOSE("Skipping SA muon with |eta| > 2.5!");
101  continue;
102  }
103  // SA muons can get saved with nonphysical pT values, checking prevents extrap crashes
104  if (MuSAMSTP->pt() > 13000000) {
105  ATH_MSG_DEBUG("Skipping SA muon with pT " << (MuSAMSTP->pt() / 1000.) << " GeV!");
106  continue;
107  }
108 
109  // SA muons can also be saved in regions with 0 magnetic field, which can cause extrapolation crashes
110  float spectrometerFieldIntegral = 0.0;
112  if (spectrometerFieldIntegral < 0.1) {
113  ATH_MSG_DEBUG("Skipping SA muon with spectrometerFieldIntegral " << muon->spectrometerFieldIntegral << " T*m!");
114  continue;
115  }
116 
117  candidateSAmuons.push_back(muon);
118  }
119 
120  // bail out if we don't have at least two valid SA muons
121  if (candidateSAmuons.size() < 2) {
122  ATH_MSG_VERBOSE("Not enough standalone muons to fit a vertex!");
123  return StatusCode::SUCCESS;
124  }
125 
126  // extrapolate SA muons only if we have enough candidates to form a vertex
127  std::vector<std::unique_ptr<xAOD::TrackParticle>> extrapolatedMuSATracks;
128  std::map<const xAOD::TrackParticle*, const xAOD::Muon*> muonToExtrapolatedTrackMap;
129  for (const auto muon : candidateSAmuons) {
130  const xAOD::TrackParticle* MuSAMSTP = muon->trackParticle(xAOD::Muon::MuonSpectrometerTrackParticle);
131  auto extrapolatedMuSATrack = extrapolateMuSA(*MuSAMSTP, eventInfo, ctx);
132  if (extrapolatedMuSATrack->definingParameters()[Trk::d0] > 8000) {
133  ATH_MSG_DEBUG("Failed to extrapolate MuSA track, skipping!");
134  continue;
135  }
136  extrapolatedMuSATracks.push_back(std::move(extrapolatedMuSATrack));
137  muonToExtrapolatedTrackMap[extrapolatedMuSATracks.back().get()] = muon;
138  ATH_MSG_VERBOSE("Extrapolated MuSA track! Total extrapolated so far: " << extrapolatedMuSATracks.size());
139  }
140 
141  if (extrapolatedMuSATracks.size() < 2) {
142  ATH_MSG_VERBOSE("Not enough extrapolated tracks to fit a vertex!");
143  return StatusCode::SUCCESS;
144  }
145 
146  std::unique_ptr<Trk::IVKalState> state = m_vertexFitter->makeState(ctx);
147  // Loop over all unique pairs.
148  for (unsigned int i = 0; i < extrapolatedMuSATracks.size(); i++) {
149  for (unsigned int j = i+1; j < extrapolatedMuSATracks.size(); j++) {
150  MuSAVtxFitterTool::WrkVrt MuSACandidate;
151  std::vector<const xAOD::TrackParticle*> tracksToFit = {
152  extrapolatedMuSATracks[i].get(),
153  extrapolatedMuSATracks[j].get()
154  };
155  std::vector<const xAOD::NeutralParticle*> dummyNeutrals;
156  StatusCode res = m_vertexFitter->VKalVrtFit(tracksToFit, dummyNeutrals,
157  MuSACandidate.pos, MuSACandidate.mom,
158  MuSACandidate.charge, MuSACandidate.cov,
159  MuSACandidate.chi2PerTrk, MuSACandidate.trkAtVrt,
160  MuSACandidate.chi2, *state);
161  if (res.isSuccess()) {
162  ATH_MSG_DEBUG("MuSA vertex fit successful!");
163  // Transfer persistent ownership by converting the unique_ptr to a shared_ptr
164  // for both tracks used in this candidate (lets unused tracks go out of scope peacefully while keeping used ones)
165  auto sharedTrack1 = std::make_shared<const xAOD::TrackParticle>(*extrapolatedMuSATracks[i]);
166  auto sharedTrack2 = std::make_shared<const xAOD::TrackParticle>(*extrapolatedMuSATracks[j]);
167  MuSACandidate.newExtrapolatedTracks.push_back(sharedTrack1);
168  MuSACandidate.newExtrapolatedTracks.push_back(sharedTrack2);
169  MuSACandidate.muonCandidates = {
170  muonToExtrapolatedTrackMap[tracksToFit[0]],
171  muonToExtrapolatedTrackMap[tracksToFit[1]]
172  };
173  MuSACandidate.minOpAng = muonToExtrapolatedTrackMap[tracksToFit[0]]->p4().DeltaR(
174  muonToExtrapolatedTrackMap[tracksToFit[1]]->p4());
175  workVerticesContainer.emplace_back(MuSACandidate);
176  } else {
177  ATH_MSG_DEBUG("MuSA vertex fit failed!");
178  }
179  }
180  }
181  // NOTE: Any remaining extrapolated tracks in the vector will be cleaned up automatically when they go out of scope
182  // this means the logic may need to be revisited if we want to "recover" extrapolated tracks that were not used in any fit through another mechanism
183  return StatusCode::SUCCESS;
184 }

◆ doPostFitSelections()

StatusCode Rec::MuSAVtxFitterTool::doPostFitSelections ( std::vector< MuSAVtxFitterTool::WrkVrt > &  workVerticesContainer) const

Definition at line 186 of file MuSAVtxFitterTool.cxx.

186  {
187  ATH_MSG_DEBUG("MuSAVtxFitterTool::doPostFitSelections");
188  //minimal method for post-fit selections
189  for (auto& workVertex : workVerticesContainer) {
190  if (workVertex.chi2 > m_baseChi2Cut) {
191  ATH_MSG_DEBUG("SA vertex chi2 too high, removing from consideration");
192  workVertex.isGood = false; // isGood flag has no specific utility here yet, but may be used in the future for more sophisticated recovery/reassembly
193  }
194  }
195 
196  //remove any vertices marked as bad
197  workVerticesContainer.erase(std::remove_if(workVerticesContainer.begin(), workVerticesContainer.end(),
198  [&](const MuSAVtxFitterTool::WrkVrt& vtx) { return !vtx.isGood; }), workVerticesContainer.end());
199 
200  return StatusCode::SUCCESS;
201 }

◆ 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

◆ extrapolateMuSA()

std::unique_ptr< xAOD::TrackParticle > Rec::MuSAVtxFitterTool::extrapolateMuSA ( const xAOD::TrackParticle trk,
const xAOD::EventInfo eventInfo,
const EventContext &  ctx 
) const

Definition at line 43 of file MuSAVtxFitterTool.cxx.

43  {
44 
45  Amg::Vector3D refPos(eventInfo.beamPosX(), eventInfo.beamPosY(), eventInfo.beamPosZ());
46  Trk::PerigeeSurface persurf(refPos);
47  Trk::PropDirection propagationDirection = Trk::oppositeMomentum;
48 
49  auto newTrack = std::make_unique<xAOD::TrackParticle>();
50  newTrack->makePrivateStore();
51 
52  auto perigee = trk.perigeeParameters();
53  auto entryPars = m_extrapolator->extrapolate(ctx, perigee, persurf, propagationDirection, false, Trk::muon);
54 
55  if (!entryPars) {
56  ATH_MSG_WARNING("Failed to back extrapolate MSTP, returning dummy!");
57  // Return a dummy track that will fail downstream cuts (extrapolations can sometimes fail due to various non-pathological reasons -- SA muons are not always high quality objects)
58  newTrack->setDefiningParameters(1.e19, 1.e19, 1.e19, 1.e19, 0);
59  return newTrack;
60  }
61 
62  newTrack->setDefiningParameters(entryPars->parameters()[Trk::d0], entryPars->parameters()[Trk::z0], entryPars->parameters()[Trk::phi], entryPars->parameters()[Trk::theta], entryPars->parameters()[Trk::qOverP]);
63  newTrack->setDefiningParametersCovMatrix(*entryPars->covariance());
64  newTrack->setParametersOrigin(eventInfo.beamPosX(), eventInfo.beamPosY(), eventInfo.beamPosZ());
65 
66  return newTrack;
67 }

◆ initialize()

StatusCode Rec::MuSAVtxFitterTool::initialize ( )
overridevirtual

Definition at line 27 of file MuSAVtxFitterTool.cxx.

28 {
29 
30  ATH_CHECK(m_vertexFitter.retrieve());
31  ATH_MSG_DEBUG("Retrieved tool " << m_vertexFitter);
32 
33  ATH_CHECK(m_extrapolator.retrieve());
34  ATH_MSG_DEBUG("Retrieved tool " << m_extrapolator);
35 
36 
37  ATH_MSG_DEBUG("Initialization successful");
38 
39  return StatusCode::SUCCESS;
40 
41 }

◆ 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& Rec::MuSAVtxFitterTool::interfaceID ( )
inlinestatic

Definition at line 30 of file MuSAVtxFitterTool.h.

30 { return IID_MuSAVtxFitterTool;}

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

◆ selectBestVertices()

StatusCode Rec::MuSAVtxFitterTool::selectBestVertices ( std::vector< MuSAVtxFitterTool::WrkVrt > &  workVerticesContainer) const

Definition at line 203 of file MuSAVtxFitterTool.cxx.

204 {
205  ATH_MSG_DEBUG("MuSAVtxFitterTool::selectBestVertices");
206  //the default logic will create vertices with all possible combinations of SA muons
207  //in rare cases this will cause two MuSA vertices in one event that re-use a muon (more likely in signal models with two or more LLP BSM decays)
208  //if this occurs we can select based on the highest chi2 and remove the poorer-quality vertex from consideration
209 
210  //first check if a muon is re-used in multiple vertices
211 
212  if (workVerticesContainer.size() < 2) {
213  ATH_MSG_VERBOSE("Only one MuSA vertex, no need to select best!");
214  return StatusCode::SUCCESS;
215  }
216 
217  //sort all the vertices by chi2 starting with the lowest
218  std::sort(workVerticesContainer.begin(), workVerticesContainer.end(), [](const MuSAVtxFitterTool::WrkVrt& v1, const MuSAVtxFitterTool::WrkVrt& v2) { return v1.chi2 < v2.chi2; });
219  ATH_MSG_VERBOSE("Sorted vertices by chi2! Lowest chi2: " << workVerticesContainer.front().chi2 << " Highest chi2: " << workVerticesContainer.back().chi2);
220 
221  //starting with the lowest chi2 vertex, check its muons and remove any other vertices that use the same muons
222  for (unsigned int i = 0; i < workVerticesContainer.size(); i++) {
223  auto& vertex = workVerticesContainer.at(i);
224  if (!vertex.isGood) {
225  continue; // skip vertices we've already marked as bad
226  }
227  for (unsigned int j = i+1; j < workVerticesContainer.size(); j++) {
228  auto& otherVertex = workVerticesContainer.at(j);
229  for (const auto& muon : vertex.muonCandidates) {
230  if (std::find(otherVertex.muonCandidates.begin(), otherVertex.muonCandidates.end(), muon) != otherVertex.muonCandidates.end()) {
231  //remove the other vertex
232  ATH_MSG_VERBOSE("Found a vertex re-using a muon with chi2: " << otherVertex.chi2 << " removing from consideration!");
233  otherVertex.isGood = false;
234  }
235  }
236  }
237  }
238 
239  //remove any vertices marked as bad
240  workVerticesContainer.erase(std::remove_if(workVerticesContainer.begin(), workVerticesContainer.end(),
241  [&](const MuSAVtxFitterTool::WrkVrt& vtx) { return !vtx.isGood; }), workVerticesContainer.end());
242 
243  return StatusCode::SUCCESS;
244 
245 
246 }

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

DoubleProperty Rec::MuSAVtxFitterTool::m_baseChi2Cut {this, "baseChi2Cut", 50., "Maximum allowed chi2 of saved vertices"}
private

Definition at line 92 of file MuSAVtxFitterTool.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_doValidation

Gaudi::Property<bool> Rec::MuSAVtxFitterTool::m_doValidation {this, "doValidation", false, "Vertex every MSTP in input as part of validation process"}
private

Definition at line 93 of file MuSAVtxFitterTool.h.

◆ m_etaCutMSTP

DoubleProperty Rec::MuSAVtxFitterTool::m_etaCutMSTP {this, "etaCutMSTP", 2.5, "Maximum |eta| of input MSTPs"}
private

Definition at line 91 of file MuSAVtxFitterTool.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_extrapolator

ToolHandle<Trk::IExtrapolator> Rec::MuSAVtxFitterTool::m_extrapolator
private
Initial value:
{
this,"Extrapolator","Trk::Extrapolator/AtlasExtrapolator","ATLAS Extrapolator tool"}

Definition at line 88 of file MuSAVtxFitterTool.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vertexFitter

ToolHandle<Trk::ITrkVKalVrtFitter> Rec::MuSAVtxFitterTool::m_vertexFitter
private
Initial value:
{
this, "VertexFitterTool", "Trk::TrkVKalVrtFitter", "Vertex fitter tool"}

Definition at line 86 of file MuSAVtxFitterTool.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:
muonContainer
xAOD::MuonContainer * muonContainer
Definition: TrigGlobEffCorrValidation.cxx:188
xAOD::TrackParticle_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: TrackParticle_v1.cxx:74
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:196
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
Trk::oppositeMomentum
@ oppositeMomentum
Definition: PropDirection.h:21
xAOD::TrackParticle_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: TrackParticle_v1.cxx:78
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
Trk::z0
@ z0
Definition: ParamDefs.h:64
Rec::MuSAVtxFitterTool::m_doValidation
Gaudi::Property< bool > m_doValidation
Definition: MuSAVtxFitterTool.h:93
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::EventInfo_v1::beamPosX
float beamPosX() const
X coordinate of the beam spot position.
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:29
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
xAOD::EventInfo_v1::beamPosY
float beamPosY() const
Y coordinate of the beam spot position.
xAOD::TrackParticle_v1::perigeeParameters
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
Definition: TrackParticle_v1.cxx:486
Trk::PropDirection
PropDirection
Definition: PropDirection.h:19
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
Rec::MuSAVtxFitterTool::m_extrapolator
ToolHandle< Trk::IExtrapolator > m_extrapolator
Definition: MuSAVtxFitterTool.h:88
Trk::theta
@ theta
Definition: ParamDefs.h:66
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthCommonDataStore::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition: AthCommonDataStore.h:145
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:11
test_pyathena.parent
parent
Definition: test_pyathena.py:15
Rec::MuSAVtxFitterTool::extrapolateMuSA
std::unique_ptr< xAOD::TrackParticle > extrapolateMuSA(const xAOD::TrackParticle &trk, const xAOD::EventInfo &eventInfo, const EventContext &ctx) const
Definition: MuSAVtxFitterTool.cxx:43
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
Trk::muon
@ muon
Definition: ParticleHypothesis.h:31
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
xAOD::EventInfo_v1::beamPosZ
float beamPosZ() const
Z coordinate of the beam spot position.
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
Trk::d0
@ d0
Definition: ParamDefs.h:63
Rec::MuSAVtxFitterTool::m_baseChi2Cut
DoubleProperty m_baseChi2Cut
Definition: MuSAVtxFitterTool.h:92
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
ReadCellNoiseFromCoolCompare.v2
v2
Definition: ReadCellNoiseFromCoolCompare.py:364
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
a
TList * a
Definition: liststreamerinfos.cxx:10
h
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:629
Trk::phi
@ phi
Definition: ParamDefs.h:75
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
Rec::MuSAVtxFitterTool::m_etaCutMSTP
DoubleProperty m_etaCutMSTP
Definition: MuSAVtxFitterTool.h:91
Rec::MuSAVtxFitterTool::m_vertexFitter
ToolHandle< Trk::ITrkVKalVrtFitter > m_vertexFitter
Definition: MuSAVtxFitterTool.h:86
MuonParameters::spectrometerFieldIntegral
@ spectrometerFieldIntegral
Discriminators and further variables.
Definition: MuonParamDefs.h:133
fitman.k
k
Definition: fitman.py:528