Signal_1fb.root
and Background_1fb.root
are the signal and background simulations corresponding to 1 inverse fb.tree
, which contains two variables invariantMass and eventWeight
, the invariant diphoton mass and the event weight, respectively.invariantMass
weighted by the eventWeight
.Ok great, but how do we know if we see a signal in the data? We have a background and signal simulation, let's load the files and read in the trees:
TFile *fSig = new TFile("Signal_1fb.root", "READ");
TFile *fBkg = new TFile("Background_1fb.root", "READ");
TTree *tSig = (TTree*) fSig -> Get("tree");
TTree *tBkg = (TTree*) fBkg -> Get("tree");
Inside the trees we see two variables:
invariantMass and eventWeight
Link the branch variables to some local variables!
double mass_sig; double eventWeight_sig;
double mass_bkg; double eventWeight_bkg;
tSig -> SetBranchAddress("invariantMass", &mass_sig);
tSig -> SetBranchAddress("eventWeight", &eventWeight_sig);
tBkg -> SetBranchAddress("invariantMass", &mass_bkg);
tBkg -> SetBranchAddress("eventWeight", &eventWeight_bkg);
Now define two histograms and fill them with the invariant mass weighted by the event weight. You will need to loop over the trees!
// define two histograms
TH1D *hSig = new TH1D("signal", "", 50, 100, 160);
TH1D *hBkg = new TH1D("bkg", "", 50, 100, 160);
int nEntries_Sig = tSig -> GetEntries();
int nEntries_Bkg = tBkg -> GetEntries();
Now loop over the trees:
for(int i = 0; i < nEntries_Sig; ++i){
tSig -> GetEntry(i);
hSig -> Fill(mass_sig, eventWeight_sig);
}
for(int i = 0; i < nEntries_Bkg; ++i){
tBkg -> GetEntry(i);
hBkg -> Fill(mass_bkg, eventWeight_bkg);
}
The simulated events correspond to 1 inverse fb, however we have recorded 100 inverse fb, so we need to scale it
std::cout << "Before reweighting: " << std::endl;
std::cout << "Signal:\t\t" << hSig -> Integral() << "\n" << "Background:\t" << hBkg -> Integral() << std::endl;
hSig -> Scale(100.0);
hBkg -> Scale(100.0);
std::cout << "After reweighting: " << std::endl;
std::cout << "Signal:\t\t" << hSig -> Integral() << "\n" << "Background:\t" << hBkg -> Integral() << std::endl;
Ok, great, that makes sense, since we had around 600k data events, lets plot the background model now:
hBkg -> SetLineColor(kBlue);
hBkg -> Draw("HSAME");
c ->Draw()