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

#include <FourMuonTool.h>

Inheritance diagram for DerivationFramework::FourMuonTool:
Collaboration diagram for DerivationFramework::FourMuonTool:

Public Member Functions

 FourMuonTool (const std::string &t, const std::string &n, const IInterface *p)
 
 ~FourMuonTool ()
 
StatusCode initialize ()
 
StatusCode performSearch (xAOD::VertexContainer *pairVxContainer, xAOD::VertexContainer *quadVxContainer, bool &acceptEvent, const EventContext &ctx) const
 
xAOD::Vertexfit (const std::vector< const xAOD::TrackParticle * > &, const xAOD::TrackParticleContainer *importedTrackCollection, const Amg::Vector3D &beamSpot) 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 std::vector< std::vector< unsigned int > > getQuadIndices (unsigned int length)
 
static std::vector< std::pair< unsigned int, unsigned int > > getPairIndices (unsigned int length)
 
static std::vector< std::vector< unsigned int > > mFromN (unsigned int m, unsigned int n)
 
static void combinatorics (unsigned int offset, unsigned int k, std::vector< unsigned int > &combination, std::vector< unsigned int > &mainList, std::vector< std::vector< unsigned int > > &allCombinations)
 
static void buildCombinations (const std::vector< const xAOD::Muon * > &muonsIn, std::vector< Combination > &pairs, std::vector< Combination > &quadruplets, unsigned int nSelectedMuons)
 
static bool passesQuadSelection (const std::vector< const xAOD::Muon * > &muonsIn)
 

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

Gaudi::Property< double > m_ptCut {this, "ptCut", 0.0}
 
Gaudi::Property< double > m_etaCut {this, "etaCut", 0.0}
 
Gaudi::Property< bool > m_useV0Fitter {this, "useV0Fitter", false}
 
SG::ReadHandleKey< xAOD::MuonContainerm_muonCollectionKey {this, "muonCollectionKey", "Muons"}
 
SG::ReadHandleKey< xAOD::TrackParticleContainerm_TrkParticleCollection {this, "TrackParticleCollection", "TrackParticleCandidate"}
 
PublicToolHandle< Trk::IVertexFitterm_iVertexFitter {this, "TrkVertexFitterTool", "Trk::TrkVKalVrtFitter"}
 
PublicToolHandle< Trk::IVertexFitterm_iV0VertexFitter {this, "V0VertexFitterTool", "Trk::V0VertexFitter"}
 
PublicToolHandle< Trk::ITrackSelectorToolm_trkSelector {this, "TrackSelectorTool", "InDet::TrackSelectorTool"}
 
SG::ReadHandleKey< xAOD::EventInfom_eventInfo_key {this, "EventInfo", "EventInfo", "Input event information"}
 
SG::WriteDecorHandleKey< xAOD::MuonContainerm_muonIndex {this, "muonIndexDec", m_muonCollectionKey, "BPHY4MuonIndex"}
 
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 132 of file FourMuonTool.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

◆ FourMuonTool()

DerivationFramework::FourMuonTool::FourMuonTool ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Definition at line 57 of file FourMuonTool.cxx.

57  : AthAlgTool(t,n,p)
58  {
59  }

◆ ~FourMuonTool()

DerivationFramework::FourMuonTool::~FourMuonTool ( )

Definition at line 61 of file FourMuonTool.cxx.

61 { }

Member Function Documentation

◆ buildCombinations()

void DerivationFramework::FourMuonTool::buildCombinations ( const std::vector< const xAOD::Muon * > &  muonsIn,
std::vector< Combination > &  pairs,
std::vector< Combination > &  quadruplets,
unsigned int  nSelectedMuons 
)
static

Definition at line 304 of file FourMuonTool.cxx.

307  {
308 
309  std::vector<std::vector<unsigned int> > quadrupletIndices = getQuadIndices(nSelectedMuons);
310  std::vector<std::pair<unsigned int, unsigned int> > pairIndices = getPairIndices(nSelectedMuons);
311 
312  // Quadruplets
313  std::vector<std::vector<unsigned int> >::iterator quadItr;
314  for (quadItr=quadrupletIndices.begin(); quadItr!=quadrupletIndices.end(); ++quadItr) {
315  const std::vector<unsigned int> &quad = (*quadItr);
316  std::vector<const xAOD::Muon*> theMuons = {muonsIn[quad[0]],muonsIn[quad[1]],muonsIn[quad[2]],muonsIn[quad[3]]};
317  if (!passesQuadSelection(theMuons)) continue;
318  Combination tmpQuad;
319  tmpQuad.muons = std::move(theMuons);
320  tmpQuad.quadIndices = quad;
321  quadruplets.emplace_back(std::move(tmpQuad));
322  }
323  if (quadruplets.size() == 0) return;
324 
325  // pairs
326  std::vector<std::pair<unsigned int, unsigned int> >::iterator pairItr;
327  for (pairItr=pairIndices.begin(); pairItr!=pairIndices.end(); ++pairItr) {
328  std::pair<unsigned int, unsigned int> pair = (*pairItr);
329  Combination tmpPair;
330  std::vector<const xAOD::Muon*> theMuons = {muonsIn[pair.first],muonsIn[pair.second]};
331  tmpPair.muons = std::move(theMuons);
332  tmpPair.pairIndices = pair;
333  pairs.emplace_back(std::move(tmpPair));
334  }
335 
336  return;
337 
338  }

◆ combinatorics()

void DerivationFramework::FourMuonTool::combinatorics ( unsigned int  offset,
unsigned int  k,
std::vector< unsigned int > &  combination,
std::vector< unsigned int > &  mainList,
std::vector< std::vector< unsigned int > > &  allCombinations 
)
static

Definition at line 262 of file FourMuonTool.cxx.

266  {
267  if (k==0) {
268  allCombinations.push_back(combination);
269  return;
270  }
271  if (k>0) {
272  for (unsigned int i=offset; i<=mainList.size()-k; ++i) {
273  combination.push_back(mainList[i]);
274  combinatorics(i+1,k-1,combination,mainList,allCombinations);
275  combination.pop_back();
276  }
277  }
278  }

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

◆ 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

◆ fit()

xAOD::Vertex * DerivationFramework::FourMuonTool::fit ( const std::vector< const xAOD::TrackParticle * > &  inputTracks,
const xAOD::TrackParticleContainer importedTrackCollection,
const Amg::Vector3D beamSpot 
) const

Definition at line 206 of file FourMuonTool.cxx.

208  {
209 
210  const Trk::TrkV0VertexFitter* concreteVertexFitter=0;
211  if (m_useV0Fitter) {
212  // making a concrete fitter for the V0Fitter
213  concreteVertexFitter = dynamic_cast<const Trk::TrkV0VertexFitter * >(&(*m_iV0VertexFitter));
214  if(concreteVertexFitter == 0) {
215  ATH_MSG_FATAL("The vertex fitter passed is not a V0 Vertex Fitter");
216  return nullptr;
217  }
218  }
219 
220  xAOD::Vertex* myVxCandidate{};
221  if (m_useV0Fitter) {
222  myVxCandidate = concreteVertexFitter->fit(inputTracks, beamSpot /*vertex startingPoint*/ );
223  } else {
224  myVxCandidate = m_iVertexFitter->fit(inputTracks, beamSpot /*vertex startingPoint*/ );
225  }
226 
227  if(myVxCandidate) BPhysPVTools::PrepareVertexLinks(myVxCandidate, importedTrackCollection);
228 
229  return myVxCandidate;
230 
231  } // End of fit method

◆ getPairIndices()

std::vector< std::pair< unsigned int, unsigned int > > DerivationFramework::FourMuonTool::getPairIndices ( unsigned int  length)
static

Definition at line 284 of file FourMuonTool.cxx.

284  {
285 
286  std::vector<std::pair<unsigned int, unsigned int> > uniquePairs;
287  std::vector<std::vector<unsigned int> > doublets = mFromN(2,length);
288  for (std::vector<std::vector<unsigned int> >::iterator it=doublets.begin(); it!=doublets.end(); ++it) {
289  std::pair<unsigned int, unsigned int> tmpPair = std::make_pair((*it).at(0),(*it).at(1));
290  uniquePairs.push_back(tmpPair);
291  }
292 
293  return(uniquePairs);
294  }

◆ getQuadIndices()

std::vector< std::vector< unsigned int > > DerivationFramework::FourMuonTool::getQuadIndices ( unsigned int  length)
static

Definition at line 240 of file FourMuonTool.cxx.

240  {
241 
242  std::vector<std::vector<unsigned int> > quadIndices = mFromN(4,length);
243  return(quadIndices);
244  }

◆ initialize()

StatusCode DerivationFramework::FourMuonTool::initialize ( )

Definition at line 32 of file FourMuonTool.cxx.

32  {
33 
34  // retrieving vertex Fitter
35  ATH_CHECK( m_iVertexFitter.retrieve() );
36  ATH_MSG_DEBUG("Retrieved tool " << m_iVertexFitter);
37 
38  // retrieving V0 Fitter
39  ATH_CHECK( m_iV0VertexFitter.retrieve(DisableTool{!m_useV0Fitter}));
40 
41  // Get the track selector tool from ToolSvc
42  ATH_CHECK ( m_trkSelector.retrieve() );
43  ATH_MSG_DEBUG("Retrieved tool " << m_trkSelector);
44 
45  // Get the beam spot service
49  m_muonIndex = m_muonCollectionKey.key() + ".BPHY4MuonIndex";
50  ATH_CHECK(m_muonIndex.initialize());
51  ATH_MSG_DEBUG("Initialize successful");
52 
53  return StatusCode::SUCCESS;
54 
55  }

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

◆ mFromN()

std::vector< std::vector< unsigned int > > DerivationFramework::FourMuonTool::mFromN ( unsigned int  m,
unsigned int  n 
)
static

Definition at line 252 of file FourMuonTool.cxx.

252  {
253 
254  std::vector<std::vector<unsigned int> > allCombinations;
255  std::vector<unsigned int> mainList;
256  std::vector<unsigned int> combination;
257  for (unsigned int i=0; i<N; ++i) mainList.push_back(i);
258  combinatorics(0,m,combination,mainList,allCombinations);
259  return allCombinations;
260  }

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

◆ passesQuadSelection()

bool DerivationFramework::FourMuonTool::passesQuadSelection ( const std::vector< const xAOD::Muon * > &  muonsIn)
static

Definition at line 346 of file FourMuonTool.cxx.

346  {
347  bool accept(false);
348  bool charges(true);
349  bool quality(false);
350  if (( muons.at(0)->muonType() == xAOD::Muon::Combined ) ||
351  ( muons.at(1)->muonType() == xAOD::Muon::Combined ) ||
352  ( muons.at(2)->muonType() == xAOD::Muon::Combined ) ||
353  ( muons.at(3)->muonType() == xAOD::Muon::Combined )
354  ) quality = true;
355  if (charges && quality) accept = true;
356  return accept;
357  }

◆ performSearch()

StatusCode DerivationFramework::FourMuonTool::performSearch ( xAOD::VertexContainer pairVxContainer,
xAOD::VertexContainer quadVxContainer,
bool &  acceptEvent,
const EventContext &  ctx 
) const

Definition at line 66 of file FourMuonTool.cxx.

67  {
68  ATH_MSG_DEBUG( "FourMuonTool::performSearch" );
69  selectEvent = false;
70 
71  // Get the muons from StoreGate
72  SG::ReadHandle<xAOD::MuonContainer> importedMuonCollection(m_muonCollectionKey, ctx);
73  ATH_CHECK(importedMuonCollection.isValid());
74  ATH_MSG_DEBUG("Muon container size "<<importedMuonCollection->size());
75 
76  // Get ID tracks
78  ATH_CHECK(importedTrackCollection.isValid());
79  ATH_MSG_DEBUG("ID TrackParticle container size "<< importedTrackCollection->size());
80 
81  // Select the muons
82  std::vector<const xAOD::Muon*> theMuonsAfterSelection;
84  unsigned int nCombMuons = 0;
85  unsigned int nSegmentTaggedMuons = 0;
86 
87  for (const auto * muon : *importedMuonCollection) {
88  if ( !muon ) continue;
89  muonDecorator(*muon) = -1; // all muons must be decorated
90  if ( (muon->muonType() != xAOD::Muon::Combined ) && (muon->muonType() != xAOD::Muon::SegmentTagged ) ) continue;
91  if (!muon->inDetTrackParticleLink().isValid()) continue; // No muons without ID tracks
92  auto& link = muon->inDetTrackParticleLink();
93  const xAOD::TrackParticle* muonTrk = *link;
94  if ( !muonTrk ) continue;
95  const xAOD::Vertex* vx{};
96  if ( !m_trkSelector->decision(*muonTrk, vx) ) continue; // all ID tracks must pass basic tracking cuts
97  if ( fabs(muonTrk->pt())<m_ptCut ) continue; // pt cut
98  if ( fabs(muonTrk->eta())>m_etaCut ) continue; // eta cut
99  if ( muon->muonType() == xAOD::Muon::Combined ) ++nCombMuons;
100  if ( muon->muonType() == xAOD::Muon::SegmentTagged ) ++nSegmentTaggedMuons;
101  theMuonsAfterSelection.push_back(muon);
102  }
103  unsigned int nSelectedMuons = theMuonsAfterSelection.size();
104  ATH_MSG_DEBUG("Number of muons after selection: " << nSelectedMuons);
105  ATH_MSG_DEBUG("of which " << nCombMuons << " are combined");
106  ATH_MSG_DEBUG("and " << nSegmentTaggedMuons << " are segment tagged");
107  if ( (nSelectedMuons < 4) || (nCombMuons < 1) ) {
108  ATH_MSG_DEBUG("Muon criteria not met. Skipping event.");
109  return StatusCode::SUCCESS;
110  }
111  selectEvent = true; // if we got this far we should definitively accept the event
112 
113  // Decorators
114  SG::AuxElement::Decorator< std::string > indexDecorator("CombinationCode");
115  SG::AuxElement::Decorator< std::string > chargeDecorator("ChargeCode");
116 
117  // Order by pT
118  std::sort(theMuonsAfterSelection.begin(), theMuonsAfterSelection.end(), [](const xAOD::Muon *a, const xAOD::Muon *b) {
119  return b->pt() < a->pt();
120  });
121 
122  // Decorate the selected muons (now pT ordered) with their index
123  unsigned int muonIndex(0);
124  for (auto selMuon : theMuonsAfterSelection) {
125  muonDecorator(*selMuon) = muonIndex;
126  ++muonIndex;
127  }
128 
129  // Quadruplet combinatorics
130  std::vector<Combination> quadruplets;
131  std::vector<Combination> pairs;
132  buildCombinations(theMuonsAfterSelection,pairs,quadruplets,nSelectedMuons);
133  if (quadruplets.size()==0) {
134  ATH_MSG_DEBUG("No acceptable quadruplets");
135  return StatusCode::SUCCESS;
136  }
137 
138  // Get the beam spot (for the vertexing starting point)
140  ATH_CHECK(evt.isValid());
141  const Amg::Vector3D beamSpot(evt->beamPosX(), evt->beamPosY(), evt->beamPosZ());
142 
143  // fit pairs
144  ATH_MSG_DEBUG("Successful pairs.....");
145  for (std::vector<Combination>::iterator pairItr = pairs.begin(); pairItr!=pairs.end(); ++pairItr) {
146  std::vector<const xAOD::TrackParticle*> theTracks = (*pairItr).trackParticles("pair1");
147  xAOD::Vertex* pairVxCandidate = fit(theTracks,importedTrackCollection.get(),beamSpot); // This line actually does the fitting and object making
148  if (pairVxCandidate) {
149  // decorate the candidate with its codes
150  indexDecorator(*pairVxCandidate) = (*pairItr).combinationIndices();
151  chargeDecorator(*pairVxCandidate) = (*pairItr).combinationCharges();
152  // decorate the candidate with refitted tracks and muons via the BPhysHelper
153  xAOD::BPhysHelper helper(pairVxCandidate);
154  helper.setRefTrks();
155  std::vector<const xAOD::Muon*> theStoredMuons;
156  theStoredMuons = (*pairItr).muons;
157  helper.setMuons(theStoredMuons,importedMuonCollection.get());
158  // Retain the vertex
159  pairVxContainer->push_back(pairVxCandidate);
160  ATH_MSG_DEBUG("..... indices: " << (*pairItr).combinationIndices() <<
161  " charges: " << (*pairItr).combinationCharges() <<
162  " chi2: " << pairVxCandidate->chiSquared());
163  } else { // fit failed
164  ATH_MSG_DEBUG("Fitter failed!");
165  }
166  }
167  ATH_MSG_DEBUG("pairContainer size " << pairVxContainer->size());
168 
169  // fit quadruplets
170  ATH_MSG_DEBUG("Successful quadruplets.....");
171  for (std::vector<Combination>::iterator quadItr = quadruplets.begin(); quadItr!=quadruplets.end(); ++quadItr) {
172  std::vector<const xAOD::TrackParticle*> theDCTracks; theDCTracks.clear();
173  theDCTracks = (*quadItr).trackParticles("DC");
174  xAOD::Vertex* dcVxCandidate = fit(theDCTracks,importedTrackCollection.get(), beamSpot);
175  if (dcVxCandidate != 0) {
176  // decorate the candidate with its codes
177  indexDecorator(*dcVxCandidate) = (*quadItr).combinationIndices();
178  chargeDecorator(*dcVxCandidate) = (*quadItr).combinationCharges();
179  // Decorate the DC candidate with the differences between its chi2 and the other
180  double dcChi2 = dcVxCandidate->chiSquared();
181  // decorate the candidate with refitted tracks and muons via the BPhysHelper
182  xAOD::BPhysHelper helper(dcVxCandidate);
183  helper.setRefTrks();
184  const std::vector<const xAOD::Muon*> &theStoredMuons = (*quadItr).muons;
185  helper.setMuons(theStoredMuons,importedMuonCollection.get());
186  // Retain the vertex
187  quadVxContainer->push_back(dcVxCandidate);
188  ATH_MSG_DEBUG("..... indices: " << (*quadItr).combinationIndices() <<
189  " charges: " << (*quadItr).combinationCharges() <<
190  " chi2(DC): " << dcChi2);
191  } else { // fit failed
192  ATH_MSG_DEBUG("Fitter failed!");
193  }
194  }
195  ATH_MSG_DEBUG("quadruplet container size " << quadVxContainer->size());
196 
197  return StatusCode::SUCCESS;;
198  }

◆ renounce()

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

Definition at line 380 of file AthCommonDataStore.h.

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

◆ renounceArray()

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

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ sysInitialize()

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

Perform system initialization for an algorithm.

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

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

◆ sysStart()

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

Handle START transition.

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

◆ updateVHKA()

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

Definition at line 308 of file AthCommonDataStore.h.

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

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_etaCut

Gaudi::Property<double> DerivationFramework::FourMuonTool::m_etaCut {this, "etaCut", 0.0}
private

Definition at line 161 of file FourMuonTool.h.

◆ m_eventInfo_key

SG::ReadHandleKey<xAOD::EventInfo> DerivationFramework::FourMuonTool::m_eventInfo_key {this, "EventInfo", "EventInfo", "Input event information"}
private

Definition at line 168 of file FourMuonTool.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_iV0VertexFitter

PublicToolHandle< Trk::IVertexFitter > DerivationFramework::FourMuonTool::m_iV0VertexFitter {this, "V0VertexFitterTool", "Trk::V0VertexFitter"}
private

Definition at line 166 of file FourMuonTool.h.

◆ m_iVertexFitter

PublicToolHandle< Trk::IVertexFitter > DerivationFramework::FourMuonTool::m_iVertexFitter {this, "TrkVertexFitterTool", "Trk::TrkVKalVrtFitter"}
private

Definition at line 165 of file FourMuonTool.h.

◆ m_muonCollectionKey

SG::ReadHandleKey<xAOD::MuonContainer> DerivationFramework::FourMuonTool::m_muonCollectionKey {this, "muonCollectionKey", "Muons"}
private

Definition at line 163 of file FourMuonTool.h.

◆ m_muonIndex

SG::WriteDecorHandleKey<xAOD::MuonContainer> DerivationFramework::FourMuonTool::m_muonIndex {this, "muonIndexDec", m_muonCollectionKey, "BPHY4MuonIndex"}
private

Definition at line 169 of file FourMuonTool.h.

◆ m_ptCut

Gaudi::Property<double> DerivationFramework::FourMuonTool::m_ptCut {this, "ptCut", 0.0}
private

Definition at line 160 of file FourMuonTool.h.

◆ m_TrkParticleCollection

SG::ReadHandleKey<xAOD::TrackParticleContainer> DerivationFramework::FourMuonTool::m_TrkParticleCollection {this, "TrackParticleCollection", "TrackParticleCandidate"}
private

Definition at line 164 of file FourMuonTool.h.

◆ m_trkSelector

PublicToolHandle< Trk::ITrackSelectorTool > DerivationFramework::FourMuonTool::m_trkSelector {this, "TrackSelectorTool", "InDet::TrackSelectorTool"}
private

Definition at line 167 of file FourMuonTool.h.

◆ m_useV0Fitter

Gaudi::Property<bool> DerivationFramework::FourMuonTool::m_useV0Fitter {this, "useV0Fitter", false}
private

Definition at line 162 of file FourMuonTool.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:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
xAOD::TrackParticle_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: TrackParticle_v1.cxx:74
DerivationFramework::FourMuonTool::m_etaCut
Gaudi::Property< double > m_etaCut
Definition: FourMuonTool.h:161
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:196
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
xAOD::BPhysHelper
Definition: BPhysHelper.h:71
DerivationFramework::FourMuonTool::m_muonCollectionKey
SG::ReadHandleKey< xAOD::MuonContainer > m_muonCollectionKey
Definition: FourMuonTool.h:163
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
xAOD::TrackParticle_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: TrackParticle_v1.cxx:78
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
DerivationFramework::FourMuonTool::combinatorics
static void combinatorics(unsigned int offset, unsigned int k, std::vector< unsigned int > &combination, std::vector< unsigned int > &mainList, std::vector< std::vector< unsigned int > > &allCombinations)
Definition: FourMuonTool.cxx:262
DerivationFramework::FourMuonTool::passesQuadSelection
static bool passesQuadSelection(const std::vector< const xAOD::Muon * > &muonsIn)
Definition: FourMuonTool.cxx:346
skel.it
it
Definition: skel.GENtoEVGEN.py:407
DerivationFramework::FourMuonTool::mFromN
static std::vector< std::vector< unsigned int > > mFromN(unsigned int m, unsigned int n)
Definition: FourMuonTool.cxx:252
DerivationFramework::FourMuonTool::m_trkSelector
PublicToolHandle< Trk::ITrackSelectorTool > m_trkSelector
Definition: FourMuonTool.h:167
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
DerivationFramework::FourMuonTool::m_iVertexFitter
PublicToolHandle< Trk::IVertexFitter > m_iVertexFitter
Definition: FourMuonTool.h:165
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
DerivationFramework::FourMuonTool::fit
xAOD::Vertex * fit(const std::vector< const xAOD::TrackParticle * > &, const xAOD::TrackParticleContainer *importedTrackCollection, const Amg::Vector3D &beamSpot) const
Definition: FourMuonTool.cxx:206
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
DerivationFramework::FourMuonTool::m_useV0Fitter
Gaudi::Property< bool > m_useV0Fitter
Definition: FourMuonTool.h:162
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
python.CreateTierZeroArgdict.pairs
pairs
Definition: CreateTierZeroArgdict.py:201
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:29
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:115
DerivationFramework::FourMuonTool::m_muonIndex
SG::WriteDecorHandleKey< xAOD::MuonContainer > m_muonIndex
Definition: FourMuonTool.h:169
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
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
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
python.TrigInDetConfig.inputTracks
inputTracks
Definition: TrigInDetConfig.py:191
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:727
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
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
DerivationFramework::FourMuonTool::m_eventInfo_key
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo_key
Definition: FourMuonTool.h:168
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::BPhysPVTools::PrepareVertexLinks
static void PrepareVertexLinks(xAOD::Vertex *theResult, const xAOD::TrackParticleContainer *importedTrackCollection)
Definition: BPhysPVTools.cxx:530
Combination
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
Trk::Combined
@ Combined
Definition: TrackSummaryTool.h:32
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
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
DerivationFramework::FourMuonTool::m_iV0VertexFitter
PublicToolHandle< Trk::IVertexFitter > m_iV0VertexFitter
Definition: FourMuonTool.h:166
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DerivationFramework::FourMuonTool::buildCombinations
static void buildCombinations(const std::vector< const xAOD::Muon * > &muonsIn, std::vector< Combination > &pairs, std::vector< Combination > &quadruplets, unsigned int nSelectedMuons)
Definition: FourMuonTool.cxx:304
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
DerivationFramework::FourMuonTool::m_TrkParticleCollection
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrkParticleCollection
Definition: FourMuonTool.h:164
Trk::TrkV0VertexFitter::fit
virtual xAOD::Vertex * fit(const std::vector< const xAOD::TrackParticle * > &vectorTrk, const Amg::Vector3D &startingPoint) const override
Interface for xAOD::TrackParticle with Amg::Vector3D starting point.
Definition: TrkV0VertexFitter.cxx:83
a
TList * a
Definition: liststreamerinfos.cxx:10
xAOD::Vertex_v1::chiSquared
float chiSquared() const
Returns the of the vertex fit as float.
h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
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
python.TrackLeptonConfig.quality
quality
Definition: TrackLeptonConfig.py:16
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:629
DerivationFramework::FourMuonTool::m_ptCut
Gaudi::Property< double > m_ptCut
Definition: FourMuonTool.h:160
DerivationFramework::FourMuonTool::getQuadIndices
static std::vector< std::vector< unsigned int > > getQuadIndices(unsigned int length)
Definition: FourMuonTool.cxx:240
python.BuildSignatureFlags.beamSpot
AthConfigFlags beamSpot(AthConfigFlags flags, str instanceName, str recoMode)
Definition: BuildSignatureFlags.py:491
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801
Trk::TrkV0VertexFitter
This class implements a vertex fitting algorithm optimised for V0 finding.
Definition: TrkV0VertexFitter.h:40
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
DerivationFramework::FourMuonTool::getPairIndices
static std::vector< std::pair< unsigned int, unsigned int > > getPairIndices(unsigned int length)
Definition: FourMuonTool.cxx:284
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
fitman.k
k
Definition: fitman.py:528
python.SystemOfUnits.m
float m
Definition: SystemOfUnits.py:106
dumpNswErrorDb.quad
def quad
Definition: dumpNswErrorDb.py:30