10#include <cdc/variables/DedxVariables.h>
11#include <analysis/VariableManager/Manager.h>
14#include <framework/gearbox/Const.h>
15#include <framework/logging/Logger.h>
16#include <framework/utilities/Conversion.h>
19#include <analysis/dataobjects/Particle.h>
20#include <mdst/dataobjects/Track.h>
21#include <cdc/dataobjects/CDCDedxTrack.h>
36 const Track* track = particle->getTrack();
51 double CDCdedx(
const Particle* part)
57 return dedxTrack->getDedx();
61 double CDCdedxnosat(
const Particle* part)
67 return dedxTrack->getDedxNoSat();
71 double pCDC(
const Particle* part)
77 return dedxTrack->getMomentum();
81 double costhCDC(
const Particle* part)
87 return dedxTrack->getCosTheta();
92 double CDCdEdx_nhits(
const Particle* part)
98 return dedxTrack->size();
102 double CDCdEdx_lnhits(
const Particle* part)
108 return dedxTrack->getNLayerHits();
112 double CDCdEdx_lnhitsused(
const Particle* part)
118 return dedxTrack->getNLayerHitsUsed();
124 if (arguments.size() < 2) {
125 B2ERROR(
"Min two arguments required to get variables related chi, predicted mean and reso");
132 }
catch (std::invalid_argument& e) {
133 B2ERROR(
"First argument of variable must be a variable name (chi or pmean or preso)");
140 }
catch (std::invalid_argument& e) {
141 B2ERROR(
"Second argument of variable must be a PDG code");
147 else if (abs(pdgCode) ==
Const::muon.getPDGCode())index = 1;
148 else if (abs(pdgCode) ==
Const::pion.getPDGCode())index = 2;
149 else if (abs(pdgCode) ==
Const::kaon.getPDGCode())index = 3;
150 else if (abs(pdgCode) ==
Const::proton.getPDGCode())index = 4;
153 auto func = [index, var](
const Particle * part) ->
double {
157 return std::numeric_limits<float>::quiet_NaN();
160 if (var ==
"chi")
return dedxTrack->getChi(index);
161 else if (var ==
"pmean")
return dedxTrack->getPmean(index);
162 else if (var ==
"preso")
return dedxTrack->getPreso(index);
163 else return std::numeric_limits<float>::quiet_NaN();
169 double CDCdEdx_chiE(
const Particle* part)
172 return std::get<double>(pidFunction(part));
175 double CDCdEdx_chiMu(
const Particle* part)
178 return std::get<double>(pidFunction(part));
181 double CDCdEdx_chiPi(
const Particle* part)
184 return std::get<double>(pidFunction(part));
187 double CDCdEdx_chiK(
const Particle* part)
190 return std::get<double>(pidFunction(part));
193 double CDCdEdx_chiP(
const Particle* part)
196 return std::get<double>(pidFunction(part));
199 double CDCdEdx_chiD(
const Particle* part)
202 return std::get<double>(pidFunction(part));
205 VARIABLE_GROUP(
"CDC dEdx");
207 REGISTER_VARIABLE(
"CDCdEdx", CDCdedx,
"CDC dE/dx truncated mean");
208 REGISTER_VARIABLE(
"CDCdEdxnosat", CDCdedxnosat,
209 "CDC dE/dx truncated mean without saturation correction (NA for current track level MC)");
210 REGISTER_VARIABLE(
"pCDC", pCDC,
"Momentum valid in the CDC");
211 REGISTER_VARIABLE(
"costhCDC", costhCDC,
"costheta valid in the CDC");
212 REGISTER_VARIABLE(
"CDCdEdx_nhits", CDCdEdx_nhits,
"total hits of dedx track");
213 REGISTER_VARIABLE(
"CDCdEdx_lnhits", CDCdEdx_lnhits,
"layer hits for dedx track");
214 REGISTER_VARIABLE(
"CDCdEdx_lnhitsused", CDCdEdx_lnhitsused,
"truncated hits of dedx track");
216 REGISTER_METAVARIABLE(
"CDCdEdx_PIDvars(var,PDG) var (= chi or pmean or preso) and PDG is of charged particles", CDCdEdx_PIDvars,
217 "advance CDC dEdx PID related variables for charged particle", Manager::VariableDataType::c_double);
219 REGISTER_VARIABLE(
"CDCdEdx_chiE", CDCdEdx_chiE,
"Chi value of electrons from CDC dEdx");
220 REGISTER_VARIABLE(
"CDCdEdx_chiMu", CDCdEdx_chiMu,
"Chi value of muons from CDC dEdx");
221 REGISTER_VARIABLE(
"CDCdEdx_chiPi", CDCdEdx_chiPi,
"Chi value of pions from CDC dEdx");
222 REGISTER_VARIABLE(
"CDCdEdx_chiK", CDCdEdx_chiK,
"Chi value of kaons from CDC dEdx");
223 REGISTER_VARIABLE(
"CDCdEdx_chiP", CDCdEdx_chiP,
"Chi value of protons from CDC dEdx");
224 REGISTER_VARIABLE(
"CDCdEdx_chiD", CDCdEdx_chiD,
"Chi value of duetrons from CDC dEdx");
Debug output for CDCDedxPID module.
static const ChargedStable muon
muon particle
static const ChargedStable pion
charged pion particle
static const ChargedStable proton
proton particle
static const ChargedStable kaon
charged kaon particle
static const ChargedStable electron
electron particle
static const ChargedStable deuteron
deuteron particle
Class to store reconstructed particles.
Class that bundles various TrackFitResults.
std::function< VarVariant(const Particle *)> FunctionPtr
functions stored take a const Particle* and return VarVariant.
CDCDedxTrack const * getDedxFromParticle(Particle const *particle)
CDC dEdx value from particle.
T convertString(const std::string &str)
Converts a string to type T (one of float, double, long double, int, long int, unsigned long int).
Abstract base class for different kinds of events.