182 if(!muonhandle.isValid()){
184 return StatusCode::FAILURE;
191 std::vector<const xAOD::TrackParticleContainer*> importedMuonTrackCollections;
195 if(!handle.isValid()){
196 ATH_MSG_WARNING(
"No muon TrackParticle collection with name " << handle.key() <<
" found in StoreGate!");
197 return StatusCode::FAILURE;
199 ATH_MSG_DEBUG(
"Found muon TrackParticle collection " << handle.key() <<
" in StoreGate!");
200 ATH_MSG_DEBUG(
"Muon TrackParticle container size "<< handle->size());
201 importedMuonTrackCollections.push_back(handle.cptr());
209 if(!handle.isValid()){
210 ATH_MSG_WARNING(
"No TrackParticle collection with name " << handle.key() <<
" found in StoreGate!");
211 return StatusCode::FAILURE;
213 importedTrackCollection = handle.cptr();
214 ATH_MSG_DEBUG(
"Found TrackParticle collection " << handle.key() <<
" in StoreGate!");
216 ATH_MSG_DEBUG(
"ID TrackParticle container size "<< handle->size());
219 typedef std::vector<const xAOD::TrackParticle*>
TrackBag;
220 typedef std::vector<const xAOD::Muon*>
MuonBag;
227 for (trkCItr=importedTrackCollection->begin(); trkCItr!=importedTrackCollection->end(); ++trkCItr) {
231 theIDTracksAfterSelection.push_back(TP);
233 if (theIDTracksAfterSelection.size() == 0)
return StatusCode::SUCCESS;;
234 ATH_MSG_DEBUG(
"Number of tracks after ID track selection: " << theIDTracksAfterSelection.size());
238 MuonBag theMuonsAfterSelection;
240 for (
auto muItr=importedMuonCollection->
begin(); muItr!=importedMuonCollection->
end(); ++muItr) {
241 if ( *muItr == NULL )
continue;
242 if (!(*muItr)->inDetTrackParticleLink().isValid())
continue;
244 if ( muonTrk==NULL)
continue;
249 if ( (*muItr)->muonType() == xAOD::Muon::SiliconAssociatedForwardMuon && !
m_useCombMeasurement)
continue;
250 theMuonsAfterSelection.push_back(*muItr);
252 if (theMuonsAfterSelection.size() == 0)
return StatusCode::SUCCESS;;
253 ATH_MSG_DEBUG(
"Number of muons after selection: " << theMuonsAfterSelection.size());
257 std::vector<JpsiCandidate> jpsiCandidates;
265 std::vector<JpsiCandidate> selectCandidates;
266 for(
auto &cand : jpsiCandidates) {
if(cand.muonTypes!=
TT) selectCandidates.push_back(cand); }
267 selectCandidates.swap(jpsiCandidates);
268 ATH_MSG_DEBUG(
"Number of candidates after requirement of at least 1 combined muon: " << jpsiCandidates.size() );
276 for (
auto jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end(); ++jpsiItr) {
277 (*jpsiItr).collection1 = importedTrackCollection;
278 (*jpsiItr).collection2 = importedTrackCollection;
283 for (
auto jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end(); ++jpsiItr) {
285 (*jpsiItr).trackParticle1 = (*jpsiItr).muon1->trackParticle( xAOD::Muon::InnerDetectorTrackParticle );
286 (*jpsiItr).trackParticle2 = (*jpsiItr).muon2->trackParticle( xAOD::Muon::InnerDetectorTrackParticle );
287 (*jpsiItr).collection1 = importedTrackCollection;
288 (*jpsiItr).collection2 = importedTrackCollection;
291 if (!(*jpsiItr).muon1->combinedTrackParticleLink().isValid()) {
292 (*jpsiItr).trackParticle1 = (*jpsiItr).muon1->trackParticle( xAOD::Muon::InnerDetectorTrackParticle );
293 (*jpsiItr).collection1 = importedTrackCollection;
296 if (!(*jpsiItr).muon2->combinedTrackParticleLink().isValid()) {
297 (*jpsiItr).trackParticle2 = (*jpsiItr).muon2->trackParticle( xAOD::Muon::InnerDetectorTrackParticle );
298 (*jpsiItr).collection2 = importedTrackCollection;
301 if ((*jpsiItr).muon1->combinedTrackParticleLink().isValid()) {
302 (*jpsiItr).trackParticle1 = (*jpsiItr).muon1->trackParticle( xAOD::Muon::CombinedTrackParticle );
303 bool foundCollection(
false);
305 for (
auto muTrkCollItr=importedMuonTrackCollections.begin(); muTrkCollItr!=importedMuonTrackCollections.end(); ++muTrkCollItr) {
306 if (
isContainedIn((*jpsiItr).trackParticle1,*muTrkCollItr)) { (*jpsiItr).collection1 = *muTrkCollItr; foundCollection=
true;
break;}
308 if (!foundCollection) {
309 (*jpsiItr).trackParticle1 = (*jpsiItr).muon1->trackParticle( xAOD::Muon::InnerDetectorTrackParticle );
310 (*jpsiItr).collection1 = importedTrackCollection;
311 ATH_MSG_WARNING(
"Muon track from muon of author " << (*jpsiItr).muon1->author() <<
" not found in muon track collections you have provided.");
312 ATH_MSG_WARNING(
"Defaulting to ID track collection - combined measurement will not be used");
316 if ((*jpsiItr).muon2->combinedTrackParticleLink().isValid()) {
317 (*jpsiItr).trackParticle2 = (*jpsiItr).muon2->trackParticle( xAOD::Muon::CombinedTrackParticle );
318 bool foundCollection(
false);
320 for (
auto muTrkCollItr=importedMuonTrackCollections.begin(); muTrkCollItr!=importedMuonTrackCollections.end(); ++muTrkCollItr) {
321 if (
isContainedIn((*jpsiItr).trackParticle2,*muTrkCollItr)) { (*jpsiItr).collection2 = *muTrkCollItr; foundCollection=
true;
break;}
323 if (!foundCollection) {
324 (*jpsiItr).trackParticle2 = (*jpsiItr).muon2->trackParticle( xAOD::Muon::InnerDetectorTrackParticle );
325 (*jpsiItr).collection2 = importedTrackCollection;
326 ATH_MSG_WARNING(
"Muon track from muon of author " << (*jpsiItr).muon2->author() <<
" not found in muon track collections you have provided.");
327 ATH_MSG_WARNING(
"Defaulting to ID track collection - combined measurement will not be used");
337 std::vector<JpsiCandidate> selectCandidates;
338 for(
auto& cand : jpsiCandidates){
339 bool reject = (fabs(cand.trackParticle1->pt()) <
m_higherPt) && (fabs(cand.trackParticle2->pt()) <
m_higherPt);
340 if(!reject) selectCandidates.push_back(cand);
342 selectCandidates.swap(jpsiCandidates);
343 ATH_MSG_DEBUG(
"Number of candidates after higherPt cut: " << jpsiCandidates.size() );
347 std::vector<JpsiCandidate> sortedJpsiCandidates;
350 ATH_MSG_DEBUG(
"Number of candidates after charge selection: " << sortedJpsiCandidates.size() );
354 std::vector<JpsiCandidate> selectCandidates;
355 for(
auto& cand : sortedJpsiCandidates){
356 double deltatheta = fabs( cand.trackParticle1->theta() - cand.trackParticle2->theta() );
359 if(!reject) selectCandidates.push_back(cand);
361 sortedJpsiCandidates.swap(selectCandidates);
362 ATH_MSG_DEBUG(
"Number of collimated candidates: " << sortedJpsiCandidates.size() );
368 std::vector<JpsiCandidate> selectCandidates;
369 for(
auto& cand : sortedJpsiCandidates){
371 bool reject = invMass < m_invMassLower || invMass >
m_invMassUpper;
372 if(!reject) selectCandidates.push_back(cand);
374 selectCandidates.swap(sortedJpsiCandidates);
375 ATH_MSG_DEBUG(
"Number of candidates passing invariant mass selection: " << sortedJpsiCandidates.size() );
378 ATH_MSG_DEBUG(
"Number of pairs passing all selections and going to vertexing: " << sortedJpsiCandidates.size() );
379 if (sortedJpsiCandidates.size() == 0)
return StatusCode::SUCCESS;;
380 std::vector<const xAOD::TrackParticle*> theTracks;
381 std::vector<const xAOD::Muon*> theStoredMuons;
383 for(
auto jpsiItr=sortedJpsiCandidates.begin(); jpsiItr!=sortedJpsiCandidates.end(); ++jpsiItr) {
385 theTracks.push_back((*jpsiItr).trackParticle1);
386 theTracks.push_back((*jpsiItr).trackParticle2);
387 std::unique_ptr<xAOD::Vertex> myVxCandidate {
fit(theTracks,importedTrackCollection)};
390 double chi2 = myVxCandidate->chiSquared();
395 bool validtrk = jpsiHelper.setRefTrks();
396 if(!validtrk)
ATH_MSG_WARNING(
"Problem setting tracks " << __FILE__ <<
':' << __LINE__);
398 theStoredMuons.clear();
399 theStoredMuons.push_back((*jpsiItr).muon1);
400 if (
m_mumu) theStoredMuons.push_back((*jpsiItr).muon2);
401 bool valid = jpsiHelper.setMuons(theStoredMuons,importedMuonCollection);
405 vxContainer.
push_back(std::move(myVxCandidate));
416 return StatusCode::SUCCESS;;