290 | | === For the E^rec^,,nu,, === |
291 | | |
292 | | |
| 291 | |
| 292 | which concludes the `FillEventVariables(FitEvent *event)` function. |
| 293 | |
| 294 | === For the E^rec^,,nu,, distribution === |
| 295 | |
| 296 | E^rec^,,nu,, needs to be reconstructed from the outgoing particles, so requires a little more work. However it follows very similar steps to the [#point_muon_dist muon case]. |
| 297 | |
| 298 | To reconstructed E^rec^,,nu,, we need: |
| 299 | |
| 300 | * Muon momentum |
| 301 | * Pion momentum |
| 302 | * Muon/neutrino angle |
| 303 | * Pion/neutrino angle |
| 304 | * Muon/pion angle |
| 305 | * All the particle masses |
| 306 | |
| 307 | So we proceed to find the `TLorentzVector`s in the event as before. We first need to make sure we have a positive pion and a negative muon in the event: |
| 308 | |
| 309 | {{{ |
| 310 | // Need to make sure there's a muon |
| 311 | if (event->NumFSParticle(13) == 0) return; |
| 312 | // Need to make sure there's a pion |
| 313 | if (event->NumFSParticle(211) == 0) return; |
| 314 | }}} |
| 315 | |
| 316 | Then get the relevant `TLorentzVector`s: |
| 317 | |
| 318 | {{{ |
| 319 | // Get the incoming neutrino |
| 320 | TLorentzVector Pnu = event->GetNeutrinoIn()->fP; |
| 321 | // Get the muon |
| 322 | TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; |
| 323 | // Get the pion |
| 324 | TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; |
| 325 | }}} |
| 326 | |
| 327 | We should now write a helper function in the `FitUtils` namespace to get `E^rec^,,nu,,` from the muon, pion and neutrino `TLorentzVector`s. The `FitUtils` implementation lives in `src/Utils/FitUtils.cxx`. |
| 328 | |
| 329 | {{{ |
| 330 | double FitUtils::EnuCC1piprec(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppi) { |
| 331 | |
| 332 | // The muon energy, momentum and mass |
| 333 | double E_mu = pmu.E() / 1000.; |
| 334 | double p_mu = pmu.Vect().Mag() / 1000.; |
| 335 | double m_mu = sqrt(E_mu * E_mu - p_mu * p_mu); |
| 336 | |
| 337 | // The pion energy, momentum and mass |
| 338 | double E_pi = ppi.E() / 1000.; |
| 339 | double p_pi = ppi.Vect().Mag() / 1000.; |
| 340 | double m_pi = sqrt(E_pi * E_pi - p_pi * p_pi); |
| 341 | |
| 342 | // The relevant angles |
| 343 | double th_nu_pi = pnu.Vect().Angle(ppi.Vect()); |
| 344 | double th_nu_mu = pnu.Vect().Angle(pmu.Vect()); |
| 345 | double th_pi_mu = ppi.Vect().Angle(pmu.Vect()); |
| 346 | |
| 347 | // Now write down the derived neutrino energy, assuming the initial state nucleon is at rest and we only have a pion, muon and nucleon in the final state |
| 348 | double rEnu = (m_mu * m_mu + m_pi * m_pi - 2 * m_n * (E_pi + E_mu) + 2 * E_pi * E_mu - |
| 349 | 2 * p_pi * p_mu * cos(th_pi_mu)) / |
| 350 | (2 * (E_pi + E_mu - p_pi * cos(th_nu_pi) - p_mu * cos(th_nu_mu) - m_n)); |
| 351 | |
| 352 | return rEnu; |
| 353 | }; |
| 354 | }}} |
| 355 | |
| 356 | Once we have the helper function implemented and tested we go back to the `FillEventVariables(FitEvent *event)` implementation and simply do |
| 357 | |
| 358 | {{{ |
| 359 | double Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip); |
| 360 | |
| 361 | fXVar = Enu; |
| 362 | |
| 363 | return; |
| 364 | }}} |
| 365 | |
| 366 | and `FillEventVariables(FitEvent *event)` is done! |