 |
Belle II Software
release-05-02-19
|
16 #include <framework/gearbox/Unit.h>
17 #include <framework/gearbox/Const.h>
18 #include <framework/logging/Logger.h>
19 #include <framework/particledb/EvtGenDatabasePDG.h>
40 #define DEFINE_UNIT_NAME(var,value,name) const double Unit::var = Unit::registerConversion(name,value)
42 #define DEFINE_UNIT(var,value) DEFINE_UNIT_NAME(var,value,#var)
138 auto it = s_conversionFactors.find(unitString);
139 if (it == s_conversionFactors.end()) {
140 B2ERROR(
"Could not find conversion factor for unit " << unitString <<
", assuming 1.0");
143 return it->second * value;
148 auto it = s_conversionFactors.find(unitString);
149 if (it == s_conversionFactors.end()) {
150 B2ERROR(
"Could not find conversion factor for unit " << unitString <<
", assuming 1.0");
153 return value / it->second;
158 if (!s_conversionFactors.insert(make_pair(name, value)).second) {
159 B2ERROR(
"Conversion factor for unit " << name <<
" already exists, ignoring");
192 if (det == 0 || det > 0x100) {
193 B2ERROR(
"Const::DetectorSet::getBit() called for an invalid detector "
194 "identifier (possibly a subdetector):" << det);
198 B2ERROR(
"Const::DetectorSet::getBit(): Invalid detector ID");
200 return (1 << (det - 1));
206 case 0x0001:
return PXD;
207 case 0x0002:
return SVD;
208 case 0x0004:
return CDC;
209 case 0x0008:
return TOP;
210 case 0x0010:
return ARICH;
211 case 0x0020:
return ECL;
212 case 0x0040:
return KLM;
213 case 0x0080:
return IR;
214 case 0x0100:
return TRG;
215 case 0x0200:
return DAQ;
216 case 0x0400:
return BEAST;
217 case 0x0800:
return TEST;
218 default:
return invalidDetector;
224 unsigned short bit = getBit(det);
225 if ((m_bits & bit) == 0)
return -1;
227 for (
unsigned short setBit = 1; setBit < bit; setBit *= 2) {
228 if ((m_bits & setBit) != 0) ++index;
235 if (index < 0)
return Const::invalidDetector;
236 for (
unsigned short setBit = 1; setBit < 0x1000; setBit *= 2) {
237 if ((m_bits & setBit) != 0) --index;
238 if (index < 0)
return getDetector(setBit);
240 return Const::invalidDetector;
246 for (
unsigned short setBit = 1; setBit < 0x1000; setBit *= 2) {
247 if ((m_bits & setBit) != 0) ++size;
254 std::string result =
"<set: ";
255 std::string detectorNames[] = {
"invalidDetector",
"PXD",
"SVD",
"CDC",
"TOP",
"ARICH",
"ECL",
"KLM",
"IR",
"TRG",
"DAQ",
"BEAST",
"TEST"};
256 for (
size_t index = 1; index <= Const::TEST; index++) {
258 if (result.size() > 6) {
261 result += detectorNames[index];
277 Const::TOP + Const::ARICH + Const::ECL + Const::KLM +
278 Const::TRG + Const::DAQ + Const::BEAST + Const::TEST;
290 *
this = invalidParticle;
292 m_pdgCode = m_set->at(++m_index).
getPDGCode();
312 return getParticlePDG()->Mass();
317 std::string result =
"<type: ";
318 result += getParticlePDG()->GetName();
369 m_particles.emplace_back(p.getPDGCode(),
this, m_particles.size());
374 return (std::find(m_particles.begin(), m_particles.end(), p) != m_particles.end());
static const DetectorSet c_set
The set of valid tracking detectors.
static const double s
[second]
std::string __repr__() const
String for printing in python.
static const double cm
Standard units with the value = 1.
static const ParticleType photon
photon particle
static const double ns
Standard of [time].
static const DetectorSet c_set
The set of valid tracking detectors.
static const ParticleType unspecifiedParticle
Unspecified particle, used when no other particle type fits.
static const double uTherm
Thermal Voltage at room temperature.
static const ParticleType invalidParticle
Invalid particle, used internally.
static const ParticleType Kshort
K^0_S particle.
ParticleType & operator++()
Prefix increment.
static const ChargedStable electron
electron particle
static const ParticleType Klong
K^0_L particle.
static const double mm3
[cubic millimeters]
static const double kBoltzmann
Boltzmann constant in GeV/K.
static const Cluster clusterjunk
junk cluster
static const ParticleSet chargedStableSet
set of charged stable particles
int getPDGCode() const
PDG code.
static const Cluster clusterelectron
electron cluster
The DetectorSet class for sets of detector IDs in the form of EDetector values.
static unsigned short getBit(EDetector det)
Conversion of detector ID to bit pattern.
static const DetectorSet c_set
The set of valid tracking detectors.
static const double eMobilitySi
Electron mobility in intrinsic Silicon at room temperature.
A set of ParticleType objects, with defined order.
static const double deuteronMass
deuteron mass
static const double permSi
Permittivity of Silicon.
DEFINE_UNIT_NAME(g_cm3, 1., "g/cm3")
Practical units with the value = 1.
EDetector
Enum for identifying the detector components (detector and subdetector).
static const double GHz
Standard of [frequency].
static const double electronMass
electron mass
static std::map< std::string, double > s_conversionFactors
Map to be able to convert between units using string representations of the unit name.
static const Cluster clustermuon
muon cluster
static const ChargedStable kaon
charged kaon particle
static const double rad
Standard of [angle].
static double convertValue(double value, const std::string &unitString)
Converts a floating point value to the standard framework unit.
static const double neutronMass
neutron mass
static const Cluster clusterKlong
K^0_L cluster.
bool contains(const ParticleType &p) const
Returns true if and only if the set contains 'p'.
static const double speedOfLight
[cm/ns]
static const ChargedStable pion
charged pion particle
static const double T
[tesla]
static const double eV
[electronvolt]
static const DetectorSet allDetectors
The set of all detectors.
DEFINE_UNIT(cm, 1.)
Standard units with the value = 1.
void add(const ParticleType &p)
Add a copy of the given ParticleType to this set.
Provides a type-safe way to pass members of the clusterSet set.
ParticleType begin() const
Returns first particle.
const ParticleType & find(int pdg) const
Returns particle in set with given PDG code, or invalidParticle if not found.
Abstract base class for different kinds of events.
static const double kg_cm3
[kg/cm^3]
static const ChargedStable deuteron
deuteron particle
static const DetectorSet c_set
The set of valid PID detectors.
B2Vector3< DataType > operator-(const TVector3 &a, const B2Vector3< DataType > &b)
non-memberfunction for substracting a TVector3 from a B2Vector3
EDetector operator[](int index) const
Accessor for a detector ID in this set.
static const ParticleType pi0
neutral pion particle
static const double Gauss
[gauss]
B2Vector3< DataType > operator+(const TVector3 &a, const B2Vector3< DataType > &b)
non-memberfunction for adding a TVector3 to a B2Vector3
static const double protonMass
proton mass
static const ParticleType antiLambda
Anti-Lambda particle.
static const ParticleType neutron
neutron particle
static double convertValueToUnit(double value, const std::string &unitString)
Converts a floating point value from the standard framework unit to the given unit.
static const double m
[meters]
static const double b
[barn]
int m_pdgCode
PDG code of the particle.
static const double pionMass
charged pion mass
static const double kaonMass
charged kaon mass
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
static double registerConversion(const std::string &name, double value)
registers the name and value of a conversion in s_conversionFactors.
static EDetector getDetector(unsigned short bit)
Conversion of bit pattern to detector ID.
ParticleType end() const
Returns an invalid particle to check if iteration should be stopped.
bool operator<(const ParticleType &other) const
Comparison operator to be usable in sets.
static const double K0Mass
neutral kaon mass
static const double mg_cm3
[mg/cm^3]
static const double mm
[millimeters]
static const Cluster clusterpion
charged hadron cluster
The ParticleType class for identifying different particle types.
static const ChargedStable proton
proton particle
Provides a type-safe way to pass members of the chargedStableSet set.
static const double K
Standard of [temperature].
static const double muonMass
muon mass
static const ChargedStable muon
muon particle
static const Cluster clusterphoton
photon cluster
static const double C
[coulomb]
static const double cm2
[square centimeters]
int getIndex(EDetector det) const
Getter for the index of a given detector in this set.
size_t size() const
Getter for number of detector IDs in this set.
static const double fineStrConst
The fine structure constant.
static const double GeV
Standard of [energy, momentum, mass].
std::string __repr__() const
String for printing in python.
static const double m2
[square meters]
static const double e
Standard of [electric charge].
static const double g_cm3
Practical units with the value set at 1.
static EvtGenDatabasePDG * Instance()
Instance method that loads the EvtGen table.
static const ParticleType Lambda
Lambda particle.
const TParticlePDG * getParticlePDG() const
Accessor for ROOT TParticlePDG object.
static const double ehEnergy
Energy needed to create an electron-hole pair in Si at std.
static const double um
[micrometers]
static const double V
[voltage]
static const ParticleSet clusterSet
set of cluster particles
double getMass() const
Particle mass.
static const double pi0Mass
neutral pion mass