Final
This commit is contained in:
parent
9748778393
commit
8a709d632b
BIN
root/background.root
Normal file
BIN
root/background.root
Normal file
Binary file not shown.
8
root/cuts
Normal file
8
root/cuts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
px: < -50; > 50
|
||||
py: < -50; > 50
|
||||
pz: < 100 !
|
||||
E: > 100 !
|
||||
|
||||
pt: > 65; < 85
|
||||
eta: ?
|
||||
phi: ?
|
||||
96
root/exc4.cc
Normal file
96
root/exc4.cc
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
#include "TROOT.h"
|
||||
#include "TFile.h"
|
||||
#include "TTree.h"
|
||||
#include "TH1F.h"
|
||||
#include "TH2D.h"
|
||||
#include "TLorentzVector.h"
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
bool inSelection(const TLorentzVector& v) {
|
||||
return v.E() > 110
|
||||
&& v.Pz() < 90
|
||||
&& v.Pt() < 80 && v.Pt() > 65;
|
||||
}
|
||||
|
||||
void exc4() {
|
||||
using namespace std;
|
||||
|
||||
Double_t px, py, pz, E;
|
||||
TFile* f = new TFile("signal.root");
|
||||
TTree* tree;
|
||||
f->GetObject("stree", tree);
|
||||
auto px_branch = tree->GetBranch("px"); px_branch->SetAddress(&px);
|
||||
auto py_branch = tree->GetBranch("py"); py_branch->SetAddress(&py);
|
||||
auto pz_branch = tree->GetBranch("pz"); pz_branch->SetAddress(&pz);
|
||||
auto e_branch = tree->GetBranch("E"); e_branch->SetAddress(&E);
|
||||
|
||||
Double_t bpx, bpy, bpz, bE;
|
||||
TFile* f2 = new TFile("background.root");
|
||||
TTree* tree2;
|
||||
f2->GetObject("btree", tree2);
|
||||
auto bpx_branch = tree2->GetBranch("px"); bpx_branch->SetAddress(&bpx);
|
||||
auto bpy_branch = tree2->GetBranch("py"); bpy_branch->SetAddress(&bpy);
|
||||
auto bpz_branch = tree2->GetBranch("pz"); bpz_branch->SetAddress(&bpz);
|
||||
auto be_branch = tree2->GetBranch("E"); be_branch->SetAddress(&bE);
|
||||
|
||||
|
||||
TH1D* signal = new TH1D("spx", "Signal E", 100, 0, 0);
|
||||
TH1D* background = new TH1D("bpx", "Background py", 100, 0, 0);
|
||||
|
||||
TH2D* signal2 = new TH2D("s2d", "Signal 2D", 100, 0, 0, 100, 0, 0);
|
||||
TH2D* background2 = new TH2D("b2d", "Background 2D", 100, 0, 0, 100, 0, 0);
|
||||
|
||||
vector<TLorentzVector> events, selection;
|
||||
assert(tree->GetEntries() == tree2->GetEntries());
|
||||
int backgrounds = 0, signals = 0;
|
||||
int N = tree->GetEntries();
|
||||
for (int i = 0; i < N; ++i) {
|
||||
px_branch->GetEntry(i);
|
||||
py_branch->GetEntry(i);
|
||||
pz_branch->GetEntry(i);
|
||||
e_branch->GetEntry(i);
|
||||
|
||||
bpx_branch->GetEntry(i);
|
||||
bpy_branch->GetEntry(i);
|
||||
bpz_branch->GetEntry(i);
|
||||
be_branch->GetEntry(i);
|
||||
|
||||
TLorentzVector vsignal;
|
||||
TLorentzVector vbackground;
|
||||
|
||||
vsignal.SetPxPyPzE(px, py, pz, E);
|
||||
vbackground.SetPxPyPzE(bpx, bpy, bpz, bE);
|
||||
|
||||
signal->Fill(vsignal.E());
|
||||
background->Fill(vbackground.E());
|
||||
|
||||
signal2->Fill(vsignal.Pt(), vsignal.Eta());
|
||||
background2->Fill(vbackground.Pt(), vbackground.Pt());
|
||||
|
||||
events.push_back(vsignal);
|
||||
events.push_back(vbackground);
|
||||
if (inSelection(vsignal)) {
|
||||
selection.push_back(vsignal);
|
||||
} else {
|
||||
signals++;
|
||||
}
|
||||
if (inSelection(vbackground)) {
|
||||
backgrounds++;
|
||||
selection.push_back(vbackground);
|
||||
}
|
||||
}
|
||||
cout << "Selection: " << selection.size() << endl
|
||||
<< "False positive: " << backgrounds << endl
|
||||
<< "False negative: " << signals << endl;
|
||||
|
||||
signal2->SetLineColor(kRed);
|
||||
signal2->SetFillColor(kRed);
|
||||
signal2->SetMarkerColor(kRed);
|
||||
signal2->Draw();
|
||||
background2->Draw("Same");
|
||||
}
|
||||
|
||||
int main() {
|
||||
exc4();
|
||||
}
|
||||
|
|
@ -21,7 +21,8 @@ void macro() {
|
|||
combined->SetParameter(4, 0.004);
|
||||
combined->SetParameter(5, 173);
|
||||
combined->SetParameter(6, 10);
|
||||
cout << "X^2: " << h->Chisquare(combined) << endl;
|
||||
h->Fit(combined, "", "", 0, 300);
|
||||
cout << "X^2: " << h->Chisquare(combined) / (h->GetNbinsX() - 7)<< endl;
|
||||
//cout << background->GetParameters() << endl;
|
||||
background->SetLineColor(kRed);
|
||||
h->Draw();
|
||||
|
|
|
|||
BIN
root/signal.root
Normal file
BIN
root/signal.root
Normal file
Binary file not shown.
19
taylor.cpp
19
taylor.cpp
|
|
@ -19,20 +19,27 @@ double sin_taylor(double x, int N) {
|
|||
return res;
|
||||
}
|
||||
void find_interval(int N) {
|
||||
for (double x = 0; x < 3.14; x += 0.00000001) {
|
||||
const double precision = 0.0000001;
|
||||
for (double x = 0; x <= 3.14; x += precision) {
|
||||
double real = sin(x);
|
||||
double taylor = sin_taylor(x, N);
|
||||
//cout << "Real: " << real << " Taylor: " << taylor << endl;
|
||||
if (abs(real - taylor) > 0.001) {
|
||||
cout << "Interval: [0, " << x - 0.01 << "]" << endl;
|
||||
break;
|
||||
cout << "Interval: [0, " << x - precision << "]" << endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout << "Interval: [0, 3.14]" << endl;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
find_interval(1);
|
||||
int main() {
|
||||
int N;
|
||||
cout << "Gib Dein N ein: ";
|
||||
cin >> N;
|
||||
cout << "Interval für N: " << endl;
|
||||
find_interval(N);
|
||||
/*find_interval(1);
|
||||
find_interval(2);
|
||||
find_interval(3);
|
||||
find_interval(3);*/
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user