64 {
66 selectEvent = false;
67
68
70 ATH_CHECK(importedMuonCollection.isValid());
71 ATH_MSG_DEBUG(
"Muon container size "<<importedMuonCollection->size());
72
73
75 ATH_CHECK(importedTrackCollection.isValid());
76 ATH_MSG_DEBUG(
"ID TrackParticle container size "<< importedTrackCollection->size());
77
78
79 std::vector<const xAOD::Muon*> theMuonsAfterSelection;
80 SG::WriteDecorHandle<xAOD::MuonContainer, int> muonDecorator(
m_muonIndex, ctx);
81 unsigned int nCombMuons = 0;
82 unsigned int nSegmentTaggedMuons = 0;
83
84 for (const auto * muon : *importedMuonCollection) {
85 if ( !muon ) continue;
86 muonDecorator(*muon) = -1;
87 if ( (
muon->muonType() != xAOD::Muon::MuonType::Combined ) && (
muon->muonType() != xAOD::Muon::MuonType::SegmentTagged ) )
continue;
88 const xAOD::TrackParticle* muonTrk =
muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
89 if ( !muonTrk ) continue;
92 if ( fabs(muonTrk->
pt())<
m_ptCut )
continue;
94 if (
muon->muonType() == xAOD::Muon::MuonType::Combined ) ++nCombMuons;
95 if (
muon->muonType() == xAOD::Muon::MuonType::SegmentTagged ) ++nSegmentTaggedMuons;
96 theMuonsAfterSelection.push_back(muon);
97 }
98 unsigned int nSelectedMuons = theMuonsAfterSelection.size();
99 ATH_MSG_DEBUG(
"Number of muons after selection: " << nSelectedMuons);
101 ATH_MSG_DEBUG(
"and " << nSegmentTaggedMuons <<
" are segment tagged");
102 if ( (nSelectedMuons < 4) || (nCombMuons < 1) ) {
104 return StatusCode::SUCCESS;
105 }
106 selectEvent = true;
107
108
109 SG::AuxElement::Decorator< std::string > indexDecorator("CombinationCode");
110 SG::AuxElement::Decorator< std::string > chargeDecorator("ChargeCode");
111
112
114 return b->pt() < a->pt();
115 });
116
117
118 unsigned int muonIndex(0);
119 for (auto selMuon : theMuonsAfterSelection) {
120 muonDecorator(*selMuon) = muonIndex;
121 ++muonIndex;
122 }
123
124
125 std::vector<Combination> quadruplets;
126 std::vector<Combination>
pairs;
128 if (quadruplets.size()==0) {
130 return StatusCode::SUCCESS;
131 }
132
133
137
138
140 for (std::vector<Combination>::iterator pairItr =
pairs.begin(); pairItr!=
pairs.end(); ++pairItr) {
141 std::vector<const xAOD::TrackParticle*> theTracks = (*pairItr).trackParticles("pair1");
142 std::unique_ptr<xAOD::Vertex> pairVxCandidate =
fit(ctx,theTracks,importedTrackCollection.get(),beamSpot);
143 if (pairVxCandidate) {
144
145 indexDecorator(*pairVxCandidate) = (*pairItr).combinationIndices();
146 chargeDecorator(*pairVxCandidate) = (*pairItr).combinationCharges();
147
148 xAOD::BPhysHelper
helper(pairVxCandidate.get());
150 std::vector<const xAOD::Muon*> theStoredMuons;
151 theStoredMuons = (*pairItr).muons;
152 helper.setMuons(theStoredMuons,importedMuonCollection.get());
153 ATH_MSG_DEBUG(
"..... indices: " << (*pairItr).combinationIndices() <<
154 " charges: " << (*pairItr).combinationCharges() <<
155 " chi2: " << pairVxCandidate->chiSquared());
156
157 pairVxContainer->
push_back(std::move(pairVxCandidate));
158 } else {
160 }
161 }
163
164
166 for (std::vector<Combination>::iterator quadItr = quadruplets.begin(); quadItr!=quadruplets.end(); ++quadItr) {
167 std::vector<const xAOD::TrackParticle*> theDCTracks; theDCTracks.clear();
168 theDCTracks = (*quadItr).trackParticles("DC");
169 std::unique_ptr<xAOD::Vertex> dcVxCandidate =
fit(ctx,theDCTracks,importedTrackCollection.get(), beamSpot);
170 if (dcVxCandidate != 0) {
171
172 indexDecorator(*dcVxCandidate) = (*quadItr).combinationIndices();
173 chargeDecorator(*dcVxCandidate) = (*quadItr).combinationCharges();
174
175 double dcChi2 = dcVxCandidate->chiSquared();
176
177 xAOD::BPhysHelper
helper(dcVxCandidate.get());
179 const std::vector<const xAOD::Muon*> &theStoredMuons = (*quadItr).muons;
180 helper.setMuons(theStoredMuons,importedMuonCollection.get());
181
182 quadVxContainer->
push_back(std::move(dcVxCandidate));
183 ATH_MSG_DEBUG(
"..... indices: " << (*quadItr).combinationIndices() <<
184 " charges: " << (*quadItr).combinationCharges() <<
185 " chi2(DC): " << dcChi2);
186 } else {
188 }
189 }
191 if(quadVxContainer->
size() > 500){
192 ATH_MSG_WARNING(
"Event Run: " <<
evt->runNumber() <<
" Event: " <<
evt->eventNumber() <<
" quadruplet container size " << quadVxContainer->
size());
193 }
194
195 return StatusCode::SUCCESS;;
196 }
#define ATH_MSG_WARNING(x)
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: