diff --git a/sw/zdclg/sim-val/plotFromCSV.cpp b/sw/zdclg/sim-val/plotFromCSV.cpp index 6239c5a0f75c3a0ff33b298ce3e0c8c75c0975b3..a9a0982d68e030e55a15a6010777df375ce0445e 100644 --- a/sw/zdclg/sim-val/plotFromCSV.cpp +++ b/sw/zdclg/sim-val/plotFromCSV.cpp @@ -1,7 +1,7 @@ /****************************************************************************** * * This script contains two primary functions. The first plotFromCSV will take a - * .CSV file with data int the format: + * .CSV file with data in the format: * * x,y,z * x,y,z @@ -36,6 +36,15 @@ * * As written, file1 should be the real data, while file2 is the simulated data. * + * or + * * TO RUN: + * Open an interactive ROOT session + * $root -l + * + * Load the script + * [0].L plotFromCSV.cpp + * [1]averageHistos("file1.root","file2.root","file3.root","file4.root") + * *******************************************************************************/ @@ -62,8 +71,8 @@ void plotFromCSV(TString fileName, TString outFileName){ } //make sure the size of each histogram is the same && the bins are in the middle - float range = 57; - TH2F *h = new TH2F("lightguideintensity","Relative Intensity (Box experiment);X-plane (mm);Z-plane (mm)",19,-range/2.,range/2.,19,-range/2.,range/2.); + float range = 54; + TH2F *h = new TH2F("lightguideintensity","Relative Intensity (Box experiment);X-plane (mm);Z-plane (mm)",18,-range/2.,range/2.,18,-range/2.,range/2.); //While we still haven't reached the end of the file, get the next line, parse it, and fill the histogram //with the value on that line @@ -119,13 +128,9 @@ void compareHistos( string file1, string file2){ hdiff->SetNameTitle("difference", "Difference;X-plane (mm);Z-plane (mm)"); hrat->SetNameTitle("divide", "Ratio;X-plane (mm);Z-plane (mm)"); - - //We want to subtract sim from real (add -1) hdiff->Add(hsim, -1); - - //Create a new histogram to hold the differences for each bin // TH1F *hDev = new TH1F("stdDev","stdDev",100,-10,10); @@ -211,7 +216,7 @@ string getDataPoint( string &input, size_t spaces, string delim ){ void averageHistos( string file1, string file2, string file3, string file4){ -//----------------------RETIREVE THE HISTOGRAMS--------------------------------- +// //----------------------RETIREVE THE HISTOGRAMS--------------------------------- //Open file 1 and retrieve the histogram from within TFile f1(file1.c_str(),"read"); TH2F *h1 = (TH2F*)f1.Get("lightguideintensity"); @@ -241,7 +246,8 @@ void averageHistos( string file1, string file2, string file3, string file4){ //divide total by 4? TH2F *haverage = (TH2F*)htotal->Clone(); - haverage->Divide(4) //might need to make a histogram where every value is 4 or something + haverage->Scale(1./4); // this should take the average of the four files + haverage->SetNameTitle("average", "Average;X-plane (mm);Z-plane (mm)"); haverage->Write();