Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
cmf::PlotUtilities Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-12-02/CovarianceMatrixFit/utilities/PlotUtilities.h"

Public Member Functions

void Initialize (fhicl::ParameterSet const &plottingPars)
 
void Initialize (fhicl::ParameterSet const &plottingPars, cmf::OscParm_t const &xParEnum, cmf::OscParm_t const &yParEnum, size_t const &numXParPoints, size_t const &numYParPoints, std::pair< double, double > const &parXExtrema, std::pair< double, double > const &parYExtrema, bool const &logXAxis=false, bool const &logYaxis=false)
 
cmf::OscParm_t const & XParamEnum () const
 
cmf::OscParm_t const & YParamEnum () const
 
void Make1DPlot (art::TFileDirectory &tfd, std::string const &chiSqrName, std::map< double, double > const &paramChiSqr, bool xPar)
 
void Make2DContours (art::TFileDirectory &tfd, std::string const &chiSqrName, cmf::PointMap const &twoDChiSqr, cmf::GridPoint const &bestFit, bool useBestFit=true)
 
void MakeCLHeatMaps (art::TFileDirectory &tfd, std::string const &baseName, std::vector< cmf::ChiSqrInfo > const &chiSqrInfoVec)
 
void MakeSpectrumHistogram (art::TFileDirectory &tfd, std::string const &baseName, cmf::Spectrum const &spectrum)
 
void Make2DHiddenParHistogram (art::TFileDirectory &tfd, std::string const &baseName, cmf::PointMap const &parVals)
 
void MakeEnergySpectraFromBins (std::vector< float > const &binSpec, std::vector< float > const &binCount, std::map< long, TH1D * > &energySpecMap, std::string const &name, art::TFileDirectory &tfd, std::string const &uniqueID)
 
void NormalizeBinContents (TH1D *hist, double normToVal)
 

Static Public Member Functions

static PlotUtilitiesInstance ()
 

Private Member Functions

 PlotUtilities ()
 
 ~PlotUtilities ()=default
 
TH2F * MakeGeneric2DHist (art::TFileDirectory &tfd, std::string const &histName)
 
TH2F * Make2DHist (art::TFileDirectory &tfd, std::string const &chiSqrName, cmf::PointMap const &twoDChiSqr)
 

Private Attributes

cmf::OscParm_t fXParamEnum
 enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h More...
 
cmf::OscParm_t fYParamEnum
 enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h More...
 
cmf::OscParm_t fFreeParamEnum
 enumerated value of the oscillation parameter that floats freely More...
 
int fXParamDivs
 number of divisions in the space for parameter 1 More...
 
int fYParamDivs
 number of divisions in the space for parameter 2 More...
 
std::pair< double, double > fXParamExtrema
 first is the min, second is the max More...
 
std::pair< double, double > fYParamExtrema
 first is the min, second is the max More...
 
std::pair< double, std::stringfXParamScale
 scale the parameter if necessary ie is x10^{-3}, string is latex friendly More...
 
std::pair< double, std::stringfYParamScale
 scale the parameter if necessary ie is x10^{-3}, string is latex friendly More...
 
std::vector< float > fXParamBinEdges
 binning for the x parameter More...
 
std::vector< float > fYParamBinEdges
 binning for the y parameter More...
 
bool fUseTrig
 Turn on plotting of trig functions for the angles. More...
 
double fContourLevel1Sigma1D
 Level value for 1 sigma 1D contour. More...
 
double fContourLevel2Sigma1D
 Level value for 2 sigma 1D contour. More...
 
double fContourLevel3Sigma1D
 Level value for 3 sigma 1D contour. More...
 
double fContourLevel1Sigma2D
 Level value for 1 sigma 2D contour. More...
 
double fContourLevel2Sigma2D
 Level value for 2 sigma 2D contour. More...
 
double fContourLevel3Sigma2D
 Level value for 3 sigma 2D contour. More...
 
std::vector< std::stringfContourSigmaLabels
 labels for contour sigma levels More...
 
bool fLogXAxis
 are bins on x axis logarithmic More...
 
bool fLogYAxis
 are bins on y axis logarithmic More...
 
bool fNormalizeBins
 whether to normalize bins with different sizes More...
 
double fNuMuNormVal
 bin normalization in GeV More...
 
double fNuENormVal
 bin normalization in GeV More...
 
double fNCNormVal
 bin normalization in GeV More...
 

Detailed Description

Definition at line 33 of file PlotUtilities.h.

Constructor & Destructor Documentation

cmf::PlotUtilities::PlotUtilities ( )
private

Definition at line 34 of file PlotUtilities.cxx.

Referenced by Instance(), and YParamEnum().

38  , fXParamExtrema (std::make_pair(cmf::kGarbageDouble, std::numeric_limits<double>::lowest()))
39  , fYParamExtrema (std::make_pair(cmf::kGarbageDouble, std::numeric_limits<double>::lowest()))
40  , fXParamScale (std::make_pair(1., ""))
41  , fYParamScale (std::make_pair(1., ""))
42  , fContourSigmaLabels(std::vector<std::string>(3))
43  {
44  }
std::pair< double, std::string > fXParamScale
scale the parameter if necessary ie is x10^{-3}, string is latex friendly
cmf::OscParm_t fFreeParamEnum
enumerated value of the oscillation parameter that floats freely
std::pair< double, std::string > fYParamScale
scale the parameter if necessary ie is x10^{-3}, string is latex friendly
std::vector< std::string > fContourSigmaLabels
labels for contour sigma levels
static const double kGarbageDouble
Definition: Constants.h:22
std::pair< double, double > fYParamExtrema
first is the min, second is the max
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
cmf::OscParm_t fYParamEnum
enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h
std::pair< double, double > fXParamExtrema
first is the min, second is the max
cmf::OscParm_t fXParamEnum
enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h
cmf::PlotUtilities::~PlotUtilities ( )
privatedefault

Referenced by YParamEnum().

Member Function Documentation

void cmf::PlotUtilities::Initialize ( fhicl::ParameterSet const &  plottingPars)

Definition at line 47 of file PlotUtilities.cxx.

References fContourLevel1Sigma1D, fContourLevel1Sigma2D, fContourLevel2Sigma1D, fContourLevel2Sigma2D, fContourLevel3Sigma1D, fContourLevel3Sigma2D, fContourSigmaLabels, fNCNormVal, fNormalizeBins, fNuENormVal, fNuMuNormVal, fUseTrig, fhicl::ParameterSet::get(), and string.

Referenced by cmf::ContourFromLibrary::endJob(), Initialize(), cmf::CMFSpectraMaker::reconfigure(), cmf::FitFeldmanCousinsPoint::reconfigure(), and cmf::CovarianceMatrixFitter::~CovarianceMatrixFitter().

48  {
49  fUseTrig = plottingPars.get<bool >("UseTrig" );
50  fContourLevel1Sigma1D = plottingPars.get<double >("ContourLevel1Sigma1D", 1 );
51  fContourLevel2Sigma1D = plottingPars.get<double >("ContourLevel2Sigma1D", 4 );
52  fContourLevel3Sigma1D = plottingPars.get<double >("ContourLevel3Sigma1D", 9 );
53  fContourLevel1Sigma2D = plottingPars.get<double >("ContourLevel1Sigma2D", 2.3 );
54  fContourLevel2Sigma2D = plottingPars.get<double >("ContourLevel2Sigma2D", 6.18 );
55  fContourLevel3Sigma2D = plottingPars.get<double >("ContourLevel3Sigma2D", 11.83 );
56  fContourSigmaLabels[0] = plottingPars.get<std::string>("Contour1SigmaLabel", "1#sigma");
57  fContourSigmaLabels[1] = plottingPars.get<std::string>("Contour2SigmaLabel", "2#sigma");
58  fContourSigmaLabels[2] = plottingPars.get<std::string>("Contour3SigmaLabel", "3#sigma");
59  fNormalizeBins = plottingPars.get<bool >("NormalizeBinWidths", false );
60  fNuMuNormVal = plottingPars.get<double >("NuMuNormVal" , 0.1 );
61  fNuENormVal = plottingPars.get<double >("NuENormVal" , 0.5 );
62  fNCNormVal = plottingPars.get<double >("NCNormVal" , 1.0 );
63  }
double fContourLevel3Sigma1D
Level value for 3 sigma 1D contour.
double fContourLevel2Sigma2D
Level value for 2 sigma 2D contour.
std::vector< std::string > fContourSigmaLabels
labels for contour sigma levels
bool fNormalizeBins
whether to normalize bins with different sizes
double fNCNormVal
bin normalization in GeV
double fContourLevel1Sigma2D
Level value for 1 sigma 2D contour.
double fContourLevel1Sigma1D
Level value for 1 sigma 1D contour.
double fNuMuNormVal
bin normalization in GeV
double fNuENormVal
bin normalization in GeV
double fContourLevel2Sigma1D
Level value for 2 sigma 1D contour.
double fContourLevel3Sigma2D
Level value for 3 sigma 2D contour.
bool fUseTrig
Turn on plotting of trig functions for the angles.
enum BeamMode string
void cmf::PlotUtilities::Initialize ( fhicl::ParameterSet const &  plottingPars,
cmf::OscParm_t const &  xParEnum,
cmf::OscParm_t const &  yParEnum,
size_t const &  numXParPoints,
size_t const &  numYParPoints,
std::pair< double, double > const &  parXExtrema,
std::pair< double, double > const &  parYExtrema,
bool const &  logXAxis = false,
bool const &  logYaxis = false 
)

Definition at line 66 of file PlotUtilities.cxx.

References cmf::cOscParams_LatexScales, cmf::cOscParams_Scales, cmf::cOscParams_Strings, fLogXAxis, fLogYAxis, fXParamBinEdges, fXParamDivs, fXParamEnum, fXParamExtrema, fXParamScale, fYParamBinEdges, fYParamDivs, fYParamEnum, fYParamExtrema, fYParamScale, MECModelEnuComparisons::i, Initialize(), std::log10(), LOG_VERBATIM, make_pair(), and cet::pow().

75  {
76  this->Initialize(plottingPars);
77 
78  fXParamExtrema = parXExtrema;
79  fYParamExtrema = parYExtrema;
80  fXParamDivs = numXParPoints;
81  fYParamDivs = numYParPoints;
82  fLogXAxis = logXAxis;
83  fLogYAxis = logYAxis;
84  fXParamEnum = xParEnum;
85  fYParamEnum = yParEnum;
86 
88  throw cet::exception("ContourMaker")
89  << "x and y parameters are the same "
91  << " - that cannot be good, bail";
92 
94  cmf::cOscParams_LatexScales[fXParamEnum]);
96  cmf::cOscParams_LatexScales[fYParamEnum]);
97 
98  LOG_VERBATIM("PlotUtilities")
99  << "Plot Utilities: "
100  << "X Parameter: "
102  << " ("
103  << fXParamExtrema.first
104  << ", "
105  << fXParamExtrema.second
106  << ") numDivs: "
107  << fXParamDivs
108  << " Log axis: "
109  << fLogXAxis
110  << " Y Parameter: "
112  << " ("
113  << fYParamExtrema.first
114  << ", "
115  << fYParamExtrema.second
116  << ") numDivs: "
117  << fYParamDivs
118  << " Log axis: "
119  << fLogYAxis;
120 
121  float paramDiv;
122  float paramStart;
123  float paramStop;
124 
125  // set the size of the vectors for the parameter bins to be the number of
126  // divisions + 2 to keep track of the end points
127  fXParamBinEdges = std::vector<float>(fXParamDivs + 2);
128  fYParamBinEdges = std::vector<float>(fYParamDivs + 2);
129 
130  if(fLogXAxis){
131  // convert extrema to log values - if we are logging a parameter we
132  // have a scale of 1, so don't bother using the f*ParamScale
133  float logXParamExtremaLow = std::log10(fXParamExtrema.first);
134  float logXParamExtremaHigh = std::log10(fXParamExtrema.second);
135  paramDiv = (logXParamExtremaHigh - logXParamExtremaLow)/float(fXParamDivs);
136  paramStart = (logXParamExtremaLow - 0.5 * paramDiv);
137  paramStop = (logXParamExtremaHigh + 0.5 * paramDiv);
138  for(size_t i = 0; i < fXParamBinEdges.size() - 1; ++i){
139  fXParamBinEdges[i] = std::pow(10,(paramStart + (i * paramDiv)));
140  }
141  fXParamBinEdges.back() = std::pow(10, paramStop);
142  }
143  else {
144 
145  paramDiv = (fXParamExtrema.second - fXParamExtrema.first )/float(fXParamDivs);
146  paramStart = (fXParamExtrema.first - 0.5 * paramDiv) * fXParamScale.first;
147  paramStop = (fXParamExtrema.second + 0.5 * paramDiv) * fXParamScale.first;
148  for (size_t i = 0; i < fXParamBinEdges.size() - 1; ++i){
149  fXParamBinEdges[i] = paramStart + (i * paramDiv * fXParamScale.first);
150  }
151  fXParamBinEdges.back() = paramStop;
152  }
153 
154  // for(auto const& itr : fXParamBinEdges){
155  // LOG_VERBATIM("PlotUtilities")
156  // << "x bin edges: "
157  // << itr;
158  // }
159 
160  if(fLogYAxis)
161  {
162  // convert extrema to log values - if we are logging a parameter we
163  // have a scale of 1, so don't bother using the f*ParamScale
164  float logYParamExtremaLow = std::log10(fYParamExtrema.first);
165  float logYParamExtremaHigh = std::log10(fYParamExtrema.second);
166  paramDiv = (logYParamExtremaHigh - logYParamExtremaLow)/float(fYParamDivs);
167  paramStart = (logYParamExtremaLow - 0.5 * paramDiv);
168  paramStop = (logYParamExtremaHigh + 0.5 * paramDiv);
169  for (size_t i = 0; i < fYParamBinEdges.size() - 1; ++i){
170  fYParamBinEdges[i] = std::pow(10,(paramStart + (i * paramDiv)));
171  }
172  fYParamBinEdges.back() = std::pow(10, paramStop);
173  }
174  else {
175  paramDiv = (fYParamExtrema.second - fYParamExtrema.first )/float(fYParamDivs);
176  paramStart = (fYParamExtrema.first - 0.5 * paramDiv) * fYParamScale.first;
177  paramStop = (fYParamExtrema.second + 0.5 * paramDiv) * fYParamScale.first;
178 
179  for (size_t i = 0; i < fYParamBinEdges.size() - 1; ++i){
180  fYParamBinEdges[i] = paramStart + (i * paramDiv * fYParamScale.first);
181  }
182  fYParamBinEdges.back() = paramStop;
183  }
184 
185  // for(auto const& itr : fYParamBinEdges){
186  // LOG_VERBATIM("PlotUtilities")
187  // << "y bin edges: "
188  // << itr;
189  // }
190 
191  }
std::pair< double, std::string > fXParamScale
scale the parameter if necessary ie is x10^{-3}, string is latex friendly
std::pair< double, std::string > fYParamScale
scale the parameter if necessary ie is x10^{-3}, string is latex friendly
constexpr T pow(T x)
Definition: pow.h:75
std::pair< double, double > fYParamExtrema
first is the min, second is the max
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
int fXParamDivs
number of divisions in the space for parameter 1
const std::string cOscParams_LatexScales[kNumOscParams]
Definition: Constants.h:236
const double cOscParams_Scales[kNumOscParams]
Definition: Constants.h:214
const std::string cOscParams_Strings[kNumOscParams]
Definition: Constants.h:257
std::vector< float > fYParamBinEdges
binning for the y parameter
bool fLogXAxis
are bins on x axis logarithmic
cmf::OscParm_t fYParamEnum
enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h
std::pair< double, double > fXParamExtrema
first is the min, second is the max
void Initialize(fhicl::ParameterSet const &plottingPars)
bool fLogYAxis
are bins on y axis logarithmic
std::vector< float > fXParamBinEdges
binning for the x parameter
cmf::OscParm_t fXParamEnum
enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h
T log10(T number)
Definition: d0nt_math.hpp:120
#define LOG_VERBATIM(category)
int fYParamDivs
number of divisions in the space for parameter 2
PlotUtilities * cmf::PlotUtilities::Instance ( )
static
void cmf::PlotUtilities::Make1DPlot ( art::TFileDirectory tfd,
std::string const &  chiSqrName,
std::map< double, double > const &  paramChiSqr,
bool  xPar 
)

Definition at line 194 of file PlotUtilities.cxx.

References canv, cmf::cOscParams_Strings, cmf::cOscParams_Strings_Latex, Draw(), fContourLevel1Sigma1D, fContourLevel2Sigma1D, fContourLevel3Sigma1D, fContourSigmaLabels, fLogXAxis, fLogYAxis, fUseTrig, fXParamBinEdges, fXParamEnum, fXParamScale, fYParamBinEdges, fYParamEnum, fYParamScale, analysePickle::hist, compareCafs::histName, kBlue, kRed, cmf::kTh23, cmf::kTh24, cmf::kTh34, submit_hadd::l, LOG_DEBUG, art::TFileDirectory::make(), art::TFileDirectory::makeAndRegister(), ParseFluxesFile::param, string, and plotROC::title.

Referenced by cmf::ContourFromLibrary::MakeAndStorePlots(), and YParamEnum().

198  {
199 
200  std::vector<float> paramBins = fYParamBinEdges;
201  cmf::OscParm_t paramEnum = fYParamEnum;
202  std::pair<double, std::string> paramScale = fYParamScale;
203  if(xPar){
204  paramBins = fXParamBinEdges;
205  paramEnum = fXParamEnum;
206  paramScale = fXParamScale;
207  }
208 
209  std::string grName = chiSqrName + cmf::cOscParams_Strings[paramEnum] + "DeltaChiSqr";
210 
211  //make vectors holding the points for the graph
212  std::vector<double> param;
213  std::vector<double> deltaChiSqr;
214 
215  for(auto itr : paramChiSqr){
216  param .emplace_back(itr.first * paramScale.first);
217  deltaChiSqr.emplace_back(itr.second);
218 
219  LOG_DEBUG("PlotUtilities")
220  << grName
221  << " "
222  << param.back()
223  << " "
224  << deltaChiSqr.back();
225  }
226 
227  // make the graph
228  auto *gr = tfd.makeAndRegister<TGraph>(grName.c_str(),
229  grName.c_str(),
230  param.size(),
231  param.data(),
232  deltaChiSqr.data());
233 
234  // make a histogram to set the axis ranges, maximum DeltaChiSqr = 15
235  std::string histName = grName + "Hist";
237  if (paramEnum == cmf::kTh23 && fUseTrig) title = ";sin^{2}(#theta_{23})";
238  else if(paramEnum == cmf::kTh24 && fUseTrig) title = ";sin^{2}(#theta_{24})";
239  else if(paramEnum == cmf::kTh34 && fUseTrig) title = ";sin^{2}(#theta_{34})";
240  title += paramScale.second + ";#Delta#chi^{2}";
241 
242  TH1F *hist = tfd.make<TH1F>(histName.c_str(),
243  title.c_str(),
244  paramBins.size() - 1,
245  paramBins.data());
246  hist->SetMaximum(15.);
247  hist->GetXaxis()->CenterTitle();
248  hist->GetXaxis()->SetDecimals();
249 
250  hist->GetYaxis()->CenterTitle();
251  hist->GetYaxis()->SetDecimals();
252 
253  // Make TLines to show CLs
254  std::vector<Color_t> sigmaColors({kBlue, kRed, kMagenta});
255  std::vector<double> cl_percentiles({fContourLevel1Sigma1D,
258  std::vector<TLine*> sigmaLines(3);
259  for(size_t l = 0; l < sigmaLines.size(); ++l){
260  sigmaLines[l]= new TLine(paramBins.front(), cl_percentiles[l], paramBins.back(), cl_percentiles[l]);
261  sigmaLines[l]->SetLineStyle(2);
262  sigmaLines[l]->SetLineColor(sigmaColors[l]);
263  }
264 
265  LOG_DEBUG("PlotUtilities")
266  << " cl_percentile[0]: "
267  << cl_percentiles[0]
268  << " "
269  << fContourSigmaLabels[0]
270  << " cl_percentile[1]: "
271  << cl_percentiles[1]
272  << " "
273  << fContourSigmaLabels[1]
274  << " cl_percentile[2]: "
275  << cl_percentiles[2]
276  << " "
277  << fContourSigmaLabels[2];
278 
279  // Add a TLegend explain them
280  auto *legLines = new TLegend(0.8, 0.1, 0.9, 0.24);
281  for(size_t l = 0; l < sigmaLines.size(); ++l){
282  legLines->AddEntry(sigmaLines[l], (fContourSigmaLabels[l] + " CL").c_str(), "l");
283  }
284 
285  legLines->SetBorderSize(0);
286  legLines->SetFillStyle(0);
287 
288  // make a Canvas to hold it all
289  std::string canvName = grName + "Canv";
290  auto *canv = tfd.makeAndRegister<TCanvas>(canvName.c_str(),
291  canvName.c_str(),
292  2);
293 
294  // Log the x axis if this parameter is to be logged - this is a 1D plot
295  // so even for the Y parameter we log the x axis
296  if ( xPar && fLogXAxis) canv->SetLogx();
297  else if(!xPar && fLogYAxis) canv->SetLogx();
298 
299  canv->cd();
300  hist->SetStats(false);
301  hist->Draw();
302  gr->Draw("lsame");
303  for(size_t l = 0; l < sigmaLines.size(); ++l) sigmaLines[l]->Draw();
304  legLines->Draw();
305 
306  // We're done here
307  canv->ForceUpdate();
308  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
tree Draw("slc.nhit")
enum cmf::osc_params OscParm_t
double fContourLevel3Sigma1D
Level value for 3 sigma 1D contour.
std::pair< double, std::string > fXParamScale
scale the parameter if necessary ie is x10^{-3}, string is latex friendly
enum BeamMode kRed
std::pair< double, std::string > fYParamScale
scale the parameter if necessary ie is x10^{-3}, string is latex friendly
std::vector< std::string > fContourSigmaLabels
labels for contour sigma levels
TCanvas * canv
const std::string cOscParams_Strings[kNumOscParams]
Definition: Constants.h:257
std::vector< float > fYParamBinEdges
binning for the y parameter
bool fLogXAxis
are bins on x axis logarithmic
cmf::OscParm_t fYParamEnum
enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h
double fContourLevel1Sigma1D
Level value for 1 sigma 1D contour.
T * makeAndRegister(char const *name, char const *title, ARGS...args) const
bool fLogYAxis
are bins on y axis logarithmic
std::vector< float > fXParamBinEdges
binning for the x parameter
const std::string cOscParams_Strings_Latex[kNumOscParams]
Definition: Constants.h:279
cmf::OscParm_t fXParamEnum
enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h
T * make(ARGS...args) const
double fContourLevel2Sigma1D
Level value for 2 sigma 1D contour.
enum BeamMode kBlue
bool fUseTrig
Turn on plotting of trig functions for the angles.
enum BeamMode string
void cmf::PlotUtilities::Make2DContours ( art::TFileDirectory tfd,
std::string const &  chiSqrName,
cmf::PointMap const &  twoDChiSqr,
cmf::GridPoint const &  bestFit,
bool  useBestFit = true 
)

Definition at line 311 of file PlotUtilities.cxx.

References canv, cmf::cOscParams_Strings, cmf::cOscParams_Strings_Latex, fContourLevel1Sigma2D, fContourLevel2Sigma2D, fContourLevel3Sigma2D, fContourSigmaLabels, fLogXAxis, fLogYAxis, fUseTrig, fXParamEnum, fXParamScale, fYParamEnum, fYParamScale, MECModelEnuComparisons::g, analysePickle::hist, compareCafs::histName, MECModelEnuComparisons::i, kBlue, kRed, cmf::kTh23, cmf::kTh24, parse_dependency_file_t::list, LOG_DEBUG, art::TFileDirectory::make(), Make2DHist(), art::TFileDirectory::makeAndRegister(), string, APDHVSetting::temp, plotROC::title, cmf::GridPoint::X(), and cmf::GridPoint::Y().

Referenced by cmf::ContourFromLibrary::MakeAndStorePlots(), and YParamEnum().

316  {
317  TH2F *hist = this->Make2DHist(tfd,
318  chiSqrName,
319  twoDChiSqr);
320 
321  std::vector<double> percentiles({fContourLevel1Sigma2D,
324  std::vector<std::string> contourNames({"1sigma",
325  "2sigma",
326  "3sigma"});
327  std::vector<std::string> contourLabels({fContourSigmaLabels[0],
329  fContourSigmaLabels[2]});
330 
331 
332  // check that the minimum for the histogram is less than the lowest contour level,
333  // if not, then get rid of that level
334  if(hist->GetMinimum() > fContourLevel1Sigma2D){
335  percentiles .erase(percentiles.begin() );
336  contourNames .erase(contourNames.begin() );
337  contourLabels.erase(contourLabels.begin());
338  }
339 
340 
341  // LOG_VERBATIM("PlotUtilities")
342  // << "draw contours for ";
343  // for(auto const& itr : percentiles)
344  // LOG_VERBATIM("PlotUtilities")
345  // << itr;
346 
347  hist->SetContour(percentiles.size(), percentiles.data());
348 
349  // This avoids disturbing canvases already
350  // Yes, we do need a canvas for this to work
351  // yes, we do need to call Update() on it
352  // No, ROOT is not very friendly.
353  TCanvas temp_can;
354  temp_can.cd();
355  hist->Draw("contlist");
356  temp_can.Update();
357 
358  auto * plah = (TObjArray *)(gROOT->GetListOfSpecials()->FindObject("contours"));
359  if(!plah) return;
360 
361  std::vector< std::vector<std::unique_ptr<TGraph> > > graphVec(percentiles.size());
362 
363  for(int i = 0; i < plah->GetSize(); ++i){
364  std::vector<std::unique_ptr<TGraph> > temp;
365  auto * list = (TList*) plah->At(i);
366  if(!list) break;
367  if(!(list->First())) break;
368  for(int igraph = 0; igraph < list->GetSize(); ++igraph){
369  if(list->At(igraph)) temp.emplace_back( std::make_unique<TGraph>( *((TGraph*) list->At(igraph))) );
370  }
371  graphVec[i] = std::move(temp);
372  }
373 
374  LOG_DEBUG("PlotAssist")
375  << "Found : "
376  << plah->GetSize()
377  << " sets of contours\n"
378  << "Parameter 1 and Enum 1: "
380  << " "
381  << "Parameter 2 and Enum 2: "
383  << " there are "
384  << graphVec.size()
385  << " vectors of graphs";
386 
387  std::string title = ";";
388  title += hist->GetXaxis()->GetTitle();
389  title += ";";
390  title += hist->GetYaxis()->GetTitle();
391 
392  int p = 0;
393  int g;
394  for(auto const& gritr : graphVec){
395 
396  LOG_DEBUG("PlotUtilities")
397  << "there are "
398  << gritr.size()
399  << " graphs for contour "
400  << p;
401 
402  g = 0;
403  for(auto const& itr : gritr){
404 
405  std::stringstream name;
406  name << std::setprecision(3)
407  << chiSqrName
408  << "ContourGraph"
411  << "_CL"
412  << contourLabels[p]
413  << "_Gr"
414  << g;
415 
416  LOG_DEBUG("PlotUtilities")
417  << "store graph with name "
418  << name.str();
419 
420  tfd.makeAndRegister<TGraph>(name.str().c_str(),
421  title.c_str(),
422  itr->GetN(),
423  itr->GetX(),
424  itr->GetY());
425 
426  ++g;
427  } // end loop over graphs for the percentile
428  ++p;
429  } // end loop over different percentile graphs
430 
431  //LOG_DEBUG << " Found " << graphVec.size() << " standard cl_contour sets\n";
432 
433  // Assign colors and line styles
434  // have to do some checks because we could have either 2 or 3 sets of graphs
435  //-------
436  g = 0;
437  for(auto & grv : graphVec){
438  for(auto & gr : grv){
439  if(percentiles.size() == 3 && g == 0){
440  gr->SetLineColor(kBlue);
441  }
442  if((percentiles.size() == 3 && g == 1) || (percentiles.size() == 2 && g == 0)){
443  gr->SetLineColor(kRed);
444  }
445  if((percentiles.size() == 3 && g == 2) || (percentiles.size() == 2 && g == 1)){
446  gr->SetLineColor(6);
447  }
448  gr->SetLineWidth(2);
449  }
450  ++g;
451  }
452 
453  // Make the 'backdrop' histogram against which the contours
454  // will be drawn
455 
456  LOG_DEBUG("PlotUtilities")
457  << "Make2DContours function: "
458  << "Parameter 1 and Enum 1: "
460  << " "
461  << "Parameter 2 and Enum 2: "
463 
464  std::string histName = (chiSqrName +
465  cmf::cOscParams_Strings[fXParamEnum] +
466  cmf::cOscParams_Strings[fYParamEnum] +
467  "CLContours");
468 
469  TH2F *hBackdrop = tfd.make<TH2F>(histName.c_str(),
470  title.c_str(),
471  hist->GetXaxis()->GetNbins(),
472  hist->GetXaxis()->GetXmin(),
473  hist->GetXaxis()->GetXmax(),
474  hist->GetYaxis()->GetNbins(),
475  hist->GetYaxis()->GetXmin(),
476  hist->GetYaxis()->GetXmax());
477 
478  hBackdrop->GetXaxis()->CenterTitle();
479  hBackdrop->GetXaxis()->SetDecimals();
480 
481  hBackdrop->GetYaxis()->CenterTitle();
482  hBackdrop->GetYaxis()->SetDecimals();
483  hBackdrop->GetYaxis()->SetTitleOffset(1.0);
484 
485  // Make a new canvas, plot the CL contours,
486  //-------
487  std::string canName(chiSqrName + "ContoursCanv");
488  auto *canv = tfd.make<TCanvas>(canName.c_str(),
489  (chiSqrName + " Contours").c_str(),
490  1200,
491  800);
492 
493  hBackdrop->Draw();
494  for(auto const& grv : graphVec){
495  for(auto const& itr : grv){
496  itr->Draw("C SAME");
497  }
498  }
499 
500  // Add a TLegend to describe the CL contours
501  // ROOT is inconsistent, and you must add graphs
502  // to a TLegend by name, rather than by pointer
503  //-------
504  TLegend legContours(0.8, 0.1, 0.9, 0.24);
505  legContours.SetBorderSize(0);
506  legContours.SetFillStyle(0);
507  g = 0;
508  for(auto & grv : graphVec){
509  if(!grv.empty()){
510  grv.front()->SetName(contourNames[g].c_str());
511  legContours.AddEntry(grv.front().get(),
512  (contourLabels[g] + " CL").c_str(),
513  "l");
514  }
515  ++g;
516  }
517  legContours.Draw();
518 
519  if(useBestFit){
520  // And a TLegend to describe the initial guess and
521  // best fit points
522  //-------
523  TLegend legPoints(0.12, 0.11, 0.27, 0.25);
524  legPoints.SetBorderSize(0);
525  legPoints.SetFillStyle(0);
526 
527  std::stringstream par1_legendentry;
528  std::stringstream par2_legendentry;
529 
531  if(fXParamEnum == cmf::kTh23 && fUseTrig) Parameter1Label = "sin^{2}(#theta_{23})";
532  if(fXParamEnum == cmf::kTh24 && fUseTrig) Parameter1Label = "sin^{2}(#theta_{24})";
533 
534  par1_legendentry
535  << Parameter1Label
536  << " = "
537  << std::setprecision(3)
538  << bestFit.X()
539  << " "
540  << fXParamScale.second;
541 
543  if(fYParamEnum == cmf::kTh23 && fUseTrig) Parameter2Label = "sin^{2}(#theta_{23})";
544  if(fYParamEnum == cmf::kTh24 && fUseTrig) Parameter2Label = "sin^{2}(#theta_{24})";
545 
546  par2_legendentry
547  << Parameter2Label
548  << " = "
549  << std::setprecision(3)
550  << bestFit.Y()
551  << " "
552  << fYParamScale.second;
553 
554  // add the initial and best fit point
555 
556  TMarker bestFitMarker(fXParamScale.first * bestFit.X(),
557  fYParamScale.first * bestFit.Y(),
558  8);
559  bestFitMarker.SetMarkerColor(1);
560  bestFitMarker.Draw();
561 
562  legPoints.AddEntry(&bestFitMarker, "Best Fit", "p");
563  legPoints.AddEntry(&bestFitMarker, par1_legendentry.str().data(), "");
564  legPoints.AddEntry(&bestFitMarker, par2_legendentry.str().data(), "");
565 
566  legPoints.Draw();
567  }
568 
569  if(fLogXAxis) canv->SetLogx();
570  if(fLogYAxis) canv->SetLogy();
571 
572  canv->Update();
573  canv->Write();
574  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
const XML_Char * name
Definition: expat.h:151
std::pair< double, std::string > fXParamScale
scale the parameter if necessary ie is x10^{-3}, string is latex friendly
enum BeamMode kRed
double fContourLevel2Sigma2D
Level value for 2 sigma 2D contour.
std::pair< double, std::string > fYParamScale
scale the parameter if necessary ie is x10^{-3}, string is latex friendly
std::vector< std::string > fContourSigmaLabels
labels for contour sigma levels
const char * p
Definition: xmltok.h:285
TCanvas * canv
const std::string cOscParams_Strings[kNumOscParams]
Definition: Constants.h:257
bool fLogXAxis
are bins on x axis logarithmic
double fContourLevel1Sigma2D
Level value for 1 sigma 2D contour.
cmf::OscParm_t fYParamEnum
enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h
T * makeAndRegister(char const *name, char const *title, ARGS...args) const
bool fLogYAxis
are bins on y axis logarithmic
TH2F * Make2DHist(art::TFileDirectory &tfd, std::string const &chiSqrName, cmf::PointMap const &twoDChiSqr)
const std::string cOscParams_Strings_Latex[kNumOscParams]
Definition: Constants.h:279
cmf::OscParm_t fXParamEnum
enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h
T * make(ARGS...args) const
double fContourLevel3Sigma2D
Level value for 3 sigma 2D contour.
enum BeamMode kBlue
bool fUseTrig
Turn on plotting of trig functions for the angles.
enum BeamMode string
void cmf::PlotUtilities::Make2DHiddenParHistogram ( art::TFileDirectory tfd,
std::string const &  baseName,
cmf::PointMap const &  parVals 
)

Definition at line 910 of file PlotUtilities.cxx.

References fXParamScale, fYParamScale, LOG_VERBATIM, and MakeGeneric2DHist().

Referenced by cmf::ContourFromLibrary::MakeAndStorePlots(), and YParamEnum().

913  {
914  if(parVals.size() < 1){
915  LOG_VERBATIM("PlotUtilities")
916  << "point map size for "
917  << baseName
918  << " is 0, are you sure you filled it?";
919  return;
920  }
921 
922  auto* parValHist = this->MakeGeneric2DHist(tfd,
923  baseName);
924 
925  for(auto const& itr : parVals){
926  parValHist->Fill(itr.first.X() * fXParamScale.first,
927  itr.first.Y() * fYParamScale.first,
928  itr.second);
929  }
930  }
std::pair< double, std::string > fXParamScale
scale the parameter if necessary ie is x10^{-3}, string is latex friendly
std::pair< double, std::string > fYParamScale
scale the parameter if necessary ie is x10^{-3}, string is latex friendly
TH2F * MakeGeneric2DHist(art::TFileDirectory &tfd, std::string const &histName)
#define LOG_VERBATIM(category)
TH2F * cmf::PlotUtilities::Make2DHist ( art::TFileDirectory tfd,
std::string const &  chiSqrName,
cmf::PointMap const &  twoDChiSqr 
)
private

Definition at line 851 of file PlotUtilities.cxx.

References cmf::cOscParams_Strings, fXParamEnum, fXParamScale, fYParamEnum, fYParamScale, analysePickle::hist, compareCafs::histName, LOG_DEBUG, MakeGeneric2DHist(), and string.

Referenced by Make2DContours(), and YParamEnum().

854  {
855  // make a 2D histogram and fill it with the Delta chiSqr values
856  std::string histName = (chiSqrName +
859  "DeltaChiSqr");
860 
861  auto* hist_deltachisq = this->MakeGeneric2DHist(tfd,
862  histName);
863 
864  histName = (chiSqrName +
867  "DeltaChiSqr_Prob");
868 
869  auto* hist = this->MakeGeneric2DHist(tfd,
870  histName);
871 
872  double dcsq;
873  for(auto const& itr : twoDChiSqr){
874 
875  LOG_DEBUG("ContourMaker")
876  << itr.first.X()
877  << " "
878  << itr.first.Y()
879  << " "
880  << itr.second;
881 
882  dcsq = (itr.second < 0.1) ? 0.1 : itr.second;
883  hist_deltachisq->Fill(itr.first.X() * fXParamScale.first,
884  itr.first.Y() * fYParamScale.first,
885  dcsq);
886 
887  hist->Fill(itr.first.X() * fXParamScale.first,
888  itr.first.Y() * fYParamScale.first,
889  1.0-TMath::Prob(itr.second, 2));
890  }
891 
892 // for(int b = 0; b < hist_deltachisq->GetXaxis()->GetNbins(); ++ b)
893 // LOG_VERBATIM("CMFContourMaker")
894 // << "x axis "
895 // << b + 1
896 // << " "
897 // << hist_deltachisq->GetXaxis()->GetBinCenter(b + 1);
898 //
899 // for(int b = 0; b < hist_deltachisq->GetYaxis()->GetNbins(); ++ b)
900 // LOG_VERBATIM("CMFContourMaker")
901 // << "y axis "
902 // << b + 1
903 // << " "
904 // << hist_deltachisq->GetYaxis()->GetBinCenter(b + 1);
905 
906  return hist;
907  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
std::pair< double, std::string > fXParamScale
scale the parameter if necessary ie is x10^{-3}, string is latex friendly
std::pair< double, std::string > fYParamScale
scale the parameter if necessary ie is x10^{-3}, string is latex friendly
const std::string cOscParams_Strings[kNumOscParams]
Definition: Constants.h:257
TH2F * MakeGeneric2DHist(art::TFileDirectory &tfd, std::string const &histName)
cmf::OscParm_t fYParamEnum
enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h
cmf::OscParm_t fXParamEnum
enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h
enum BeamMode string
void cmf::PlotUtilities::MakeCLHeatMaps ( art::TFileDirectory tfd,
std::string const &  baseName,
std::vector< cmf::ChiSqrInfo > const &  chiSqrInfoVec 
)

Definition at line 577 of file PlotUtilities.cxx.

References canv, cmf::cOscParams_Strings, fContourLevel1Sigma2D, fContourLevel2Sigma2D, fContourLevel3Sigma2D, Fill(), fLogXAxis, fLogYAxis, fXParamEnum, fXParamScale, fYParamEnum, fYParamScale, MECModelEnuComparisons::i, LOG_DEBUG, art::TFileDirectory::make(), MakeGeneric2DHist(), string, and art::to_string().

Referenced by cmf::ContourFromLibrary::MakeAndStorePlots(), and YParamEnum().

580  {
581 
582  // make a 2D histogram for each CL
583  // make a 2D histogram and fill it with the Delta chiSqr values
584  std::string name = (baseName +
587  "1sigmaHeatMap");
588 
589  std::vector<TH2F*> hmVec(3);
590 
591  for(size_t i = 0; i < hmVec.size(); ++i){
592 
593  if(i > 0)
594  name.replace(name.find(std::to_string(i) + "sigma"), 1, std::to_string(i+1));
595 
596  hmVec[i] = this->MakeGeneric2DHist(tfd,
597  name);
598  hmVec[i]->SetTitle((std::to_string(i + 1) + "#sigma").c_str());
599  }
600 
601  // loop over the chiSqrInfo structs to find the delta chiSqr at each point
602  LOG_DEBUG("PlotUtilities")
603  << "there are "
604  << chiSqrInfoVec.size()
605  << " chiSqrInfo objects to loop over";
606 
607  size_t uni = 0;
608  for(auto const& csItr : chiSqrInfoVec){
609  for(auto const& twoDItr : csItr.twoDChiSqr){
610 
611  LOG_DEBUG("PlotUtilities")
612  << "twoDChiSqr for universe "
613  << uni
614  << " "
615  << twoDItr.first
616  << " "
617  << twoDItr.second;
618 
619  if(1.0-TMath::Prob(twoDItr.second, 2) < fContourLevel1Sigma2D)
620  hmVec[0]->Fill(twoDItr.first.X() * fXParamScale.first,
621  twoDItr.first.Y() * fYParamScale.first);
622  if(1.0-TMath::Prob(twoDItr.second, 2) < fContourLevel2Sigma2D)
623  hmVec[1]->Fill(twoDItr.first.X() * fXParamScale.first,
624  twoDItr.first.Y() * fYParamScale.first);
625  if(1.0-TMath::Prob(twoDItr.second, 2) < fContourLevel3Sigma2D)
626  hmVec[2]->Fill(twoDItr.first.X() * fXParamScale.first,
627  twoDItr.first.Y() * fYParamScale.first);
628  }
629  ++uni;
630  } // end loop over ChiSqrInfos
631 
632  // make a canvas to hold these histograms
633  name = baseName +
636  "HeatMapCanv";
637 
638  auto *canv = tfd.make<TCanvas>(name.c_str(),
639  name.c_str(),
640  800,
641  800);
642 
643  if(fLogXAxis) canv->SetLogx();
644  if(fLogYAxis) canv->SetLogy();
645  canv->Divide(2,2);
646 
647  for(size_t i = 0; i < hmVec.size(); ++i){
648  canv->cd(i + 1);
649  hmVec[i]->Draw("colz");
650  }
651 
652  canv->Update();
653  canv->Write();
654 
655  return;
656  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
const XML_Char * name
Definition: expat.h:151
std::pair< double, std::string > fXParamScale
scale the parameter if necessary ie is x10^{-3}, string is latex friendly
double fContourLevel2Sigma2D
Level value for 2 sigma 2D contour.
std::pair< double, std::string > fYParamScale
scale the parameter if necessary ie is x10^{-3}, string is latex friendly
TCanvas * canv
const std::string cOscParams_Strings[kNumOscParams]
Definition: Constants.h:257
TH2F * MakeGeneric2DHist(art::TFileDirectory &tfd, std::string const &histName)
bool fLogXAxis
are bins on x axis logarithmic
correl_yv Fill(-(dy[iP-1][iC-1]), hyv->GetBinContent(iP, iC))
double fContourLevel1Sigma2D
Level value for 1 sigma 2D contour.
cmf::OscParm_t fYParamEnum
enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h
bool fLogYAxis
are bins on y axis logarithmic
cmf::OscParm_t fXParamEnum
enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h
T * make(ARGS...args) const
double fContourLevel3Sigma2D
Level value for 3 sigma 2D contour.
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
cons_index_list< index_uni, nil_index_list > uni
enum BeamMode string
void cmf::PlotUtilities::MakeEnergySpectraFromBins ( std::vector< float > const &  binSpec,
std::vector< float > const &  binCount,
std::map< long, TH1D * > &  energySpecMap,
std::string const &  name,
art::TFileDirectory tfd,
std::string const &  uniqueID 
)

Definition at line 674 of file PlotUtilities.cxx.

References b, cmf::MetaData::BeamType(), bins, cmf::CovarianceBinUtility::BinToEnergy(), cmf::cBeamType_LatexStrings, cmf::cBeamType_Strings, cmf::cSelectionType_LatexStrings, cmf::cSelectionType_Strings, cmf::MetaData::detector, cmf::MetaData::DetectorString(), e, fNCNormVal, fNuENormVal, fNuMuNormVal, analysePickle::hist, compareCafs::histName, cmf::CovarianceBinUtility::Instance(), cmf::SelectionUtility::Instance(), cmf::MetaData::isMC, cmf::MetaData::IsNCSelected(), cmf::MetaData::IsNuESelected(), cmf::MetaData::IsNuMuSelected(), cmf::CovarianceBinUtility::KeyToOffset(), cmf::KeyToSelectionType(), cmf::kFHC, cmf::kNEARDET, kRed, LOG_DEBUG, LOG_VERBATIM, art::TFileDirectory::make(), fetch_tb_beamline_files::md, NormalizeBinContents(), PandAna.reco_validation.add_data::offset, cmf::MetaData::period, scale, cmf::CovarianceBinUtility::SelectionHighEdges(), cmf::CovarianceBinUtility::SelectionHistBinning(), cmf::MetaData::selectionType, gen_flatrecord::size, std::sqrt(), and string.

Referenced by cmf::CMFSpectraMaker::FillHistograms(), cmf::CovarianceFitHelper::MakeResultPlots(), and YParamEnum().

680  {
682  std::string histTitle;
683  std::vector<double> bins;
684  TH1D *hist;
685 
686  // loop over the keys we are using to determine
687  // the offset for each selection
688  long offset;
690 
691  double binE;
692  double scale;
693 
694  for(auto const& dbsItr : cmf::SelectionUtility::Instance()->SelectionsToUse()){
695  md.detector = dbsItr.Detector();
696  md.period = (dbsItr.BeamType() == cmf::kFHC) ? 1 : 4;
697  scale = (dbsItr.Detector() == cmf::kNEARDET) ? 1.e-3 : 1.;
698 
699  for(auto const& itr : dbsItr.Keys()){
701 
702  // reverse engineer the metadata
704 
705  bins.clear();
707 
708  // check that we have a sane number of bins
709  if(offset + cmf::CovarianceBinUtility::Instance()->SelectionHighEdges(md).size() > binSpec.size())
710  throw cet::exception("CovarianceFitHelper")
711  << "Filling data energy spectra appears to want more bins"
712  << " than are in the data bin spectrum: "
714  << " vs "
715  << binSpec.size();
716 
717  histName = (name +
718  uniqueID +
720  md.DetectorString() +
722 
723  histTitle = (cmf::cBeamType_LatexStrings[md.BeamType()] + " " +
724  md.DetectorString() + " " +
726  ";Energy (GeV);");
727  histTitle += (scale < 1) ? "#times10^{3} Events" : "Events";
728 
729  if(md.isMC) histTitle.insert(0, "MC ");
730 
731  LOG_DEBUG("CovarianceFitHelper")
732  << "total Energy spectrum hist is "
733  << histName
734  << " "
735  << itr;
736 
737 // for(auto const& binitr : bins)
738 // LOG_VERBATIM("CovarianceFitHelper")
739 // << "bin edge: "
740 // << binitr;
741 
742  if(energySpecMap.count(itr) < 1)
743  hist = energySpecMap.emplace(itr, tfd.make<TH1D>(histName.c_str(),
744  histTitle.c_str(),
745  bins.size() - 1,
746  &bins[0])).first->second;
747  else
748  hist = energySpecMap.find(itr)->second;
749 
750  hist->GetXaxis()->CenterTitle();
751  hist->GetYaxis()->CenterTitle();
752  if(name.find("MC") != std::string::npos){
753  hist->SetMarkerColor(kRed);
754  hist->SetLineColor(kRed);
755  }
756 
757  for(size_t b = offset; b < offset + cmf::CovarianceBinUtility::Instance()->SelectionHighEdges(md).size(); ++b){
759  hist->Fill(binE, binSpec[b] * scale);
760 
761  // the uncertainty for each bin is the fractional uncertainty for the total count in the
762  // bin (1 / sqrt(binCount[b]) multiplied by the total weight in the bin (binSpec[b])
763  // only do it if the bin count > 0
764  if(binCount[b] > 0.)
765  hist->SetBinError(hist->FindBin(binE),
766  scale * (binSpec[b] / std::sqrt(binCount[b])));
767  }// end filling the spectrum
768 
769  LOG_VERBATIM("PlotUtilities")
770  << "histogram "
771  << hist->GetName()
772  << " has "
773  << hist->Integral()
774  << " selected events";
775 
776  // now normalize the bin contents if desired to the desired width
777  if(md.IsNuESelected())
778  this->NormalizeBinContents(hist, fNuENormVal);
779  else if(md.IsNuMuSelected())
780  this->NormalizeBinContents(hist, fNuMuNormVal);
781  else if (md.IsNCSelected())
782  this->NormalizeBinContents(hist, fNCNormVal);
783 
784  } // end loop over keys to use
785  } // end loop over selections being used in the analysis
786  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
const XML_Char * name
Definition: expat.h:151
enum BeamMode kRed
int KeyToOffset(long const &key, bool allSels=false)
void SelectionHistBinning(cmf::MetaData const &md, std::vector< double > &bins)
const std::string cSelectionType_Strings[12]
Definition: Constants.h:79
cmf::DetType_t detector
Definition: Structs.h:114
T sqrt(T number)
Definition: d0nt_math.hpp:156
static SelectionUtility * Instance()
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
std::string DetectorString() const
Definition: Structs.h:151
double BinToEnergy(int const &bin, bool allSels=false)
Double_t scale
Definition: plot.C:25
cmf::SelectionType_t selectionType
Definition: Structs.h:116
double fNCNormVal
bin normalization in GeV
bool IsNuMuSelected() const
Definition: Structs.cxx:219
const Binning bins
double fNuMuNormVal
bin normalization in GeV
double fNuENormVal
bin normalization in GeV
T * make(ARGS...args) const
std::map< double, int > const & SelectionHighEdges(cmf::MetaData const &md)
const hit & b
Definition: hits.cxx:21
static cmf::SelectionType_t KeyToSelectionType(long const &key)
Definition: StaticFuncs.h:170
void NormalizeBinContents(TH1D *hist, double normToVal)
long period
Definition: Structs.h:118
cmf::BeamType_t BeamType() const
Definition: Structs.cxx:178
#define LOG_VERBATIM(category)
const std::string cBeamType_LatexStrings[4]
Definition: Constants.h:40
Float_t e
Definition: plot.C:35
const std::string cBeamType_Strings[4]
Definition: Constants.h:35
const std::string cSelectionType_LatexStrings[12]
Definition: Constants.h:92
static CovarianceBinUtility * Instance()
bool IsNuESelected() const
Definition: Structs.cxx:225
bool IsNCSelected() const
Definition: Structs.cxx:231
enum BeamMode string
TH2F * cmf::PlotUtilities::MakeGeneric2DHist ( art::TFileDirectory tfd,
std::string const &  histName 
)
private

Definition at line 814 of file PlotUtilities.cxx.

References cmf::cOscParams_Strings_Latex, fUseTrig, fXParamBinEdges, fXParamDivs, fXParamEnum, fXParamScale, fYParamBinEdges, fYParamDivs, fYParamEnum, fYParamScale, cmf::IsAngleParameter(), LOG_DEBUG, art::TFileDirectory::make(), string, and plotROC::title.

Referenced by Make2DHiddenParHistogram(), Make2DHist(), MakeCLHeatMaps(), and YParamEnum().

816  {
817  // Delta m^2 is always on the y axis for numu
818  // angle is always on y axis for nue contours
819 
822 
825 
826  std::string title = (";" + XaxisTitle +
827  ";" + YaxisTitle);
828 
829 
830  LOG_DEBUG("ContourMaker")
831  << "Creating 2D histogram with range "
832  << fXParamBinEdges.front() << " " << fXParamBinEdges.back() << " "
833  << fYParamBinEdges.front() << " " << fYParamBinEdges.back();
834 
835  auto* hist2D = tfd.make<TH2F>(histName.c_str(),
836  title.c_str(),
837  fXParamDivs+1,
838  fXParamBinEdges.data(),
839  fYParamDivs+1,
840  fYParamBinEdges.data());
841 
842  hist2D->GetXaxis()->CenterTitle();
843  hist2D->GetXaxis()->SetDecimals();
844  hist2D->GetYaxis()->CenterTitle();
845  hist2D->GetYaxis()->SetDecimals();
846 
847  return hist2D;
848  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
std::pair< double, std::string > fXParamScale
scale the parameter if necessary ie is x10^{-3}, string is latex friendly
std::pair< double, std::string > fYParamScale
scale the parameter if necessary ie is x10^{-3}, string is latex friendly
int fXParamDivs
number of divisions in the space for parameter 1
static bool IsAngleParameter(cmf::OscParm_t const &par)
Definition: StaticFuncs.h:350
std::vector< float > fYParamBinEdges
binning for the y parameter
cmf::OscParm_t fYParamEnum
enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h
std::vector< float > fXParamBinEdges
binning for the x parameter
const std::string cOscParams_Strings_Latex[kNumOscParams]
Definition: Constants.h:279
cmf::OscParm_t fXParamEnum
enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h
T * make(ARGS...args) const
bool fUseTrig
Turn on plotting of trig functions for the angles.
int fYParamDivs
number of divisions in the space for parameter 2
enum BeamMode string
void cmf::PlotUtilities::MakeSpectrumHistogram ( art::TFileDirectory tfd,
std::string const &  baseName,
cmf::Spectrum const &  spectrum 
)

Definition at line 789 of file PlotUtilities.cxx.

References b, LOG_VERBATIM, and art::TFileDirectory::make().

Referenced by cmf::ContourFromLibrary::MakeAndStorePlots(), and YParamEnum().

792  {
793  if(spectrum.size() < 1){
794  LOG_VERBATIM("PlotUtilities")
795  << "spectrum size for "
796  << baseName
797  << " is 0, are you sure you filled it?";
798  return;
799  }
800 
801  auto *spectrumHist = tfd.make<TH1F>(baseName.c_str(),
802  ";Bin;Events",
803  spectrum.size(),
804  0,
805  spectrum.size());
806 
807  for(size_t b = 0; b < spectrum.size(); ++b) spectrumHist->Fill(b, spectrum[b]);
808 
809  }
T * make(ARGS...args) const
const hit & b
Definition: hits.cxx:21
#define LOG_VERBATIM(category)
void cmf::PlotUtilities::NormalizeBinContents ( TH1D *  hist,
double  normToVal 
)

Definition at line 660 of file PlotUtilities.cxx.

References b, fNormalizeBins, and norm.

Referenced by cmf::CovarianceFitHelper::Make1DSpectra(), MakeEnergySpectraFromBins(), and YParamEnum().

662  {
663  if(!fNormalizeBins) return;
664 
665  double norm;
666  for(int b = 0; b < hist->GetNbinsX(); ++b){
667  norm = normToVal / hist->GetBinWidth(b + 1);
668  hist->SetBinContent(b + 1, hist->GetBinContent(b + 1) * norm);
669  hist->SetBinError(b + 1, hist->GetBinError(b + 1) * norm);
670  } // end loop over bins
671  }
bool fNormalizeBins
whether to normalize bins with different sizes
Float_t norm
const hit & b
Definition: hits.cxx:21
cmf::OscParm_t const& cmf::PlotUtilities::XParamEnum ( ) const
inline

Definition at line 51 of file PlotUtilities.h.

References fXParamEnum.

51 { return fXParamEnum; }
cmf::OscParm_t fXParamEnum
enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h
cmf::OscParm_t const& cmf::PlotUtilities::YParamEnum ( ) const
inline

Member Data Documentation

double cmf::PlotUtilities::fContourLevel1Sigma1D
private

Level value for 1 sigma 1D contour.

Definition at line 112 of file PlotUtilities.h.

Referenced by Initialize(), and Make1DPlot().

double cmf::PlotUtilities::fContourLevel1Sigma2D
private

Level value for 1 sigma 2D contour.

Definition at line 115 of file PlotUtilities.h.

Referenced by Initialize(), Make2DContours(), and MakeCLHeatMaps().

double cmf::PlotUtilities::fContourLevel2Sigma1D
private

Level value for 2 sigma 1D contour.

Definition at line 113 of file PlotUtilities.h.

Referenced by Initialize(), and Make1DPlot().

double cmf::PlotUtilities::fContourLevel2Sigma2D
private

Level value for 2 sigma 2D contour.

Definition at line 116 of file PlotUtilities.h.

Referenced by Initialize(), Make2DContours(), and MakeCLHeatMaps().

double cmf::PlotUtilities::fContourLevel3Sigma1D
private

Level value for 3 sigma 1D contour.

Definition at line 114 of file PlotUtilities.h.

Referenced by Initialize(), and Make1DPlot().

double cmf::PlotUtilities::fContourLevel3Sigma2D
private

Level value for 3 sigma 2D contour.

Definition at line 117 of file PlotUtilities.h.

Referenced by Initialize(), Make2DContours(), and MakeCLHeatMaps().

std::vector<std::string> cmf::PlotUtilities::fContourSigmaLabels
private

labels for contour sigma levels

Definition at line 118 of file PlotUtilities.h.

Referenced by Initialize(), Make1DPlot(), and Make2DContours().

cmf::OscParm_t cmf::PlotUtilities::fFreeParamEnum
private

enumerated value of the oscillation parameter that floats freely

Definition at line 102 of file PlotUtilities.h.

bool cmf::PlotUtilities::fLogXAxis
private

are bins on x axis logarithmic

Definition at line 119 of file PlotUtilities.h.

Referenced by Initialize(), Make1DPlot(), Make2DContours(), and MakeCLHeatMaps().

bool cmf::PlotUtilities::fLogYAxis
private

are bins on y axis logarithmic

Definition at line 120 of file PlotUtilities.h.

Referenced by Initialize(), Make1DPlot(), Make2DContours(), and MakeCLHeatMaps().

double cmf::PlotUtilities::fNCNormVal
private

bin normalization in GeV

Definition at line 124 of file PlotUtilities.h.

Referenced by Initialize(), and MakeEnergySpectraFromBins().

bool cmf::PlotUtilities::fNormalizeBins
private

whether to normalize bins with different sizes

Definition at line 121 of file PlotUtilities.h.

Referenced by Initialize(), and NormalizeBinContents().

double cmf::PlotUtilities::fNuENormVal
private

bin normalization in GeV

Definition at line 123 of file PlotUtilities.h.

Referenced by Initialize(), and MakeEnergySpectraFromBins().

double cmf::PlotUtilities::fNuMuNormVal
private

bin normalization in GeV

Definition at line 122 of file PlotUtilities.h.

Referenced by Initialize(), and MakeEnergySpectraFromBins().

bool cmf::PlotUtilities::fUseTrig
private

Turn on plotting of trig functions for the angles.

Definition at line 111 of file PlotUtilities.h.

Referenced by Initialize(), Make1DPlot(), Make2DContours(), and MakeGeneric2DHist().

std::vector<float> cmf::PlotUtilities::fXParamBinEdges
private

binning for the x parameter

Definition at line 109 of file PlotUtilities.h.

Referenced by Initialize(), Make1DPlot(), and MakeGeneric2DHist().

int cmf::PlotUtilities::fXParamDivs
private

number of divisions in the space for parameter 1

Definition at line 103 of file PlotUtilities.h.

Referenced by Initialize(), and MakeGeneric2DHist().

cmf::OscParm_t cmf::PlotUtilities::fXParamEnum
private

enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h

Definition at line 100 of file PlotUtilities.h.

Referenced by Initialize(), Make1DPlot(), Make2DContours(), Make2DHist(), MakeCLHeatMaps(), MakeGeneric2DHist(), and XParamEnum().

std::pair<double, double> cmf::PlotUtilities::fXParamExtrema
private

first is the min, second is the max

Definition at line 105 of file PlotUtilities.h.

Referenced by Initialize().

std::pair<double, std::string> cmf::PlotUtilities::fXParamScale
private

scale the parameter if necessary ie is x10^{-3}, string is latex friendly

Definition at line 107 of file PlotUtilities.h.

Referenced by Initialize(), Make1DPlot(), Make2DContours(), Make2DHiddenParHistogram(), Make2DHist(), MakeCLHeatMaps(), and MakeGeneric2DHist().

std::vector<float> cmf::PlotUtilities::fYParamBinEdges
private

binning for the y parameter

Definition at line 110 of file PlotUtilities.h.

Referenced by Initialize(), Make1DPlot(), and MakeGeneric2DHist().

int cmf::PlotUtilities::fYParamDivs
private

number of divisions in the space for parameter 2

Definition at line 104 of file PlotUtilities.h.

Referenced by Initialize(), and MakeGeneric2DHist().

cmf::OscParm_t cmf::PlotUtilities::fYParamEnum
private

enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h

Definition at line 101 of file PlotUtilities.h.

Referenced by Initialize(), Make1DPlot(), Make2DContours(), Make2DHist(), MakeCLHeatMaps(), MakeGeneric2DHist(), and YParamEnum().

std::pair<double, double> cmf::PlotUtilities::fYParamExtrema
private

first is the min, second is the max

Definition at line 106 of file PlotUtilities.h.

Referenced by Initialize().

std::pair<double, std::string> cmf::PlotUtilities::fYParamScale
private

scale the parameter if necessary ie is x10^{-3}, string is latex friendly

Definition at line 108 of file PlotUtilities.h.

Referenced by Initialize(), Make1DPlot(), Make2DContours(), Make2DHiddenParHistogram(), Make2DHist(), MakeCLHeatMaps(), and MakeGeneric2DHist().


The documentation for this class was generated from the following files: