160 return StatusCode::FAILURE;
167 std::vector<const xAOD::TrackParticleContainer*> importedMuonTrackCollections;
171 if(!handle.isValid()){
172 ATH_MSG_WARNING(
"No muon TrackParticle collection with name " << handle.key() <<
" found in StoreGate!");
173 return StatusCode::FAILURE;
175 ATH_MSG_DEBUG(
"Found muon TrackParticle collection " << handle.key() <<
" in StoreGate!");
176 ATH_MSG_DEBUG(
"Muon TrackParticle container size "<< handle->size());
177 importedMuonTrackCollections.push_back(handle.cptr());
185 if(!handle.isValid()){
186 ATH_MSG_WARNING(
"No TrackParticle collection with name " << handle.key() <<
" found in StoreGate!");
187 return StatusCode::FAILURE;
189 importedTrackCollection = handle.cptr();
190 ATH_MSG_DEBUG(
"Found TrackParticle collection " << handle.key() <<
" in StoreGate!");
192 ATH_MSG_DEBUG(
"ID TrackParticle container size "<< handle->size());
195 typedef std::vector<const xAOD::TrackParticle*> TrackBag;
196 typedef std::vector<const xAOD::Muon*> MuonBag;
200 TrackBag theIDTracksAfterSelection;
203 for (trkCItr=importedTrackCollection->
begin(); trkCItr!=importedTrackCollection->
end(); ++trkCItr) {
207 theIDTracksAfterSelection.push_back(TP);
209 if (theIDTracksAfterSelection.size() == 0)
return StatusCode::SUCCESS;;
210 ATH_MSG_DEBUG(
"Number of tracks after ID track selection: " << theIDTracksAfterSelection.size());
214 MuonBag theMuonsAfterSelection;
216 for (
auto muItr=importedMuonCollection->
begin(); muItr!=importedMuonCollection->
end(); ++muItr) {
217 if ( *muItr ==
nullptr )
continue;
218 const xAOD::TrackParticle* muonTrk = (*muItr)->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
219 if ( muonTrk==NULL)
continue;
223 if (
m_combOnly && (*muItr)->muonType() != xAOD::Muon::MuonType::Combined )
continue;
224 if ( (*muItr)->muonType() == xAOD::Muon::MuonType::SiliconAssociatedForwardMuon && !
m_useCombMeasurement)
continue;
225 theMuonsAfterSelection.push_back(*muItr);
227 if (theMuonsAfterSelection.size() == 0)
return StatusCode::SUCCESS;;
228 ATH_MSG_DEBUG(
"Number of muons after selection: " << theMuonsAfterSelection.size());
232 std::vector<JpsiCandidate> jpsiCandidates;
240 std::vector<JpsiCandidate> selectCandidates;
241 for(
auto &cand : jpsiCandidates) {
if(cand.muonTypes!=
TT) selectCandidates.push_back(cand); }
242 selectCandidates.swap(jpsiCandidates);
243 ATH_MSG_DEBUG(
"Number of candidates after requirement of at least 1 combined muon: " << jpsiCandidates.size() );
251 for (
auto jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end(); ++jpsiItr) {
252 (*jpsiItr).collection1 = importedTrackCollection;
253 (*jpsiItr).collection2 = importedTrackCollection;
258 using enum xAOD::Muon::TrackParticleType;
259 for (
auto jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end(); ++jpsiItr) {
261 (*jpsiItr).trackParticle1 = (*jpsiItr).muon1->trackParticle(InnerDetectorTrackParticle);
262 (*jpsiItr).trackParticle2 = (*jpsiItr).muon2->trackParticle(InnerDetectorTrackParticle);
263 (*jpsiItr).collection1 = importedTrackCollection;
264 (*jpsiItr).collection2 = importedTrackCollection;
267 if (!(*jpsiItr).muon1->trackParticle(CombinedTrackParticle)) {
268 (*jpsiItr).trackParticle1 = (*jpsiItr).muon1->trackParticle(InnerDetectorTrackParticle );
269 (*jpsiItr).collection1 = importedTrackCollection;
272 if (!(*jpsiItr).muon2->trackParticle(CombinedTrackParticle)) {
273 (*jpsiItr).trackParticle2 = (*jpsiItr).muon2->trackParticle(InnerDetectorTrackParticle );
274 (*jpsiItr).collection2 = importedTrackCollection;
277 if ((*jpsiItr).muon1->trackParticle(CombinedTrackParticle)) {
278 (*jpsiItr).trackParticle1 = (*jpsiItr).muon1->trackParticle(CombinedTrackParticle);
279 bool foundCollection(
false);
281 for (
auto muTrkCollItr=importedMuonTrackCollections.begin(); muTrkCollItr!=importedMuonTrackCollections.end(); ++muTrkCollItr) {
282 if (
isContainedIn((*jpsiItr).trackParticle1,*muTrkCollItr)) { (*jpsiItr).collection1 = *muTrkCollItr; foundCollection=
true;
break;}
284 if (!foundCollection) {
285 (*jpsiItr).trackParticle1 = (*jpsiItr).muon1->trackParticle( InnerDetectorTrackParticle );
286 (*jpsiItr).collection1 = importedTrackCollection;
287 ATH_MSG_WARNING(
"Muon track from muon of author " << (*jpsiItr).muon1->author() <<
" not found in muon track collections you have provided.");
288 ATH_MSG_WARNING(
"Defaulting to ID track collection - combined measurement will not be used");
292 if ((*jpsiItr).muon2->trackParticle(CombinedTrackParticle)) {
293 (*jpsiItr).trackParticle2 = (*jpsiItr).muon2->trackParticle(CombinedTrackParticle );
294 bool foundCollection(
false);
296 for (
auto muTrkCollItr=importedMuonTrackCollections.begin(); muTrkCollItr!=importedMuonTrackCollections.end(); ++muTrkCollItr) {
297 if (
isContainedIn((*jpsiItr).trackParticle2,*muTrkCollItr)) { (*jpsiItr).collection2 = *muTrkCollItr; foundCollection=
true;
break;}
299 if (!foundCollection) {
300 (*jpsiItr).trackParticle2 = (*jpsiItr).muon2->trackParticle(InnerDetectorTrackParticle);
301 (*jpsiItr).collection2 = importedTrackCollection;
302 ATH_MSG_WARNING(
"Muon track from muon of author " << (*jpsiItr).muon2->author() <<
" not found in muon track collections you have provided.");
303 ATH_MSG_WARNING(
"Defaulting to ID track collection - combined measurement will not be used");
313 std::vector<JpsiCandidate> selectCandidates;
314 for(
auto& cand : jpsiCandidates){
315 bool reject = (fabs(cand.trackParticle1->pt()) <
m_higherPt) && (fabs(cand.trackParticle2->pt()) <
m_higherPt);
316 if(!reject) selectCandidates.push_back(cand);
318 selectCandidates.swap(jpsiCandidates);
319 ATH_MSG_DEBUG(
"Number of candidates after higherPt cut: " << jpsiCandidates.size() );
323 std::vector<JpsiCandidate> sortedJpsiCandidates;
326 ATH_MSG_DEBUG(
"Number of candidates after charge selection: " << sortedJpsiCandidates.size() );
330 std::vector<JpsiCandidate> selectCandidates;
331 for(
auto& cand : sortedJpsiCandidates){
332 double deltatheta = fabs( cand.trackParticle1->theta() - cand.trackParticle2->theta() );
335 if(!reject) selectCandidates.push_back(cand);
337 sortedJpsiCandidates.swap(selectCandidates);
338 ATH_MSG_DEBUG(
"Number of collimated candidates: " << sortedJpsiCandidates.size() );
344 std::vector<JpsiCandidate> selectCandidates;
345 for(
auto& cand : sortedJpsiCandidates){
347 bool reject = invMass < m_invMassLower || invMass >
m_invMassUpper;
348 if(!reject) selectCandidates.push_back(cand);
350 selectCandidates.swap(sortedJpsiCandidates);
351 ATH_MSG_DEBUG(
"Number of candidates passing invariant mass selection: " << sortedJpsiCandidates.size() );
354 ATH_MSG_DEBUG(
"Number of pairs passing all selections and going to vertexing: " << sortedJpsiCandidates.size() );
355 if (sortedJpsiCandidates.size() == 0)
return StatusCode::SUCCESS;;
356 std::vector<const xAOD::TrackParticle*> theTracks;
357 std::vector<const xAOD::Muon*> theStoredMuons;
359 for(
auto jpsiItr=sortedJpsiCandidates.begin(); jpsiItr!=sortedJpsiCandidates.end(); ++jpsiItr) {
361 theTracks.push_back((*jpsiItr).trackParticle1);
362 theTracks.push_back((*jpsiItr).trackParticle2);
363 std::unique_ptr<xAOD::Vertex> myVxCandidate {
fit(ctx, theTracks,importedTrackCollection)};
366 double chi2 = myVxCandidate->chiSquared();
372 if(!validtrk)
ATH_MSG_WARNING(
"Problem setting tracks " << __FILE__ <<
':' << __LINE__);
374 theStoredMuons.clear();
375 theStoredMuons.push_back((*jpsiItr).muon1);
376 if (
m_mumu) theStoredMuons.push_back((*jpsiItr).muon2);
377 bool valid = jpsiHelper.
setMuons(theStoredMuons,importedMuonCollection);
378 if(!valid)
ATH_MSG_WARNING(
"Problem setting muons " << __FILE__ <<
':' << __LINE__);
381 vxContainer.
push_back(std::move(myVxCandidate));
391 return StatusCode::SUCCESS;;
A number of constexpr particle constants to avoid hardcoding them directly in various places.