diff --git a/root/background.root b/root/background.root new file mode 100644 index 0000000..3cda804 Binary files /dev/null and b/root/background.root differ diff --git a/root/cuts b/root/cuts new file mode 100644 index 0000000..b38a813 --- /dev/null +++ b/root/cuts @@ -0,0 +1,8 @@ +px: < -50; > 50 +py: < -50; > 50 +pz: < 100 ! +E: > 100 ! + +pt: > 65; < 85 +eta: ? +phi: ? diff --git a/root/exc4.cc b/root/exc4.cc new file mode 100644 index 0000000..bcc61e6 --- /dev/null +++ b/root/exc4.cc @@ -0,0 +1,96 @@ +#include "TROOT.h" +#include "TFile.h" +#include "TTree.h" +#include "TH1F.h" +#include "TH2D.h" +#include "TLorentzVector.h" +#include +#include + +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 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(); +} diff --git a/root/macro.C b/root/macro.C index 45b6a44..d71876e 100644 --- a/root/macro.C +++ b/root/macro.C @@ -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(); diff --git a/root/signal.root b/root/signal.root new file mode 100644 index 0000000..a058594 Binary files /dev/null and b/root/signal.root differ diff --git a/taylor b/taylor index 12b975b..86caed2 100755 Binary files a/taylor and b/taylor differ diff --git a/taylor.cpp b/taylor.cpp index 6d8d6fb..72d0459 100644 --- a/taylor.cpp +++ b/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; }