Skip to content
Snippets Groups Projects
Commit 862a44d6 authored by Volker Friese's avatar Volker Friese
Browse files

Catch case of ions and cherenkov photons not present in the standard...

Catch case of ions and cherenkov photons not present in the standard TDatabasePDG in CbmMCTrack::GetMass() and GetCharge(). Refs #1806 @1.5h
parent bc6809b4
No related branches found
No related tags found
1 merge request!87Catch case of ions and cherenkov photons not present in the standard...
......@@ -112,31 +112,67 @@ CbmMCTrack::~CbmMCTrack() {}
// ----- Public method GetMass -----------------------------------------
Double_t CbmMCTrack::GetMass() const {
if (TDatabasePDG::Instance()) {
TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(fPdgCode);
if (particle)
return particle->Mass();
else
// Particle found in TDatabasePDG
if (particle) return particle->Mass();
// Ions may not be in the TDatabasePDG, but their mass number is encoded
// in the PDG code like 10LZZZAAAI, where L is strangeness, Z is charge,
// A is number of nucleons, and I is isomer level.
else if (fPdgCode > 1000000000) {
Int_t a = (fPdgCode % 10000) / 10;
return Double_t(a) * CbmProtonMass();
}
// Cherenkov photons
else if (fPdgCode == 50000050)
return 0.;
}
return 0.;
// Unknown particle type
else
LOG(fatal) << "CbmMCTrack: Unknown PDG code " << fPdgCode;
} //? Instance of TDatabasePDG
LOG(fatal) << "CbmMCTrack: No TDatabasePDG";
return -1.;
}
// -------------------------------------------------------------------------
// ----- Public method GetCharge ---------------------------------------
Double_t CbmMCTrack::GetCharge() const {
if (TDatabasePDG::Instance()) {
TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(fPdgCode);
if (particle)
return particle->Charge();
else
// Particle found in TDatabasePDG
if (particle) return particle->Charge();
// Ions may not be in the TDatabasePDG, but their charge number is encoded
// in the PDG code like 10LZZZAAAI, where L is strangeness, Z is charge,
// A is number of nucleons, and I is isomer level.
else if (fPdgCode > 1000000000) {
return Double_t((fPdgCode % 10000000) / 10000);
}
// Cherenkov photons
else if (fPdgCode == 50000050)
return 0.;
}
// Unknown particle type
else
LOG(fatal) << "CbmMCTrack: Unknown PDG code " << fPdgCode;
} //? Instance of TDatabasePDG
LOG(fatal) << "CbmMCTrack: No TDatabasePDG";
return 0.;
}
// -------------------------------------------------------------------------
// ----- Public method GetRapidity -------------------------------------
Double_t CbmMCTrack::GetRapidity() const {
Double_t e = GetEnergy();
......
......@@ -76,8 +76,25 @@ public:
Double_t GetStartY() const { return fStartY; }
Double_t GetStartZ() const { return fStartZ; }
Double_t GetStartT() const { return fStartT; }
/** @brief Mass of the associated particle
** @return Particle mass [GeV]
**
** The mass is taken from TDatabasePDG if the particle exists there.
** For ions, the mass is calculated from the PDG code. The method
** throws an error for unknown PDG codes.
**/
Double_t GetMass() const;
/** @brief Charge of the associated particle
** @return Particle charge [e]
**
** The charge is taken from TDatabasePDG if the particle exists there.
** For ions, the charge is calculated from the PDG code. The method
** throws an error for unknown PDG codes.
**/
Double_t GetCharge() const;
Double_t GetEnergy() const;
Double_t GetPt() const { return TMath::Sqrt(fPx * fPx + fPy * fPy); }
Double_t GetP() const {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment