I am interested in plotting two variables defined in a prior analysis file I have named “muon_eta” and “MCAngleBW” against one another. I looked into doing this with ROOT and ended up with a general format:
// Define the variables to plot
TString xvar = “muon_eta”;
TString yvar = “MCAngleBW”;
// Create a canvas and a 2D histogram
TCanvas *c1 = new TCanvas(“c1”, “2D Histogram”, 800, 600);
TH2D *h2d = new TH2D(“h2d”, “”, 100, 0, 5, 100, 0, 5);
// Set the axis titles
h2d->GetXaxis()->SetTitle(“Eta”);
h2d->GetYaxis()->SetTitle(“Angle Between Muons”);
// Fill the histogram with data from a TTree
TFile *file = TFile::Open(“filename.root”);
TTree tree = (TTree) file->Get(“treename”);
tree->Draw(yvar+“:”+xvar+“>>h2d”);
// Draw the histogram and save to a file
h2d->Draw(“COLZ”);
c1->SaveAs(“output.png”);
But this throws a syntax error. My assumption was that I’d simply need to define the histogram in analysis_final.py, but it seems like I am misunderstanding where to make an addition such as this. Conversely, would there be a simpler way to create a two-variable histogram writing a line similar to examples in the github like:
“mz”:{“name”:“Zcand_m”,“title”:“m_{Z} [GeV]”,“bin”:125,“xmin”:0,“xmax”:250},
but by adding another comma with something like “xaxis”:“muon_eta” and “yaxis”:“MCdeltaR”?
Thanks,
Hayden Shaddix