//C++ code #include #include #include #include #include #include #include #include //Root Code #include #include #include #include #include #include #include #include #include #include #include #include //roofit #ifndef __CINT__ #include "RooGlobalFunc.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include using namespace RooFit ; //etc using namespace std; //supporting methods TTree* makeTTree() ; //main test code void testdatahist() { //Test Data hist and such. TTree * mytree = makeTTree(); TCanvas *can = new TCanvas("c1"); TH1F* test_hist[10]; Double_t chi2cutval = 1.0; Double_t massmin = 0; Double_t massmax = 40; TCut chi2_test_cut[10]; TCut mass_cut = Form("mass>%lf && mass<%lf",massmin, massmax); //Check cuts for root histogram only; for(int i=0; i<10; ++i){ chi2cutval+=0.5; chi2_test_cut[i] = Form("max(track0_chi2,track1_chi2)<%lf",chi2cutval); mytree->Draw("mass>>h1",chi2_test_cut[i]); test_hist[i] = (TH1F*)gPad->GetPrimitive("h1"); cout<<"test_hist[i]->Integral() = "<Integral()<binnedClone("data"); RooDataHist* reduced_data; RooDataSet *data_unbinned_reduced; for(int i=0; i<10;++i){ data_unbinned_reduced = (RooDataSet*)data_unbinned->reduce(Cut(chi2_test_cut[i])); reduced_data = (RooDataHist*)data->reduce(Cut(chi2_test_cut[i])); cout<<"reduced_data->sumEntries() = "<sumEntries()<sumEntries() = "<sumEntries()<Branch("x",px,"x/D") ; //tree->Branch("y",py,"y/D") ; tree->Branch("track0_chi2",track0_chi2_x,"track0_chi2/D"); tree->Branch("track1_chi2",track1_chi2_x,"track1_chi2/D"); tree->Branch("mass",mass_x,"mass/D"); for (int i=0 ; i<10000 ; i++) { *track0_chi2_x = gRandom->Landau(1,0.5); *track1_chi2_x = gRandom->Landau(1,0.5); *mass_x = gRandom->Gaus(20,3); tree->Fill() ; } return tree ; }