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)
131 auto it = s_conversionFactors.find(unitString);
132 if (it == s_conversionFactors.end()) {
133 B2ERROR(
"Could not find conversion factor for unit " << unitString <<
", assuming 1.0");
136 return it->second * value;
141 auto it = s_conversionFactors.find(unitString);
142 if (it == s_conversionFactors.end()) {
143 B2ERROR(
"Could not find conversion factor for unit " << unitString <<
", assuming 1.0");
146 return value / it->second;
151 if (!s_conversionFactors.insert(make_pair(name, value)).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);
205 if (det == 0 || det > 0x100) {
206 B2ERROR(
"Const::DetectorSet::getBit() called for an invalid detector "
207 "identifier (possibly a subdetector):" << det);
211 B2ERROR(
"Const::DetectorSet::getBit(): Invalid detector ID");
213 return (1 << (det - 1));
219 case 0x0001:
return PXD;
220 case 0x0002:
return SVD;
221 case 0x0004:
return CDC;
222 case 0x0008:
return TOP;
223 case 0x0010:
return ARICH;
224 case 0x0020:
return ECL;
225 case 0x0040:
return KLM;
226 case 0x0080:
return IR;
227 case 0x0100:
return TRG;
228 case 0x0200:
return DAQ;
229 case 0x0400:
return BEAST;
230 case 0x0800:
return TEST;
231 default:
return invalidDetector;
237 unsigned short bit = getBit(det);
238 if ((m_bits & bit) == 0)
return -1;
240 for (
unsigned short setBit = 1; setBit < bit; setBit *= 2) {
241 if ((m_bits & setBit) != 0) ++index;
248 if (index < 0)
return Const::invalidDetector;
249 for (
unsigned short setBit = 1; setBit < 0x1000; setBit *= 2) {
250 if ((m_bits & setBit) != 0) --index;
251 if (index < 0)
return getDetector(setBit);
253 return Const::invalidDetector;
259 for (
unsigned short setBit = 1; setBit < 0x1000; setBit *= 2) {
260 if ((m_bits & setBit) != 0) ++size;
267 std::string result =
"<set: ";
268 std::string detectorNames[] = {
"invalidDetector",
"PXD",
"SVD",
"CDC",
"TOP",
"ARICH",
"ECL",
"KLM",
"IR",
"TRG",
"DAQ",
"BEAST",
"TEST"};
269 for (
size_t index = 1; index <= Const::TEST; index++) {
271 if (result.size() > 6) {
274 result += detectorNames[index];
290 Const::TOP + Const::ARICH + Const::ECL + Const::KLM +
291 Const::TRG + Const::DAQ + Const::BEAST + Const::TEST;
303 *
this = invalidParticle;
305 m_pdgCode = m_set->at(++m_index).
getPDGCode();
325 return getParticlePDG()->Mass();
330 std::string result =
"<type: ";
331 result += getParticlePDG()->GetName();
387 m_particles.emplace_back(p.getPDGCode(),
this, m_particles.size());
392 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.
The DetectorSet class for sets of detector IDs in the form of EDetector values.
size_t size() const
Getter for number of detector IDs in this set.
static EDetector getDetector(unsigned short bit)
Conversion of bit pattern to detector ID.
int getIndex(EDetector det) const
Getter for the index of a given detector in this set.
static unsigned short getBit(EDetector det)
Conversion of detector ID to bit pattern.
std::string __repr__() const
String for printing in python.
EDetector operator[](int index) const
Accessor for a detector ID in this set.
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 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 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]
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
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.
DEFINE_UNIT(cm, 1.)
Standard units with the value = 1.
static double convertValue(double value, const std::string &unitString)
Converts a floating point value to the standard framework unit.
DEFINE_UNIT_NAME(g_cm3, 1., "g/cm3")
Practical units with the value = 1.
B2Vector3< DataType > operator-(const TVector3 &a, const B2Vector3< DataType > &b)
non-memberfunction for substracting a TVector3 from a B2Vector3
B2Vector3< DataType > operator+(const TVector3 &a, const B2Vector3< DataType > &b)
non-memberfunction for adding a TVector3 to a B2Vector3
Abstract base class for different kinds of events.