ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
DerivationFramework::BPhysAddMuonBasedInvMass Class Reference

Augment secondary vertices with muon-information-based mass. More...

#include <BPhysAddMuonBasedInvMass.h>

Inheritance diagram for DerivationFramework::BPhysAddMuonBasedInvMass:
Collaboration diagram for DerivationFramework::BPhysAddMuonBasedInvMass:

Public Member Functions

 BPhysAddMuonBasedInvMass (const std::string &t, const std::string &n, const IInterface *p)
 Main contructor. More...
 
virtual StatusCode initialize ()
 Initialize augmentation tool. More...
 
virtual StatusCode finalize ()
 Finalize augmentation tool. More...
 
virtual StatusCode addBranches () const
 Main method called for each event. More...
 

Protected Member Functions

Internal protected methods

Calculate muon-information based mass values if available.

Parameters
[in]vtxsecondary vertex
[in]trkMassesordered vector of track mass values
[in]nMuRequestednumber of muons requested
Returns
muon-information based invariant mass for secondary vertex and the corresponding uncertainty
std::pair< double, double > getMuCalcMass (xAOD::BPhysHelper &vtx, const std::vector< double > &trkMasses, int nMuRequested, BasedInvCache &cache) const
 
std::pair< TrackBag, int > getTracksWithMuons (xAOD::BPhysHelper &vtx, BasedInvCache &) const
 Obtain a set of tracks with muon track information if available. More...
 
std::pair< double, double > getInvariantMassWithError (TrackBag trksIn, const std::vector< double > &massHypotheses, const Amg::Vector3D &pos, BasedInvCache &) const
 Calculate invariant mass and uncertainty from a set of tracks. More...
 
double getMinChi2ToAnyPV (xAOD::BPhysHelper &vtx, const xAOD::VertexContainer *pvContainer, const std::vector< int > &pvtypes, const int minNTracksInPV, const int mode, const xAOD::BPhysHelper::pv_type &pvAssocType, BasedInvCache &cache) const
 Determine minimum log chi2 of signal muon tracks w.r.t. More...
 
double getTrackPVChi2 (const xAOD::TrackParticle &track, const Amg::Vector3D &pos, BasedInvCache &cache) const
 Calculate log chi2 value of a track w.r.t. More...
 
MuonBag findAllMuonsInDecay (xAOD::BPhysHelper &vtx) const
 Find all muons associated to secondary vertex. More...
 
TrackBag getIdTracksForMuons (MuonBag &muons) const
 Obtain a set of ID tracks for a set of muons. More...
 
const xAOD::TrackParticleadjustTrackParticle (const xAOD::Muon *muon, BasedInvCache &cache) const
 Extract TrackParticle for Muon and adjust kinematics. More...
 
void initPvAssocTypeVec ()
 Initialize PV-to-SV association type vector. More...
 

Private Attributes

std::vector< xAOD::BPhysHelper::pv_typem_pvAssocTypes
 
job options
std::string m_branchPrefix
 
std::string m_vertexContainerName
 
std::vector< double > m_trkMasses
 
ToolHandle< Reco::ITrackToVertexm_trackToVertexTool
 
bool m_adjustToMuonKinematics
 
int m_addMinChi2ToAnyPVMode
 
std::string m_pvContainerName
 
int m_minNTracksInPV
 
std::vector< int > m_pvTypesToConsider
 
int m_doVertexType
 

Detailed Description

Augment secondary vertices with muon-information-based mass.

Author
Wolfgang Walkowiak wolfg.nosp@m.ang..nosp@m.walko.nosp@m.wiak.nosp@m.@cern.nosp@m..ch

Add muon-information based invarient mass to secondary vertices using a four vector sum. Optionally, it also calculates the minimum chi2 for all muon tracks of the secondary vertex candidate w.r.t. any primary vertex matching the selection criteria.

Job options provided by this class:

Name
Description
BranchPrefix assign the prefix of added branches (possibly the derivation format's name)
VertexContainerName name of container for vertices
TrkMasses ordered list of track masses (Important to keep proper order: J/psi muons go first!)
TrackToVertexTool
ToolHandle for track-to-vertex tool
AdjustToMuonKinematics Adjust the primary track particle's kinematics to the one of the muon.
AddMinChi2ToAnyPVMode mode of minLogChi2ToAnyPV calculation: (default: 0)
Value Explanation
0 no such calculation
1 use all PVs of requested type(s)
2 exclude PVs associated to SVs
3 replace PVs associated to SVs by corresponding refitted PVs
PrimaryVertexContainerName name of container for primary vertices
MinNTracksInPV minimum number of tracks in PV for PV to be considered in calculation of minChi2MuToAnyPV variable.
PVTypesToConsider list of primary vertex types to consider (default: {1, 3})
DoVertexType PV-to-SV association types to be considered (bitwise variable, see xAODBPhys::BPhysHelper)
Note: only needed for AddMinChi2ToAnyPVMode > 1
Note

For a usage example see BPHY8.py .

Definition at line 105 of file BPhysAddMuonBasedInvMass.h.

Constructor & Destructor Documentation

◆ BPhysAddMuonBasedInvMass()

DerivationFramework::BPhysAddMuonBasedInvMass::BPhysAddMuonBasedInvMass ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Main contructor.

Definition at line 44 of file BPhysAddMuonBasedInvMass.cxx.

47  : base_class(t,n,p), m_trackToVertexTool("Reco::TrackToVertex") {
48 
49 
50  // Declare branch prefix
51  declareProperty("BranchPrefix", m_branchPrefix = "_NONE_");
52  // Necessary containers
53  declareProperty("VertexContainerName" , m_vertexContainerName = "");
54  // track mass assignment
55  declareProperty("TrkMasses", m_trkMasses = std::vector<double>());
56  // track-to-vertex tool
57  declareProperty("TrackToVertexTool" , m_trackToVertexTool);
58  // adjust track from muon kinematics?
59  declareProperty("AdjustToMuonKinematics", m_adjustToMuonKinematics = false);
60  // add minChi2ToAnyPV decoration
61  declareProperty("AddMinChi2ToAnyPVMode" , m_addMinChi2ToAnyPVMode = 0);
62  // name of container for primary vertices
63  declareProperty("PrimaryVertexContainerName", m_pvContainerName = "");
64  // minimum number of tracks in PV for PV to be considered in calculation
65  // of minChi2MuToAnyPV variable
66  declareProperty("MinNTracksInPV" , m_minNTracksInPV = 0);
67  // list of primary vertex types to consider
68  declareProperty("PVTypesToConsider" , m_pvTypesToConsider = {1,3});
69  // PV-to-SV association types to be considered
70  declareProperty("DoVertexType" , m_doVertexType = 63);
71  }

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::BPhysAddMuonBasedInvMass::addBranches ( ) const
virtual

Main method called for each event.

Definition at line 122 of file BPhysAddMuonBasedInvMass.cxx.

122  {
123 
124  ATH_MSG_DEBUG("BPhysAddMuonBasedInvMass::addBranches() -- begin");
125  BasedInvCache cache;
126  // vertex container and its auxilliary store
127  xAOD::VertexContainer* vtxContainer = NULL;
128  xAOD::VertexAuxContainer* vtxAuxContainer = NULL;
129 
130  // retrieve from StoreGate
131  CHECK(evtStore()->retrieve(vtxContainer , m_vertexContainerName));
132  CHECK(evtStore()->retrieve(vtxAuxContainer, m_vertexContainerName+"Aux."));
133 
134  const xAOD::VertexContainer* pvContainer = NULL;
135  if ( m_addMinChi2ToAnyPVMode > 0 ) {
136  CHECK(evtStore()->retrieve(pvContainer , m_pvContainerName));
137  }
138 
139  // apply the decorations
140  std::string branchPrefix("");
141  if ( m_branchPrefix != "" && m_branchPrefix != "_NONE_" ) {
142  branchPrefix = m_branchPrefix + "_";
143  }
144 
145  // loop over secondary vertices
146  for (xAOD::VertexContainer::iterator vtxItr = vtxContainer->begin();
147  vtxItr!=vtxContainer->end(); ++vtxItr) {
148 
149  xAOD::BPhysHelper vtx(*vtxItr);
150 
152  d_mucalc_mass(branchPrefix+"MUCALC_mass");
154  d_mucalc_massErr(branchPrefix+"MUCALC_massErr");
155 
156  // TODO: check number of muons requested!
157  std::pair<double,double> MuCalcCandMass =
158  getMuCalcMass(vtx, m_trkMasses, 2, cache);
159 
160  // fill default values
161  d_mucalc_mass(**vtxItr) = MuCalcCandMass.first;
162  d_mucalc_massErr(**vtxItr) = MuCalcCandMass.second;
163 
164  // add MinChi2ToAnyPV information if requested
165  if ( m_addMinChi2ToAnyPVMode > 0 ) {
166 
167  if (m_addMinChi2ToAnyPVMode == 1) {
168  // w.r.t. to all PVs
170  d_minChi2ToAnyPV(branchPrefix+"minLogChi2ToAnyPV");
171  // fill it
172  d_minChi2ToAnyPV(**vtxItr) =
173  getMinChi2ToAnyPV(vtx, pvContainer, m_pvTypesToConsider,
175  xAOD::BPhysHelper::PV_MIN_A0, cache); // dummy
176  } else if (m_addMinChi2ToAnyPVMode > 1 && m_addMinChi2ToAnyPVMode < 4) {
177  // skip or replace associated PVs
178  for (auto pvAssocType : m_pvAssocTypes) {
180  d_minChi2ToAnyPV(branchPrefix+"minLogChi2ToAnyPV_"
181  +xAOD::BPhysHelper::pv_type_str[pvAssocType]);
182  // fill it
183  d_minChi2ToAnyPV(**vtxItr) =
184  getMinChi2ToAnyPV(vtx, pvContainer, m_pvTypesToConsider,
186  pvAssocType, cache);
187 
188  } // for pvAssocType
189  } else {
190  ATH_MSG_WARNING("BPhysAddMuonBasedInvMass::addBranches():"
191  << " Undefined AddMinChi2ToAnyPVMode value: "
193  }
194  } // if m_addMinChi2ToAnyPVMode
195  } // end of loop over vertices
196 
197 
198  ATH_MSG_DEBUG("BPhysAddMuonBasedInvMass::addBranches() -- end");
199 
200  // nothing to do here
201  return StatusCode::SUCCESS;
202  }

◆ adjustTrackParticle()

const xAOD::TrackParticle * DerivationFramework::BPhysAddMuonBasedInvMass::adjustTrackParticle ( const xAOD::Muon muon,
BasedInvCache cache 
) const
protected

Extract TrackParticle for Muon and adjust kinematics.

Extract primary track particle from muon; if configured adjust pt, eta and phi of it before returning a pointer to it.

Parameters
[in]muonpointer to muon
Returns
TrackParticle pointer

Definition at line 315 of file BPhysAddMuonBasedInvMass.cxx.

316  {
317 
318  const xAOD::TrackParticle* tp = NULL;
319  const xAOD::TrackParticle* org = muon->primaryTrackParticle();
320 
321  if ( m_adjustToMuonKinematics ) {
322  if ( org != NULL ) {
323  auto it = cache.adjTpCache.find(org);
324  if ( it != cache.adjTpCache.end() ) {
325  // copy cached link
326  tp = it->second;
327  ATH_MSG_DEBUG("adjustTrackParticle(): from cache: tp = " << tp);
328  } else {
329  // copy object -- this does not work because of seg fault later
330  // xAOD::TrackParticle* newTp = new xAOD::TrackParticle(*org);
331 
332  // create new object and copy properties
334  newTp->makePrivateStore(*org);
335 
336  // ajdust pt, eta and phi to the muon's properties
337  xAOD::IParticle::FourMom_t p4 = muon->p4();
338  float qoverp = p4.P() > 0. ? 1./p4.P() : 10.e6;
339  if ( org->qOverP() < 0. ) qoverp *= -1.;
340  newTp->setDefiningParameters(org->d0(), org->z0(),
341  p4.Phi(), p4.Theta(), qoverp);
342  // cache new TrackParticle
343  cache.adjTpCache[org] = newTp;
344  tp = newTp;
345  ATH_MSG_DEBUG("adjustTrackParticle(): new tp = " << tp
346  << " org = " << org);
347  } // if it != end()
348  } // if != NULL
349  } else {
350  // copy pointer
351  tp = org;
352  ATH_MSG_DEBUG("adjustTrackParticle(): copy: org: " << org
353  << " -> tp: " << tp);
354  }
355 
356  // debug output
357  if ( org != NULL ) {
358  ATH_MSG_DEBUG("adjustTrackParticle(): org: " << org << " ("
359  << org->d0() << "," << org->z0() << "," << org->phi0()
360  << "," << org->theta() << "," << org->qOverP() << ") pt: "
361  << org->pt());
362  } else {
363  ATH_MSG_DEBUG("adjustTrackParticle(): org = NULL");
364  }
365  if ( org != NULL ) {
366  ATH_MSG_DEBUG("adjustTrackParticle(): tp : " << tp << " ("
367  << tp->d0() << "," << tp->z0() << "," << tp->phi0()
368  << "," << tp->theta() << "," << tp->qOverP() << ") pt: "
369  << tp->pt());
370  } else {
371  ATH_MSG_DEBUG("adjustTrackParticle(): tp = NULL");
372  }
373  return tp;
374  }

◆ finalize()

StatusCode DerivationFramework::BPhysAddMuonBasedInvMass::finalize ( )
virtual

Finalize augmentation tool.

Definition at line 114 of file BPhysAddMuonBasedInvMass.cxx.

114  {
115 
116  ATH_MSG_DEBUG("BPhysAddMuonBasedInvMass::finalize()");
117 
118  // everything all right
119  return StatusCode::SUCCESS;
120  }

◆ findAllMuonsInDecay()

MuonBag DerivationFramework::BPhysAddMuonBasedInvMass::findAllMuonsInDecay ( xAOD::BPhysHelper vtx) const
protected

Find all muons associated to secondary vertex.

Returns a vector of xAOD::Muon objects found in this vertex and subsequent decay vertices. Recursively calls itself if necessary.

Parameters
[in]vtxsecondary vertex
Returns
container of muons found

Definition at line 381 of file BPhysAddMuonBasedInvMass.cxx.

382  {
383 
384  MuonBag muons = vtx.muons();
385 
386  // loop over preceeding vertices
387  for (int ivtx = 0; ivtx < vtx.nPrecedingVertices(); ++ivtx) {
388  xAOD::BPhysHelper precVtx(vtx.precedingVertex(ivtx));
389  MuonBag muonsForVtx = findAllMuonsInDecay(precVtx);
390  muons.insert(muons.end(), muonsForVtx.begin(), muonsForVtx.end());
391  }
392  return muons;
393  }

◆ getIdTracksForMuons()

TrackBag DerivationFramework::BPhysAddMuonBasedInvMass::getIdTracksForMuons ( MuonBag muons) const
protected

Obtain a set of ID tracks for a set of muons.

Parameters
[in]muonscontainer of muon objects
Returns
container of associated ID tracks

Definition at line 238 of file BPhysAddMuonBasedInvMass.cxx.

238  {
239 
240  TrackBag muTracks;
241 
242  for (auto &muon : muons) {
243  if ( muon != nullptr ) {
244  const xAOD::TrackParticle* trk =
245  muon->trackParticle(xAOD::Muon::InnerDetectorTrackParticle);
246  if ( trk != nullptr ) {
247  muTracks.push_back(trk);
248  } else {
249  ATH_MSG_WARNING("BPhysAddMuonBasedInvMass::getIdTracksForMuon:"
250  << " no ID track for muon found.");
251  }
252  } else {
253  ATH_MSG_WARNING("BPhysAddMuonBasedInvMass::getIdTracksForMuon:"
254  << " muon pointer is NULL!");
255  }
256  } // for muon
257  return muTracks;
258  }

◆ getInvariantMassWithError()

std::pair< double, double > DerivationFramework::BPhysAddMuonBasedInvMass::getInvariantMassWithError ( TrackBag  trksIn,
const std::vector< double > &  massHypotheses,
const Amg::Vector3D pos,
BasedInvCache cache 
) const
protected

Calculate invariant mass and uncertainty from a set of tracks.

Returns invariant mass and mass error given a set of tracks, their mass hypotheses and a reference position. Each track must have a separate mass hypothesis in the vector, and they must be in the same order as the tracks in the track vector. Otherwise it will go horribly wrong.

Parameters
[in]trksIncontainer with tracks to be considered
[in]massHypoThesesvector of mass hypotheses in the same order as the tracks
[in]posposition of the vertex
Returns
invariant mass value and uncertainty

Definition at line 517 of file BPhysAddMuonBasedInvMass.cxx.

521  {
522 
523  std::pair<double, double> mass(0.,0.);
524 
525  // ensure there is a mass hypothesis for each track
526  if ( trksIn.size() == massHypotheses.size() ) {
529  auto massHypItr = massHypotheses.cbegin();
530 
531  double pxTmp,pyTmp,pzTmp,massTmp,eTmp;
532 
533  std::vector<TLorentzVector> trkMom;
534  TLorentzVector totMom;
535  std::vector<const Trk::Perigee*> trkPer;
536  const auto &ctx = cache.ctx;
537  for (;trItr != trItrEnd; ++trItr,++massHypItr){
538  auto trkPerigee =
539  m_trackToVertexTool->perigeeAtVertex(ctx, *(*trItr), pos);
540 
541  if ( trkPerigee != NULL ) {
542  // try to get the correct momentum measurement
543  pxTmp = trkPerigee->momentum()[Trk::px];
544  pyTmp = trkPerigee->momentum()[Trk::py];
545  pzTmp = trkPerigee->momentum()[Trk::pz];
546  ATH_MSG_DEBUG("getInvariantMassWithError(): pvec = ("
547  << pxTmp << "," << pyTmp << "," << pzTmp << ")");
548  } else {
549  // otherwise default to this one
550  pxTmp = ((*trItr)->p4()).Px();
551  pyTmp = ((*trItr)->p4()).Py();
552  pzTmp = ((*trItr)->p4()).Pz();
553  ATH_MSG_WARNING("BPhysAddMuonBasedInvMass::getInvariantMassError: "
554  "defaulting to simple momentum!");
555  }
556  trkPer.push_back(trkPerigee.release());
557  massTmp = *massHypItr;
558  eTmp = pxTmp*pxTmp+pyTmp*pyTmp+pzTmp*pzTmp+massTmp*massTmp;
559  eTmp = eTmp > 0. ? sqrt(eTmp) : 0.;
560  TLorentzVector tmpMom(pxTmp, pyTmp, pzTmp, eTmp);
561  trkMom.push_back(tmpMom);
562  totMom += tmpMom;
563  }
564  mass.first = totMom.M();
565  double mErr2 = 0.;
566  // reset trItr
567  trItr = trksIn.begin();
568  std::vector<TLorentzVector>::iterator tmItr = trkMom.begin();
569  std::vector<const Trk::Perigee*>::iterator perItr = trkPer.begin();
570  AmgVector(3) dMdP;
571  dMdP.setZero();
572  for (; tmItr != trkMom.end(); ++tmItr, ++trItr, ++perItr) {
573  dMdP(0) = (totMom.E() * tmItr->Px()/tmItr->E() - totMom.Px())/totMom.M();
574  dMdP(1) = (totMom.E() * tmItr->Py()/tmItr->E() - totMom.Py())/totMom.M();
575  dMdP(2) = (totMom.E() * tmItr->Pz()/tmItr->E() - totMom.Pz())/totMom.M();
576  if ( *perItr != NULL ) {
577  mErr2 += (dMdP.transpose() * getMomentumCov(*perItr) * dMdP)(0,0);
578  } else {
579  mErr2 += (dMdP.transpose() * getMomentumCov(*trItr ) * dMdP)(0,0);
580  }
581  }
582  mass.second = mErr2 > 0. ? sqrt(mErr2) : 0.;
583  // clean up
584  for ( perItr = trkPer.begin(); perItr != trkPer.end(); ++perItr) {
585  delete (*perItr);
586  }
587  } else {
588  ATH_MSG_WARNING("BPhysAddMuonBasedInvMass::getInvariantMassError: "
589  "size mismatch of tracks and mass hypotheses vectors!");
590  } // if size comparison
591 
592  return mass;
593  }

◆ getMinChi2ToAnyPV()

double DerivationFramework::BPhysAddMuonBasedInvMass::getMinChi2ToAnyPV ( xAOD::BPhysHelper vtx,
const xAOD::VertexContainer pvContainer,
const std::vector< int > &  pvtypes,
const int  minNTracksInPV,
const int  mode,
const xAOD::BPhysHelper::pv_type pvAssocType,
BasedInvCache cache 
) const
protected

Determine minimum log chi2 of signal muon tracks w.r.t.

Find minimum log chi2 distance of signal muons w.r.t any primary vertex of required types and with a minimum number of tracks cut. It also depends on the mode w.r.t. the treatment of the associated primary vertex and the type of PV-to-SV association. Returns this minimum chi2.

Parameters
[in]vtxsecondary vertex
[in]pvContainercontainer of primary vertices @parma[in] pvtypes vector of primary vertex types to be considered
[in]minNTracksInPVminimum number of tracks in primary vertex for it to be considered
[in]modemode of operation (possible values: 0, 1, 2 ,3)
[in]pv_typetype of PV-to-SV association
Returns
minimum log chi2 = log(d0^2/d0e^+z0^2/z0e^2) w.r.t. any primary vertex

Definition at line 403 of file BPhysAddMuonBasedInvMass.cxx.

411  {
412 
413  MuonBag muons = findAllMuonsInDecay(vtx);
414  TrackBag tracks = getIdTracksForMuons(muons);
415  const xAOD::Vertex* origPV = nullptr;
416  const xAOD::Vertex* refPV = nullptr;
417 
418  if ( mode > 1 ) {
419  // need to obtain original PV
420  origPV = vtx.origPv(pvAssocType);
421  if ( origPV == nullptr ) {
422  ATH_MSG_WARNING("BPhysAddMuonBasedInvMass::getMinChi2ToAnyPV:"
423  << " origPV == NULL for pvAssocType = "
424  << pvAssocType);
425  }
426  if ( mode > 2 ) {
427  refPV = vtx.pv(pvAssocType);
428  if ( refPV == nullptr ) {
429  ATH_MSG_WARNING("BPhysAddMuonBasedInvMass::getMinChi2ToAnyPV:"
430  << " refPV == NULL for pvAssocType = "
431  << pvAssocType);
432  }
433  }
434  }
435 
436  double minChi2 = std::numeric_limits<double>::max();
437 
438  for (const auto pvtx : *pvContainer) {
439  if ( pvtx != nullptr ) {
440  if ( std::find(pvtypes.begin(),pvtypes.end(),pvtx->vertexType())
441  != pvtypes.end() ) {
442  const xAOD::Vertex* cvtx = pvtx;
443  // switch if PV matches original PV and replacement is requested
444  if ( mode > 1 && pvtx == origPV ) {
445  // mode 2 -- skip
446  switch(mode) {
447  case 2: // skip current PV
448  continue;
449  break;
450  case 3: // replace by refitted PV
451  if ( refPV != nullptr ) {
452  cvtx = refPV;
453  } else {
454  ATH_MSG_WARNING("BPhysAddMuonBasedInvMass::getMinChi2ToAnyPV:"
455  << " refPV == NULL!");
456  continue;
457  }
458  break;
459  }
460  }
461  if ( (int)cvtx->nTrackParticles() >= minNTracksInPV ) {
462  for (auto &track : tracks) {
463  const Amg::Vector3D pos = cvtx->position();
464  minChi2 = std::min(minChi2, getTrackPVChi2(*track, pos, cache));
465  } // for track
466  } // if minNTracksInPV
467  } // if pvTypes in pvtypes vector
468  } else {
469  ATH_MSG_WARNING("BPhysAddMuonBasedInvMass::getMinChi2ToAnyPV:"
470  << " pvtx == NULL!");
471  } // if vtx != nullptr
472  } // for pvtx
473 
474  return minChi2;
475  }

◆ getMuCalcMass()

std::pair< double, double > DerivationFramework::BPhysAddMuonBasedInvMass::getMuCalcMass ( xAOD::BPhysHelper vtx,
const std::vector< double > &  trkMasses,
int  nMuRequested,
BasedInvCache cache 
) const
protected

Definition at line 207 of file BPhysAddMuonBasedInvMass.cxx.

209  {
210 
211  std::pair<double, double> mpe(0., -1.);
212 
213  std::pair<TrackBag, int> tracksWithMu = getTracksWithMuons(vtx, cache);
214 
215  if ( tracksWithMu.second == nMuRequested ) {
216  if ( tracksWithMu.first.size() == trkMasses.size() ) {
217  mpe = getInvariantMassWithError(tracksWithMu.first,
218  trkMasses,
219  vtx.vtx()->position(), cache);
220  } else {
221  ATH_MSG_WARNING("BPhysAddMuonBasedInvMass::getMuCalcMass:"
222  << " vector sizes disagree!"
223  << " tracksWithMu: " << tracksWithMu.first.size()
224  << " BtrkMasses: " << trkMasses.size());
225  }
226  } else {
227  mpe.second = -10 - tracksWithMu.second;
228  ATH_MSG_DEBUG("BPhysAddMuonBasedInvMass::getMuCalcMass:"
229  << " muon number mismatch:"
230  << " tracksWithMu: " << tracksWithMu.second
231  << " requested: " << nMuRequested);
232  }
233  return mpe;
234  }

◆ getTrackPVChi2()

double DerivationFramework::BPhysAddMuonBasedInvMass::getTrackPVChi2 ( const xAOD::TrackParticle track,
const Amg::Vector3D pos,
BasedInvCache cache 
) const
protected

Calculate log chi2 value of a track w.r.t.

a position.

Calculate the log chi2 ( = log((d0/d0e)^2+(z0/z0e)^2) contribution of a track at the position closest to the given PV.

Parameters
[in]tracktrack considered
[in]posposition considered
Returns
log chi2 value

Definition at line 482 of file BPhysAddMuonBasedInvMass.cxx.

483  {
484 
485  double chi2 = -100.;
486 
487  auto trkPerigee =
488  m_trackToVertexTool->perigeeAtVertex(cache.ctx, track, pos);
489  if ( trkPerigee != NULL ) {
490  const AmgSymMatrix(5)* locError = trkPerigee->covariance();
491  if ( locError != NULL ) {
492  double d0 = trkPerigee->parameters()[Trk::d0];
493  double z0 = trkPerigee->parameters()[Trk::z0];
494  double d0Err = Amg::error(*locError, Trk::d0);
495  double z0Err = Amg::error(*locError, Trk::z0);
496  if (fabs(d0Err) > 0. && fabs(z0Err) > 0.) {
497  chi2 = log( pow(d0/d0Err,2.0) + pow(z0/z0Err,2.0) );
498  } else {
499  ATH_MSG_WARNING("BPhysAddMuonBasedInvMass::getTrackPVChi2():"
500  << " d0 = " << d0 << ", d0Err = " << d0Err
501  << ", z0 = " << z0 << ", z0Err = " << z0Err);
502  }
503  } // locError != NULL
504  } else {
505  ATH_MSG_WARNING("getTrackPVChi2: Could not get perigee");
506  }
507 
508  return chi2;
509 }

◆ getTracksWithMuons()

std::pair< TrackBag, int > DerivationFramework::BPhysAddMuonBasedInvMass::getTracksWithMuons ( xAOD::BPhysHelper vtx,
BasedInvCache cache 
) const
protected

Obtain a set of tracks with muon track information if available.

Parameters
[in]vtxsecondary vertex
Returns
container of muon tracks, number of muons found

Definition at line 263 of file BPhysAddMuonBasedInvMass.cxx.

263  {
264 
265  TrackBag tracksWithMu;
266  int nMuFound = 0;
267  std::vector<int> vnMuFound;
268 
269  MuonBag muons = findAllMuonsInDecay(vtx);
270 
271  if ( muons.size() > 0 ) {
272  for (int itrk=0; itrk<vtx.nRefTrks(); ++itrk) {
273  // only charged tracks are of interest
274  if ( abs(vtx.refTrkCharge(itrk)) > 0. ) {
275  const xAOD::TrackParticle* trkParticle =
276  (xAOD::TrackParticle*)vtx.refTrkOrigin(itrk);
277  for (unsigned int imu = 0; imu<muons.size(); ++imu) {
278  if ( vtx.refTrkOrigin(itrk) ==
279  muons.at(imu)->trackParticle(xAOD::Muon::InnerDetectorTrackParticle) ) {
280  const xAOD::TrackParticle* trkMuon =
281  adjustTrackParticle(muons.at(imu), cache);
282  if ( trkMuon != NULL ) {
283  trkParticle = trkMuon;
284  nMuFound++;
285  break;
286  }
287  }
288  } // for imu
289  tracksWithMu.push_back(trkParticle);
290  vnMuFound.push_back(nMuFound);
291  } // for charged track
292  } // for itrk
293  } else {
294  ATH_MSG_DEBUG("BPhysAddMuonBasedInvMass::getTracksWithMuons: "
295  "vertex contains no muons, but "
296  << vtx.nRefTrks() << " refitted tracks ...");
297  }
298  // debug output
299  std::string svnMuFound = "[";
300  for (unsigned int i=0; i<vnMuFound.size(); ++i) {
301  svnMuFound += std::to_string(vnMuFound[i]) + ',';
302  }
303  svnMuFound.back() = ']';
304  ATH_MSG_DEBUG("BPhysAddMuonBasedInvMass::getTracksWithMuons: "
305  "nMuFound = " << nMuFound
306  << "\nvnMuFound = " << svnMuFound );
307 
308  return std::pair<TrackBag, int>(std::move(tracksWithMu), nMuFound);
309  }

◆ initialize()

StatusCode DerivationFramework::BPhysAddMuonBasedInvMass::initialize ( )
virtual

Initialize augmentation tool.

Definition at line 73 of file BPhysAddMuonBasedInvMass.cxx.

73  {
74 
75  ATH_MSG_DEBUG("BPhysAddMuonBasedInvMass::initialize() -- begin");
76 
77  // candidate vertices container
78  if ( m_vertexContainerName == "" ) {
79  ATH_MSG_ERROR("No vertex container name provided!");
80  }
81 
82  // TrackToVertexTool
83  CHECK(m_trackToVertexTool.retrieve());
84 
85  // PV container if needed
86  if ( m_addMinChi2ToAnyPVMode > 0 && m_pvContainerName == "" ) {
87  ATH_MSG_ERROR("No primary vertex container name provided!");
88  }
89 
90  // PV type list if needed
91  if ( m_addMinChi2ToAnyPVMode > 0 && m_pvTypesToConsider.size() == 0 ) {
92  ATH_MSG_ERROR("No primary vertex types to be considered provided!");
93  }
94 
95  // PV-to-SV association type if needed
96  if ( m_addMinChi2ToAnyPVMode > 1 && m_doVertexType < 1 ) {
97  ATH_MSG_ERROR("No PV-to-SV association types to be considered provided!");
98  }
99 
100  ATH_MSG_INFO("BPhysAddMuonBasedInvMass::initialize(): "
101  << "AdjustToMuonKinematics = " << m_adjustToMuonKinematics);
102 
103  ATH_MSG_INFO("BPhysAddMuonBasedInvMass::initialize(): "
104  << "AddMinChi2ToAnyPVMode = " << m_addMinChi2ToAnyPVMode);
105 
106  // initialize PV-to-SV association type vector
108 
109  ATH_MSG_DEBUG("BPhysAddMuonBasedInvMass::initialize() -- end");
110 
111  return StatusCode::SUCCESS;
112  }

◆ initPvAssocTypeVec()

void DerivationFramework::BPhysAddMuonBasedInvMass::initPvAssocTypeVec ( )
protected

Initialize PV-to-SV association type vector.

Member Data Documentation

◆ m_addMinChi2ToAnyPVMode

int DerivationFramework::BPhysAddMuonBasedInvMass::m_addMinChi2ToAnyPVMode
private

Definition at line 281 of file BPhysAddMuonBasedInvMass.h.

◆ m_adjustToMuonKinematics

bool DerivationFramework::BPhysAddMuonBasedInvMass::m_adjustToMuonKinematics
private

Definition at line 280 of file BPhysAddMuonBasedInvMass.h.

◆ m_branchPrefix

std::string DerivationFramework::BPhysAddMuonBasedInvMass::m_branchPrefix
private

Definition at line 276 of file BPhysAddMuonBasedInvMass.h.

◆ m_doVertexType

int DerivationFramework::BPhysAddMuonBasedInvMass::m_doVertexType
private

Definition at line 285 of file BPhysAddMuonBasedInvMass.h.

◆ m_minNTracksInPV

int DerivationFramework::BPhysAddMuonBasedInvMass::m_minNTracksInPV
private

Definition at line 283 of file BPhysAddMuonBasedInvMass.h.

◆ m_pvAssocTypes

std::vector<xAOD::BPhysHelper::pv_type> DerivationFramework::BPhysAddMuonBasedInvMass::m_pvAssocTypes
private

cache for individual vertex types

Definition at line 290 of file BPhysAddMuonBasedInvMass.h.

◆ m_pvContainerName

std::string DerivationFramework::BPhysAddMuonBasedInvMass::m_pvContainerName
private

Definition at line 282 of file BPhysAddMuonBasedInvMass.h.

◆ m_pvTypesToConsider

std::vector<int> DerivationFramework::BPhysAddMuonBasedInvMass::m_pvTypesToConsider
private

Definition at line 284 of file BPhysAddMuonBasedInvMass.h.

◆ m_trackToVertexTool

ToolHandle<Reco::ITrackToVertex> DerivationFramework::BPhysAddMuonBasedInvMass::m_trackToVertexTool
private

Definition at line 279 of file BPhysAddMuonBasedInvMass.h.

◆ m_trkMasses

std::vector<double> DerivationFramework::BPhysAddMuonBasedInvMass::m_trkMasses
private

Definition at line 278 of file BPhysAddMuonBasedInvMass.h.

◆ m_vertexContainerName

std::string DerivationFramework::BPhysAddMuonBasedInvMass::m_vertexContainerName
private

Definition at line 277 of file BPhysAddMuonBasedInvMass.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
xAOD::BPhysHelper::refTrkCharge
float refTrkCharge(const size_t index) const
Returns charge of the i-th track.
Definition: BPhysHelper.cxx:255
DerivationFramework::BPhysAddMuonBasedInvMass::m_minNTracksInPV
int m_minNTracksInPV
Definition: BPhysAddMuonBasedInvMass.h:283
xAOD::TrackParticle_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: TrackParticle_v1.cxx:73
Trk::py
@ py
Definition: ParamDefs.h:60
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:196
xAOD::Vertex_v1::nTrackParticles
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
Definition: Vertex_v1.cxx:270
xAOD::BPhysHelper
Definition: BPhysHelper.h:71
xAOD::VertexAuxContainer_v1
Temporary container used until we have I/O for AuxStoreInternal.
Definition: VertexAuxContainer_v1.h:32
xAOD::BPhysHelper::pv_type_str
static const std::string pv_type_str[]
Definition: BPhysHelper.h:605
xAOD::BPhysHelper::nRefTrks
int nRefTrks()
Returns number of stored refitted track momenta.
Definition: BPhysHelper.cxx:115
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
DerivationFramework::BPhysAddMuonBasedInvMass::adjustTrackParticle
const xAOD::TrackParticle * adjustTrackParticle(const xAOD::Muon *muon, BasedInvCache &cache) const
Extract TrackParticle for Muon and adjust kinematics.
Definition: BPhysAddMuonBasedInvMass.cxx:316
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
DerivationFramework::BPhysAddMuonBasedInvMass::m_pvAssocTypes
std::vector< xAOD::BPhysHelper::pv_type > m_pvAssocTypes
Definition: BPhysAddMuonBasedInvMass.h:290
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
skel.it
it
Definition: skel.GENtoEVGEN.py:407
DerivationFramework::BPhysAddMuonBasedInvMass::m_pvTypesToConsider
std::vector< int > m_pvTypesToConsider
Definition: BPhysAddMuonBasedInvMass.h:284
xAOD::TrackParticle_v1::z0
float z0() const
Returns the parameter.
ParticleTest.tp
tp
Definition: ParticleTest.py:25
xAOD::TrackParticle_v1::setDefiningParameters
void setDefiningParameters(float d0, float z0, float phi0, float theta, float qOverP)
Set the defining parameters.
Definition: TrackParticle_v1.cxx:177
Trk::z0
@ z0
Definition: ParamDefs.h:64
xAOD::Vertex_v1::position
const Amg::Vector3D & position() const
Returns the 3-pos.
DerivationFramework::BPhysAddMuonBasedInvMass::findAllMuonsInDecay
MuonBag findAllMuonsInDecay(xAOD::BPhysHelper &vtx) const
Find all muons associated to secondary vertex.
Definition: BPhysAddMuonBasedInvMass.cxx:381
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Trk::pz
@ pz
global momentum (cartesian)
Definition: ParamDefs.h:61
DerivationFramework::BPhysAddMuonBasedInvMass::initPvAssocTypeVec
void initPvAssocTypeVec()
Initialize PV-to-SV association type vector.
DerivationFramework::MuonBag
std::vector< const xAOD::Muon * > MuonBag
Definition: BPhysAddMuonBasedInvMass.h:33
xAOD::TrackParticle_v1::d0
float d0() const
Returns the parameter.
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
DerivationFramework::AmgSymMatrix
AmgSymMatrix(3) BPhysAddMuonBasedInvMass
Definition: BPhysAddMuonBasedInvMass.cxx:600
xAOD::IParticle::FourMom_t
TLorentzVector FourMom_t
Definition of the 4-momentum type.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:69
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
DerivationFramework::BPhysAddMuonBasedInvMass::getInvariantMassWithError
std::pair< double, double > getInvariantMassWithError(TrackBag trksIn, const std::vector< double > &massHypotheses, const Amg::Vector3D &pos, BasedInvCache &) const
Calculate invariant mass and uncertainty from a set of tracks.
Definition: BPhysAddMuonBasedInvMass.cxx:518
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
xAOD::BPhysHelper::precedingVertex
const xAOD::Vertex * precedingVertex(const size_t index)
Returns pointer to a preceding vertex.
Definition: BPhysHelper.cxx:613
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AmgVector
AmgVector(4) T2BSTrackFilterTool
Definition: T2BSTrackFilterTool.cxx:114
DerivationFramework::BPhysAddMuonBasedInvMass::m_doVertexType
int m_doVertexType
Definition: BPhysAddMuonBasedInvMass.h:285
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:525
TRT::Track::d0
@ d0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:62
Trk::px
@ px
Definition: ParamDefs.h:59
xAOD::BPhysHelper::PV_MIN_A0
@ PV_MIN_A0
Definition: BPhysHelper.h:475
Preparation.mode
mode
Definition: Preparation.py:107
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DerivationFramework::TrackBag
std::vector< const xAOD::TrackParticle * > TrackBag
Definition: BPhysAddMuonBasedInvMass.h:32
xAOD::BPhysHelper::origPv
const xAOD::Vertex * origPv(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
original PV
Definition: BPhysHelper.cxx:807
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
DerivationFramework::BPhysAddMuonBasedInvMass::m_addMinChi2ToAnyPVMode
int m_addMinChi2ToAnyPVMode
Definition: BPhysAddMuonBasedInvMass.h:281
xAOD::BPhysHelper::refTrkOrigin
const xAOD::IParticle * refTrkOrigin(const size_t index) const
: Returns the original track (charged or neutral) corresponding to the i-th refitted track
Definition: BPhysHelper.cxx:171
DerivationFramework::BPhysAddMuonBasedInvMass::m_trkMasses
std::vector< double > m_trkMasses
Definition: BPhysAddMuonBasedInvMass.h:278
xAOD::TrackParticle_v1::phi0
float phi0() const
Returns the parameter, which has range to .
Definition: TrackParticle_v1.cxx:158
xAOD::TrackParticle_v1::qOverP
float qOverP() const
Returns the parameter.
Trk::d0
@ d0
Definition: ParamDefs.h:63
xAOD::BPhysHelper::vtx
const xAOD::Vertex * vtx() const
Getter method for the cached xAOD::Vertex.
Definition: BPhysHelper.h:108
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
Amg::error
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Definition: EventPrimitivesHelpers.h:40
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:192
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
DerivationFramework::BPhysAddMuonBasedInvMass::getMinChi2ToAnyPV
double getMinChi2ToAnyPV(xAOD::BPhysHelper &vtx, const xAOD::VertexContainer *pvContainer, const std::vector< int > &pvtypes, const int minNTracksInPV, const int mode, const xAOD::BPhysHelper::pv_type &pvAssocType, BasedInvCache &cache) const
Determine minimum log chi2 of signal muon tracks w.r.t.
Definition: BPhysAddMuonBasedInvMass.cxx:403
DerivationFramework::BPhysAddMuonBasedInvMass::m_pvContainerName
std::string m_pvContainerName
Definition: BPhysAddMuonBasedInvMass.h:282
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DerivationFramework::BPhysAddMuonBasedInvMass::m_adjustToMuonKinematics
bool m_adjustToMuonKinematics
Definition: BPhysAddMuonBasedInvMass.h:280
DerivationFramework::BPhysAddMuonBasedInvMass::getTrackPVChi2
double getTrackPVChi2(const xAOD::TrackParticle &track, const Amg::Vector3D &pos, BasedInvCache &cache) const
Calculate log chi2 value of a track w.r.t.
Definition: BPhysAddMuonBasedInvMass.cxx:482
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
DerivationFramework::BPhysAddMuonBasedInvMass::getIdTracksForMuons
TrackBag getIdTracksForMuons(MuonBag &muons) const
Obtain a set of ID tracks for a set of muons.
Definition: BPhysAddMuonBasedInvMass.cxx:238
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DerivationFramework::BPhysAddMuonBasedInvMass::getTracksWithMuons
std::pair< TrackBag, int > getTracksWithMuons(xAOD::BPhysHelper &vtx, BasedInvCache &) const
Obtain a set of tracks with muon track information if available.
Definition: BPhysAddMuonBasedInvMass.cxx:263
xAOD::BPhysHelper::nPrecedingVertices
int nPrecedingVertices()
: Links to preceding vertices
Definition: BPhysHelper.cxx:601
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
xAOD::BPhysHelper::pv
const xAOD::Vertex * pv(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Get the refitted collision vertex of type pv_type.
Definition: BPhysHelper.cxx:796
DerivationFramework::BPhysAddMuonBasedInvMass::m_vertexContainerName
std::string m_vertexContainerName
Definition: BPhysAddMuonBasedInvMass.h:277
xAOD::track
@ track
Definition: TrackingPrimitives.h:513
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
xAOD::BPhysHelper::muons
const std::vector< const xAOD::Muon * > & muons()
Returns linked muons.
Definition: BPhysHelper.cxx:468
DerivationFramework::BPhysAddMuonBasedInvMass::m_trackToVertexTool
ToolHandle< Reco::ITrackToVertex > m_trackToVertexTool
Definition: BPhysAddMuonBasedInvMass.h:279
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
xAOD::TrackParticle_v1::theta
float theta() const
Returns the parameter, which has range 0 to .
DerivationFramework::BPhysAddMuonBasedInvMass::getMuCalcMass
std::pair< double, double > getMuCalcMass(xAOD::BPhysHelper &vtx, const std::vector< double > &trkMasses, int nMuRequested, BasedInvCache &cache) const
Definition: BPhysAddMuonBasedInvMass.cxx:207
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
DerivationFramework::BPhysAddMuonBasedInvMass::m_branchPrefix
std::string m_branchPrefix
Definition: BPhysAddMuonBasedInvMass.h:276