ATLAS Offline Software
Loading...
Searching...
No Matches
FourMuonTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// ****************************************************************************
6// ----------------------------------------------------------------------------
7// FourMuonTool header file
8//
9// James Catmore <James.Catmore@cern.ch>
10
11// ----------------------------------------------------------------------------
12// ****************************************************************************
13#ifndef BPHY4TOOL_H
14#define BPHY4TOOL_H
16#include "GaudiKernel/ToolHandle.h"
19#include "xAODMuon/Muon.h"
21
22#include <vector>
23#include <string>
25
26namespace Trk {
27 class IVertexFitter;
30}
31
32namespace DerivationFramework {
33
34 // Struct and enum to associate muon pairs with track pairs
35 // and make the program flow more straightforward
37 {
38 std::vector<const xAOD::Muon*> muons;
39 std::vector<unsigned int> quadIndices;
40 std::pair<unsigned int, unsigned int> pairIndices;
41
42 std::string combinationCharges() {
43 std::string chargeStr = "";
44 if (muons.at(0)->charge() > 0) {chargeStr += "+";}
45 else {chargeStr += "-";}
46 if (muons.at(1)->charge() > 0) {chargeStr += "+";}
47 else {chargeStr += "-";}
48 if (muons.size()==4) {
49 if (muons.at(2)->charge() > 0) {chargeStr += "+";}
50 else {chargeStr += "-";}
51 if (muons.at(3)->charge() > 0) {chargeStr += "+";}
52 else {chargeStr += "-";}
53 }
54 return chargeStr;
55 }
56
57 std::string combinationIndices() {
58 std::string indexStr = "";
59 std::stringstream ss;
60 if (muons.size()==2) {
61 ss.str(""); ss.clear();
62 ss << pairIndices.first;
63 indexStr+=ss.str();
64 ss.str(""); ss.clear();
65 ss << pairIndices.second;
66 indexStr+=ss.str();
67 }
68 if (muons.size()==4) {
69 for (unsigned int i=0; i<4; ++i) {
70 ss.str(""); ss.clear();
71 ss << quadIndices[i];
72 indexStr+=ss.str();
73 }
74 }
75 return indexStr;
76 }
77
79 auto& link = mu->inDetTrackParticleLink();
80 return link.isValid() ? *link : nullptr;
81 }
82
83 std::vector<const xAOD::TrackParticle*> trackParticles(const std::string& specify) {
84 std::vector<const xAOD::TrackParticle*> theTracks;
85 bool oppCh(false);
86 if (muons.at(0)->charge()*muons.at(1)->charge() < 0) oppCh=true;
87 if (specify=="pair1") {
88 theTracks.push_back(GetMuonTrack(muons.at(0)));
89 theTracks.push_back(GetMuonTrack(muons.at(1)));
90 }
91 if (specify=="pair2") {
92 theTracks.push_back(GetMuonTrack(muons.at(2)));
93 theTracks.push_back(GetMuonTrack(muons.at(3)));
94 }
95 if (specify=="DC") {
96 if (oppCh) {
97 theTracks.push_back(GetMuonTrack(muons.at(0)));
98 theTracks.push_back(GetMuonTrack(muons.at(1)));
99 theTracks.push_back(GetMuonTrack(muons.at(2)));
100 theTracks.push_back(GetMuonTrack(muons.at(3)));
101 } else {
102 theTracks.push_back(GetMuonTrack(muons.at(0)));
103 theTracks.push_back(GetMuonTrack(muons.at(2)));
104 theTracks.push_back(GetMuonTrack(muons.at(1)));
105 theTracks.push_back(GetMuonTrack(muons.at(3)));
106 }
107 }
108 if (specify=="AC") {
109 theTracks.push_back(GetMuonTrack(muons.at(0)));
110 theTracks.push_back(GetMuonTrack(muons.at(3)));
111 theTracks.push_back(GetMuonTrack(muons.at(1)));
112 theTracks.push_back(GetMuonTrack(muons.at(2)));
113 }
114 if (specify=="SS") {
115 if (oppCh) {
116 theTracks.push_back(GetMuonTrack(muons.at(0)));
117 theTracks.push_back(GetMuonTrack(muons.at(2)));
118 theTracks.push_back(GetMuonTrack(muons.at(1)));
119 theTracks.push_back(GetMuonTrack(muons.at(3)));
120 } else {
121 theTracks.push_back(GetMuonTrack(muons.at(0)));
122 theTracks.push_back(GetMuonTrack(muons.at(1)));
123 theTracks.push_back(GetMuonTrack(muons.at(2)));
124 theTracks.push_back(GetMuonTrack(muons.at(3)));
125 }
126 }
127 return theTracks;
128 }
129
130 };
131
133 {
134 public:
135 FourMuonTool(const std::string& t, const std::string& n, const IInterface* p);
137 StatusCode initialize();
138
139 //-------------------------------------------------------------------------------------
140 //Doing Calculation and inline functions
141 StatusCode performSearch(xAOD::VertexContainer* pairVxContainer, xAOD::VertexContainer* quadVxContainer,
142 bool &acceptEvent, const EventContext& ctx) const;
143 xAOD::Vertex* fit(const std::vector<const xAOD::TrackParticle*>& ,const xAOD::TrackParticleContainer* importedTrackCollection, const Amg::Vector3D &beamSpot) const;
144 static std::vector<std::vector<unsigned int> > getQuadIndices(unsigned int length);
145 static std::vector<std::pair<unsigned int, unsigned int> > getPairIndices(unsigned int length);
146 static std::vector<std::vector<unsigned int> > mFromN(unsigned int m, unsigned int n);
147 static void combinatorics(unsigned int offset,
148 unsigned int k,
149 std::vector<unsigned int> &combination,
150 std::vector<unsigned int> &mainList,
151 std::vector<std::vector<unsigned int> > &allCombinations);
152 static void buildCombinations(const std::vector<const xAOD::Muon*> &muonsIn,
153 std::vector<Combination> &pairs,
154 std::vector<Combination> &quadruplets,
155 unsigned int nSelectedMuons);
156 static bool passesQuadSelection(const std::vector<const xAOD::Muon*> &muonsIn);
157 //-------------------------------------------------------------------------------------
158
159 private:
160 Gaudi::Property<double> m_ptCut{this, "ptCut", 0.0};
161 Gaudi::Property<double> m_etaCut{this, "etaCut", 0.0};
162 Gaudi::Property<bool> m_useV0Fitter{this, "useV0Fitter", false};
164 SG::ReadHandleKey<xAOD::TrackParticleContainer> m_TrkParticleCollection{this, "TrackParticleCollection", "TrackParticleCandidate"};
165 PublicToolHandle < Trk::IVertexFitter > m_iVertexFitter{this, "TrkVertexFitterTool", "Trk::TrkVKalVrtFitter"};
166 PublicToolHandle < Trk::IVertexFitter > m_iV0VertexFitter{this, "V0VertexFitterTool", "Trk::V0VertexFitter"};
167 PublicToolHandle < Trk::ITrackSelectorTool > m_trkSelector{this, "TrackSelectorTool", "InDet::TrackSelectorTool"};
168 SG::ReadHandleKey<xAOD::EventInfo> m_eventInfo_key{this, "EventInfo", "EventInfo", "Input event information"};
170
171 };
172} // end of namespace
173#endif
double length(const pvec &v)
static Double_t ss
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
FourMuonTool(const std::string &t, const std::string &n, const IInterface *p)
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 bool passesQuadSelection(const std::vector< const xAOD::Muon * > &muonsIn)
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo_key
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrkParticleCollection
xAOD::Vertex * fit(const std::vector< const xAOD::TrackParticle * > &, const xAOD::TrackParticleContainer *importedTrackCollection, const Amg::Vector3D &beamSpot) const
PublicToolHandle< Trk::ITrackSelectorTool > m_trkSelector
PublicToolHandle< Trk::IVertexFitter > m_iVertexFitter
static std::vector< std::vector< unsigned int > > getQuadIndices(unsigned int length)
SG::ReadHandleKey< xAOD::MuonContainer > m_muonCollectionKey
Gaudi::Property< bool > m_useV0Fitter
static void buildCombinations(const std::vector< const xAOD::Muon * > &muonsIn, std::vector< Combination > &pairs, std::vector< Combination > &quadruplets, unsigned int nSelectedMuons)
StatusCode performSearch(xAOD::VertexContainer *pairVxContainer, xAOD::VertexContainer *quadVxContainer, bool &acceptEvent, const EventContext &ctx) const
Gaudi::Property< double > m_etaCut
static std::vector< std::pair< unsigned int, unsigned int > > getPairIndices(unsigned int length)
SG::WriteDecorHandleKey< xAOD::MuonContainer > m_muonIndex
Gaudi::Property< double > m_ptCut
static std::vector< std::vector< unsigned int > > mFromN(unsigned int m, unsigned int n)
PublicToolHandle< Trk::IVertexFitter > m_iV0VertexFitter
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
The abstract interface base class for track selector tools.
Interface class for vertex fitting AlgTools, for more detailed information, take a look at the header...
This class implements a vertex fitting algorithm optimised for V0 finding.
Eigen::Matrix< double, 3, 1 > Vector3D
THE reconstruction tool.
Ensure that the ATLAS eigen extensions are properly loaded.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Muon_v1 Muon
Reference the current persistent version:
std::vector< const xAOD::Muon * > muons
std::vector< unsigned int > quadIndices
std::pair< unsigned int, unsigned int > pairIndices
const xAOD::TrackParticle * GetMuonTrack(const xAOD::Muon *mu) const
std::vector< const xAOD::TrackParticle * > trackParticles(const std::string &specify)