Need to remove the alpha background present in the spectrum

Hi,

I need to remove the alpha background present in the background spectrum. The run244.root is the background run. I am using the following macro to make the cut. But I don’t know how to save the spectrum. Also I want to plot the histogram of background run with the other run to see how much background I still have in the spectrum. How shall I do it?
Here is the macro.
psdB0C6.C (752 Bytes) run244.root (69.9 KB) run324.root (45.0 KB) run325.root (47.7 KB) run326.root (64.8 KB) run327.root (38.5 KB) run328.root (56.5 KB) run329.root (53.0 KB) run330.root (56.2 KB) run332.root (55.3 KB) run333.root (54.5 KB) run335.root (53.0 KB) run336.root (53.8 KB) run338.root (56.2 KB) run340.root (53.8 KB) run342.root (57.2 KB) run344.root (55.4 KB) run346.root (59.4 KB) run348.root (56.8 KB) run350.root (55.7 KB) run352.root (56.3 KB) run354.root (30.1 KB) run355.root (54.7 KB) run357.root (53.1 KB) run359.root (55.6 KB) run361.root (58.6 KB) run363.root (60.6 KB) run365.root (45.9 KB) run366.root (53.1 KB) run368.root (54.6 KB) run370.root (21.9 KB) run371.root (25.3 KB) run372.root (45.8 KB) run373.root (57.9 KB) run375.root (59.3 KB) run377.root (58.2 KB) run379.root (59.9 KB) run381.root (59.5 KB) run383.root (59.2 KB) run385.root (66.8 KB) run386.root (64.1 KB) run388.root (59.7 KB) run389.root (57.6 KB) run390.root (58.9 KB) run391.root (56.8 KB) run392.root (59.3 KB) run393.root (57.8 KB) run394.root (56.9 KB) run395.root (59.1 KB) run396.root (55.7 KB) run397.root (61.6 KB) run398.root (60.2 KB) run399.root (59.4 KB) run400.root (59.1 KB) run401.root (60.9 KB) run402.root (60.5 KB) run405.root (63.8 KB) run406.root (59.8 KB) run407.root (59.3 KB) run408.root (59.5 KB) run409.root (58.2 KB) run410.root (61.1 KB) run411.root (61.9 KB) run413.root (61.9 KB) run414.root (61.9 KB) run415.root (59.2 KB) run416.root (55.2 KB) run418.root (57.7 KB) run419.root (56.9 KB) run420.root (54.5 KB) run421.root (39.4 KB) run422.root (57.1 KB) run423.root (57.5 KB) run424.root (58.1 KB) run425.root (57.3 KB) run426.root (62.2 KB) run427.root (58.3 KB) run428.root (55.2 KB) run429.root (56.8 KB) run431.root (56.9 KB) run432.root (62.2 KB) run433.root (62.4 KB)
Here are the different runs.

These are the root files with trees.
Uploading: compass_run_244.root… https://drive.google.com/file/d/1ZWEnOGk-xOU3KfKQMwa-ecoJS6oI4mn2/view?usp=sharing

I cleaned up your macro the following way:

void psdB0C6() {
   gStyle->SetPalette(53);
   TFile *f = new TFile("compass_run_324.root");
   TTree *dataTree = static_cast<TTree*>(f->Get("Data"));

   TFile *cutFile = new TFile("alphaCut_b0c6.root");
   TCutG *alphas = dynamic_cast<TCutG*>(cutFile->Get("alphas"));
   TCanvas *c0 = new TCanvas("c0","c0");
   c0->cd();
   dataTree->Draw("(EnergyShort+rndm(1)-0.5)/(Energy+rndm(7)-0.5):Energy+rndm(3)-0.5>>hist1(1500,0,1500,50,0.9,1.0)","Energy>0 &&     Board==0 && Channel==6 && Energy>50 && !alphas","colz");
   TCanvas *c1 = new TCanvas("c1","c1");
   c1->cd();

   dataTree->Draw("Energy>>hist2(5000,0,5000)","!alphas && Board==0 && Channel==6");
}

It gives me:

Error in <TFile::TFile>: file alphaCut_b0c6.root does not exist