149 if(!jpsiCollectionhandle.
isValid()){
151 return StatusCode::FAILURE;
153 importedJpsiCollection = jpsiCollectionhandle.
cptr();
161 if(!TrkParticleHandle.
isValid()){
163 return StatusCode::FAILURE;
165 importedTrackCollection = TrkParticleHandle.
cptr();
174 importedGSFTrackCollection =
h.cptr();
184 return StatusCode::FAILURE;
186 importedMuonCollection =
h.cptr();
198 return StatusCode::FAILURE;
200 importedElectronCollection =
h.cptr();
208 typedef std::vector<const xAOD::TrackParticle*> TrackBag;
209 typedef std::vector<const xAOD::Electron*> ElectronBag;
213 TrackBag theIDTracksAfterSelection;
214 for (
auto trkPBItr=importedTrackCollection->
cbegin(); trkPBItr!=importedTrackCollection->
cend(); ++trkPBItr) {
221 if (
m_trkSelector->decision(*tp, vx) ) theIDTracksAfterSelection.push_back(tp);
226 ATH_MSG_DEBUG(
"importedTrackCollection contains GSF tracks " << importedGSFTrackCollection->
size());
227 for (
auto trkPBItr=importedGSFTrackCollection->
cbegin(); trkPBItr!=importedGSFTrackCollection->
cend(); ++trkPBItr) {
234 if (
m_trkSelector->decision(*tp, vx)) theIDTracksAfterSelection.push_back(tp);
237 if (theIDTracksAfterSelection.empty())
return StatusCode::SUCCESS;
238 ATH_MSG_DEBUG(
"Number of tracks after ID trkSelector: " << theIDTracksAfterSelection.size());
241 std::vector<const xAOD::Vertex*> selectedJpsiCandidates;
242 std::vector<const xAOD::TrackParticle*> jpsiTracks;
243 for(
auto vxcItr=importedJpsiCollection->
cbegin(); vxcItr!=importedJpsiCollection->
cend(); ++vxcItr) {
251 selectedJpsiCandidates.push_back(*vxcItr);
258 jpsiTracks.push_back(jpsiTP1);
259 jpsiTracks.push_back(jpsiTP2);
264 std::vector<double> massHypotheses;
268 massHypotheses.push_back(
kMass); massHypotheses.push_back(
piMass);
274 std::vector<double> massCuts;
278 for(
auto muon : *importedMuonCollection){
279 auto track = muon->trackParticle( xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
280 if(track==
nullptr)
continue;
282 muonTracks.push_back(track);
286 TrackBag electronTracks;
287 ElectronBag theElectronsAfterSelection;
288 if (importedElectronCollection && !importedElectronCollection->
empty()) {
289 for(
auto electron : *importedElectronCollection) {
290 if (!electron->trackParticleLink().isValid())
continue;
292 elTrk = electron->trackParticleLink().cachedElement();
293 if (!elTrk)
continue;
294 theElectronsAfterSelection.push_back(electron);
295 electronTracks.push_back(elTrk);
297 if (
m_skipNoElectron && theElectronsAfterSelection.size() == 0)
return StatusCode::SUCCESS;
298 ATH_MSG_DEBUG(
"Number of electrons after selection: " << theElectronsAfterSelection.size());
301 std::vector<const xAOD::TrackParticle*> tracks(3,
nullptr);
303 for(
auto jpsiItr=selectedJpsiCandidates.cbegin(); jpsiItr!=selectedJpsiCandidates.cend(); ++jpsiItr) {
312 jpsiTracks.resize(2);
313 jpsiTracks[0] = jpsiTP1;
314 jpsiTracks[1] = jpsiTP2;
318 for (
auto trkItr=theIDTracksAfterSelection.cbegin(); trkItr!=theIDTracksAfterSelection.cend(); ++trkItr) {
321 return StatusCode::SUCCESS;
324 int linkedMuonTrk = 0;
327 if (linkedMuonTrk)
ATH_MSG_DEBUG(
"This id track is a muon track!");
329 if (linkedMuonTrk)
ATH_MSG_DEBUG(
"ID track removed: id track is slected to build Jpsi!");
335 int linkedElectronTrk = 0;
337 if (linkedElectronTrk)
ATH_MSG_DEBUG(
"This id track is an electron track!");
339 if (linkedElectronTrk)
ATH_MSG_DEBUG(
"ID track removed: id track is selected to build Jpsi!");
353 fabs(theThirdTP->
z0() + theThirdTP->
vz() - (*jpsiItr)->z()) >
m_trkDeltaZ )
361 bool passRoughMassCuts(
true);
369 if (!passRoughMassCuts)
continue;
373 std::unique_ptr<xAOD::Vertex> bVertex(
fit(ctx, tracks, importedTrackCollection, importedGSFTrackCollection));
377 double bChi2DOF = bVertex->chiSquared()/bVertex->numberDoF();
381 if(!chi2CutPassed) {
ATH_MSG_DEBUG(
"Chi Cut failed!");
continue; }
388 bool masspTpassed =
true;
390 masspTpassed =
false;
391 for (
double masshypo3rd : massHypotheses) {
392 tripletMasses.push_back(masshypo3rd);
393 TLorentzVector bMomentum = bHelper.
totalP(tripletMasses);
394 tripletMasses.pop_back();
395 double bpt = bMomentum.Pt();
397 double bMass = bMomentum.M();
398 ATH_MSG_DEBUG(
"candidate pt/mass under track mass hypothesis of " << masshypo3rd <<
" is " << bpt <<
" / " << bMass);
400 if(masscut && PtPassed) { masspTpassed =
true;
break; }
405 std::vector<const xAOD::Vertex*> theJpsiPreceding;
406 theJpsiPreceding.push_back(*jpsiItr);
418 return StatusCode::SUCCESS;
430 std::unique_ptr<Trk::IVKalState> state =
m_VKVFitter->makeState(ctx);
440 std::array<int,2>
indices = {1, 2};
447 StatusCode
sc=
m_VKVFitter->VKalVrtFitFast(inputTracks, startingPoint, *state);
451 std::unique_ptr<xAOD::Vertex> theResult =
m_VKVFitter->fit(inputTracks, startingPoint, *state);
455 std::vector<ElementLink<DataVector<xAOD::TrackParticle> > > newLinkVector;
456 for(
unsigned int i=0; i< theResult->trackParticleLinks().
size(); i++)
460 newLinkVector.push_back( mylink );
462 theResult->clearTracks();
463 theResult->setTrackParticleLinks( newLinkVector );
A number of constexpr particle constants to avoid hardcoding them directly in various places.
float vz() const
The z origin for the parameters.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
constexpr double muonMassInMeV
the mass of the muon (in MeV)
constexpr double chargedKaonMassInMeV
the mass of the charged kaon (in MeV)
constexpr double JpsiMassInMeV
the mass of the J/psi meson (in MeV)
constexpr double chargedPionMassInMeV
the mass of the charged pion (in MeV)