9#include <framework/gearbox/Unit.h>
10#include <framework/gearbox/Const.h>
11#include <framework/logging/Logger.h>
12#include <framework/particledb/EvtGenDatabasePDG.h>
33#define DEFINE_UNIT_NAME(var,value,name) const double Unit::var = Unit::registerConversion(name,value)
35#define DEFINE_UNIT(var,value) DEFINE_UNIT_NAME(var,value,#var)
133 B2ERROR(
"Could not find conversion factor for unit " << unitString <<
", assuming 1.0");
136 return it->second * value;
143 B2ERROR(
"Could not find conversion factor for unit " << unitString <<
", assuming 1.0");
146 return value / it->second;
152 B2ERROR(
"Conversion factor for unit " << name <<
" already exists, ignoring");
164 if (det == Const::PXD)
return "PXD";
165 else if (det == Const::SVD)
return "SVD";
166 else if (det == Const::CDC)
return "CDC";
167 else if (det == Const::TOP)
return "TOP";
168 else if (det == Const::ARICH)
return "ARICH";
169 else if (det == Const::ECL)
return "ECL";
170 else if (det == Const::KLM)
return "KLM";
171 else if (det == Const::BKLM)
return "BKLM";
172 else if (det == Const::EKLM)
return "EKLM";
173 else if (det == Const::IR)
return "IR";
174 else if (det == Const::TRG)
return "TRG";
175 else if (det == Const::DAQ)
return "DAQ";
176 else if (det == Const::BEAST)
return "BEAST";
177 else if (det == Const::TEST)
return "TEST";
178 else B2FATAL(
"Unknown detector component: " << det);
197bool Const::DetectorSet::Iterator::operator==(
200 return m_SetBit == iterator.
m_SetBit;
203bool Const::DetectorSet::Iterator::operator!=(
206 return m_SetBit != iterator.
m_SetBit;
212 while ((
m_bits & setBit) == 0) {
213 setBit = setBit << 1;
214 if (setBit >= 0x1000)
248 if (det == 0 || det > 0x100) {
249 B2ERROR(
"Const::DetectorSet::getBit() called for an invalid detector "
250 "identifier (possibly a subdetector):" << det);
254 B2ERROR(
"Const::DetectorSet::getBit(): Invalid detector ID");
256 return (1 << (det - 1));
262 case 0x0001:
return PXD;
263 case 0x0002:
return SVD;
264 case 0x0004:
return CDC;
265 case 0x0008:
return TOP;
266 case 0x0010:
return ARICH;
267 case 0x0020:
return ECL;
268 case 0x0040:
return KLM;
269 case 0x0080:
return IR;
270 case 0x0100:
return TRG;
271 case 0x0200:
return DAQ;
272 case 0x0400:
return BEAST;
273 case 0x0800:
return TEST;
274 default:
return invalidDetector;
280 unsigned short bit =
getBit(det);
281 if ((
m_bits & bit) == 0)
return -1;
283 for (
unsigned short setBit = 1; setBit < bit; setBit *= 2) {
284 if ((
m_bits & setBit) != 0) ++index;
292 for (
unsigned short setBit = 1; setBit < 0x1000; setBit *= 2) {
300 std::string result =
"<set: ";
301 const std::string detectorNames[] = {
"invalidDetector",
"PXD",
"SVD",
"CDC",
"TOP",
"ARICH",
"ECL",
"KLM",
"IR",
"TRG",
"DAQ",
"BEAST",
"TEST"};
302 for (
size_t index = 1; index <= Const::TEST; index++) {
304 if (result.size() > 6) {
307 result += detectorNames[index];
323 Const::TOP + Const::ARICH + Const::ECL + Const::KLM +
324 Const::TRG + Const::DAQ + Const::BEAST + Const::TEST;
338 m_pdgCode = m_set->at(++m_index).
getPDGCode();
358 return getParticlePDG()->Mass();
363 std::string result =
"<type: ";
364 result += getParticlePDG()->GetName();
421 m_particles.emplace_back(p.getPDGCode(),
this, m_particles.size());
426 return (std::find(m_particles.begin(), m_particles.end(), p) != m_particles.end());
Provides a type-safe way to pass members of the chargedStableSet set.
static const DetectorSet c_set
The set of valid tracking detectors.
Provides a type-safe way to pass members of the clusterSet set.
uint16_t m_DetectorSetBits
Bits in DetectorSet.
uint16_t m_SetBit
Set bit.
The DetectorSet class for sets of detector IDs in the form of EDetector values.
std::string __str__() const
String for printing in python.
size_t size() const
Getter for number of detector IDs in this set.
int getIndex(EDetector det) const
Getter for the index of a given detector in this set.
Iterator end() const
Ending iterator.
uint16_t m_bits
The internal representation of the set as bit pattern.
static uint16_t getBit(EDetector det)
Conversion of detector ID to bit pattern.
bool contains(const DetectorSet &set) const
Check whether this set contains another set.
static EDetector getDetector(uint16_t bit)
Conversion of bit pattern to detector ID.
Iterator begin() const
Beginning iterator.
static const DetectorSet c_set
The set of valid PID detectors.
A set of ParticleType objects, with defined order.
ParticleType begin() const
Returns first particle.
bool contains(const ParticleType &p) const
Returns true if and only if the set contains 'p'.
ParticleType end() const
Returns an invalid particle to check if iteration should be stopped.
void add(const ParticleType &p)
Add a copy of the given ParticleType to this set.
const ParticleType & find(int pdg) const
Returns particle in set with given PDG code, or invalidParticle if not found.
The ParticleType class for identifying different particle types.
int getPDGCode() const
PDG code.
std::string __repr__() const
String for printing in python.
bool operator<(const ParticleType &other) const
Comparison operator to be usable in sets.
int m_pdgCode
PDG code of the particle.
const TParticlePDG * getParticlePDG() const
Accessor for ROOT TParticlePDG object.
ParticleType & operator++()
Prefix increment.
double getMass() const
Particle mass.
static const DetectorSet c_set
The set of valid tracking detectors.
static const DetectorSet c_set
The set of valid tracking detectors.
static const ParticleType neutron
neutron particle
static const ParticleType unspecifiedParticle
Unspecified particle, used when no other particle type fits.
static const ParticleType pi0
neutral pion particle
static const Cluster clustermuon
muon cluster
static const ParticleType Lambda
Lambda particle.
static const DetectorSet allDetectors
The set of all detectors.
static const double eMobilitySi
Electron mobility in intrinsic Silicon at room temperature.
static const ParticleSet clusterSet
set of cluster particles
static const ChargedStable muon
muon particle
static const ParticleSet chargedStableSet
set of charged stable particles
static const float floatNaN
quiet_NaN
static const double kBoltzmann
Boltzmann constant in GeV/K.
static const Cluster clusterelectron
electron cluster
static const double kaonMass
charged kaon mass
EDetector
Enum for identifying the detector components (detector and subdetector).
static const double K0Mass
neutral kaon mass
static const Cluster clusterpion
charged hadron cluster
static const ChargedStable pion
charged pion particle
static std::string parseDetectors(EDetector det)
Converts Const::EDetector object to string.
static const double pionMass
charged pion mass
static const ParticleType Klong
K^0_L particle.
static const ParticleSet finalStateParticlesSet
set of final set particles that can be created by the ParticleLoader
static const double permSi
Permittivity of Silicon.
static const double speedOfLight
[cm/ns]
static const double electronMass
electron mass
static const double neutronMass
neutron mass
static const Cluster clusterKlong
K^0_L cluster.
static const ParticleType antiLambda
Anti-Lambda particle.
static const double deuteronMass
deuteron mass
static const ChargedStable proton
proton particle
static const ParticleType invalidParticle
Invalid particle, used internally.
static const double ehEnergy
Energy needed to create an electron-hole pair in Si at std.
static const ParticleType Kshort
K^0_S particle.
static const double protonMass
proton mass
static const double doubleNaN
quiet_NaN
static const ParticleType antiNeutron
Anti-neutron particle.
static const double fineStrConst
The fine structure constant.
static const Cluster clusterjunk
junk cluster
static const double uTherm
Thermal Voltage at room temperature.
static const ChargedStable kaon
charged kaon particle
static const ParticleType photon
photon particle
static const double pi0Mass
neutral pion mass
static const Cluster clusterphoton
photon cluster
static const double muonMass
muon mass
static const ChargedStable electron
electron particle
static const ChargedStable deuteron
deuteron particle
static EvtGenDatabasePDG * Instance()
Instance method that loads the EvtGen table.
static const double mm
[millimeters]
static const double e
Standard of [electric charge].
static const double mm3
[cubic millimeters]
static const double GHz
Standard of [frequency].
static const double rad
Standard of [angle].
static const double kg_cm3
[kg/cm^3]
static const double Gauss
[gauss]
static const double um
[micrometers]
static const double V
[voltage]
static const double eV
[electronvolt]
static const double m2
[square meters]
static const double b
[barn]
static const double m
[meters]
static const double C
[coulomb]
static const double cm
Standard units with the value = 1.
static const double K
Standard of [temperature].
static const double g_cm3
Practical units with the value set at 1.
static const double mg_cm3
[mg/cm^3]
static const double ns
Standard of [time].
static const double s
[second]
static const double GeV
Standard of [energy, momentum, mass].
static const double T
[tesla]
static const double cm2
[square centimeters]
static std::map< std::string, double > s_conversionFactors
Map to be able to convert between units using string representations of the unit name.
static double registerConversion(const std::string &name, double value)
registers the name and value of a conversion in s_conversionFactors.
static double convertValueToUnit(double value, const std::string &unitString)
Converts a floating point value from the standard framework unit to the given unit.
B2Vector3< DataType > operator-(const TVector3 &a, const B2Vector3< DataType > &b)
non-memberfunction for substracting a TVector3 from a B2Vector3
static double convertValue(double value, const std::string &unitString)
Converts a floating point value to the standard framework unit.
#define DEFINE_UNIT_NAME(var, value, name)
Define a new Unit given a name for the conversion table.
B2Vector3< DataType > operator+(const TVector3 &a, const B2Vector3< DataType > &b)
non-memberfunction for adding a TVector3 to a B2Vector3
#define DEFINE_UNIT(var, value)
Define a new Unit and take the variable name as name for the conversion table.
Abstract base class for different kinds of events.