// ----------------------------------------------------------------------------------- // /* ROOT macro for analysing the coffee usage in the NBI group. For a period in 2009-2010, the usage of the old coffey machine in the NBI HEP group was (somewhat irregularly) monitored. Below is the count of total number of cups of coffey brewed at given dates. 28479 4/11-2009 28674 13/11-2009 28777 18/11-2009 28964 25/11-2009 29041 27/11-2009 29374 10/12-2009 ~29650 8/ 1-2010 30001 29/ 1-2010 (?) 32412 17/ 5-2010 33676 11/ 8-2010 34008 9/ 9-2010 Author: Troels C. Petersen (NBI) Email: petersen@nbi.dk Date: 15th of September 2011 */ // ----------------------------------------------------------------------------------- // // Include from C++: #include #include // Include from ROOT: #include #include #include #include #include #include //---------------------------------------------------------------------------------- double sqr(double a) { return a*a; } // ----------------------------------------------------------------------------------- // double func_pol1(double *x, double *par) { // ----------------------------------------------------------------------------------- // return par[0] + par[1]*x[0]; } // ----------------------------------------------------------------------------------- // void CoffeeUsage() { // ----------------------------------------------------------------------------------- // // Set the showing of statistics and fitting results (0 means off, 1111 means all on): gROOT->Reset(); gStyle->SetOptStat(1111); gStyle->SetOptFit(1111); // Set the graphics: gStyle->SetStatBorderSize(1); gStyle->SetStatFontSize(0.055); gStyle->SetCanvasColor(0); gStyle->SetPalette(1); // Data set (So small that we will note use a seperate file for it!) // We define 4/11-09 to be day 0, and count from there. const int Ndata = 11; double days[Ndata] = { 0, 9, 14, 21, 23, 36, 65, 76, 194, 280, 309}; double cups[Ndata] = {28479, 28674, 28777, 28964, 29041, 29374, 29650, 30001, 32412, 33676, 34008}; double edays[Ndata]; double ecups[Ndata]; // Assign errors to these data points (just crude estimates!!!): for (int i=0; i < Ndata; i++) { edays[i] = 0.0; ecups[i] = 20.0; printf(" days: %3.0f cups: %5.0f \n", days[i], cups[i]); } // ----------------------------------------------------------------------------------- // // Fit and plot histogram on screen: // Make canvas: TCanvas* canvas = new TCanvas("canvas", "", 250, 20, 600, 450); // Make a new window // Make a graph (which differs from a histogram by being created from pairs of x and y values): TGraphErrors* graph = new TGraphErrors(Ndata, days, cups, edays, ecups); TF1* fit = new TF1("fit", func_pol1, -10.0, 320.0, 2); // Define your model/hypothesis graph->Fit("fit","R"); // Fit histogram with function graph->Draw("AP"); canvas->Update(); // canvas->SaveAs("Result_CoffeyUsage.png"); // Alternative formats: jpg, eps, pdf, etc! } //---------------------------------------------------------------------------------- /* Questions: ---------- 1) Do the numbers follow the hypothesis of constant use? Does taking into account vacations improve the above hypothesis? And if the "constant use" hypothesis is rejected, can you identify periods of higher coffey drinking? 2) The total number of cups of coffey ever brewed was 36716, after which the old coffey machine was decommissioned. From the above data, estimate when this happened (including error!) And when would you estimate that the coffey machine was commissioned originally? */ //----------------------------------------------------------------------------------