|
ATLAS Offline Software
|
Go to the documentation of this file.
30 typedef std::map<const xAOD::TrackParticle*, const xAOD::TrackParticle*>
34 const EventContext&
ctx;
47 :
AthAlgTool(
t,
n,
p), m_trackToVertexTool(
"Reco::TrackToVertex") {
49 declareInterface<DerivationFramework::IAugmentationTool>(
this);
76 ATH_MSG_DEBUG(
"BPhysAddMuonBasedInvMass::initialize() -- begin");
93 ATH_MSG_ERROR(
"No primary vertex types to be considered provided!");
98 ATH_MSG_ERROR(
"No PV-to-SV association types to be considered provided!");
110 ATH_MSG_DEBUG(
"BPhysAddMuonBasedInvMass::initialize() -- end");
112 return StatusCode::SUCCESS;
120 return StatusCode::SUCCESS;
125 ATH_MSG_DEBUG(
"BPhysAddMuonBasedInvMass::addBranches() -- begin");
141 std::string branchPrefix(
"");
148 vtxItr!=vtxContainer->
end(); ++vtxItr) {
153 d_mucalc_mass(branchPrefix+
"MUCALC_mass");
155 d_mucalc_massErr(branchPrefix+
"MUCALC_massErr");
158 std::pair<double,double> MuCalcCandMass =
162 d_mucalc_mass(**vtxItr) = MuCalcCandMass.first;
163 d_mucalc_massErr(**vtxItr) = MuCalcCandMass.second;
171 d_minChi2ToAnyPV(branchPrefix+
"minLogChi2ToAnyPV");
173 d_minChi2ToAnyPV(**vtxItr) =
181 d_minChi2ToAnyPV(branchPrefix+
"minLogChi2ToAnyPV_"
184 d_minChi2ToAnyPV(**vtxItr) =
192 <<
" Undefined AddMinChi2ToAnyPVMode value: "
199 ATH_MSG_DEBUG(
"BPhysAddMuonBasedInvMass::addBranches() -- end");
202 return StatusCode::SUCCESS;
207 std::pair<double, double>
209 const std::vector<double> &trkMasses,
212 std::pair<double, double> mpe(0., -1.);
216 if ( tracksWithMu.second == nMuRequested ) {
217 if ( tracksWithMu.first.size() == trkMasses.size() ) {
223 <<
" vector sizes disagree!"
224 <<
" tracksWithMu: " << tracksWithMu.first.size()
225 <<
" BtrkMasses: " << trkMasses.size());
228 mpe.second = -10 - tracksWithMu.second;
230 <<
" muon number mismatch:"
231 <<
" tracksWithMu: " << tracksWithMu.second
232 <<
" requested: " << nMuRequested);
243 for (
auto &
muon : muons) {
244 if (
muon !=
nullptr ) {
246 muon->trackParticle(xAOD::Muon::InnerDetectorTrackParticle);
247 if ( trk !=
nullptr ) {
248 muTracks.push_back(trk);
251 <<
" no ID track for muon found.");
255 <<
" muon pointer is NULL!");
263 std::pair<TrackBag, int>
268 std::vector<int> vnMuFound;
272 if ( muons.size() > 0 ) {
273 for (
int itrk=0; itrk<vtx.
nRefTrks(); ++itrk) {
278 for (
unsigned int imu = 0; imu<muons.size(); ++imu) {
280 muons.at(imu)->trackParticle(xAOD::Muon::InnerDetectorTrackParticle) ) {
283 if ( trkMuon != NULL ) {
284 trkParticle = trkMuon;
290 tracksWithMu.push_back(trkParticle);
291 vnMuFound.push_back(nMuFound);
295 ATH_MSG_DEBUG(
"BPhysAddMuonBasedInvMass::getTracksWithMuons: "
296 "vertex contains no muons, but "
297 << vtx.
nRefTrks() <<
" refitted tracks ...");
300 std::string svnMuFound =
"[";
301 for (
unsigned int i=0;
i<vnMuFound.size(); ++
i) {
304 svnMuFound.back() =
']';
305 ATH_MSG_DEBUG(
"BPhysAddMuonBasedInvMass::getTracksWithMuons: "
306 "nMuFound = " << nMuFound
307 <<
"\nvnMuFound = " << svnMuFound );
309 return std::pair<TrackBag, int>(std::move(tracksWithMu), nMuFound);
322 if ( m_adjustToMuonKinematics ) {
339 float qoverp = p4.P() > 0. ? 1./p4.P() : 10.e6;
340 if ( org->
qOverP() < 0. ) qoverp *= -1.;
342 p4.Phi(), p4.Theta(), qoverp);
347 <<
" org = " << org);
354 <<
" -> tp: " <<
tp);
360 << org->
d0() <<
"," << org->
z0() <<
"," << org->
phi0()
361 <<
"," << org->
theta() <<
"," << org->
qOverP() <<
") pt: "
368 <<
tp->d0() <<
"," <<
tp->z0() <<
"," <<
tp->phi0()
369 <<
"," <<
tp->theta() <<
"," <<
tp->qOverP() <<
") pt: "
391 muons.insert(muons.end(), muonsForVtx.begin(), muonsForVtx.end());
407 const std::vector<int>& pvtypes,
408 const int minNTracksInPV,
421 origPV = vtx.
origPv(pvAssocType);
422 if ( origPV ==
nullptr ) {
424 <<
" origPV == NULL for pvAssocType = "
428 refPV = vtx.
pv(pvAssocType);
429 if ( refPV ==
nullptr ) {
431 <<
" refPV == NULL for pvAssocType = "
439 for (
const auto pvtx : *pvContainer) {
440 if ( pvtx !=
nullptr ) {
441 if (
std::find(pvtypes.begin(),pvtypes.end(),pvtx->vertexType())
445 if (
mode > 1 && pvtx == origPV ) {
452 if ( refPV !=
nullptr ) {
456 <<
" refPV == NULL!");
463 for (
auto &
track : tracks) {
471 <<
" pvtx == NULL!");
490 if ( trkPerigee != NULL ) {
491 const AmgSymMatrix(5)* locError = trkPerigee->covariance();
492 if ( locError != NULL ) {
493 double d0 = trkPerigee->parameters()[
Trk::d0];
494 double z0 = trkPerigee->parameters()[
Trk::z0];
497 if (fabs(d0Err) > 0. && fabs(z0Err) > 0.) {
501 <<
" d0 = " <<
d0 <<
", d0Err = " << d0Err
502 <<
", z0 = " <<
z0 <<
", z0Err = " << z0Err);
520 const std::vector<double> &massHypotheses,
524 std::pair<double, double>
mass(0.,0.);
527 if ( trksIn.size() == massHypotheses.size() ) {
530 auto massHypItr = massHypotheses.cbegin();
532 double pxTmp,pyTmp,pzTmp,massTmp,eTmp;
534 std::vector<TLorentzVector> trkMom;
535 TLorentzVector totMom;
536 std::vector<const Trk::Perigee*> trkPer;
537 const auto &ctx = cache.
ctx;
538 for (;trItr != trItrEnd; ++trItr,++massHypItr){
542 if ( trkPerigee != NULL ) {
544 pxTmp = trkPerigee->momentum()[
Trk::px];
545 pyTmp = trkPerigee->momentum()[
Trk::py];
546 pzTmp = trkPerigee->momentum()[
Trk::pz];
548 << pxTmp <<
"," << pyTmp <<
"," << pzTmp <<
")");
551 pxTmp = ((*trItr)->p4()).Px();
552 pyTmp = ((*trItr)->p4()).Py();
553 pzTmp = ((*trItr)->p4()).Pz();
555 "defaulting to simple momentum!");
557 trkPer.push_back(trkPerigee.release());
558 massTmp = *massHypItr;
559 eTmp = pxTmp*pxTmp+pyTmp*pyTmp+pzTmp*pzTmp+massTmp*massTmp;
560 eTmp = eTmp > 0. ? sqrt(eTmp) : 0.;
561 TLorentzVector tmpMom(pxTmp, pyTmp, pzTmp, eTmp);
562 trkMom.push_back(tmpMom);
565 mass.first = totMom.M();
568 trItr = trksIn.begin();
573 for (; tmItr != trkMom.end(); ++tmItr, ++trItr, ++perItr) {
574 dMdP(0) = (totMom.E() * tmItr->Px()/tmItr->E() - totMom.Px())/totMom.M();
575 dMdP(1) = (totMom.E() * tmItr->Py()/tmItr->E() - totMom.Py())/totMom.M();
576 dMdP(2) = (totMom.E() * tmItr->Pz()/tmItr->E() - totMom.Pz())/totMom.M();
577 if ( *perItr != NULL ) {
578 mErr2 += (dMdP.transpose() * getMomentumCov(*perItr) * dMdP)(0,0);
580 mErr2 += (dMdP.transpose() * getMomentumCov(*trItr ) * dMdP)(0,0);
583 mass.second = mErr2 > 0. ? sqrt(mErr2) : 0.;
585 for ( perItr = trkPer.begin(); perItr != trkPer.end(); ++perItr) {
590 "size mismatch of tracks and mass hypotheses vectors!");
607 if (
track != NULL ) {
608 cov = getMomentumCov( &
track->perigeeParameters() );
619 ::getMomentumCov(
const Trk::Perigee* perigee)
const {
624 if ( perigee != NULL ) {
625 cov = getMomentumCov(perigee->parameters(), *perigee->covariance());
650 double theta =
pars[
Trk::theta];
653 if ( qoverp != 0. ) {
655 sin(phi)*
sin(theta)/fabs(qoverp),
656 cos(theta)/fabs(qoverp) );
662 der(0,1) =
cos(phi) *
p.
z();
663 der(1,1) =
sin(phi) *
p.
z();
664 der(2,1) = -
sin(theta) / fabs(qoverp);
665 der(0,2) = -
p.
x()/qoverp;
666 der(1,2) = -
p.
y()/qoverp;
667 der(2,2) = -
p.
z()/qoverp;
669 for (
unsigned int i=0;
i<3;
i++) {
670 for (
unsigned int j=0; j<3; j++) {
671 for (
unsigned int k=0;
k<3;
k++) {
672 for (
unsigned int l=0;
l<3;
l++) {
673 cov(
i,j) += der(
i,
k)*cMatrix(
k+2,
l+2)*der(j,
l);
680 ATH_MSG_DEBUG(
"BPhysAddMuonBasedInvMass::getTracksWithMuons:"
681 <<
"\nlocalErrCov:\n"
682 << std::setprecision(10) << cMatrix
684 << std::setprecision(10) <<
cov
685 <<
"\np: " << std::setprecision(10) <<
p
687 << std::setprecision(10) << der);
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.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
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.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
const Amg::Vector3D & position() const
Returns the 3-pos.
MuonBag findAllMuonsInDecay(xAOD::BPhysHelper &vtx) const
Find all muons associated to secondary vertex.
bool const RAWDATA *ch2 const
@ pz
global momentum (cartesian)
void initPvAssocTypeVec()
Initialize PV-to-SV association type vector.
std::vector< const xAOD::Muon * > MuonBag
#define AmgMatrix(rows, cols)
float d0() const
Returns the parameter.
Augment secondary vertices with muon-information-based mass.
AmgSymMatrix(3) BPhysAddMuonBasedInvMass
Augmentation with muon-information based invariant mass.
TLorentzVector FourMom_t
Definition of the 4-momentum type.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
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.
pv_type
: Enum type of the PV
Helper class to provide type-safe access to aux data.
(Non-const) Iterator class for DataVector/DataList.
::StatusCode StatusCode
StatusCode definition for legacy code.
const xAOD::Vertex * precedingVertex(const size_t index)
Returns pointer to a preceding vertex.
double chi2(TH1 *h0, TH1 *h1)
TpMap_t adjTpCache
map of adjusted track particles as cache
#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 .
Ensure that the ATLAS eigen extensions are properly loaded.
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.
BPhysAddMuonBasedInvMass(const std::string &t, const std::string &n, const IInterface *p)
Main contructor.
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.
virtual StatusCode addBranches() const
Main method called for each event.
std::string m_pvContainerName
: B-physics xAOD helpers.
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
static const unsigned int n_pv_types
Class describing a TrackParticle.
std::map< const xAOD::TrackParticle *, const xAOD::TrackParticle * > TpMap_t
map original -> adjusted track particles
const std::vector< const xAOD::Muon * > & muons()
Returns linked muons.
BasedInvCache(const EventContext &c=Gaudi::Hive::currentContext())
ToolHandle< Reco::ITrackToVertex > m_trackToVertexTool
constexpr int pow(int base, int exp) noexcept
virtual StatusCode finalize()
Finalize augmentation tool.
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
virtual StatusCode initialize()
Initialize augmentation tool.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
std::string m_branchPrefix