Skip to content

Commit

Permalink
fix: some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks committed May 31, 2024
1 parent 8910ab2 commit 63b8818
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 46 deletions.
77 changes: 38 additions & 39 deletions src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ namespace iguana::clas12 {
m_output_file = new TFile(m_output_file_basename + ".root", "RECREATE");

}
InitializeHistograms();
}


void FTEnergyCorrectionValidator::Run(hipo::banklist& banks) const
{
// get the momenta before
auto& ParticleBank = GetBank(banks, b_particle, "REC::Particle");
auto& particle_bank = GetBank(banks, b_particle, "REC::Particle");
double px_el, py_el, pz_el, E_el;
double px_pim, py_pim, pz_pim;
double px_pip, py_pip, pz_pip;
Expand All @@ -47,80 +46,80 @@ namespace iguana::clas12 {

for(auto const& row : particle_bank.getRowList()){

if(ParticleBank.getInt("pid", row) == particle::PDG::electron){
if(particle_bank.getInt("pid", row) == particle::PDG::electron){

px_el = ParticleBank.getFloat("px", row);
py_el = ParticleBank.getFloat("py", row);
pz_el = ParticleBank.getFloat("pz", row);
px_el = particle_bank.getFloat("px", row);
py_el = particle_bank.getFloat("py", row);
pz_el = particle_bank.getFloat("pz", row);
electron.SetXYZM(px_el, py_el, pz_el, electron_mass);
}

if(ParticleBank.getInt("pid", row) == particle::PDG::pion_minus){
if(particle_bank.getInt("pid", row) == particle::PDG::pi_minus){

px_pim = ParticleBank.getFloat("px", row);
py_pim = ParticleBank.getFloat("py", row);
pz_pim = ParticleBank.getFloat("pz", row);
px_pim = particle_bank.getFloat("px", row);
py_pim = particle_bank.getFloat("py", row);
pz_pim = particle_bank.getFloat("pz", row);
pion_minus.SetXYZM(px_pim, py_pim, pz_pim, 0.139600);
}

if(ParticleBank.getInt("pid", row) == particle::PDG::pion_plus){
if(particle_bank.getInt("pid", row) == particle::PDG::pi_plus){

px_pip = ParticleBank.getFloat("px", row);
py_pip = ParticleBank.getFloat("py", row);
pz_pip = ParticleBank.getFloat("pz", row);
px_pip = particle_bank.getFloat("px", row);
py_pip = particle_bank.getFloat("py", row);
pz_pip = particle_bank.getFloat("pz", row);
pion_plus.SetXYZM(px_pip, py_pip, pz_pip, 0.139600);
}

if(ParticleBank.getInt("pid", row) == particle::PDG::proton){
if(particle_bank.getInt("pid", row) == particle::PDG::proton){

px_pr = ParticleBank.getFloat("px", row);
py_pr = ParticleBank.getFloat("py", row);
pz_pr = ParticleBank.getFloat("pz", row);
px_pr = particle_bank.getFloat("px", row);
py_pr = particle_bank.getFloat("py", row);
pz_pr = particle_bank.getFloat("pz", row);
proton.SetXYZM(px_pr, py_pr, pz_pr, 0.938272);
}
miss_el = beam + target - pion_minus - pion_plus - proton;
DeltaE = miss_el.E() - el.E();
h_beforecorr->Fill(el.E(), DeltaE);
DeltaE = miss_el.E() - electron.E();
h_beforecorr->Fill(electron.E(), DeltaE);
}
// run the energy corrections
m_algo_seq->Run(banks);

for(auto const& row : particle_bank.getRowList()){

if(ParticleBank.getInt("pid", row) == particle::PDG::electron){
if(particle_bank.getInt("pid", row) == particle::PDG::electron){

px_el = ParticleBank.getFloat("px", row);
py_el = ParticleBank.getFloat("py", row);
pz_el = ParticleBank.getFloat("pz", row);
px_el = particle_bank.getFloat("px", row);
py_el = particle_bank.getFloat("py", row);
pz_el = particle_bank.getFloat("pz", row);
electron.SetXYZM(px_el, py_el, pz_el, electron_mass);
}

if(ParticleBank.getInt("pid", row) == particle::PDG::pion_minus){
if(particle_bank.getInt("pid", row) == particle::PDG::pi_minus){

px_pim = ParticleBank.getFloat("px", row);
py_pim = ParticleBank.getFloat("py", row);
pz_pim = ParticleBank.getFloat("pz", row);
px_pim = particle_bank.getFloat("px", row);
py_pim = particle_bank.getFloat("py", row);
pz_pim = particle_bank.getFloat("pz", row);
pion_minus.SetXYZM(px_pim, py_pim, pz_pim, 0.139600);
}

if(ParticleBank.getInt("pid", row) == particle::PDG::pion_plus){
if(particle_bank.getInt("pid", row) == particle::PDG::pi_plus){

px_pip = ParticleBank.getFloat("px", row);
py_pip = ParticleBank.getFloat("py", row);
pz_pip = ParticleBank.getFloat("pz", row);
px_pip = particle_bank.getFloat("px", row);
py_pip = particle_bank.getFloat("py", row);
pz_pip = particle_bank.getFloat("pz", row);
pion_plus.SetXYZM(px_pip, py_pip, pz_pip, 0.139600);
}

if(ParticleBank.getInt("pid", row) == particle::PDG::proton){
if(particle_bank.getInt("pid", row) == particle::PDG::proton){

px_pr = ParticleBank.getFloat("px", row);
py_pr = ParticleBank.getFloat("py", row);
pz_pr = ParticleBank.getFloat("pz", row);
px_pr = particle_bank.getFloat("px", row);
py_pr = particle_bank.getFloat("py", row);
pz_pr = particle_bank.getFloat("pz", row);
proton.SetXYZM(px_pr, py_pr, pz_pr, 0.938272);
}
miss_el = beam + target - pion_minus - pion_plus - proton;
DeltaE = miss_el.E() - el.E();
h_aftercorr->Fill(el.E(), DeltaE);
DeltaE = miss_el.E() - electron.E();
h_aftercorr->Fill(electron.E(), DeltaE);
}

}
Expand All @@ -147,7 +146,7 @@ namespace iguana::clas12 {
h_beforecorr->Draw("colz");
break;
case 1:
h_aftercorr->Draw("colz")
h_aftercorr->Draw("colz");
break;
}
}
Expand Down
11 changes: 4 additions & 7 deletions src/iguana/algorithms/clas12/FTEnergyCorrection/Validator.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#pragma once

#include "iguana/algorithms/Algorithm.h"
#include "iguana/algorithms/Validator.h"
#include "iguana/algorithms/TypeDefs.h"
#include <TH1F.h>
#include <TH2D.h>
#include <TFile.h>
#include <TCanvas.h>
#include <TStyle.h>
#include <Math/Vector4D.h>
#include <map>

namespace iguana::clas12 {

Expand Down Expand Up @@ -46,15 +44,14 @@ namespace iguana::clas12 {
private:

// How can I change this FillHistograms function so it works for TH2D histograms? I'm probably being stupid.
void InitializeHistograms();
hipo::banklist::size_type b_particle;
double electron_mass;
std::vector<int> const u_pdg_list = {particle::PDG::electron, particle::PDG::pion_plus, particle::PDG::pion_minus, particle::PDG::proton};
std::vector<int> const u_pdg_list = {particle::PDG::electron, particle::PDG::pi_plus, particle::PDG::pi_minus, particle::PDG::proton};
TString m_output_file_basename;
TFile* m_output_file;

std::map<float, TH2D*> h_beforecorr;
std::map<float, TH2D*> h_aftercorr;
TH2D* h_beforecorr;
TH2D* h_aftercorr;
};

}

0 comments on commit 63b8818

Please sign in to comment.