15 #include "TObjArray.h" 49 fUseTrig = plottingPars.
get<
bool >(
"UseTrig", false );
57 fContourSigmaLabels[1] = plottingPars.
get<
std::string>(
"Contour2SigmaLabel",
"2#sigma");
58 fContourSigmaLabels[2] = plottingPars.
get<
std::string>(
"Contour3SigmaLabel",
"3#sigma");
69 size_t const& numXParPoints,
70 size_t const& numYParPoints,
71 std::pair<double, double>
const& parXExtrema,
72 std::pair<double, double>
const& parYExtrema,
89 <<
"x and y parameters are the same " 91 <<
" - that cannot be good, bail";
135 paramDiv = (logXParamExtremaHigh - logXParamExtremaLow)/
float(
fXParamDivs);
136 paramStart = (logXParamExtremaLow - 0.5 * paramDiv);
137 paramStop = (logXParamExtremaHigh + 0.5 * paramDiv);
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)));
172 fYParamBinEdges.back() =
std::pow(10, paramStop);
179 for (
size_t i = 0;
i < fYParamBinEdges.size() - 1; ++
i){
180 fYParamBinEdges[
i] = paramStart + (
i * paramDiv *
fYParamScale.first);
182 fYParamBinEdges.back() = paramStop;
196 std::map<double, double>
const& paramChiSqr,
202 std::pair<double, std::string> paramScale =
fYParamScale;
212 std::vector<double>
param;
213 std::vector<double> deltaChiSqr;
215 for(
auto itr : paramChiSqr){
216 param .emplace_back(itr.first * paramScale.first);
217 deltaChiSqr.emplace_back(itr.second);
224 << deltaChiSqr.back();
228 auto *gr = tfd.makeAndRegister<TGraph>(grName.c_str(),
240 title += paramScale.second +
";#Delta#chi^{2}";
242 TH1F *
hist = tfd.make<TH1F>(histName.c_str(),
244 paramBins.size() - 1,
246 hist->SetMaximum(15.);
247 hist->GetXaxis()->CenterTitle();
248 hist->GetXaxis()->SetDecimals();
250 hist->GetYaxis()->CenterTitle();
251 hist->GetYaxis()->SetDecimals();
254 std::vector<Color_t> sigmaColors({
kBlue,
kRed, kMagenta});
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]);
266 <<
" cl_percentile[0]: " 270 <<
" cl_percentile[1]: " 274 <<
" cl_percentile[2]: " 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");
285 legLines->SetBorderSize(0);
286 legLines->SetFillStyle(0);
290 auto *
canv = tfd.makeAndRegister<TCanvas>(canvName.c_str(),
300 hist->SetStats(
false);
303 for(
size_t l = 0;
l < sigmaLines.size(); ++
l) sigmaLines[
l]->
Draw();
324 std::vector<std::string> contourNames({
"1sigma",
329 fContourSigmaLabels[2]});
335 percentiles .erase(percentiles.begin() );
336 contourNames .erase(contourNames.begin() );
337 contourLabels.erase(contourLabels.begin());
347 hist->SetContour(percentiles.size(), percentiles.data());
355 hist->Draw(
"contlist");
358 auto * plah = (TObjArray *)(gROOT->GetListOfSpecials()->FindObject(
"contours"));
361 std::vector< std::vector<std::unique_ptr<TGraph> > > graphVec(percentiles.size());
363 for(
int i = 0;
i < plah->GetSize(); ++
i){
364 std::vector<std::unique_ptr<TGraph> >
temp;
365 auto *
list = (TList*) plah->At(
i);
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))) );
371 graphVec[
i] = std::move(temp);
377 <<
" sets of contours\n" 378 <<
"Parameter 1 and Enum 1: " 381 <<
"Parameter 2 and Enum 2: " 385 <<
" vectors of graphs";
388 title += hist->GetXaxis()->GetTitle();
390 title += hist->GetYaxis()->GetTitle();
394 for(
auto const& gritr : graphVec){
399 <<
" graphs for contour " 403 for(
auto const& itr : gritr){
405 std::stringstream
name;
406 name << std::setprecision(3)
417 <<
"store graph with name " 420 tfd.makeAndRegister<TGraph>(name.str().c_str(),
437 for(
auto & grv : graphVec){
438 for(
auto & gr : grv){
439 if(percentiles.size() == 3 && g == 0){
440 gr->SetLineColor(
kBlue);
442 if((percentiles.size() == 3 && g == 1) || (percentiles.size() == 2 && g == 0)){
443 gr->SetLineColor(
kRed);
445 if((percentiles.size() == 3 && g == 2) || (percentiles.size() == 2 && g == 1)){
457 <<
"Make2DContours function: " 458 <<
"Parameter 1 and Enum 1: " 461 <<
"Parameter 2 and Enum 2: " 469 TH2F *hBackdrop = tfd.make<TH2F>(histName.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());
478 hBackdrop->GetXaxis()->CenterTitle();
479 hBackdrop->GetXaxis()->SetDecimals();
481 hBackdrop->GetYaxis()->CenterTitle();
482 hBackdrop->GetYaxis()->SetDecimals();
483 hBackdrop->GetYaxis()->SetTitleOffset(1.0);
488 auto *
canv = tfd.make<TCanvas>(canName.c_str(),
489 (chiSqrName +
" Contours").c_str(),
494 for(
auto const& grv : graphVec){
495 for(
auto const& itr : grv){
504 TLegend legContours(0.8, 0.1, 0.9, 0.24);
505 legContours.SetBorderSize(0);
506 legContours.SetFillStyle(0);
508 for(
auto & grv : graphVec){
510 grv.front()->SetName(contourNames[g].c_str());
511 legContours.AddEntry(grv.front().get(),
512 (contourLabels[
g] +
" CL").c_str(),
523 TLegend legPoints(0.12, 0.11, 0.27, 0.25);
524 legPoints.SetBorderSize(0);
525 legPoints.SetFillStyle(0);
527 std::stringstream par1_legendentry;
528 std::stringstream par2_legendentry;
537 << std::setprecision(3)
549 << std::setprecision(3)
559 bestFitMarker.SetMarkerColor(1);
560 bestFitMarker.Draw();
562 legPoints.AddEntry(&bestFitMarker,
"Best Fit",
"p");
563 legPoints.AddEntry(&bestFitMarker, par1_legendentry.str().data(),
"");
564 legPoints.AddEntry(&bestFitMarker, par2_legendentry.str().data(),
"");
579 std::vector<cmf::ChiSqrInfo>
const& chiSqrInfoVec)
589 std::vector<TH2F*> hmVec(3);
591 for(
size_t i = 0;
i < hmVec.size(); ++
i){
604 << chiSqrInfoVec.size()
605 <<
" chiSqrInfo objects to loop over";
608 for(
auto const& csItr : chiSqrInfoVec){
609 for(
auto const& twoDItr : csItr.twoDChiSqr){
612 <<
"twoDChiSqr for universe " 638 auto *
canv = tfd.make<TCanvas>(name.c_str(),
647 for(
size_t i = 0;
i < hmVec.size(); ++
i){
649 hmVec[
i]->Draw(
"colz");
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);
676 std::map<long, TH1D*> & energySpecMap,
678 art::TFileDirectory & tfd,
712 <<
"Filling data energy spectra appears to want more bins" 713 <<
" than are in the data bin spectrum: " 728 histTitle += (scale < 1) ?
"#times10^{3} Events" :
"Events";
730 if(name.find(
"MC") != std::string::npos) histTitle.insert(0,
"MC ");
733 <<
"total Energy spectrum hist is " 743 if(energySpecMap.count(itr) < 1)
744 hist = energySpecMap.emplace(itr, tfd.make<TH1D>(histName.c_str(),
747 bins.data())).first->second;
749 hist = energySpecMap.find(itr)->second;
751 hist->GetXaxis()->CenterTitle();
752 hist->GetYaxis()->CenterTitle();
753 if(name.find(
"MC") != std::string::npos){
754 hist->SetMarkerColor(
kRed);
755 hist->SetLineColor(
kRed);
760 hist->Fill(binE, binSpec[
b] * scale);
766 hist->SetBinError(hist->FindBin(binE),
775 <<
" selected events";
794 if(spectrum.size() < 1){
796 <<
"spectrum size for " 798 <<
" is 0, are you sure you filled it?";
802 auto spectrumHist = tfd.make<TH1F>(baseName.c_str(),
808 spectrumHist->Sumw2();
810 for(
size_t b = 0;
b < spectrum.size(); ++
b) spectrumHist->Fill(
b, spectrum[
b]);
835 <<
"Creating 2D histogram with range " 839 auto* hist2D = tfd.make<TH2F>(histName.c_str(),
846 hist2D->GetXaxis()->CenterTitle();
847 hist2D->GetXaxis()->SetDecimals();
848 hist2D->GetYaxis()->CenterTitle();
849 hist2D->GetYaxis()->SetDecimals();
868 histName = (chiSqrName +
877 for(
auto const& itr : twoDChiSqr){
886 dcsq = (itr.second < 0.1) ? 0.1 : itr.second;
887 hist_deltachisq->Fill(itr.first.X() *
fXParamScale.first,
893 1.0-TMath::Prob(itr.second, 2));
918 if(parVals.size() < 1){
920 <<
"point map size for " 922 <<
" is 0, are you sure you filled it?";
929 for(
auto const& itr : parVals){
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
int KeyToOffset(long const &key, bool allSels=false)
static bool IsNCSelected(cmf::SelectionType_t const &sel)
cmf::OscParm_t fFreeParamEnum
enumerated value of the oscillation parameter that floats freely
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
static PlotUtilities * gPlotUtil
const std::vector< std::string > cDetType_Strings({"UnknownDet","NearDet","FarDet","MINOSNear","MINOSFar","AllDetectors"})
static const double kGarbageDouble
std::pair< double, double > fYParamExtrema
first is the min, second is the max
bool fNormalizeBins
whether to normalize bins with different sizes
static SelectionUtility * Instance()
std::vector< double > Spectrum
enum cmf::det_type DetType_t
::xsd::cxx::tree::exception< char > exception
void SelectionHistBinning(cmf::MetaData const &md, cmf::Spectrum &bins)
TH1F * MakeSpectrumHistogram(art::TFileDirectory &tfd, std::string const &baseName, std::string const &baseTitle, cmf::Spectrum const &spectrum)
const std::vector< std::string > cOscParams_LatexScales({" (m)"," (g/cc)"," (#times10^{-5} eV^{2})"," (#times10^{-3} eV^{2})","","",""," (#pi rad)","","","","(eV^{2})"," (#pi rad)","","","","","","","","",""})
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
int fXParamDivs
number of divisions in the space for parameter 1
static cmf::BeamType_t KeyToBeamType(long const &key)
enum cmf::sel_type SelectionType_t
static bool IsAngleParameter(cmf::OscParm_t const &par)
static bool IsNuESelected(cmf::SelectionType_t const &sel)
void Make1DPlot(art::TFileDirectory &tfd, std::string const &chiSqrName, std::map< double, double > const ¶mChiSqr, bool xPar)
void Make2DContours(art::TFileDirectory &tfd, std::string const &chiSqrName, cmf::PointMap const &twoDChiSqr, cmf::GridPoint const &bestFit, bool useBestFit=true)
double BinToEnergy(int const &bin, bool allSels=false)
static bool IsNuMuSelected(cmf::SelectionType_t const &sel)
std::vector< float > fYParamBinEdges
binning for the y parameter
TH2F * MakeGeneric2DHist(art::TFileDirectory &tfd, std::string const &histName)
const std::vector< std::string > cOscParams_Strings_Latex({"L","#rho","#Delta m^{2}_{21}","#Delta m^{2}_{32}","#theta_{12}","#theta_{13}","#theta_{23}","#delta_{CP}","#theta_{14}","#theta_{24}","#theta_{34}","#Delta m^{2}_{41}","#delta_{24}","#epsilon_{ee}","#epsilon_{e#mu}","#epsilon_{e#tau}","#epsilon_{#mu#mu}","#epsilon_{#mu#tau}","#epsilon_{#tau#tau}","#delta_{e#mu}","#delta_{e#tau}","#delta_{#mu#tau}"})
double fNCNormVal
bin normalization in GeV
bool fLogXAxis
are bins on x axis logarithmic
void MakeEnergySpectraFromBins(cmf::Spectrum const &binSpec, cmf::Spectrum const &binCount, std::map< long, TH1D * > &energySpecMap, std::string const &name, art::TFileDirectory &tfd, std::string const &uniqueID)
correl_yv Fill(-(dy[iP-1][iC-1]), hyv->GetBinContent(iP, iC))
static cmf::DetType_t KeyToDetectorType(long const &key)
T get(std::string const &key) const
double fContourLevel1Sigma2D
Level value for 1 sigma 2D contour.
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
const std::vector< std::string > cSelectionType_Strings({"NuESel_AllPID","NuESel_LowPID","NuESel_MidPID","NuESel_HighPID","NuESel_Peripheral","NuMuSel","NuMuSelQ1","NuMuSelQ2","NuMuSelQ3","NuMuSelQ4","NCSel","UnknownSel"})
const std::vector< std::string > cBeamType_Strings({"FHC","RHC","0HC","UnknownBeam"})
double fContourLevel1Sigma1D
Level value for 1 sigma 1D contour.
void Initialize(fhicl::ParameterSet const &plottingPars)
bool fLogYAxis
are bins on y axis logarithmic
std::vector< float > fXParamBinEdges
binning for the x parameter
TH2F * Make2DHist(art::TFileDirectory &tfd, std::string const &chiSqrName, cmf::PointMap const &twoDChiSqr)
double fNuMuNormVal
bin normalization in GeV
Module to combine a set of results into a single file currently only does one data product type at a ...
double fNuENormVal
bin normalization in GeV
cmf::OscParm_t fXParamEnum
enumerated value of the parameter from CovarianceMatrixFit/dataProducts/Constants.h
double fContourLevel2Sigma1D
Level value for 2 sigma 1D contour.
std::map< cmf::GridPoint, double > PointMap
std::map< double, int > const & SelectionHighEdges(cmf::MetaData const &md)
#define MF_LOG_VERBATIM(category)
enum cmf::beam_type BeamType_t
static PlotUtilities * Instance()
static cmf::SelectionType_t KeyToSelectionType(long const &key)
const std::vector< double > cOscParams_Scales({1., 1., 1.e5, 1.e3, 1., 1., 1., 1./3.14159, 1., 1., 1., 1., 1./3.14159, 1., 1., 1., 1., 1., 1., 1., 1., 1.})
void MakeCLHeatMaps(art::TFileDirectory &tfd, std::string const &baseName, std::vector< cmf::ChiSqrInfo > const &chiSqrInfoVec)
const std::vector< std::string > cSelectionType_LatexStrings({"#nu_{e} Selection","#nu_{e} Selection - Low PID","#nu_{e} Selection - Mid PID","#nu_{e} Selection - High PID","#nu_{e} Selection - Peripheral","#nu_{#mu} Selection","#nu_{#mu} Selection - Quantile 1","#nu_{#mu} Selection - Quantile 2","#nu_{#mu} Selection - Quantile 3","#nu_{#mu} Selection - Quantile 4","NC Selection","Unknown Selection"})
double fContourLevel3Sigma2D
Level value for 3 sigma 2D contour.
void NormalizeBinContents(TH1 *hist, double normToVal)
std::string to_string(ModuleType const mt)
bool fUseTrig
Turn on plotting of trig functions for the angles.
void Make2DHiddenParHistogram(art::TFileDirectory &tfd, std::string const &baseName, cmf::PointMap const &parVals)
int fYParamDivs
number of divisions in the space for parameter 2
const std::vector< std::string > cBeamType_LatexStrings({"FHC","RHC","0HC""Unknown Beam"})
static CovarianceBinUtility * Instance()
const std::vector< std::string > cOscParams_Strings({"L","Rho","Dmsq21","Dmsq32","Th12","Th13","Th23","dCP","Th14","Th24","Th34","Dmsq41","d24","Eps_ee","Eps_emu","Eps_etau","Eps_mumu","Eps_mutau","Eps_tautau","Delta_emu","Delta_etau","Delta_mutau"})