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 if(!muon->inDetTrackParticleLink().isValid())
continue;
280 auto track = muon->trackParticle( xAOD::Muon::InnerDetectorTrackParticle );
281 if(track==
nullptr)
continue;
283 muonTracks.push_back(track);
287 TrackBag electronTracks;
288 ElectronBag theElectronsAfterSelection;
289 if (importedElectronCollection && !importedElectronCollection->
empty()) {
290 for(
auto electron : *importedElectronCollection) {
291 if (!electron->trackParticleLink().isValid())
continue;
293 elTrk = electron->trackParticleLink().cachedElement();
294 if (!elTrk)
continue;
295 theElectronsAfterSelection.push_back(electron);
296 electronTracks.push_back(elTrk);
298 if (
m_skipNoElectron && theElectronsAfterSelection.size() == 0)
return StatusCode::SUCCESS;
299 ATH_MSG_DEBUG(
"Number of electrons after selection: " << theElectronsAfterSelection.size());
302 std::vector<const xAOD::TrackParticle*> tracks(3,
nullptr);
304 for(
auto jpsiItr=selectedJpsiCandidates.cbegin(); jpsiItr!=selectedJpsiCandidates.cend(); ++jpsiItr) {
313 jpsiTracks.resize(2);
314 jpsiTracks[0] = jpsiTP1;
315 jpsiTracks[1] = jpsiTP2;
319 for (
auto trkItr=theIDTracksAfterSelection.cbegin(); trkItr!=theIDTracksAfterSelection.cend(); ++trkItr) {
322 return StatusCode::SUCCESS;
325 int linkedMuonTrk = 0;
328 if (linkedMuonTrk)
ATH_MSG_DEBUG(
"This id track is a muon track!");
330 if (linkedMuonTrk)
ATH_MSG_DEBUG(
"ID track removed: id track is slected to build Jpsi!");
336 int linkedElectronTrk = 0;
338 if (linkedElectronTrk)
ATH_MSG_DEBUG(
"This id track is an electron track!");
340 if (linkedElectronTrk)
ATH_MSG_DEBUG(
"ID track removed: id track is selected to build Jpsi!");
354 fabs(theThirdTP->
z0() + theThirdTP->
vz() - (*jpsiItr)->z()) >
m_trkDeltaZ )
362 bool passRoughMassCuts(
true);
370 if (!passRoughMassCuts)
continue;
374 std::unique_ptr<xAOD::Vertex> bVertex(
fit(tracks, importedTrackCollection, importedGSFTrackCollection));
378 double bChi2DOF = bVertex->chiSquared()/bVertex->numberDoF();
382 if(!chi2CutPassed) {
ATH_MSG_DEBUG(
"Chi Cut failed!");
continue; }
389 bool masspTpassed =
true;
391 masspTpassed =
false;
392 for (
double masshypo3rd : massHypotheses) {
393 tripletMasses.push_back(masshypo3rd);
394 TLorentzVector bMomentum = bHelper.
totalP(tripletMasses);
395 tripletMasses.pop_back();
396 double bpt = bMomentum.Pt();
398 double bMass = bMomentum.M();
399 ATH_MSG_DEBUG(
"candidate pt/mass under track mass hypothesis of " << masshypo3rd <<
" is " << bpt <<
" / " << bMass);
401 if(masscut && PtPassed) { masspTpassed =
true;
break; }
406 std::vector<const xAOD::Vertex*> theJpsiPreceding;
407 theJpsiPreceding.push_back(*jpsiItr);
419 return StatusCode::SUCCESS;
431 std::unique_ptr<Trk::IVKalState> state =
m_VKVFitter->makeState();
441 std::array<int,2> indices = {1, 2};
448 StatusCode
sc=
m_VKVFitter->VKalVrtFitFast(inputTracks, startingPoint, *state);
456 std::vector<ElementLink<DataVector<xAOD::TrackParticle> > > newLinkVector;
461 newLinkVector.push_back( mylink );
A number of constexpr particle constants to avoid hardcoding them directly in various places.
float vz() const
The z origin for the parameters.
constexpr double muonMassInMeV
the mass of the muon (in MeV)
constexpr double chargedKaonMassInMeV
the mass of the charged kaon (in MeV)
constexpr double chargedPionMassInMeV
the mass of the charged pion (in MeV)