12 #include <reconstruction/variables/DedxVariables.h>
13 #include <analysis/VariableManager/Manager.h>
16 #include <framework/gearbox/Const.h>
17 #include <framework/logging/Logger.h>
18 #include <framework/utilities/Conversion.h>
21 #include <analysis/dataobjects/Particle.h>
22 #include <mdst/dataobjects/Track.h>
23 #include <reconstruction/dataobjects/CDCDedxTrack.h>
24 #include <reconstruction/dataobjects/VXDDedxTrack.h>
39 const Track* track = particle->getTrack();
44 const CDCDedxTrack* dedxTrack = track->getRelatedTo<CDCDedxTrack>();
57 const Track* track = particle->getTrack();
62 const VXDDedxTrack* dedxTrack = track->getRelatedTo<VXDDedxTrack>();
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();
143 double CDCdEdx_llog(
const Particle* part,
const int index)
149 return dedxTrack->getLogl(index);
153 double CDCdEdx_llogE(
const Particle* part)
155 return CDCdEdx_llog(part, 0);
158 double CDCdEdx_llogMu(
const Particle* part)
160 return CDCdEdx_llog(part, 1);
163 double CDCdEdx_llogPi(
const Particle* part)
165 return CDCdEdx_llog(part, 2);
168 double CDCdEdx_llogK(
const Particle* part)
170 return CDCdEdx_llog(part, 3);
173 double CDCdEdx_llogP(
const Particle* part)
175 return CDCdEdx_llog(part, 4);
178 double CDCdEdx_llogD(
const Particle* part)
180 return CDCdEdx_llog(part, 5);
187 if (arguments.size() < 2) {
188 B2ERROR(
"Min two arguments required to get variables related chi, predicted mean and reso");
195 }
catch (std::invalid_argument& e) {
196 B2ERROR(
"First argument of variable must be a variable name (chi or pmean or preso)");
202 pdgCode = Belle2::convertString<int>(arguments[1]);
203 }
catch (std::invalid_argument& e) {
204 B2ERROR(
"Second argument of variable must be a PDG code");
209 if (abs(pdgCode) == 11)index = 0;
210 else if (abs(pdgCode) == 13)index = 1;
211 else if (abs(pdgCode) == 211)index = 2;
212 else if (abs(pdgCode) == 321)index = 3;
213 else if (abs(pdgCode) == 2212)index = 4;
214 else if (abs(pdgCode) == 1000010020)index = 5;
216 auto func = [index, var](
const Particle * part) ->
double {
220 return std::numeric_limits<float>::quiet_NaN();
222 if (var ==
"chi")
return dedxTrack->getChi(index);
223 else if (var ==
"pmean")
return dedxTrack->getPmean(index);
224 else if (var ==
"preso")
return dedxTrack->getPreso(index);
225 else return std::numeric_limits<float>::quiet_NaN();
231 double CDCdEdx_chiE(
const Particle* part)
236 double CDCdEdx_chiMu(
const Particle* part)
241 double CDCdEdx_chiPi(
const Particle* part)
246 double CDCdEdx_chiK(
const Particle* part)
251 double CDCdEdx_chiP(
const Particle* part)
256 double CDCdEdx_chiD(
const Particle* part)
262 double SVD_p(
const Particle* part)
268 return dedxTrack->getMomentum();
272 double SVD_pTrue(
const Particle* part)
278 return dedxTrack->getTrueMomentum();
282 double SVDdedx(
const Particle* part)
288 return dedxTrack->getDedx(Const::EDetector::SVD);
292 double SVD_CosTheta(
const Particle* part)
298 return dedxTrack->getCosTheta();
301 double SVD_nHits(
const Particle* part)
307 return dedxTrack->size();
311 VARIABLE_GROUP(
"Dedx");
313 REGISTER_VARIABLE(
"CDCdEdx", CDCdedx,
"CDC dE/dx truncated mean");
314 REGISTER_VARIABLE(
"CDCdEdxnosat", CDCdedxnosat,
"CDC dE/dx truncated mean without saturation correction");
315 REGISTER_VARIABLE(
"pCDC", pCDC,
"Momentum valid in the CDC");
316 REGISTER_VARIABLE(
"costhCDC", costhCDC,
"costheta valid in the CDC");
317 REGISTER_VARIABLE(
"CDCdEdx_nhits", CDCdEdx_nhits,
"total hits of dedx track");
318 REGISTER_VARIABLE(
"CDCdEdx_lnhits", CDCdEdx_lnhits,
"layer hits for dedx track");
319 REGISTER_VARIABLE(
"CDCdEdx_lnhitsused", CDCdEdx_lnhitsused,
"truncated hits of dedx track");
321 REGISTER_VARIABLE(
"CDCdEdx_PIDvars(var,PDG) var (= chi or pmean or preso) and PDG is of charged particles", CDCdEdx_PIDvars,
322 "advance CDC dEdx PID related variables for charged particle");
324 REGISTER_VARIABLE(
"CDCdEdx_chiE", CDCdEdx_chiE,
"Chi value of electrons from CDC dEdx");
325 REGISTER_VARIABLE(
"CDCdEdx_chiMu", CDCdEdx_chiMu,
"Chi value of muons from CDC dEdx");
326 REGISTER_VARIABLE(
"CDCdEdx_chiPi", CDCdEdx_chiPi,
"Chi value of pions from CDC dEdx");
327 REGISTER_VARIABLE(
"CDCdEdx_chiK", CDCdEdx_chiK,
"Chi value of kaons from CDC dEdx");
328 REGISTER_VARIABLE(
"CDCdEdx_chiP", CDCdEdx_chiP,
"Chi value of protons from CDC dEdx");
329 REGISTER_VARIABLE(
"CDCdEdx_chiD", CDCdEdx_chiD,
"Chi value of duetrons from CDC dEdx");
331 REGISTER_VARIABLE(
"CDCdEdx_llogE", CDCdEdx_llogE,
"Log likelihood value of electrons from CDC dEdx");
332 REGISTER_VARIABLE(
"CDCdEdx_llogMu", CDCdEdx_llogMu,
"Log likelihood value of muons from CDC dEdx");
333 REGISTER_VARIABLE(
"CDCdEdx_llogPi", CDCdEdx_llogPi,
"Log likelihood value of pions from CDC dEdx");
334 REGISTER_VARIABLE(
"CDCdEdx_llogK", CDCdEdx_llogK,
"Log likelihood value of kaons from CDC dEdx");
335 REGISTER_VARIABLE(
"CDCdEdx_llogP", CDCdEdx_llogP,
"Log likelihood value of protons from CDC dEdx");
336 REGISTER_VARIABLE(
"CDCdEdx_llogD", CDCdEdx_llogD,
"Log likelihood value of duetrons from CDC dEdx");
339 REGISTER_VARIABLE(
"SVDdEdx", SVDdedx,
"SVD dE/dx truncated mean");
340 REGISTER_VARIABLE(
"pSVD", SVD_p,
"momentum valid in the SVD");
341 REGISTER_VARIABLE(
"SVD_pTrue", SVD_pTrue,
"true MC momentum valid in the SVD");
342 REGISTER_VARIABLE(
"SVD_CosTheta", SVD_CosTheta,
"cos(theta) of the track valid in the SVD");
343 REGISTER_VARIABLE(
"SVD_nHits", SVD_nHits,
"number of hits of the track valid in the SVD");