 |
ATLAS Offline Software
|
Augment secondary vertices with muon-information-based mass.
More...
#include <BPhysAddMuonBasedInvMass.h>
|
|
Calculate muon-information based mass values if available.
- Parameters
-
[in] | vtx | secondary vertex |
[in] | trkMasses | ordered vector of track mass values |
[in] | nMuRequested | number 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::TrackParticle * | adjustTrackParticle (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...
|
|
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.
◆ BPhysAddMuonBasedInvMass()
DerivationFramework::BPhysAddMuonBasedInvMass::BPhysAddMuonBasedInvMass |
( |
const std::string & |
t, |
|
|
const std::string & |
n, |
|
|
const IInterface * |
p |
|
) |
| |
◆ addBranches()
StatusCode DerivationFramework::BPhysAddMuonBasedInvMass::addBranches |
( |
| ) |
const |
|
virtual |
Main method called for each event.
Definition at line 122 of file BPhysAddMuonBasedInvMass.cxx.
124 ATH_MSG_DEBUG(
"BPhysAddMuonBasedInvMass::addBranches() -- begin");
140 std::string branchPrefix(
"");
147 vtxItr!=vtxContainer->
end(); ++vtxItr) {
152 d_mucalc_mass(branchPrefix+
"MUCALC_mass");
154 d_mucalc_massErr(branchPrefix+
"MUCALC_massErr");
157 std::pair<double,double> MuCalcCandMass =
161 d_mucalc_mass(**vtxItr) = MuCalcCandMass.first;
162 d_mucalc_massErr(**vtxItr) = MuCalcCandMass.second;
170 d_minChi2ToAnyPV(branchPrefix+
"minLogChi2ToAnyPV");
172 d_minChi2ToAnyPV(**vtxItr) =
180 d_minChi2ToAnyPV(branchPrefix+
"minLogChi2ToAnyPV_"
183 d_minChi2ToAnyPV(**vtxItr) =
191 <<
" Undefined AddMinChi2ToAnyPVMode value: "
198 ATH_MSG_DEBUG(
"BPhysAddMuonBasedInvMass::addBranches() -- end");
201 return StatusCode::SUCCESS;
◆ adjustTrackParticle()
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
-
- Returns
- TrackParticle pointer
Definition at line 315 of file BPhysAddMuonBasedInvMass.cxx.
323 auto it = cache.adjTpCache.find(org);
324 if (
it != cache.adjTpCache.end() ) {
338 float qoverp = p4.P() > 0. ? 1./p4.P() : 10.e6;
339 if ( org->
qOverP() < 0. ) qoverp *= -1.;
341 p4.Phi(), p4.Theta(), qoverp);
343 cache.adjTpCache[org] = newTp;
346 <<
" org = " << org);
353 <<
" -> tp: " <<
tp);
359 << org->
d0() <<
"," << org->
z0() <<
"," << org->
phi0()
360 <<
"," << org->
theta() <<
"," << org->
qOverP() <<
") pt: "
367 <<
tp->d0() <<
"," <<
tp->z0() <<
"," <<
tp->phi0()
368 <<
"," <<
tp->theta() <<
"," <<
tp->qOverP() <<
") pt: "
◆ finalize()
StatusCode DerivationFramework::BPhysAddMuonBasedInvMass::finalize |
( |
| ) |
|
|
virtual |
◆ findAllMuonsInDecay()
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
-
- Returns
- container of muons found
Definition at line 381 of file BPhysAddMuonBasedInvMass.cxx.
390 muons.insert(muons.end(), muonsForVtx.begin(), muonsForVtx.end());
◆ getIdTracksForMuons()
TrackBag DerivationFramework::BPhysAddMuonBasedInvMass::getIdTracksForMuons |
( |
MuonBag & |
muons | ) |
const |
|
protected |
Obtain a set of ID tracks for a set of muons.
- Parameters
-
[in] | muons | container of muon objects |
- Returns
- container of associated ID tracks
Definition at line 238 of file BPhysAddMuonBasedInvMass.cxx.
242 for (
auto &
muon : muons) {
243 if (
muon !=
nullptr ) {
245 muon->trackParticle(xAOD::Muon::InnerDetectorTrackParticle);
246 if ( trk !=
nullptr ) {
247 muTracks.push_back(trk);
250 <<
" no ID track for muon found.");
254 <<
" muon pointer is NULL!");
◆ 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] | trksIn | container with tracks to be considered |
[in] | massHypoTheses | vector of mass hypotheses in the same order as the tracks |
[in] | pos | position of the vertex |
- Returns
- invariant mass value and uncertainty
Definition at line 517 of file BPhysAddMuonBasedInvMass.cxx.
523 std::pair<double, double>
mass(0.,0.);
526 if ( trksIn.size() == massHypotheses.size() ) {
529 auto massHypItr = massHypotheses.cbegin();
531 double pxTmp,pyTmp,pzTmp,massTmp,eTmp;
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){
541 if ( trkPerigee != NULL ) {
543 pxTmp = trkPerigee->momentum()[
Trk::px];
544 pyTmp = trkPerigee->momentum()[
Trk::py];
545 pzTmp = trkPerigee->momentum()[
Trk::pz];
547 << pxTmp <<
"," << pyTmp <<
"," << pzTmp <<
")");
550 pxTmp = ((*trItr)->p4()).Px();
551 pyTmp = ((*trItr)->p4()).Py();
552 pzTmp = ((*trItr)->p4()).Pz();
554 "defaulting to simple momentum!");
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);
564 mass.first = totMom.M();
567 trItr = trksIn.begin();
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);
579 mErr2 += (dMdP.transpose() * getMomentumCov(*trItr ) * dMdP)(0,0);
582 mass.second = mErr2 > 0. ? sqrt(mErr2) : 0.;
584 for ( perItr = trkPer.begin(); perItr != trkPer.end(); ++perItr) {
589 "size mismatch of tracks and mass hypotheses vectors!");
◆ getMinChi2ToAnyPV()
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] | vtx | secondary vertex |
[in] | pvContainer | container of primary vertices @parma[in] pvtypes vector of primary vertex types to be considered |
[in] | minNTracksInPV | minimum number of tracks in primary vertex for it to be considered |
[in] | mode | mode of operation (possible values: 0, 1, 2 ,3) |
[in] | pv_type | type 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.
420 origPV = vtx.
origPv(pvAssocType);
421 if ( origPV ==
nullptr ) {
423 <<
" origPV == NULL for pvAssocType = "
427 refPV = vtx.
pv(pvAssocType);
428 if ( refPV ==
nullptr ) {
430 <<
" refPV == NULL for pvAssocType = "
438 for (
const auto pvtx : *pvContainer) {
439 if ( pvtx !=
nullptr ) {
440 if (
std::find(pvtypes.begin(),pvtypes.end(),pvtx->vertexType())
444 if (
mode > 1 && pvtx == origPV ) {
451 if ( refPV !=
nullptr ) {
455 <<
" refPV == NULL!");
462 for (
auto &
track : tracks) {
470 <<
" pvtx == NULL!");
◆ 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.
211 std::pair<double, double> mpe(0., -1.);
215 if ( tracksWithMu.second == nMuRequested ) {
216 if ( tracksWithMu.first.size() == trkMasses.size() ) {
222 <<
" vector sizes disagree!"
223 <<
" tracksWithMu: " << tracksWithMu.first.size()
224 <<
" BtrkMasses: " << trkMasses.size());
227 mpe.second = -10 - tracksWithMu.second;
229 <<
" muon number mismatch:"
230 <<
" tracksWithMu: " << tracksWithMu.second
231 <<
" requested: " << nMuRequested);
◆ getTrackPVChi2()
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] | track | track considered |
[in] | pos | position considered |
- Returns
- log chi2 value
Definition at line 482 of file BPhysAddMuonBasedInvMass.cxx.
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];
496 if (fabs(d0Err) > 0. && fabs(z0Err) > 0.) {
500 <<
" d0 = " <<
d0 <<
", d0Err = " << d0Err
501 <<
", z0 = " <<
z0 <<
", z0Err = " << z0Err);
◆ getTracksWithMuons()
Obtain a set of tracks with muon track information if available.
- Parameters
-
- Returns
- container of muon tracks, number of muons found
Definition at line 263 of file BPhysAddMuonBasedInvMass.cxx.
267 std::vector<int> vnMuFound;
271 if ( muons.size() > 0 ) {
272 for (
int itrk=0; itrk<vtx.
nRefTrks(); ++itrk) {
277 for (
unsigned int imu = 0; imu<muons.size(); ++imu) {
279 muons.at(imu)->trackParticle(xAOD::Muon::InnerDetectorTrackParticle) ) {
282 if ( trkMuon != NULL ) {
283 trkParticle = trkMuon;
289 tracksWithMu.push_back(trkParticle);
290 vnMuFound.push_back(nMuFound);
294 ATH_MSG_DEBUG(
"BPhysAddMuonBasedInvMass::getTracksWithMuons: "
295 "vertex contains no muons, but "
296 << vtx.
nRefTrks() <<
" refitted tracks ...");
299 std::string svnMuFound =
"[";
300 for (
unsigned int i=0;
i<vnMuFound.size(); ++
i) {
303 svnMuFound.back() =
']';
304 ATH_MSG_DEBUG(
"BPhysAddMuonBasedInvMass::getTracksWithMuons: "
305 "nMuFound = " << nMuFound
306 <<
"\nvnMuFound = " << svnMuFound );
308 return std::pair<TrackBag, int>(std::move(tracksWithMu), nMuFound);
◆ initialize()
StatusCode DerivationFramework::BPhysAddMuonBasedInvMass::initialize |
( |
| ) |
|
|
virtual |
◆ initPvAssocTypeVec()
void DerivationFramework::BPhysAddMuonBasedInvMass::initPvAssocTypeVec |
( |
| ) |
|
|
protected |
Initialize PV-to-SV association type vector.
◆ m_addMinChi2ToAnyPVMode
int DerivationFramework::BPhysAddMuonBasedInvMass::m_addMinChi2ToAnyPVMode |
|
private |
◆ m_adjustToMuonKinematics
bool DerivationFramework::BPhysAddMuonBasedInvMass::m_adjustToMuonKinematics |
|
private |
◆ m_branchPrefix
std::string DerivationFramework::BPhysAddMuonBasedInvMass::m_branchPrefix |
|
private |
◆ m_doVertexType
int DerivationFramework::BPhysAddMuonBasedInvMass::m_doVertexType |
|
private |
◆ m_minNTracksInPV
int DerivationFramework::BPhysAddMuonBasedInvMass::m_minNTracksInPV |
|
private |
◆ m_pvAssocTypes
◆ m_pvContainerName
std::string DerivationFramework::BPhysAddMuonBasedInvMass::m_pvContainerName |
|
private |
◆ m_pvTypesToConsider
std::vector<int> DerivationFramework::BPhysAddMuonBasedInvMass::m_pvTypesToConsider |
|
private |
◆ m_trackToVertexTool
◆ m_trkMasses
std::vector<double> DerivationFramework::BPhysAddMuonBasedInvMass::m_trkMasses |
|
private |
◆ m_vertexContainerName
std::string DerivationFramework::BPhysAddMuonBasedInvMass::m_vertexContainerName |
|
private |
The documentation for this class was generated from the following files:
def retrieve(aClass, aKey=None)
JetConstituentVector::iterator iterator
float refTrkCharge(const size_t index) const
Returns charge of the i-th track.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
Temporary container used until we have I/O for AuxStoreInternal.
static const std::string pv_type_str[]
int nRefTrks()
Returns number of stored refitted track momenta.
std::string find(const std::string &s)
return a remapped string
const xAOD::TrackParticle * adjustTrackParticle(const xAOD::Muon *muon, BasedInvCache &cache) const
Extract TrackParticle for Muon and adjust kinematics.
std::vector< xAOD::BPhysHelper::pv_type > m_pvAssocTypes
std::vector< int > m_pvTypesToConsider
float z0() const
Returns the parameter.
void setDefiningParameters(float d0, float z0, float phi0, float theta, float qOverP)
Set the defining parameters.
const Amg::Vector3D & position() const
Returns the 3-pos.
MuonBag findAllMuonsInDecay(xAOD::BPhysHelper &vtx) const
Find all muons associated to secondary vertex.
@ pz
global momentum (cartesian)
void initPvAssocTypeVec()
Initialize PV-to-SV association type vector.
std::vector< const xAOD::Muon * > MuonBag
float d0() const
Returns the parameter.
AmgSymMatrix(3) BPhysAddMuonBasedInvMass
TLorentzVector FourMom_t
Definition of the 4-momentum type.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
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.
Helper class to provide type-safe access to aux data.
(Non-const) Iterator class for DataVector/DataList.
const xAOD::Vertex * precedingVertex(const size_t index)
Returns pointer to a preceding vertex.
double chi2(TH1 *h0, TH1 *h1)
#define CHECK(...)
Evaluate an expression and check for errors.
std::vector< const xAOD::TrackParticle * > TrackBag
const xAOD::Vertex * origPv(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
original PV
int m_addMinChi2ToAnyPVMode
const xAOD::IParticle * refTrkOrigin(const size_t index) const
: Returns the original track (charged or neutral) corresponding to the i-th refitted track
std::vector< double > m_trkMasses
float phi0() const
Returns the parameter, which has range to .
float qOverP() const
Returns the parameter.
const xAOD::Vertex * vtx() const
Getter method for the cached xAOD::Vertex.
std::string to_string(const DetectorType &type)
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 ...
void makePrivateStore()
Create a new (empty) private store for this object.
Eigen::Matrix< double, 3, 1 > Vector3D
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.
std::string m_pvContainerName
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
bool m_adjustToMuonKinematics
double getTrackPVChi2(const xAOD::TrackParticle &track, const Amg::Vector3D &pos, BasedInvCache &cache) const
Calculate log chi2 value of a track w.r.t.
Class describing a Vertex.
TrackBag getIdTracksForMuons(MuonBag &muons) const
Obtain a set of ID tracks for a set of muons.
#define ATH_MSG_WARNING(x)
std::pair< TrackBag, int > getTracksWithMuons(xAOD::BPhysHelper &vtx, BasedInvCache &) const
Obtain a set of tracks with muon track information if available.
int nPrecedingVertices()
: Links to preceding vertices
const xAOD::Vertex * pv(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Get the refitted collision vertex of type pv_type.
std::string m_vertexContainerName
Class describing a TrackParticle.
const std::vector< const xAOD::Muon * > & muons()
Returns linked muons.
ToolHandle< Reco::ITrackToVertex > m_trackToVertexTool
constexpr int pow(int base, int exp) noexcept
float theta() const
Returns the parameter, which has range 0 to .
std::pair< double, double > getMuCalcMass(xAOD::BPhysHelper &vtx, const std::vector< double > &trkMasses, int nMuRequested, BasedInvCache &cache) const
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
std::string m_branchPrefix