Can't get histogram to draw after reading from .root file

I’m trying to write some code that reads in a histogram from a .root file and then graphs it. However, for whatever reason, when I run the code, it reads in the histogram fine (according to a cout statement which says I have ~100 entries in it, which is what I expected) but it refuses to draw it. I tried messing around with using .Paint() for the histogram instead of .Draw() and using .Modified() and .Update() for the canvas, but when I do that the histogram flashes briefly on the canvas before disappearing. Does anyone know how to resolve this?

Here’s my code for reference:

#include "TPythia8.h"
#include "TClonesArray.h"
#include "TParticle.h"
#include "TCanvas.h"
#include "TH2F.h"
#include "TMath.h"
#include "TLorentzVector.h"
#include "TVector3.h"

#include <cmath>
#include <vector>
#include <math.h>

using namespace Pythia8;
using namespace std;
using namespace RooFit;

void drellyan_read(Double_t dilution_factor=0.250) {
	cout << "Starting code\n";
	gSystem->Load("libEG");
	gSystem->Load("libEGPythia8");

	//print graphing results
	gStyle->SetOptFit(1111);

	cout << "Reading data \n";

	TFile allbinsfile("allbinsfile.root");
	TH2F * eq_9_hist = (TH2F *) allbinsfile.Get("equation_9_fit");

	cout << "Eq 9 N: " << eq_9_hist->GetEntries() << "\n";

	cout << "Data read!\n";

	// ******************
	// *** GRAPH DATA ***
	// ******************

	//drawing the fit of eq 9
	cout << "Making the canvas\n";
	TCanvas * ca = new TCanvas("Eq 9 Fit", "Eq 9 Fit", 1200, 600);
	cout << "Canvas made!\n";

	eq_9_hist->Paint("Colz");
	ca->Modified();
	ca->Update();
	cout << "Drawing complete\n";
} //macro function

ROOT Version: 6.22
Platform: Ubuntu 18.04.5
Compiler: Not Provided


#include "TROOT.h"
// ...
	eq_9_hist->SetDirectory(gROOT);
	eq_9_hist->Draw("COLZ");