//////////////////////////////////////////////////////////////////////// // // RunGuru.cpp, written by Gavin Hesketh (ghesketh@fnal.gov), Feb 2007 // // A c++ interface to the fortran functions of the guru package // This code reads in plots from a root file, and calls the unfolding. // // For more information on this code: http://www-d0.fnal.gov/~ghesketh/unfolding/ // GURU algorithm and fortran code written by // Vato Kartvelishvili (v.kartvelishvili@lancaster.ac.uk) // For more information on GURU, see Arxiv hep-ph/9509307 // // // To run, you need at least these two plots: // true_mat_plot = migration matrix // bdata_plot = data distribution // // You can also provide the following: // prob_mat_plot = migration matrix, probability form: // xini_plot = truth distribution used to generate the migration matrix // xtst_plot = the actual MC trugh shape: // btst_plot = the MC measured (reco) shape: // // Note: if these plots are not provided (set to zero), they are derived as follows: // xini = Y axis projection of true_mat_plot (excluding under/overflows) // xtst = Y axis projection of true_mat_plot (excluding under/overflows) // btst = X axis projection of true_mat_plot (excluding under/overflows) // prob_mat_plot = true_mat_plot / xini // // // Change log: // 13th Feb 2007: original version. // //////////////////////////////////////////////////////////////////////// #include #include #include "TFile.h" #include "TH2.h" #include "TH1.h" #include "guru_interface.cpp" main() { //First, some declarations: //These are the two basic plots you must have: TH2 *true_mat_plot=0; //migration matrix TH1 *bdata_plot=0; //data distribution //additional plots, load in if available, otherwise leave as 0; TH2 *prob_mat_plot = 0; //migration matrix, probability form: TH1 *xini_plot = 0; //truth distribution used to generate the migration matrix TH1 *xtst_plot = 0; //the actual MC trugh shape: TH1 *btst_plot = 0; //the MC measured (reco) shape: //----------------------------------------------------------- // First, call the unfolding on the example: // final argument set up the example (default = false) RunGuru("output_example.root",0,0,0,0,0,0, true); //----------------------------------------------------------- //Now, read in the basic plots from the output, and unfold again // Always zero the plots before starting! prob_mat_plot = 0; xini_plot = 0; xtst_plot = 0; btst_plot = 0; true_mat_plot=0; bdata_plot=0; //open the input file: TFile *mc_input = new TFile("output_example.root", "READ"); mc_input->cd(); //We need at least these two plots to run: //the migration matrix from MC: true_mat_plot = (TH2*)gDirectory->Get("02_Tru_Mat_APRO"); //the data plot: bdata_plot = (TH1*)gDirectory->Get("06_bdata"); // Load these plots if we have them: prob_mat_plot = (TH2*)gDirectory->Get("01_Prob_Mat_APRO"); xini_plot = (TH1*)gDirectory->Get("03_xini"); xtst_plot = (TH1*)gDirectory->Get("04_xtst"); btst_plot = (TH1*)gDirectory->Get("05_btst"); // call the unfolding: RunGuru("output_guru.root", bdata_plot, true_mat_plot, xini_plot, xtst_plot); //if you only have the two basic plots, can call like: //note, the chi^2 table won't make any sense, as you don't provide xtst! string output_file_name = "output_guru_2.root"; RunGuru(output_file_name, bdata_plot, true_mat_plot); return 0; }