All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FluxCalcPrep.h
Go to the documentation of this file.
1 // Based on ubsim / EventWeight / Calculators / FluxUnisimWeightCalc.cxx @ UBOONE_SUITE_v08_00_00_55
2 // Ported to/adapted for SBNCode by Keng Lin July 2021
3 
4 #include "nugen/NuReweight/art/NuReweight.h"
5 #include "nusimdata/SimulationBase/MCFlux.h"
6 #include "nusimdata/SimulationBase/MCTruth.h"
7 
9 #include "art/Framework/Principal/Event.h"
11 #include "sbncode/SBNEventWeight/Base/SmearingUtils.h"//MultiGaussianSmearing!
12 
13 //#include <sys/stat.h> //for exit(0); debugging purpose
14 
15 #include "TH1F.h"
16 #include "TFile.h"
17 #include "TDecompChol.h"//for Choleskey Decomposition
18 
19 namespace sbn {
20  namespace evwgh {
21 
22  class FluxWeightCalc : public WeightCalc {
23  public:
25 
26  //Read FHiCL and store the settings for the reweighting environment and the calculator.
27  void Configure(fhicl::ParameterSet const& p,
28  CLHEP::HepRandomEngine& engine) override;
29 
30 
31  //GetWeight() returns the final weights as a vector
32  // each weight evaluaed by *WeightCalc() function;
33  //inu - the ith parameter.
34  std::vector<float> GetWeight(art::Event& e, size_t inu) override;
35 
36  //UnisimWeightCalc() - Function for evaluating a specific weight
37  //enu - neutrino energy from simb::MCTruth;
38  //ptype- parent particles label: pi, k, k0, mu from simb:MCFlux
39  //ntype - neutrino flavor label: numu, numubar, nue, nuebar from simb:MCFlux
40  //randomN - input randmo number
41  //noNeg - determine what formulas to use for weights depending on input histograms.
42 
43  //4 *WeightCalc() functions
44  double UnisimWeightCalc(double enu, int ptype, int ntype, double randomN, bool noNeg);//Unisim
45  std::pair<bool, double> PHNWeightCalc (simb::MCFlux flux, float rand);//PrimaryHadronNormalizationWeightCalc
46  std::pair<bool, double> PHFSWeightCalc (simb::MCFlux flux, std::vector<float> rand);//PrimaryHadronFeynmanScaling
47  std::pair<bool, double> PHSWWeightCalc (simb::MCFlux flux, std::vector<float> rand);//PrimaryHadronSanfordWangWeightCalc
48  std::pair<bool, double> PHSWCSVWeightCalc(simb::MCFlux flux, std::vector<float> rand);//PrimaryHadronSWCentralSplineVariationWeightCalc
49 
50  //Handy tool
51  std::vector<double> ConvertToVector(TArrayD const* array);
52 
53  private:
54  //fParameterSet was prepared in `sbncode/Base/WeightManager.h`
55  std::string fGeneratorModuleLabel;
56  std::string CalcType;
57 
58  double fScalePos{};
59  double fScaleNeg = 1; //for Unisim
60 
61  //for Unisim
62  //load histograms values: [mu/pi/k-/k] x [nue,anue,numu,anumu] x [bin#]
63  double fCV[4][4][200];
64  double fRWpos[4][4][200];
65  double fRWneg[4][4][200];
66  bool PosOnly{false};
67 
68  //for HadronsProduction
69  std::vector<int> fprimaryHad = {0};
70  //-- FeynmanScaling
71  std::vector<double> FitVal{};//Shared to SanfordWang
72  TMatrixD* FitCov{nullptr};//Shared to SanfordWang
73 
74  //-- SWCentaralSplineVariation
75  TMatrixD* HARPXSec{nullptr};
76  std::vector<double> HARPmomentumBounds{};
77  std::vector<double> HARPthetaBounds{};
78  std::vector<double> SWParam{};
79  bool fIsDecomposed{false};
80 
81  //Weight Counter
82  int wc = 0;
83  int wcn = 0;
84  int wc0 = 0;
85  int wc1 = 0;
86  int wc30 = 0;
87 
89  };
90 
91  } // namespace evwgh
92 } // namespace sbn
std::vector< double > FitVal
Definition: FluxCalcPrep.h:71
std::vector< double > HARPmomentumBounds
Definition: FluxCalcPrep.h:76
std::string fGeneratorModuleLabel
Definition: FluxCalcPrep.h:55
std::pair< bool, double > PHSWCSVWeightCalc(simb::MCFlux flux, std::vector< float > rand)
pdgs p
Definition: selectors.fcl:22
double UnisimWeightCalc(double enu, int ptype, int ntype, double randomN, bool noNeg)
double fRWpos[4][4][200]
Definition: FluxCalcPrep.h:64
std::pair< bool, double > PHSWWeightCalc(simb::MCFlux flux, std::vector< float > rand)
std::vector< double > SWParam
Definition: FluxCalcPrep.h:78
then ntype
std::vector< double > ConvertToVector(TArrayD const *array)
std::vector< double > HARPthetaBounds
Definition: FluxCalcPrep.h:77
double fRWneg[4][4][200]
Definition: FluxCalcPrep.h:65
void Configure(fhicl::ParameterSet const &p, CLHEP::HepRandomEngine &engine) override
do i e
std::pair< bool, double > PHNWeightCalc(simb::MCFlux flux, float rand)
std::pair< bool, double > PHFSWeightCalc(simb::MCFlux flux, std::vector< float > rand)
std::vector< int > fprimaryHad
Definition: FluxCalcPrep.h:69
double fCV[4][4][200]
Definition: FluxCalcPrep.h:63
std::vector< float > GetWeight(art::Event &e, size_t inu) override