9#include <mdst/dataobjects/MCParticle.h> 
   10#include <framework/logging/Logger.h> 
   11#include <framework/datastore/DataStore.h> 
   12#include <framework/datastore/StoreArray.h> 
   13#include <framework/utilities/HTML.h> 
   14#include <framework/utilities/Conversion.h> 
   16#include <TDatabasePDG.h> 
   20#include <boost/algorithm/string.hpp> 
   30  if (TDatabasePDG::Instance()->GetParticle(
m_pdg) == 
nullptr)
 
   31    throw(ParticlePDGNotKnownError() << 
m_pdg);
 
   32  m_mass = TDatabasePDG::Instance()->GetParticle(
m_pdg)->Mass();
 
 
   43  if (TDatabasePDG::Instance()->GetParticle(
m_pdg) == 
nullptr) {
 
   44    B2ERROR(
"PDG=" << 
m_pdg << 
" ***code unknown to TDatabasePDG");
 
   48  return TDatabasePDG::Instance()->GetParticle(
m_pdg)->Charge() / 3.0;
 
 
   54  vector<MCParticle*> result;
 
   61      result.push_back(
static_cast<MCParticle*
>(plist[i]));
 
 
   86  TClonesArray* plist(0);
 
   91  if (MCParticles && MCParticles.
getPtr()->IndexOf(
this) >= 0) {
 
   92    plist = MCParticles.
getPtr();
 
   97      TClonesArray* value = 
dynamic_cast<TClonesArray*
>(iter->second.ptr);
 
   98      if (value && value->GetClass() == Class() && value->IndexOf(
this) >= 0) {
 
  106    B2ERROR(
"Could not determine StoreArray the MCParticle belongs to !");
 
  107    throw NoParticleListSetError();
 
  111  for (
int i = 0; i < plist->GetEntriesFast(); i++) {
 
 
  119  const TParticlePDG* p = TDatabasePDG::Instance()->GetParticle(
m_pdg);
 
  123    return std::to_string(
m_pdg);
 
 
  127  std::stringstream out;
 
  128  out << 
"<b>Charge</b>=" << (int)
getCharge();
 
  129  out << 
", <b>PDG</b>=" << 
getPDG();
 
  130  out << 
" (" << 
getName() << 
")";
 
  133  out << 
",<b>isInitial</b>=" << 
isInitial();
 
  134  out << 
",<b>isVirtual</b>=" << 
isVirtual();
 
 
  155  std::vector<std::string> generalizedIndexes;
 
  156  boost::split(generalizedIndexes, generalizedIndex, boost::is_any_of(
":"));
 
  158  if (generalizedIndexes.empty()) {
 
  159    B2WARNING(
"Generalized index of MC daughter particle is empty. Skipping.");
 
  170  for (
auto& indexString : generalizedIndexes) {
 
  175    } 
catch (std::invalid_argument&) {
 
  176      B2WARNING(
"Found the string " << indexString << 
"instead of a daughter index.");
 
  181    if (dauIndex >= 
int(currentPart->
getNDaughters()) or dauIndex < 0) {
 
  182      B2WARNING(
"Daughter index out of range" << 
LogVar(
"daughter index", dauIndex));
 
  183      B2WARNING(
"Trying to access non-existing particle.");
 
  187      currentPart = dauPart;
 
 
StoreEntryMap::const_iterator StoreEntryConstIter
const_iterator for a StoreEntry map.
StoreEntryMap & getStoreEntryMap(EDurability durability)
Get a reference to the object/array map.
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
static DataStore & Instance()
Instance of singleton Store.
std::map< std::string, StoreEntry > StoreEntryMap
Map for StoreEntries.
int m_lastDaughter
1-based index of last daughter particle in collection, 0 if no daughters
int m_firstDaughter
1-based index of first daughter particle in collection, 0 if no daughters
float m_mass
mass of the particle
virtual std::string getName() const override
Return name of this particle.
const MCParticle * getParticleFromGeneralizedIndexString(const std::string &generalizedIndex) const
Explores the decay tree of the MC particle and returns the (grand^n)daughter identified by a generali...
std::vector< Belle2::MCParticle * > getDaughters() const
Get vector of all daughter particles, empty vector if none.
static const double c_epsilon
limit of precision for two doubles to be the same.
int getArrayIndex() const
Get 0-based index of the particle in the corresponding MCParticle list.
ROOT::Math::XYZVector getProductionVertex() const
Return production vertex position.
virtual std::string getInfoHTML() const override
Return a short summary of this object's contents in HTML format.
int m_pdg
PDG-Code of the particle.
const MCParticle * getDaughter(int i) const
Return i-th daughter.
int getNDaughters() const
Return number of daughter MCParticles.
int getLastDaughter() const
Get 1-based index of last daughter, 0 if no daughters.
float getCharge() const
Return the particle charge defined in TDatabasePDG.
float m_momentum_z
momentum of particle, z component
void fixParticleList() const
Search the DataStore for the corresponding MCParticle array.
int getPDG() const
Return PDG code of particle.
ROOT::Math::XYZVector getMomentum() const
Return momentum.
MCParticle()
Default constructor for ROOT.
TClonesArray * m_plist
Internal pointer to DataStore Array containing particles belonging to this collection.
int getFirstDaughter() const
Get 1-based index of first daughter, 0 if no daughters.
void setMassFromPDG()
Sets the mass for the particle from the particle's PDG code.
std::string getArrayName() const
Get name of array this object is stored in, or "" if not found.
Accessor to arrays stored in the data store.
TClonesArray * getPtr() const
Raw access to the underlying TClonesArray.
Class to store variables with their name which were sent to the logging service.
T convertString(const std::string &str)
Converts a string to type T (one of float, double, long double, int, long int, unsigned long int).
bool isInitial() const
Check if particle is an initial particle such as ISR.
MCParticle * getMother() const
Returns a pointer to the mother particle.
bool isPrimaryParticle() const
Check if particle is a primary particle which was created by the generator (and not,...
bool isVirtual() const
Check if particle is virtual.
std::string getStringConvertToUnit(const ROOT::Math::XYZVector &vec, int precision=2, const std::string &unitType="cm")
get a string with vector coordinates: (x, y, z).
std::string chooseUnitOfLength(const ROOT::Math::XYZVector &vec)
get a string with a unit type to convert a vector, so that it is easily readable.
Abstract base class for different kinds of events.