NueCCIncGlobalFitter.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 //ROOT Includes
6 #include "TH1.h"
7 #include "TH2.h"
8 #include "THStack.h"
9 #include "TCanvas.h"
10 #include "TLegend.h"
11 #include "TStyle.h"
12 #include "TFile.h"
13 #include <vector>
14 #include <math.h>
15 #include "TLine.h"
16 #include "TFile.h"
17 #include "TTree.h"
18 #include "TCanvas.h"
19 #include "TF1.h"
20 #include "TH1F.h"
21 #include "TH2F.h"
22 #include "TF2.h"
23 #include "TH2.h"
24 #include "TCutG.h"
25 #include "TMath.h"
26 #include "TCanvas.h"
27 #include "TStyle.h"
28 #include "TRandom.h"
29 #include "TGraph.h"
30 #include "TColor.h"
31 #include "TF3.h"
32 #include "TH3.h"
33 #include "TH3F.h"
34 #include "TMinuit.h"
35 #include "TLegend.h"
36 #include "THStack.h"
37 #include "TMatrix.h"
38 #include "TGraphErrors.h"
39 #include "TGraph.h"
40 #include "TDecompLU.h"
41 #include "TDecompSVD.h"
42 #include "TRandom.h"
43 
44 //C++
45 #include <iostream>
46 #include <fstream>
47 #include <iomanip>
48 #include <vector>
49 #include <cmath>
50 #include <math.h>
51 #include <string>
52 #include <stdint.h>
53 #include <sstream>
54 #include <functional>
55 #include <stdexcept>
56 
57 namespace nueccinc_test
58 {
59  const int TotalXBins = 8;
60  const int TotalYBins = 13;
61  const int TotalZBins = 17;
62  const int TotalYZBins = TotalYBins * TotalZBins;
63  const int numPIDBins = 1768;
64  const int numberParameters = 40;
65 
67  public:
68  NueCCIncGlobalFitter(TH1F* da,
69  std::vector<TH1F*> templates,
70  std::vector<TH3F*> analysis,
71  TH1F* cv,
72  std::vector<TH1F*> systs_up,
73  std::vector<TH1F*> systs_down,
74  std::vector<TH1F*> systs_oneside,
75  std::vector<TH1F*> multiverse);
76  virtual ~NueCCIncGlobalFitter() {};
77 
78  void FCNMinuit();
79  std::vector<TH3F*> doFullFit();
80  std::vector<TH1F*> getFullTemplates(bool isReduced);
81  std::vector<TH1F*> getFullFitTemplates();
82  TH2F* getCovarianceMatrix();
84  TH2F* getCorrelationMatrix();
88  std::vector<std::pair<TH2F*,TH2F*>> GetTemplateWeightsAndErrors();
89 
90 
91 
92  TH2F* parNumMin;
93  TH2F* parNumMax;
101  double chisquared;
102 
103  std::vector<std::vector<double>> parCovariance;
104  std::vector<std::vector<double>> parCorrelation;
105 
106 
107  private:
108  bool CheckSystsSize();
109  void FillValueHolders();
110  std::vector<TH1F*> CalculateOneSigmaShiftFull();
111  void FillCovarianceMatrixFull(bool makePlots = false);
113  double GetCovarianceMatrixFullValue(int binx, int biny);
114  double GetStatisticMatrixFullValue(int binx, int biny);
115  void ReducePhaseSpace();
116  std::vector<TH1F*> CalculateOneSigmaShiftReduced();
117  void FillCovarianceMatrixReduced(bool makePlots = false);
119  double GetCovarianceMatrixReducedValue(int binx, int biny);
120  double GetStatisticMatrixReducedValue(int binx, int biny);
121  void InvertCovarianceMatrix();
123  std::pair<float,float> searchFitInfo(float parNum,
124  std::string fitSearch);
125  static void fcn(Int_t &npar, Double_t *gin,Double_t &f,
126  Double_t *par,Int_t iflag);
127  double myFunction(std::vector<double> par);
128  void FillParameterCovariance(std::vector<std::vector<double>> cov);
130  std::vector<TH1F*> GetTemplates();
131  std::vector<TH1F*> GetTemplatesReduced();
132  std::vector<TH1F*> GetTemplatesReducedPostFit();
133  std::vector<TH3F*> GetAnalysisTemplates();
134 
135 
136  TH1F* hData1D;
137  std::vector<TH1F*> hTemplates1D;
138  std::vector<TH3F*> hAnalysis3D;
139  TH1F* hCV1D;
140  std::vector<TH1F*> hSystsUp1D;
141  std::vector<TH1F*> hSystsDown1D;
142  std::vector<TH1F*> hSystsOneSided;
143  std::vector<TH1F*> hSystsMultiverse;
144 
145  std::vector<float> vDataValues;
146  std::vector<float> vMCValues;
147  std::vector<float> vSignalLike_Values;
148  std::vector<float> vNC_Values;
149  std::vector<float> vNumuLike_Values;
150  std::vector<float> vOther_Values;
151 
152  std::vector<std::vector<float>> vCovarianceMatrixFull;
153  std::vector<std::vector<float>> vStatCovarianceMatrixFull;
154 
155  //Reduced Phase Space Histograms
157  std::vector<TH1F*> hTemplates1DReduced;
159  std::vector<TH1F*> hSystsUp1DReduced;
160  std::vector<TH1F*> hSystsDown1DReduced;
161  std::vector<TH1F*> hSystsOneSidedReduced;
162  std::vector<TH1F*> hSystsMultiverseReduced;
163 
164  std::vector<float> vDataValuesReduced;
165  std::vector<float> vMCValuesReduced;
166  std::vector<float> vSignalLike_ValuesReduced;
167  std::vector<float> vNC_ValuesReduced;
168  std::vector<float> vNumuLike_ValuesReduced;
169  std::vector<float> vOther_ValuesReduced;
170 
171  std::vector<std::vector<float>> vCovarianceMatrixReduced;
172  std::vector<std::vector<float>> vStatCovarianceMatrixReduced;
173  std::vector<std::vector<float>> vInvertedCovarianceMatrixReduced;
174 
175 
176  };//end class
177 }
std::vector< TH1F * > GetTemplatesReducedPostFit()
void FillCovarianceMatrixReduced(bool makePlots=false)
double GetStatisticMatrixReducedValue(int binx, int biny)
std::vector< std::pair< TH2F *, TH2F * > > GetTemplateWeightsAndErrors()
std::vector< std::vector< double > > parCorrelation
std::vector< std::vector< float > > vCovarianceMatrixFull
void makePlots()
Definition: makePlots.C:17
Int_t par
Definition: SimpleIterate.C:24
void FillParameterCovariance(std::vector< std::vector< double >> cov)
std::vector< std::vector< float > > vInvertedCovarianceMatrixReduced
std::vector< std::vector< double > > parCovariance
double myFunction(std::vector< double > par)
std::vector< std::vector< float > > vStatCovarianceMatrixFull
static void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
std::vector< std::vector< float > > vStatCovarianceMatrixReduced
const std::string cv[Ncv]
std::pair< float, float > searchFitInfo(float parNum, std::string fitSearch)
double GetCovarianceMatrixFullValue(int binx, int biny)
void FillCovarianceMatrixFull(bool makePlots=false)
std::vector< TH1F * > CalculateOneSigmaShiftReduced()
NueCCIncGlobalFitter(TH1F *da, std::vector< TH1F * > templates, std::vector< TH3F * > analysis, TH1F *cv, std::vector< TH1F * > systs_up, std::vector< TH1F * > systs_down, std::vector< TH1F * > systs_oneside, std::vector< TH1F * > multiverse)
const int numberParameters
std::vector< TH1F * > CalculateOneSigmaShiftFull()
std::vector< TH1F * > getFullTemplates(bool isReduced)
std::vector< std::vector< float > > vCovarianceMatrixReduced
double GetStatisticMatrixFullValue(int binx, int biny)
double GetCovarianceMatrixReducedValue(int binx, int biny)
enum BeamMode string