66 {
68 selectEvent = false;
69
70
72 ATH_CHECK(importedMuonCollection.isValid());
73 ATH_MSG_DEBUG(
"Muon container size "<<importedMuonCollection->size());
74
75
77 ATH_CHECK(importedTrackCollection.isValid());
78 ATH_MSG_DEBUG(
"ID TrackParticle container size "<< importedTrackCollection->size());
79
80
81 std::vector<const xAOD::Muon*> theMuonsAfterSelection;
82 SG::WriteDecorHandle<xAOD::MuonContainer, int> muonDecorator(
m_muonIndex, ctx);
83 unsigned int nCombMuons = 0;
84 unsigned int nSegmentTaggedMuons = 0;
85
86 for (const auto * muon : *importedMuonCollection) {
87 if ( !muon ) continue;
88 muonDecorator(*muon) = -1;
89 if ( (
muon->muonType() != xAOD::Muon::MuonType::Combined ) && (
muon->muonType() != xAOD::Muon::MuonType::SegmentTagged ) )
continue;
90 const xAOD::TrackParticle* muonTrk =
muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
91 if ( !muonTrk ) continue;
94 if ( fabs(muonTrk->
pt())<
m_ptCut )
continue;
96 if (
muon->muonType() == xAOD::Muon::MuonType::Combined ) ++nCombMuons;
97 if (
muon->muonType() == xAOD::Muon::MuonType::SegmentTagged ) ++nSegmentTaggedMuons;
98 theMuonsAfterSelection.push_back(muon);
99 }
100 unsigned int nSelectedMuons = theMuonsAfterSelection.size();
101 ATH_MSG_DEBUG(
"Number of muons after selection: " << nSelectedMuons);
103 ATH_MSG_DEBUG(
"and " << nSegmentTaggedMuons <<
" are segment tagged");
104 if ( (nSelectedMuons < 4) || (nCombMuons < 1) ) {
106 return StatusCode::SUCCESS;
107 }
108 selectEvent = true;
109
110
111 SG::AuxElement::Decorator< std::string > indexDecorator("CombinationCode");
112 SG::AuxElement::Decorator< std::string > chargeDecorator("ChargeCode");
113
114
116 return b->pt() < a->pt();
117 });
118
119
120 unsigned int muonIndex(0);
121 for (auto selMuon : theMuonsAfterSelection) {
122 muonDecorator(*selMuon) = muonIndex;
123 ++muonIndex;
124 }
125
126
127 std::vector<Combination> quadruplets;
128 std::vector<Combination>
pairs;
130 if (quadruplets.size()==0) {
132 return StatusCode::SUCCESS;
133 }
134
135
139
140
142 for (std::vector<Combination>::iterator pairItr =
pairs.begin(); pairItr!=
pairs.end(); ++pairItr) {
143 std::vector<const xAOD::TrackParticle*> theTracks = (*pairItr).trackParticles("pair1");
144 std::unique_ptr<xAOD::Vertex> pairVxCandidate =
fit(ctx,theTracks,importedTrackCollection.get(),beamSpot);
145 if (pairVxCandidate) {
146
147 indexDecorator(*pairVxCandidate) = (*pairItr).combinationIndices();
148 chargeDecorator(*pairVxCandidate) = (*pairItr).combinationCharges();
149
150 xAOD::BPhysHelper
helper(pairVxCandidate.get());
152 std::vector<const xAOD::Muon*> theStoredMuons;
153 theStoredMuons = (*pairItr).muons;
154 helper.setMuons(theStoredMuons,importedMuonCollection.get());
155 ATH_MSG_DEBUG(
"..... indices: " << (*pairItr).combinationIndices() <<
156 " charges: " << (*pairItr).combinationCharges() <<
157 " chi2: " << pairVxCandidate->chiSquared());
158
159 pairVxContainer->
push_back(std::move(pairVxCandidate));
160 } else {
162 }
163 }
165
166
168 for (std::vector<Combination>::iterator quadItr = quadruplets.begin(); quadItr!=quadruplets.end(); ++quadItr) {
169 std::vector<const xAOD::TrackParticle*> theDCTracks; theDCTracks.clear();
170 theDCTracks = (*quadItr).trackParticles("DC");
171 std::unique_ptr<xAOD::Vertex> dcVxCandidate =
fit(ctx,theDCTracks,importedTrackCollection.get(), beamSpot);
172 if (dcVxCandidate != 0) {
173
174 indexDecorator(*dcVxCandidate) = (*quadItr).combinationIndices();
175 chargeDecorator(*dcVxCandidate) = (*quadItr).combinationCharges();
176
177 double dcChi2 = dcVxCandidate->chiSquared();
178
179 xAOD::BPhysHelper
helper(dcVxCandidate.get());
181 const std::vector<const xAOD::Muon*> &theStoredMuons = (*quadItr).muons;
182 helper.setMuons(theStoredMuons,importedMuonCollection.get());
183
184 quadVxContainer->
push_back(std::move(dcVxCandidate));
185 ATH_MSG_DEBUG(
"..... indices: " << (*quadItr).combinationIndices() <<
186 " charges: " << (*quadItr).combinationCharges() <<
187 " chi2(DC): " << dcChi2);
188 } else {
190 }
191 }
193
194 return StatusCode::SUCCESS;;
195 }
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Eigen::Matrix< double, 3, 1 > Vector3D
AthConfigFlags beamSpot(AthConfigFlags flags, str instanceName, str recoMode)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
Muon_v1 Muon
Reference the current persistent version: