163 return StatusCode::FAILURE;
170 std::vector<const xAOD::TrackParticleContainer*> importedMuonTrackCollections;
174 if(!handle.isValid()){
175 ATH_MSG_WARNING(
"No muon TrackParticle collection with name " << handle.key() <<
" found in StoreGate!");
176 return StatusCode::FAILURE;
178 ATH_MSG_DEBUG(
"Found muon TrackParticle collection " << handle.key() <<
" in StoreGate!");
179 ATH_MSG_DEBUG(
"Muon TrackParticle container size "<< handle->size());
180 importedMuonTrackCollections.push_back(handle.cptr());
188 if(!handle.isValid()){
189 ATH_MSG_WARNING(
"No TrackParticle collection with name " << handle.key() <<
" found in StoreGate!");
190 return StatusCode::FAILURE;
192 importedTrackCollection = handle.cptr();
193 ATH_MSG_DEBUG(
"Found TrackParticle collection " << handle.key() <<
" in StoreGate!");
195 ATH_MSG_DEBUG(
"ID TrackParticle container size "<< handle->size());
198 typedef std::vector<const xAOD::TrackParticle*> TrackBag;
199 typedef std::vector<const xAOD::Muon*> MuonBag;
203 TrackBag theIDTracksAfterSelection;
206 for (trkCItr=importedTrackCollection->
begin(); trkCItr!=importedTrackCollection->
end(); ++trkCItr) {
210 theIDTracksAfterSelection.push_back(TP);
212 if (theIDTracksAfterSelection.size() == 0)
return StatusCode::SUCCESS;;
213 ATH_MSG_DEBUG(
"Number of tracks after ID track selection: " << theIDTracksAfterSelection.size());
217 MuonBag theMuonsAfterSelection;
219 for (
auto muItr=importedMuonCollection->
begin(); muItr!=importedMuonCollection->
end(); ++muItr) {
220 if ( *muItr ==
nullptr )
continue;
221 const xAOD::TrackParticle* muonTrk = (*muItr)->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
222 if ( muonTrk==NULL)
continue;
226 if (
m_combOnly && (*muItr)->muonType() != xAOD::Muon::MuonType::Combined )
continue;
227 if ( (*muItr)->muonType() == xAOD::Muon::MuonType::SiliconAssociatedForwardMuon && !
m_useCombMeasurement)
continue;
228 theMuonsAfterSelection.push_back(*muItr);
230 if (theMuonsAfterSelection.size() == 0)
return StatusCode::SUCCESS;;
231 ATH_MSG_DEBUG(
"Number of muons after selection: " << theMuonsAfterSelection.size());
235 std::vector<JpsiCandidate> jpsiCandidates;
243 std::vector<JpsiCandidate> selectCandidates;
244 for(
auto &cand : jpsiCandidates) {
if(cand.muonTypes!=
TT) selectCandidates.push_back(cand); }
245 selectCandidates.swap(jpsiCandidates);
246 ATH_MSG_DEBUG(
"Number of candidates after requirement of at least 1 combined muon: " << jpsiCandidates.size() );
254 for (
auto jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end(); ++jpsiItr) {
255 (*jpsiItr).collection1 = importedTrackCollection;
256 (*jpsiItr).collection2 = importedTrackCollection;
261 using enum xAOD::Muon::TrackParticleType;
262 for (
auto jpsiItr=jpsiCandidates.begin(); jpsiItr!=jpsiCandidates.end(); ++jpsiItr) {
264 (*jpsiItr).trackParticle1 = (*jpsiItr).muon1->trackParticle(InnerDetectorTrackParticle);
265 (*jpsiItr).trackParticle2 = (*jpsiItr).muon2->trackParticle(InnerDetectorTrackParticle);
266 (*jpsiItr).collection1 = importedTrackCollection;
267 (*jpsiItr).collection2 = importedTrackCollection;
270 if (!(*jpsiItr).muon1->trackParticle(CombinedTrackParticle)) {
271 (*jpsiItr).trackParticle1 = (*jpsiItr).muon1->trackParticle(InnerDetectorTrackParticle );
272 (*jpsiItr).collection1 = importedTrackCollection;
275 if (!(*jpsiItr).muon2->trackParticle(CombinedTrackParticle)) {
276 (*jpsiItr).trackParticle2 = (*jpsiItr).muon2->trackParticle(InnerDetectorTrackParticle );
277 (*jpsiItr).collection2 = importedTrackCollection;
280 if ((*jpsiItr).muon1->trackParticle(CombinedTrackParticle)) {
281 (*jpsiItr).trackParticle1 = (*jpsiItr).muon1->trackParticle(CombinedTrackParticle);
282 bool foundCollection(
false);
284 for (
auto muTrkCollItr=importedMuonTrackCollections.begin(); muTrkCollItr!=importedMuonTrackCollections.end(); ++muTrkCollItr) {
285 if (
isContainedIn((*jpsiItr).trackParticle1,*muTrkCollItr)) { (*jpsiItr).collection1 = *muTrkCollItr; foundCollection=
true;
break;}
287 if (!foundCollection) {
288 (*jpsiItr).trackParticle1 = (*jpsiItr).muon1->trackParticle( InnerDetectorTrackParticle );
289 (*jpsiItr).collection1 = importedTrackCollection;
290 ATH_MSG_WARNING(
"Muon track from muon of author " << (*jpsiItr).muon1->author() <<
" not found in muon track collections you have provided.");
291 ATH_MSG_WARNING(
"Defaulting to ID track collection - combined measurement will not be used");
295 if ((*jpsiItr).muon2->trackParticle(CombinedTrackParticle)) {
296 (*jpsiItr).trackParticle2 = (*jpsiItr).muon2->trackParticle(CombinedTrackParticle );
297 bool foundCollection(
false);
299 for (
auto muTrkCollItr=importedMuonTrackCollections.begin(); muTrkCollItr!=importedMuonTrackCollections.end(); ++muTrkCollItr) {
300 if (
isContainedIn((*jpsiItr).trackParticle2,*muTrkCollItr)) { (*jpsiItr).collection2 = *muTrkCollItr; foundCollection=
true;
break;}
302 if (!foundCollection) {
303 (*jpsiItr).trackParticle2 = (*jpsiItr).muon2->trackParticle(InnerDetectorTrackParticle);
304 (*jpsiItr).collection2 = importedTrackCollection;
305 ATH_MSG_WARNING(
"Muon track from muon of author " << (*jpsiItr).muon2->author() <<
" not found in muon track collections you have provided.");
306 ATH_MSG_WARNING(
"Defaulting to ID track collection - combined measurement will not be used");
316 std::vector<JpsiCandidate> selectCandidates;
317 for(
auto& cand : jpsiCandidates){
318 bool reject = (fabs(cand.trackParticle1->pt()) <
m_higherPt) && (fabs(cand.trackParticle2->pt()) <
m_higherPt);
319 if(!reject) selectCandidates.push_back(cand);
321 selectCandidates.swap(jpsiCandidates);
322 ATH_MSG_DEBUG(
"Number of candidates after higherPt cut: " << jpsiCandidates.size() );
326 std::vector<JpsiCandidate> sortedJpsiCandidates;
329 ATH_MSG_DEBUG(
"Number of candidates after charge selection: " << sortedJpsiCandidates.size() );
333 std::vector<JpsiCandidate> selectCandidates;
334 for(
auto& cand : sortedJpsiCandidates){
335 double deltatheta = fabs( cand.trackParticle1->theta() - cand.trackParticle2->theta() );
338 if(!reject) selectCandidates.push_back(cand);
340 sortedJpsiCandidates.swap(selectCandidates);
341 ATH_MSG_DEBUG(
"Number of collimated candidates: " << sortedJpsiCandidates.size() );
347 std::vector<JpsiCandidate> selectCandidates;
348 for(
auto& cand : sortedJpsiCandidates){
350 bool reject = invMass < m_invMassLower || invMass >
m_invMassUpper;
351 if(!reject) selectCandidates.push_back(cand);
353 selectCandidates.swap(sortedJpsiCandidates);
354 ATH_MSG_DEBUG(
"Number of candidates passing invariant mass selection: " << sortedJpsiCandidates.size() );
357 ATH_MSG_DEBUG(
"Number of pairs passing all selections and going to vertexing: " << sortedJpsiCandidates.size() );
358 if (sortedJpsiCandidates.size() == 0)
return StatusCode::SUCCESS;;
359 std::vector<const xAOD::TrackParticle*> theTracks;
360 std::vector<const xAOD::Muon*> theStoredMuons;
362 for(
auto jpsiItr=sortedJpsiCandidates.begin(); jpsiItr!=sortedJpsiCandidates.end(); ++jpsiItr) {
364 theTracks.push_back((*jpsiItr).trackParticle1);
365 theTracks.push_back((*jpsiItr).trackParticle2);
366 std::unique_ptr<xAOD::Vertex> myVxCandidate {
fit(ctx, theTracks,importedTrackCollection)};
369 double chi2 = myVxCandidate->chiSquared();
375 if(!validtrk)
ATH_MSG_WARNING(
"Problem setting tracks " << __FILE__ <<
':' << __LINE__);
377 theStoredMuons.clear();
378 theStoredMuons.push_back((*jpsiItr).muon1);
379 if (
m_mumu) theStoredMuons.push_back((*jpsiItr).muon2);
380 bool valid = jpsiHelper.
setMuons(theStoredMuons,importedMuonCollection);
381 if(!valid)
ATH_MSG_WARNING(
"Problem setting muons " << __FILE__ <<
':' << __LINE__);
384 vxContainer.
push_back(std::move(myVxCandidate));
394 return StatusCode::SUCCESS;;
A number of constexpr particle constants to avoid hardcoding them directly in various places.