10#include <reconstruction/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 <reconstruction/dataobjects/CDCDedxTrack.h>
22#include <reconstruction/dataobjects/VXDDedxTrack.h>
39 const Track* track = particle->getTrack();
57 const Track* track = particle->getTrack();
72 double CDCdedx(
const Particle* part)
78 return dedxTrack->getDedx();
82 double CDCdedxnosat(
const Particle* part)
88 return dedxTrack->getDedxNoSat();
92 double pCDC(
const Particle* part)
98 return dedxTrack->getMomentum();
102 double costhCDC(
const Particle* part)
108 return dedxTrack->getCosTheta();
113 double CDCdEdx_nhits(
const Particle* part)
119 return dedxTrack->size();
123 double CDCdEdx_lnhits(
const Particle* part)
129 return dedxTrack->getNLayerHits();
133 double CDCdEdx_lnhitsused(
const Particle* part)
139 return dedxTrack->getNLayerHitsUsed();
145 if (arguments.size() < 2) {
146 B2ERROR(
"Min two arguments required to get variables related chi, predicted mean and reso");
153 }
catch (std::invalid_argument& e) {
154 B2ERROR(
"First argument of variable must be a variable name (chi or pmean or preso)");
160 pdgCode = Belle2::convertString<int>(arguments[1]);
161 }
catch (std::invalid_argument& e) {
162 B2ERROR(
"Second argument of variable must be a PDG code");
168 else if (abs(pdgCode) ==
Const::muon.getPDGCode())index = 1;
169 else if (abs(pdgCode) ==
Const::pion.getPDGCode())index = 2;
170 else if (abs(pdgCode) ==
Const::kaon.getPDGCode())index = 3;
171 else if (abs(pdgCode) ==
Const::proton.getPDGCode())index = 4;
174 auto func = [index, var](
const Particle * part) ->
double {
178 return std::numeric_limits<float>::quiet_NaN();
181 if (var ==
"chi")
return dedxTrack->getChi(index);
182 else if (var ==
"pmean")
return dedxTrack->getPmean(index);
183 else if (var ==
"preso")
return dedxTrack->getPreso(index);
184 else return std::numeric_limits<float>::quiet_NaN();
190 double CDCdEdx_chiE(
const Particle* part)
193 return std::get<double>(pidFunction(part));
196 double CDCdEdx_chiMu(
const Particle* part)
199 return std::get<double>(pidFunction(part));
202 double CDCdEdx_chiPi(
const Particle* part)
205 return std::get<double>(pidFunction(part));
208 double CDCdEdx_chiK(
const Particle* part)
211 return std::get<double>(pidFunction(part));
214 double CDCdEdx_chiP(
const Particle* part)
217 return std::get<double>(pidFunction(part));
220 double CDCdEdx_chiD(
const Particle* part)
223 return std::get<double>(pidFunction(part));
227 double SVD_p(
const Particle* part)
233 return dedxTrack->getMomentum();
237 double SVD_pTrue(
const Particle* part)
243 return dedxTrack->getTrueMomentum();
247 double SVDdedx(
const Particle* part)
253 return dedxTrack->getDedx(Const::EDetector::SVD);
257 double SVD_CosTheta(
const Particle* part)
263 return dedxTrack->getCosTheta();
266 double SVD_nHits(
const Particle* part)
272 return dedxTrack->size();
276 VARIABLE_GROUP(
"Dedx");
278 REGISTER_VARIABLE(
"CDCdEdx", CDCdedx,
"CDC dE/dx truncated mean");
279 REGISTER_VARIABLE(
"CDCdEdxnosat", CDCdedxnosat,
280 "CDC dE/dx truncated mean without saturation correction (NA for current track level MC)");
281 REGISTER_VARIABLE(
"pCDC", pCDC,
"Momentum valid in the CDC");
282 REGISTER_VARIABLE(
"costhCDC", costhCDC,
"costheta valid in the CDC");
283 REGISTER_VARIABLE(
"CDCdEdx_nhits", CDCdEdx_nhits,
"total hits of dedx track");
284 REGISTER_VARIABLE(
"CDCdEdx_lnhits", CDCdEdx_lnhits,
"layer hits for dedx track");
285 REGISTER_VARIABLE(
"CDCdEdx_lnhitsused", CDCdEdx_lnhitsused,
"truncated hits of dedx track");
287 REGISTER_METAVARIABLE(
"CDCdEdx_PIDvars(var,PDG) var (= chi or pmean or preso) and PDG is of charged particles", CDCdEdx_PIDvars,
288 "advance CDC dEdx PID related variables for charged particle", Manager::VariableDataType::c_double);
290 REGISTER_VARIABLE(
"CDCdEdx_chiE", CDCdEdx_chiE,
"Chi value of electrons from CDC dEdx");
291 REGISTER_VARIABLE(
"CDCdEdx_chiMu", CDCdEdx_chiMu,
"Chi value of muons from CDC dEdx");
292 REGISTER_VARIABLE(
"CDCdEdx_chiPi", CDCdEdx_chiPi,
"Chi value of pions from CDC dEdx");
293 REGISTER_VARIABLE(
"CDCdEdx_chiK", CDCdEdx_chiK,
"Chi value of kaons from CDC dEdx");
294 REGISTER_VARIABLE(
"CDCdEdx_chiP", CDCdEdx_chiP,
"Chi value of protons from CDC dEdx");
295 REGISTER_VARIABLE(
"CDCdEdx_chiD", CDCdEdx_chiD,
"Chi value of duetrons from CDC dEdx");
298 REGISTER_VARIABLE(
"SVDdEdx", SVDdedx,
"SVD dE/dx truncated mean");
299 REGISTER_VARIABLE(
"pSVD", SVD_p,
"momentum valid in the SVD");
300 REGISTER_VARIABLE(
"SVD_pTrue", SVD_pTrue,
"true MC momentum valid in the SVD");
301 REGISTER_VARIABLE(
"SVD_CosTheta", SVD_CosTheta,
"cos(theta) of the track valid in the SVD");
302 REGISTER_VARIABLE(
"SVD_nHits", SVD_nHits,
"number of hits of the track valid in the SVD");
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.
Debug output for VXDDedxPID module.
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.
VXDDedxTrack const * getSVDDedxFromParticle(Particle const *particle)
SVD dEdx value from particle.
Abstract base class for different kinds of events.