diff --git a/TODO b/TODO deleted file mode 100644 index 95d8a31..0000000 --- a/TODO +++ /dev/null @@ -1,18 +0,0 @@ -# General todolist to track things that need to be added to make life easier for would be fitters. -# If you have any suggestions that are not in this list and don't have time to add them yourself please add them to this list or email "p.stowell@sheffield.ac.uk". -- Add licensing info to every page -- Grep for swear words etc -- Spline implementation -- Event manager -- More documentation -- More flexible input formats (e.g., vectors of strings for all parameters in card file) -- Make output format appropriate for input format (e.g., ability to throw errors according to covariance and parameters in an output file) -- Basic validation checks for us to ensure everything works before making a public release -- Long term need to think about more sophisticated validation, e.g. continuous validation tools. -- Extend CINT libraries to all samples -- Organise all the different data reading classes - -CWRET ADDED: -- Validate setting constraints from previous fit (i.e. the covar option in card file; say I want to do a nuclear fit constrained by a previous nucleon fit.) - Previously had problems with negative chi2 when this was used; I think the _FREE covariances in the output .root files were wrong? -- Document fluxes properly now diff --git a/app/nuisflat.cxx b/app/nuisflat.cxx index 450a347..1588e0a 100644 --- a/app/nuisflat.cxx +++ b/app/nuisflat.cxx @@ -1,72 +1,132 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ +#include "InputUtils.h" + #include "ComparisonRoutines.h" //******************************* -void printInputCommands(){ -//******************************* - +void printInputCommands() { + //******************************* + std::cout << "nuisflat [-c cardfile] -o outfile [-q configname=configval] \n"; std::cout << "\n Arguments : \n"; - std::cout << " -c cardfile: Path to NUISANCE card file defining fit samples \n"; - std::cout <<" -o outFile: Path to root file that will be created to save output file.\n"; - std::cout <<" -q config_name=config_val : Allows any config parameter to be overridden from the command line.\n"; - std::cout <<" This will take priority over those given in the default, or cardFile. \n"; - std::cout <<" example: -q verbosity=6 -q maxevents=10000 \n" << std::endl; + std::cout + << " -i inputvector: Path to input vector of events to flatten \n"; + std::cout + << " -c cardfile: Path to NUISANCE card file defining fit samples \n"; + std::cout << " -o outFile: Path to root file that will be created to " + "save output file.\n"; + std::cout << " -q config_name=config_val : Allows any config parameter to " + "be overridden from the command line.\n"; + std::cout << " This will take priority over " + "those given in the default, or cardFile. \n"; + std::cout << " example: -q verbosity=6 -q " + "maxevents=10000 \n" + << std::endl; exit(-1); - }; //******************************* -int main(int argc, char* argv[]){ -//******************************* +int main(int argc, char* argv[]) { + //******************************* // Program status; int status = 0; - + + std::string inpFileName = ""; + std::string OutputFile = ""; + std::string maxevents_flag = ""; + // If No Arguments print commands if (argc == 1) printInputCommands(); - - for (int i = 1; i< argc; ++i){ - // Cardfile - if (!std::strcmp(argv[i], "-h")) printInputCommands(); - else break; + + for (int i = 1; i < argc; ++i) { + if (!std::strcmp(argv[i], "-h")) { + printInputCommands(); + } else if (!std::strcmp(argv[i], "-i")) { + inpFileName = argv[++i]; + } else if (!std::strcmp(argv[i], "-n")) { + maxevents_flag = argv[++i]; + } else if (!std::strcmp(argv[i], "-o")) { + OutputFile = argv[++i]; + } } - - // Read input arguments such as card file, parameter arguments, and fit routines - LOG(FIT)<<"Starting nuisflat.exe"<<std::endl; - // Make minimizer class and run fit - ComparisonRoutines* flat = new ComparisonRoutines(argc,argv); + // Read input arguments such as card file, parameter arguments, and fit + // routines + LOG(FIT) << "Starting nuisflat.exe" << std::endl; - // Run the fit rotines - flat->Run(); - flat->SaveCurrentState(); - - // Show Final Status - LOG(FIT)<<"-------------------------------------"<<std::endl; - LOG(FIT)<<"Flattree Generation Complete."<<std::endl; - LOG(FIT)<<"-------------------------------------"<<std::endl; - - return status; -} + if (!inpFileName.length()) { // Run with card file + // Make minimizer class and run fit + ComparisonRoutines* flat = new ComparisonRoutines(argc, argv); + + // Run the fit rotines + flat->Run(); + flat->SaveCurrentState(); + } else { // Run standalone + if (!OutputFile.length()) { + OutputFile = inpFileName + ".root"; + ERR(WRN) << "Didn't recieve outputfile name. Using \"" << OutputFile + << "\" instead." << std::endl; + } + std::string fullInputName = + InputUtils::PrependGuessedInputTypeToName(inpFileName); + std::string par_dir = GeneralUtils::GetTopLevelDir() + "/parameters/"; + FitPar::Config().ReadParamFile(par_dir + "config.list.dat"); + if (!maxevents_flag.empty()) { + FitPar::Config().SetParI("input.maxevents", atoi(maxevents_flag.c_str())); + } + + LOG_VERB(FitPar::Config().GetParI("VERBOSITY")); + ERR_VERB(FitPar::Config().GetParI("ERROR")); + // Outputs + // --------------------------- + // Save Configs to output file + FitPar::Config().out = new TFile(OutputFile.c_str(), "RECREATE"); + FitPar::Config().out->cd(); + FitPar::Config().Write(); + + std::list<MeasurementBase*> fChain; + bool LoadedSample = + SampleUtils::LoadSample(&fChain, "GenericFlux_", fullInputName, + "DEFAULT", "", FitBase::GetRW()); + + if (!LoadedSample) { + ERR(FTL) << "Could not Flattener sample. Please report this as a bug." + << std::endl; + throw; + } + + fChain.front()->Reconfigure(); + + FitPar::Config().out->Write(); + FitPar::Config().out->Close(); + } + + // Show Final Status + LOG(FIT) << "-------------------------------------" << std::endl; + LOG(FIT) << "Flattree Generation Complete." << std::endl; + LOG(FIT) << "-------------------------------------" << std::endl; + + return status; +} diff --git a/cmake/GiBUUSetup.cmake b/cmake/GiBUUSetup.cmake index 3914d92..8c865dd 100644 --- a/cmake/GiBUUSetup.cmake +++ b/cmake/GiBUUSetup.cmake @@ -1,35 +1,46 @@ # Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret ################################################################################ # This file is part of NUISANCE. # # NUISANCE is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # NUISANCE is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. ################################################################################ if(DEFINED BUILD_GiBUU AND BUILD_GiBUU) + + if (DEFINED NO_EXTERNAL_UPDATE AND NO_EXTERNAL_UPDATE) + set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + PROPERTY EP_UPDATE_DISCONNECTED 1) + cmessage(STATUS "Will not attempt to update third party GiBUU tools for each build.") + else() + set(NO_EXTERNAL_UPDATE 0) + endif() + include(ExternalProject) ExternalProject_Add(GiBUUTools PREFIX "${PROJECT_BINARY_DIR}/GiBUUTools" GIT_REPOSITORY https://github.com/luketpickering/GiBUU-t2k-dev.git CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - -DUSE_GIBUU=1) + -DUSE_GiBUU=1 + -DFORCECPP03=1 + -DNO_EXTERNAL_UPDATE=${NO_EXTERNAL_UPDATE}) cmessage(STATUS "Building GiBUU and GiBUUTools") set(BUILD_GiBUU 1) else() set(BUILD_GiBUU 0) endif() diff --git a/data/ANL/CC1pi0_on_n/anl82-numu-n-to-mu-p-pi0-lowW_edges.txt b/data/ANL/CC1pi0_on_n/anl82-numu-n-to-mu-p-pi0-lowW_edges.txt deleted file mode 100755 index a200e6e..0000000 --- a/data/ANL/CC1pi0_on_n/anl82-numu-n-to-mu-p-pi0-lowW_edges.txt +++ /dev/null @@ -1,6 +0,0 @@ -0.30 0.006E-38 0.004E-38 -0.50 0.052E-38 0.012E-38 -0.75 0.143E-38 0.025E-38 -1.00 0.097E-38 0.023E-38 -1.25 0.13E-38 0.034E-38 -1.50 0.00E-38 0.000E-38 diff --git a/data/ANL/CC1pi0_on_n/anl82corr-numu-n-to-mu-p-pi0-noW_edges.txt b/data/ANL/CC1pi0_on_n/anl82corr-numu-n-to-mu-p-pi0-noW_edges.txt new file mode 100755 index 0000000..5862f8a --- /dev/null +++ b/data/ANL/CC1pi0_on_n/anl82corr-numu-n-to-mu-p-pi0-noW_edges.txt @@ -0,0 +1,8 @@ +0.3 0.006E-38 0.003E-38 +0.5 0.043E-38 0.010E-38 +0.7 0.123E-38 0.029E-38 +0.8 0.198E-38 0.031E-38 +1.0 0.111E-38 0.021E-38 +1.2 0.233E-38 0.063E-38 +1.3 0.260E-38 0.057E-38 +1.5 0.000 0.000 diff --git a/data/ANL/CC1pip_on_n/anl82-numu-n-to-mu-n-piplus-lowW_edges.txt b/data/ANL/CC1pip_on_n/anl82-numu-n-to-mu-n-piplus-lowW_edges.txt deleted file mode 100755 index 26ce6b8..0000000 --- a/data/ANL/CC1pip_on_n/anl82-numu-n-to-mu-n-piplus-lowW_edges.txt +++ /dev/null @@ -1,6 +0,0 @@ -0.30 0.009E-38 0.005E-38 -0.50 0.061E-38 0.012E-38 -0.75 0.105E-38 0.019E-38 -1.00 0.098E-38 0.021E-38 -1.25 0.112E-38 0.03E-38 -1.50 0.000E-38 0.00E-38 diff --git a/data/ANL/CC1pip_on_n/anl82corr-numu-n-to-mu-n-piplus-noW_edges.txt b/data/ANL/CC1pip_on_n/anl82corr-numu-n-to-mu-n-piplus-noW_edges.txt new file mode 100755 index 0000000..9e36d61 --- /dev/null +++ b/data/ANL/CC1pip_on_n/anl82corr-numu-n-to-mu-n-piplus-noW_edges.txt @@ -0,0 +1,8 @@ +0.3 0.014E-38 0.005E-38 +0.5 0.061E-38 0.011E-38 +0.7 0.132E-38 0.029E-38 +0.8 0.144E-38 0.025E-38 +1.0 0.131E-38 0.023E-38 +1.2 0.109E-38 0.038E-38 +1.3 0.209E-38 0.047E-38 +1.5 0.000E-38 0.000E-38 diff --git a/data/ANL/CC1pip_on_p/anl82-numu-cc1ppip-14Wcut.txt b/data/ANL/CC1pip_on_p/anl82-numu-cc1ppip-14Wcut.txt index 377933e..da8368d 100644 --- a/data/ANL/CC1pip_on_p/anl82-numu-cc1ppip-14Wcut.txt +++ b/data/ANL/CC1pip_on_p/anl82-numu-cc1ppip-14Wcut.txt @@ -1,9 +1,9 @@ -0.30 0.019 0.006 -0.50 0.155 0.017 -0.75 0.332 0.030 -1.00 0.427 0.041 -1.25 0.455 0.053 -1.50 0.614 0.078 -2.50 0.650 0.164 -3.50 0.368 0.121 +0.30 0.019E-38 0.006E-38 +0.50 0.155E-38 0.017E-38 +0.75 0.332E-38 0.030E-38 +1.00 0.427E-38 0.041E-38 +1.25 0.455E-38 0.053E-38 +1.50 0.614E-38 0.078E-38 +2.50 0.650E-38 0.164E-38 +3.50 0.368E-38 0.121E-38 6.00 0.000 0.000 diff --git a/data/ANL/CC1pip_on_p/anl82-numu-cc1ppip-16Wcut.txt b/data/ANL/CC1pip_on_p/anl82-numu-cc1ppip-16Wcut.txt index d255618..a5db8eb 100644 --- a/data/ANL/CC1pip_on_p/anl82-numu-cc1ppip-16Wcut.txt +++ b/data/ANL/CC1pip_on_p/anl82-numu-cc1ppip-16Wcut.txt @@ -1,9 +1,9 @@ -0.30 0.019 0.006 -0.50 0.155 0.017 -0.75 0.335 0.030 -1.00 0.435 0.042 -1.25 0.438 0.055 -1.50 0.683 0.085 -2.50 0.722 0.174 -3.50 0.515 0.145 +0.30 0.019E-38 0.006E-38 +0.50 0.155E-38 0.017E-38 +0.75 0.335E-38 0.030E-38 +1.00 0.435E-38 0.042E-38 +1.25 0.438E-38 0.055E-38 +1.50 0.683E-38 0.085E-38 +2.50 0.722E-38 0.174E-38 +3.50 0.515E-38 0.145E-38 6.00 0.000 0.000 diff --git a/data/ANL/CC1pip_on_p/anl82-numu-cc1ppip-noWcut.txt b/data/ANL/CC1pip_on_p/anl82-numu-cc1ppip-noWcut.txt index a540fed..89db8ee 100644 --- a/data/ANL/CC1pip_on_p/anl82-numu-cc1ppip-noWcut.txt +++ b/data/ANL/CC1pip_on_p/anl82-numu-cc1ppip-noWcut.txt @@ -1,9 +1,9 @@ -0.30 0.019 0.006 -0.50 0.155 0.017 -0.75 0.335 0.030 -1.00 0.435 0.042 -1.25 0.488 0.055 -1.50 0.707 0.087 -2.50 0.722 0.174 -3.50 0.552 0.150 +0.30 0.019E-38 0.006E-38 +0.50 0.155E-38 0.017E-38 +0.75 0.335E-38 0.030E-38 +1.00 0.435E-38 0.042E-38 +1.25 0.488E-38 0.055E-38 +1.50 0.707E-38 0.087E-38 +2.50 0.722E-38 0.174E-38 +3.50 0.552E-38 0.150E-38 6.00 0.000 0.000 diff --git a/data/ANL/CC1pip_on_p/anl82-numu-p-to-mu-p-piplus-lowW_edges.txt b/data/ANL/CC1pip_on_p/anl82-numu-p-to-mu-p-piplus-lowW_edges.txt deleted file mode 100755 index ff0d196..0000000 --- a/data/ANL/CC1pip_on_p/anl82-numu-p-to-mu-p-piplus-lowW_edges.txt +++ /dev/null @@ -1,9 +0,0 @@ -0.3 0.019E-38 0.006E-38 -0.5 0.155E-38 0.017E-38 -0.75 0.332E-38 0.03E-38 -1.00 0.427E-38 0.041E-38 -1.25 0.455E-38 0.053E-38 -1.50 0.614E-38 0.078E-38 -2.50 0.65E-38 0.164E-38 -3.50 0.368E-38 0.121E-38 -6.00 0.000E-38 0.000E-38 diff --git a/data/ANL/CC1pip_on_p/anl82corr-numu-p-to-mu-p-piplus-noW_edges.txt b/data/ANL/CC1pip_on_p/anl82corr-numu-p-to-mu-p-piplus-noW_edges.txt new file mode 100755 index 0000000..3391683 --- /dev/null +++ b/data/ANL/CC1pip_on_p/anl82corr-numu-p-to-mu-p-piplus-noW_edges.txt @@ -0,0 +1,9 @@ +0.2 0.002E-38 0.002E-38 +0.4 0.070E-38 0.012E-38 +0.6 0.278E-38 0.032E-38 +0.8 0.497E-38 0.060E-38 +1.0 0.476E-38 0.046E-38 +1.4 0.714E-38 0.091E-38 +2.2 0.773E-38 0.227E-38 +3.0 0.952E-38 0.380E-38 +6.0 0.000 0.000 diff --git a/data/T2K/CC1pip/H2O/README b/data/T2K/CC1pip/H2O/README old mode 100755 new mode 100644 index bc8b63c..35615d3 --- a/data/T2K/CC1pip/H2O/README +++ b/data/T2K/CC1pip/H2O/README @@ -1,27 +1,7 @@ -################################################################################################################# -# This is the data release for the CC1pi+ cross-section analysis in the FGD2 water modules. # -# For more information on the analysis please refer to the latest version of TN-210 on t2k.org # -# This is a preliminary data realease for the NIWG group. # -# For info contact: Linda Cremonesi l.cremonesi@qmul.ac.uk # -################################################################################################################# - -The root file contains 6 directories with the differential cross-section results and the muon neutrino flux histogram for T2K Run I-IV. - -Summary of cross-section analysis: - - True signal is defined as true CC1pi+ (after FSI) in the true FV of the FGD2 water modules. - - Reconstructed signal sample is selected by requiring 1 muon and 1 positive pion reconstructed in the FGD2 X layer (please see TN for detailed definition of signal sample and sidebands). - - Phase-space restriction: (p_mu > 200 MeV) && (p_pi > 200 MeV) && (cos theta_mu > 0.3) && (cos theta_pi > 0.3) in both true and reconstructed variables. - - Production 5F, Data Run II-IV. - -The differential cross-section is given as a function of: - - pion kinematics (PosPionMom, PosPionCos); - - muon kinematics (MuMom, MuCos); - - muon-pion angle (MuPiCos); - - reconstructed neutrino energy (*model dependent result*, as it has been unfolded to the NEUT prediction) using two formulae: - -- EnuRec_Delta (energy reconstructed by looking at muon kinematics and assuming Delta resonance); - -- EnuRec_MB (energy reconstructed by looking at both muon and pion kinematics). - -Each roofile contains: - - hResultStat, hResultSyst: histograms of extracted cross-section from Data Run II-IV with statistical or total uncertainties; - - hTotalCovariance: covariance matrix for all systematic uncertainties (NB: the first bin in all histogram is the under/overflow bin); - - All the other histograms are the fractional covariance matrices for each source (NB: the first bin in all histogram is the under/overflow bin). \ No newline at end of file +This data release is from the T2K-experiment.org webpage + +Source: +http://t2k-experiment.org/wp-content/uploads/nd280data-numu-cc1pi-xs-on-h2o-2015.tar + +Or just: +T2K-experiment.org -> Results -> CC1pi+ H2O measurement diff --git a/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root b/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root new file mode 100644 index 0000000..419fc8e Binary files /dev/null and b/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root differ diff --git a/data/T2K/CC1pip/H2O/raw/README.pdf b/data/T2K/CC1pip/H2O/raw/README.pdf new file mode 100644 index 0000000..64afa55 Binary files /dev/null and b/data/T2K/CC1pip/H2O/raw/README.pdf differ diff --git a/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-EnuRec_Delta.csv b/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-EnuRec_Delta.csv new file mode 100644 index 0000000..025b6c4 --- /dev/null +++ b/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-EnuRec_Delta.csv @@ -0,0 +1,81 @@ +E_{#nu} (#Delta) ,0 - 0.8,0.8 - 1,1 - 1.2,1.2 - 1.5,1.5 - 1.8,1.8 - 2.1,2.1 - 2.55,2.55 - 3,3 - 3.6,3.6 - 4.35,4.35 - 6, +Cross-section (x10^{-40} cm^2/nucleon) ,0.889495,4.154,7.57369,13.496,22.1463,26.318,27.0126,35.3287,35.1943,30.4311,28.0816, +Total uncertainty (x10^{-40} cm^2/nucleon) ,0.32055,1.85793,3.26881,4.7674,7.22924,9.02612,9.84472,11.819,12.9608,14.2385,29.2917, + +Total covariance matrix (x10^{-40} cm^2/nucleon)^2 +0 - 0.8,0.102752,0.520817,0.820979,1.15819,1.59421,1.70972,1.56585,2.21574,2.13048,1.85612,1.93732, +0.8 - 1,0.520817,3.45192,5.65105,7.49316,10.1937,10.7982,9.7195,12.7553,12.2362,10.7337,10.4949, +1 - 1.2,0.820979,5.65105,10.6851,14.4666,19.2581,20.4559,18.7997,24.0587,23.2882,21.0325,21.353, +1.2 - 1.5,1.15819,7.49316,14.4666,22.7281,31.8904,33.8644,32.5351,37.6811,38.1056,35.6595,42.0494, +1.5 - 1.8,1.59421,10.1937,19.2581,31.8904,52.2619,60.37,60.9309,58.6211,64.6702,65.3251,94.6388, +1.8 - 2.1,1.70972,10.7982,20.4559,33.8644,60.37,81.4709,84.5893,68.2887,83.469,90.9098,153.238, +2.1 - 2.55,1.56585,9.7195,18.7997,32.5351,60.9309,84.5893,96.9186,71.3358,93.4263,105.426,192.406, +2.55 - 3,2.21574,12.7553,24.0587,37.6811,58.6211,68.2887,71.3358,139.689,139.356,127.133,155.514, +3 - 3.6,2.13048,12.2362,23.2882,38.1056,64.6702,83.469,93.4263,139.356,167.983,173.965,274.257, +3.6 - 4.35,1.85612,10.7337,21.0325,35.6595,65.3251,90.9098,105.426,127.133,173.965,202.736,367.395, +4.35 - 6,1.93732,10.4949,21.353,42.0494,94.6388,153.238,192.406,155.514,274.257,367.395,858.007, + +Statistical covariance matrix (x10^{-40} cm^2/nucleon)^2 +0 - 0.8,0.026216,0.0832843,0.0638817,0.0667276,0.0681804,0.0590474,0.0304125,0.0251083,0.0319203,0.0209349,0.0502141, +0.8 - 1,0.0832843,0.570645,0.717561,0.633546,0.616091,0.417627,0.309735,0.147347,0.178415,0.177259,0.178378, +1 - 1.2,0.0638817,0.717561,1.93572,2.05814,1.74816,1.37528,1.12094,0.734976,0.746878,0.84346,0.564884, +1.2 - 1.5,0.0667276,0.633546,2.05814,4.15275,4.63809,3.22627,2.90192,2.13307,1.88095,1.62262,1.61014, +1.5 - 1.8,0.0681804,0.616091,1.74816,4.63809,9.11616,8.12254,7.27692,6.62792,5.11268,3.79447,3.43545, +1.8 - 2.1,0.0590474,0.417627,1.37528,3.22627,8.12254,12.8042,10.4931,10.9589,8.4859,6.08353,4.59228, +2.1 - 2.55,0.0304125,0.309735,1.12094,2.90192,7.27692,10.4931,12.3957,14.9188,12.5703,9.01237,6.64043, +2.55 - 3,0.0251083,0.147347,0.734976,2.13307,6.62792,10.9589,14.9188,26.5313,24.1098,19.1382,13.9818, +3 - 3.6,0.0319203,0.178415,0.746878,1.88095,5.11268,8.4859,12.5703,24.1098,28.4204,24.6748,21.8712, +3.6 - 4.35,0.0209349,0.177259,0.84346,1.62262,3.79447,6.08353,9.01237,19.1382,24.6748,27.2599,29.0805, +4.35 - 6,0.0502141,0.178378,0.564884,1.61014,3.43545,4.59228,6.64043,13.9818,21.8712,29.0805,68.2753, + +Flux covariance matrix (x10^{-40} cm^2/nucleon)^2 +0 - 0.8,0.0395768,0.209545,0.378738,0.586018,0.885178,1.00328,1.01516,1.3111,1.34016,1.23065,1.51721, +0.8 - 1,0.209545,1.15968,2.11683,3.28294,4.9546,5.59698,5.65378,7.26719,7.39727,6.7703,8.26243, +1 - 1.2,0.378738,2.11683,3.91124,6.11784,9.29457,10.5516,10.6974,13.8,14.0624,12.9306,16.0796, +1.2 - 1.5,0.586018,3.28294,6.11784,9.64161,14.7491,16.8436,17.162,22.2886,22.8099,21.1084,26.8269, +1.5 - 1.8,0.885178,4.9546,9.29457,14.7491,22.7509,26.1868,26.8802,35.2714,36.3157,33.7882,43.4561, +1.8 - 2.1,1.00328,5.59698,10.5516,16.8436,26.1868,30.3942,31.4583,41.7885,43.4425,40.8122,53.8917, +2.1 - 2.55,1.01516,5.65378,10.6974,17.162,26.8802,31.4583,32.865,44.2882,46.6196,44.291,60.2236, +2.55 - 3,1.3111,7.26719,13.8,22.2886,35.2714,41.7885,44.2882,61.1009,65.758,63.6833,91.1041, +3 - 3.6,1.34016,7.39727,14.0624,22.8099,36.3157,43.4425,46.6196,65.758,72.5922,72.0624,110.429, +3.6 - 4.35,1.23065,6.7703,12.9306,21.1084,33.7882,40.8122,44.291,63.6833,72.0624,73.6218,121.934, +4.35 - 6,1.51721,8.26243,16.0796,26.8269,43.4561,53.8917,60.2236,91.1041,110.429,121.934,242.306, + +Theory cross-section covariance matrix (x10^{-40} cm^2/nucleon)^2 +0 - 0.8,0.0264115,0.180928,0.302753,0.37584,0.473699,0.487982,0.397237,0.789386,0.734633,0.633261,0.640153, +0.8 - 1,0.180928,1.45634,2.42391,2.95302,3.80906,4.02185,3.15537,4.86434,4.44376,3.88238,3.08177, +1 - 1.2,0.302753,2.42391,4.11097,5.09931,6.67626,7.12238,5.80375,8.44511,7.84186,6.97423,5.98055, +1.2 - 1.5,0.37584,2.95302,5.09931,6.6429,9.41593,10.9009,9.94988,10.756,11.5805,11.6935,15.0275, +1.5 - 1.8,0.473699,3.80906,6.67626,9.41593,15.8523,21.5521,22.7062,12.2591,19.5282,24.8484,47.6261, +1.8 - 2.1,0.487982,4.02185,7.12238,10.9009,21.5521,33.1487,38.0316,10.0057,26.6498,39.8774,91.837, +2.1 - 2.55,0.397237,3.15537,5.80375,9.94988,22.7062,38.0316,46.9937,6.01346,28.4104,46.8764,119.972, +2.55 - 3,0.789386,4.86434,8.44511,10.756,12.2591,10.0057,6.01346,42.5456,39.8167,34.7379,36.0343, +3 - 3.6,0.734633,4.44376,7.84186,11.5805,19.5282,26.6498,28.4104,39.8167,55.9686,65.9883,123.233, +3.6 - 4.35,0.633261,3.88238,6.97423,11.6935,24.8484,39.8774,46.8764,34.7379,65.9883,89.0192,193.501, +4.35 - 6,0.640153,3.08177,5.98055,15.0275,47.6261,91.837,119.972,36.0343,123.233,193.501,494.701, + +FSI covariance matrix (x10^{-40} cm^2/nucleon)^2 +0 - 0.8,0.00272697,0.0140073,0.0152752,0.0197484,0.0297205,0.0463979,0.0339502,0.0418207,0.0286755,0.01179,0.0286985, +0.8 - 1,0.0140073,0.108115,0.112392,0.140291,0.19662,0.267834,0.19458,0.228257,0.209077,0.0469308,0.190049, +1 - 1.2,0.0152752,0.112392,0.183087,0.218932,0.26113,0.308849,0.242388,0.344488,0.32744,0.246864,0.617989, +1.2 - 1.5,0.0197484,0.140291,0.218932,0.345241,0.444121,0.554493,0.435243,0.678098,0.690028,0.668395,1.51369, +1.5 - 1.8,0.0297205,0.19662,0.26113,0.444121,0.644706,0.888731,0.694896,1.0376,1.03283,0.995469,2.06547, +1.8 - 2.1,0.0463979,0.267834,0.308849,0.554493,0.888731,1.39814,1.08346,1.54497,1.43837,1.34425,2.58094, +2.1 - 2.55,0.0339502,0.19458,0.242388,0.435243,0.694896,1.08346,0.970349,1.53456,1.46278,1.51602,2.82404, +2.55 - 3,0.0418207,0.228257,0.344488,0.678098,1.0376,1.54497,1.53456,2.74427,2.71373,3.16145,6.04666, +3 - 3.6,0.0286755,0.209077,0.32744,0.690028,1.03283,1.43837,1.46278,2.71373,2.9904,3.55548,6.67865, +3.6 - 4.35,0.01179,0.0469308,0.246864,0.668395,0.995469,1.34425,1.51602,3.16145,3.55548,4.95023,9.20034, +4.35 - 6,0.0286985,0.190049,0.617989,1.51369,2.06547,2.58094,2.82404,6.04666,6.67865,9.20034,19.3541, + +Detector covariance matrix (x10^{-40} cm^2/nucleon)^2 +0 - 0.8,0.00782108,0.033053,0.0603318,0.109857,0.137431,0.113012,0.0890879,0.0483224,-0.00490379,-0.0405139,-0.298954, +0.8 - 1,0.033053,0.157134,0.280351,0.483357,0.617321,0.493934,0.406031,0.248128,0.00765363,-0.143157,-1.21775, +1 - 1.2,0.0603318,0.280351,0.544127,0.972417,1.27798,1.09779,0.935286,0.734112,0.309637,0.0372703,-1.89003, +1.2 - 1.5,0.109857,0.483357,0.972417,1.94562,2.6432,2.33914,2.08605,1.82529,1.1442,0.566571,-2.9288, +1.5 - 1.8,0.137431,0.617321,1.27798,2.6432,3.89781,3.61987,3.37263,3.42502,2.68073,1.89848,-1.94426, +1.8 - 2.1,0.113012,0.493934,1.09779,2.33914,3.61987,3.72565,3.52287,3.9906,3.45239,2.79233,0.336419, +2.1 - 2.55,0.0890879,0.406031,0.935286,2.08605,3.37263,3.52287,3.69382,4.58082,4.3633,3.73059,2.74578, +2.55 - 3,0.0483224,0.248128,0.734112,1.82529,3.42502,3.9906,4.58082,6.76656,6.95788,6.41245,8.3469, +3 - 3.6,-0.00490379,0.00765363,0.309637,1.1442,2.68073,3.45239,4.3633,6.95788,8.01163,7.68399,12.0462, +3.6 - 4.35,-0.0405139,-0.143157,0.0372703,0.566571,1.89848,2.79233,3.73059,6.41245,7.68399,7.88471,13.6793, +4.35 - 6,-0.298954,-1.21775,-1.89003,-2.9288,-1.94426,0.336419,2.74578,8.3469,12.0462,13.6793,33.3707, diff --git a/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-EnuRec_MB.csv b/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-EnuRec_MB.csv new file mode 100644 index 0000000..ed9214f --- /dev/null +++ b/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-EnuRec_MB.csv @@ -0,0 +1,81 @@ +E_{#nu} (#mu, #pi) ,0 - 0.8,0.8 - 1,1 - 1.2,1.2 - 1.5,1.5 - 1.8,1.8 - 2.1,2.1 - 2.55,2.55 - 3,3 - 3.6,3.6 - 4.35,4.35 - 6, +Cross-section (x10^{-40} cm^2/nucleon) ,0.945076,3.53532,6.65924,12.9365,25.8139,35.0003,30.7362,37.8228,36.0422,27.7713,21.6247, +Total uncertainty (x10^{-40} cm^2/nucleon) ,0.295604,1.54062,2.90155,4.85431,8.43593,10.7945,11.4322,13.8102,14.9848,16.16,38.0586, + +Total covariance matrix (x10^{-40} cm^2/nucleon)^2 +0 - 0.8,0.087382,0.338921,0.554456,0.896865,1.46071,1.70622,1.37853,1.8705,1.63161,1.16062,0.918853, +0.8 - 1,0.338921,2.37352,3.60433,5.24006,7.92177,8.72441,6.64772,8.43984,6.71593,4.24176,0.641099, +1 - 1.2,0.554456,3.60433,8.419,12.2253,17.3723,19.5534,15.3705,20.5715,16.458,10.5022,4.1025, +1.2 - 1.5,0.896865,5.24006,12.2253,23.5644,34.3033,38.0423,30.6693,39.0939,32.9108,22.9076,17.6316, +1.5 - 1.8,1.46071,7.92177,17.3723,34.3033,71.1649,82.831,68.3794,76.371,72.5902,60.4043,82.5013, +1.8 - 2.1,1.70622,8.72441,19.5534,38.0423,82.831,116.522,103.573,103.564,106.494,95.6517,156.509, +2.1 - 2.55,1.37853,6.64772,15.3705,30.6693,68.3794,103.573,130.695,110.014,129.07,126.173,241.072, +2.55 - 3,1.8705,8.43984,20.5715,39.0939,76.371,103.564,110.014,190.721,178.149,150.142,227.428, +3 - 3.6,1.63161,6.71593,16.458,32.9108,72.5902,106.494,129.07,178.149,224.545,223.45,418.599, +3.6 - 4.35,1.16062,4.24176,10.5022,22.9076,60.4043,95.6517,126.173,150.142,223.45,261.147,557.638, +4.35 - 6,0.918853,0.641099,4.1025,17.6316,82.5013,156.509,241.072,227.428,418.599,557.638,1448.46, + +Statistical covariance matrix (x10^{-40} cm^2/nucleon)^2 +0 - 0.8,0.0331221,0.0613056,0.0349484,0.0245819,0.0217299,0.0118798,0.0256542,0.055381,0.0772789,0.0608276,0.0833135, +0.8 - 1,0.0613056,0.642258,0.568136,0.278804,0.137413,0.0568312,0.180182,0.258146,0.222658,0.219831,0.313369, +1 - 1.2,0.0349484,0.568136,2.40794,2.14363,0.999137,0.7772,0.89948,1.10393,0.923748,0.631641,0.418179, +1.2 - 1.5,0.0245819,0.278804,2.14363,5.87412,4.66028,3.00482,1.9061,1.75562,1.27941,0.872683,0.668758, +1.5 - 1.8,0.0217299,0.137413,0.999137,4.66028,16.6943,15.3279,7.48017,5.3883,3.53051,2.73389,2.80587, +1.8 - 2.1,0.0118798,0.0568312,0.7772,3.00482,15.3279,26.4506,14.9137,10.2151,5.96357,4.17244,4.16837, +2.1 - 2.55,0.0256542,0.180182,0.89948,1.9061,7.48017,14.9137,23.8718,23.2907,14.4247,7.80635,6.70137, +2.55 - 3,0.055381,0.258146,1.10393,1.75562,5.3883,10.2151,23.2907,41.6408,31.7954,20.1098,14.3721, +3 - 3.6,0.0772789,0.222658,0.923748,1.27941,3.53051,5.96357,14.4247,31.7954,40.9968,31.1712,21.9712, +3.6 - 4.35,0.0608276,0.219831,0.631641,0.872683,2.73389,4.17244,7.80635,20.1098,31.1712,34.6212,33.8659, +4.35 - 6,0.0833135,0.313369,0.418179,0.668758,2.80587,4.16837,6.70137,14.3721,21.9712,33.8659,76.9711, + +Flux covariance matrix (x10^{-40} cm^2/nucleon)^2 +0 - 0.8,0.0327873,0.135633,0.261667,0.46784,0.820209,1.03085,0.932536,1.18801,1.14516,0.969788,1.28348, +0.8 - 1,0.135633,0.61998,1.2211,2.15971,3.66803,4.53496,4.01618,4.98483,4.67866,3.80852,4.48226, +1 - 1.2,0.261667,1.2211,2.51554,4.54782,7.87014,9.8097,8.71801,10.813,10.0948,8.26187,10.1041, +1.2 - 1.5,0.46784,2.15971,4.54782,8.38872,14.9095,18.8382,16.9916,21.4414,20.3654,17.1873,23.1549, +1.5 - 1.8,0.820209,3.66803,7.87014,14.9095,27.6201,35.6254,32.9817,42.7996,41.715,36.4474,53.5016, +1.8 - 2.1,1.03085,4.53496,9.8097,18.8382,35.6254,46.4537,43.6448,57.5759,56.996,50.81,78.0702, +2.1 - 2.55,0.932536,4.01618,8.71801,16.9916,32.9817,43.6448,42.1237,57.0245,57.6657,52.3504,82.6266, +2.55 - 3,1.18801,4.98483,10.813,21.4414,42.7996,57.5759,57.0245,79.7195,83.2821,78.1581,131.145, +3 - 3.6,1.14516,4.67866,10.0948,20.3654,41.715,56.996,57.6657,83.2821,90.1484,87.7193,157.046, +3.6 - 4.35,0.969788,3.80852,8.26187,17.1873,36.4474,50.81,52.3504,78.1581,87.7193,89.7636,176.998, +4.35 - 6,1.28348,4.48226,10.1041,23.1549,53.5016,78.0702,82.6266,131.145,157.046,176.998,410.687, + +Theory cross-section covariance matrix (x10^{-40} cm^2/nucleon)^2 +0 - 0.8,0.0169207,0.122318,0.211269,0.330707,0.513438,0.498491,0.304662,0.541875,0.372081,0.190312,-0.203806, +0.8 - 1,0.122318,0.96,1.58048,2.4059,3.67084,3.3954,1.88125,2.78999,1.61393,0.510599,-2.88177, +1 - 1.2,0.211269,1.58048,2.84002,4.46573,6.92243,6.64994,3.907,7.06183,4.55623,2.01377,-3.71541, +1.2 - 1.5,0.330707,2.4059,4.46573,7.18681,11.4815,11.5735,7.869,12.4989,9.29609,5.49766,-0.958524, +1.5 - 1.8,0.513438,3.67084,6.92243,11.4815,20.2616,22.9364,20.7554,21.5824,23.4411,21.4154,33.0384, +1.8 - 2.1,0.498491,3.3954,6.64994,11.5735,22.9364,29.7063,33.9361,25.6863,37.3854,40.4066,83.8258, +2.1 - 2.55,0.304662,1.88125,3.907,7.869,20.7554,33.9361,53.9508,19.1686,49.477,63.4808,156.367, +2.55 - 3,0.541875,2.78999,7.06183,12.4989,21.5824,25.6863,19.1686,55.59,51.4061,42.7573,71.6162, +3 - 3.6,0.372081,1.61393,4.55623,9.29609,23.4411,37.3854,49.477,51.4061,79.6557,91.3671,217.987, +3.6 - 4.35,0.190312,0.510599,2.01377,5.49766,21.4154,40.4066,63.4808,42.7573,91.3671,118.098,307.824, +4.35 - 6,-0.203806,-2.88177,-3.71541,-0.958524,33.0384,83.8258,156.367,71.6162,217.987,307.824,865.488, + +FSI covariance matrix (x10^{-40} cm^2/nucleon)^2 +0 - 0.8,0.00142321,0.00971869,0.0155756,0.0178302,0.0130348,0.0308802,0.010659,0.0130834,0.00754027,-0.00244865,-0.0129334, +0.8 - 1,0.00971869,0.0994257,0.122235,0.200117,0.141498,0.325768,0.211347,0.120098,0.0400908,-0.185208,-0.669086, +1 - 1.2,0.0155756,0.122235,0.20595,0.264271,0.185882,0.355242,0.141845,0.121933,0.0291829,-0.166463,-0.576101, +1.2 - 1.5,0.0178302,0.200117,0.264271,0.533064,0.390035,0.65044,0.489226,0.275117,0.174,-0.425797,-1.54282, +1.5 - 1.8,0.0130348,0.141498,0.185882,0.390035,0.556559,0.724806,0.319418,0.0133491,-0.0533128,-0.375595,-0.961244, +1.8 - 2.1,0.0308802,0.325768,0.355242,0.65044,0.724806,1.88876,1.22046,0.836594,0.41909,0.0202162,-0.899174, +2.1 - 2.55,0.010659,0.211347,0.141845,0.489226,0.319418,1.22046,1.55863,1.60047,1.37903,1.06146,0.70764, +2.55 - 3,0.0130834,0.120098,0.121933,0.275117,0.0133491,0.836594,1.60047,3.67942,4.25801,5.47836,10.8761, +3 - 3.6,0.00754027,0.0400908,0.0291829,0.174,-0.0533128,0.41909,1.37903,4.25801,6.28709,7.76416,16.4839, +3.6 - 4.35,-0.00244865,-0.185208,-0.166463,-0.425797,-0.375595,0.0202162,1.06146,5.47836,7.76416,11.4579,25.7279, +4.35 - 6,-0.0129334,-0.669086,-0.576101,-1.54282,-0.961244,-0.899174,0.70764,10.8761,16.4839,25.7279,60.8013, + +Detector covariance matrix (x10^{-40} cm^2/nucleon)^2 +0 - 0.8,0.00312864,0.00994626,0.0309955,0.0559057,0.0923001,0.13412,0.105019,0.0721501,0.0295486,-0.0578549,-0.231205, +0.8 - 1,0.00994626,0.0518569,0.11238,0.195525,0.303995,0.411447,0.358765,0.286764,0.160595,-0.111984,-0.603668, +1 - 1.2,0.0309955,0.11238,0.449551,0.803854,1.39468,1.96132,1.7042,1.47077,0.854032,-0.238645,-2.12823, +1.2 - 1.5,0.0559057,0.195525,0.803854,1.58166,2.86197,3.97539,3.41337,3.12295,1.79589,-0.224215,-3.69064, +1.5 - 1.8,0.0923001,0.303995,1.39468,2.86197,6.03242,8.21657,6.84276,6.58735,3.95689,0.18324,-5.88332, +1.8 - 2.1,0.13412,0.411447,1.96132,3.97539,8.21657,12.0225,9.85779,9.25025,5.72955,0.24246,-8.65597, +2.1 - 2.55,0.105019,0.358765,1.7042,3.41337,6.84276,9.85779,9.18969,8.92939,6.1237,1.47426,-5.33077, +2.55 - 3,0.0721501,0.286764,1.47077,3.12295,6.58735,9.25025,8.92939,10.0914,7.40753,3.63869,-0.58139, +3 - 3.6,0.0295486,0.160595,0.854032,1.79589,3.95689,5.72955,6.1237,7.40753,7.45672,5.42878,5.11074, +3.6 - 4.35,-0.0578549,-0.111984,-0.238645,-0.224215,0.18324,0.24246,1.47426,3.63869,5.42878,7.20593,13.2221, +4.35 - 6,-0.231205,-0.603668,-2.12823,-3.69064,-5.88332,-8.65597,-5.33077,-0.58139,5.11074,13.2221,34.508, diff --git a/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-MuCos.csv b/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-MuCos.csv new file mode 100644 index 0000000..a5462dd --- /dev/null +++ b/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-MuCos.csv @@ -0,0 +1,87 @@ +cos #theta_{#mu} ,0.3 - 0.62,0.62 - 0.72,0.72 - 0.78,0.78 - 0.83,0.83 - 0.87,0.87 - 0.9,0.9 - 0.93,0.93 - 0.95,0.95 - 0.96,0.96 - 0.98,0.98 - 0.99,0.99 - 1, +Cross-section (x10^{-40} cm^2/nucleon) ,1.64253,2.97897,3.37236,3.87434,5.47814,6.93602,12.4575,14.0298,20.0312,28.3643,38.2444,67.2747, +Total uncertainty (x10^{-40} cm^2/nucleon) ,1.08601,1.83931,2.23963,2.50787,3.37358,4.61573,6.07351,6.86879,8.73887,11.4549,14.1623,21.4416, + +Total covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.3 - 0.62,1.17941,1.28916,1.41262,1.48379,2.04771,2.77789,3.52493,3.54268,4.35279,5.51999,5.74442,7.21977, +0.62 - 0.72,1.28916,3.38306,3.13971,2.88938,3.75932,4.81165,6.52965,6.85641,8.53785,10.9643,11.7046,15.2421, +0.72 - 0.78,1.41262,3.13971,5.01595,4.15771,4.702,5.94969,8.12451,8.71671,10.8318,13.5591,14.6035,19.4386, +0.78 - 0.83,1.48379,2.88938,4.15771,6.2894,6.08511,6.55285,8.71428,9.01727,11.3982,15.1382,17.0082,23.3571, +0.83 - 0.87,2.04771,3.75932,4.702,6.08511,11.3811,12.1991,13.7523,14.3004,17.9454,23.1582,25.8789,33.3762, +0.87 - 0.9,2.77789,4.81165,5.94969,6.55285,12.1991,21.305,22.5806,20.444,25.136,32.8651,36.7351,46.4264, +0.9 - 0.93,3.52493,6.52965,8.12451,8.71428,13.7523,22.5806,36.8876,34.3528,39.3861,49.1586,55.3437,71.9378, +0.93 - 0.95,3.54268,6.85641,8.71671,9.01727,14.3004,20.444,34.3528,47.1803,54.7821,58.2096,64.7067,83.825, +0.95 - 0.96,4.35279,8.53785,10.8318,11.3982,17.9454,25.136,39.3861,54.7821,76.3679,87.8042,90.2449,115.098, +0.96 - 0.98,5.51999,10.9643,13.5591,15.1382,23.1582,32.8651,49.1586,58.2096,87.8042,131.214,137.545,166.827, +0.98 - 0.99,5.74442,11.7046,14.6035,17.0082,25.8789,36.7351,55.3437,64.7067,90.2449,137.545,200.57,244.143, +0.99 - 1,7.21977,15.2421,19.4386,23.3571,33.3762,46.4264,71.9378,83.825,115.098,166.827,244.143,459.742, + +Statistical covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.3 - 0.62,0.441318,0.112745,0.0215671,0.0322305,0.0293157,0.0225619,0.0127267,-0.00726637,0.0700216,0.20789,0.0733563,0.00399826, +0.62 - 0.72,0.112745,1.13917,0.536693,0.153279,0.0766303,0.0636386,0.157735,0.236889,0.301566,0.293548,0.20086,0.48647, +0.72 - 0.78,0.0215671,0.536693,1.77432,0.828467,0.129922,0.100534,0.0866326,0.114562,0.218499,0.183743,0.218813,1.14057, +0.78 - 0.83,0.0322305,0.153279,0.828467,2.48321,1.0834,0.280954,0.195374,0.0964024,0.144666,0.350288,0.405361,1.5026, +0.83 - 0.87,0.0293157,0.0766303,0.129922,1.0834,3.86493,2.5014,0.679075,0.123449,0.130884,0.335237,0.688075,0.965203, +0.87 - 0.9,0.0225619,0.0636386,0.100534,0.280954,2.5014,6.21623,2.95249,0.502828,0.103266,0.630834,0.807525,1.14603, +0.9 - 0.93,0.0127267,0.157735,0.0866326,0.195374,0.679075,2.95249,9.22726,5.30051,2.46935,1.02132,0.889611,0.683772, +0.93 - 0.95,-0.00726637,0.236889,0.114562,0.0964024,0.123449,0.502828,5.30051,13.6031,11.9329,3.15942,2.17466,1.92542, +0.95 - 0.96,0.0700216,0.301566,0.218499,0.144666,0.130884,0.103266,2.46935,11.9329,20.3016,14.5638,5.59214,3.04466, +0.96 - 0.98,0.20789,0.293548,0.183743,0.350288,0.335237,0.630834,1.02132,3.15942,14.5638,31.1972,18.4848,5.51788, +0.98 - 0.99,0.0733563,0.20086,0.218813,0.405361,0.688075,0.807525,0.889611,2.17466,5.59214,18.4848,50.9139,35.522, +0.99 - 1,0.00399826,0.48647,1.14057,1.5026,0.965203,1.14603,0.683772,1.92542,3.04466,5.51788,35.522,147.499, + +Flux covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.3 - 0.62,0.239876,0.424391,0.513764,0.589922,0.795203,1.00149,1.48927,1.61292,2.14478,2.85941,3.45487,5.42206, +0.62 - 0.72,0.424391,0.762542,0.920697,1.05787,1.44659,1.84254,2.7828,3.04081,4.10159,5.53156,6.74066,10.4522, +0.72 - 0.78,0.513764,0.920697,1.11733,1.28468,1.75745,2.23846,3.36751,3.6786,4.94473,6.64133,8.05435,12.4912, +0.78 - 0.83,0.589922,1.05787,1.28468,1.47785,2.02344,2.57885,3.88159,4.24286,5.70657,7.66601,9.2938,14.3997, +0.83 - 0.87,0.795203,1.44659,1.75745,2.02344,2.82007,3.63793,5.55575,6.1328,8.34528,11.3042,13.7696,21.0958, +0.87 - 0.9,1.00149,1.84254,2.23846,2.57885,3.63793,4.735,7.30159,8.11021,11.1244,15.1527,18.5254,28.1773, +0.9 - 0.93,1.48927,2.7828,3.36751,3.88159,5.55575,7.30159,11.4385,12.8044,17.7871,24.4778,30.1445,45.4981, +0.93 - 0.95,1.61292,3.04081,3.6786,4.24286,6.1328,8.11021,12.8044,14.403,20.1241,27.803,34.3071,51.5202, +0.95 - 0.96,2.14478,4.10159,4.94473,5.70657,8.34528,11.1244,17.7871,20.1241,28.414,39.588,49.1278,73.365, +0.96 - 0.98,2.85941,5.53156,6.64133,7.66601,11.3042,15.1527,24.4778,27.803,39.588,55.5679,69.3315,103.205, +0.98 - 0.99,3.45487,6.74066,8.05435,9.2938,13.7696,18.5254,30.1445,34.3071,49.1278,69.3315,86.9397,129.285, +0.99 - 1,5.42206,10.4522,12.4912,14.3997,21.0958,28.1773,45.4981,51.5202,73.365,103.205,129.285,193.471, + +Theory cross-section covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.3 - 0.62,0.405268,0.711144,0.812308,0.821065,1.11141,1.51766,1.71961,1.60722,1.82223,2.13215,1.81724,1.04698, +0.62 - 0.72,0.711144,1.28493,1.50081,1.51062,2.0965,2.87784,3.37246,3.20311,3.66405,4.32209,3.74305,2.39523, +0.72 - 0.78,0.812308,1.50081,1.84528,1.84267,2.60083,3.55383,4.36974,4.22299,4.88766,5.77331,5.19039,3.88561, +0.78 - 0.83,0.821065,1.51062,1.84267,1.95698,2.67841,3.55827,4.35939,4.23873,4.98757,6.1332,6.03024,5.50622, +0.83 - 0.87,1.11141,2.0965,2.60083,2.67841,4.05713,5.62647,7.04404,7.26659,8.63088,10.6249,10.4441,9.61713, +0.87 - 0.9,1.51766,2.87784,3.55383,3.55827,5.62647,8.24521,10.1428,10.6836,12.6889,15.5683,15.29,13.3863, +0.9 - 0.93,1.71961,3.37246,4.36974,4.35939,7.04404,10.1428,13.1519,13.9676,16.6896,20.5473,20.3954,19.2203, +0.93 - 0.95,1.60722,3.20311,4.22299,4.23873,7.26659,10.6836,13.9676,15.5144,18.7632,23.4743,24.355,24.4906, +0.95 - 0.96,1.82223,3.66405,4.88766,4.98757,8.63088,12.6889,16.6896,18.7632,22.8857,28.953,30.8202,32.1427, +0.96 - 0.98,2.13215,4.32209,5.77331,6.1332,10.6249,15.5683,20.5473,23.4743,28.953,37.5086,41.6168,45.7014, +0.98 - 0.99,1.81724,3.74305,5.19039,6.03024,10.4441,15.29,20.3954,24.355,30.8202,41.6168,50.7318,61.1354, +0.99 - 1,1.04698,2.39523,3.88561,5.50622,9.61713,13.3863,19.2203,24.4906,32.1427,45.7014,61.1354,82.8018, + +FSI covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.3 - 0.62,0.0587673,0.0118852,0.0279782,0.000264888,0.0481477,0.162483,0.189628,0.173733,0.132046,0.132716,0.152545,0.524358, +0.62 - 0.72,0.0118852,0.0706555,0.0863966,0.062232,0.043148,-0.105267,-0.0383553,0.181227,0.209096,0.23584,0.114221,0.354537, +0.72 - 0.78,0.0279782,0.0863966,0.135535,0.060979,0.0845357,-0.129568,-0.0395539,0.316234,0.319102,0.291746,0.14043,0.490897, +0.78 - 0.83,0.000264888,0.062232,0.060979,0.170429,0.115061,-0.117074,-0.13206,-0.0255719,-0.0212552,0.110885,0.0103009,0.205126, +0.83 - 0.87,0.0481477,0.043148,0.0845357,0.115061,0.341377,0.0895721,0.0013974,0.174948,0.0836002,-0.0589961,-0.133258,0.42207, +0.87 - 0.9,0.162483,-0.105267,-0.129568,-0.117074,0.0895721,1.61545,1.54152,0.434002,0.341534,0.272408,0.485981,1.7201, +0.9 - 0.93,0.189628,-0.0383553,-0.0395539,-0.13206,0.0013974,1.54152,1.87422,0.952573,0.870312,1.00006,1.08183,2.65467, +0.93 - 0.95,0.173733,0.181227,0.316234,-0.0255719,0.174948,0.434002,0.952573,1.63068,1.56335,1.42419,1.11074,2.83206, +0.95 - 0.96,0.132046,0.209096,0.319102,-0.0212552,0.0836002,0.341534,0.870312,1.56335,1.72329,1.59021,1.16973,2.67877, +0.96 - 0.98,0.132716,0.23584,0.291746,0.110885,-0.0589961,0.272408,1.00006,1.42419,1.59021,2.07434,1.68876,3.31676, +0.98 - 0.99,0.152545,0.114221,0.14043,0.0103009,-0.133258,0.485981,1.08183,1.11074,1.16973,1.68876,1.96079,3.15303, +0.99 - 1,0.524358,0.354537,0.490897,0.205126,0.42207,1.7201,2.65467,2.83206,2.67877,3.31676,3.15303,9.03063, + +Detector covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.3 - 0.62,0.0341814,0.0289922,0.0370045,0.0403022,0.0636314,0.0736944,0.113698,0.156077,0.18371,0.187824,0.246408,0.222375, +0.62 - 0.72,0.0289922,0.125769,0.0951112,0.10537,0.0964507,0.132911,0.255016,0.194387,0.261538,0.581228,0.905777,1.55364, +0.72 - 0.78,0.0370045,0.0951112,0.143487,0.14092,0.129261,0.186427,0.340186,0.384327,0.461825,0.66897,0.9995,1.4304, +0.78 - 0.83,0.0403022,0.10537,0.14092,0.200916,0.184802,0.251847,0.409985,0.464849,0.580654,0.877821,1.26855,1.74349, +0.83 - 0.87,0.0636314,0.0964507,0.129261,0.184802,0.297541,0.343738,0.472066,0.602654,0.75478,0.952874,1.1104,1.27596, +0.87 - 0.9,0.0736944,0.132911,0.186427,0.251847,0.343738,0.493087,0.642266,0.71334,0.87788,1.24085,1.62623,1.99667, +0.9 - 0.93,0.113698,0.255016,0.340186,0.409985,0.472066,0.642266,1.19567,1.32769,1.56965,2.11213,2.8324,3.8809, +0.93 - 0.95,0.156077,0.194387,0.384327,0.464849,0.602654,0.71334,1.32769,2.02914,2.39855,2.34874,2.7592,3.0567, +0.95 - 0.96,0.18371,0.261538,0.461825,0.580654,0.75478,0.87788,1.56965,2.39855,3.04328,3.10916,3.53497,3.86727, +0.96 - 0.98,0.187824,0.581228,0.66897,0.877821,0.952874,1.24085,2.11213,2.34874,3.10916,4.86654,6.42296,9.08614, +0.98 - 0.99,0.246408,0.905777,0.9995,1.26855,1.1104,1.62623,2.8324,2.7592,3.53497,6.42296,10.0234,15.0479, +0.99 - 1,0.222375,1.55364,1.4304,1.74349,1.27596,1.99667,3.8809,3.0567,3.86727,9.08614,15.0479,26.9395, diff --git a/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-MuMom.csv b/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-MuMom.csv new file mode 100644 index 0000000..04c92ad --- /dev/null +++ b/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-MuMom.csv @@ -0,0 +1,105 @@ +p_{#mu} / GeV,0.2 - 0.3,0.3 - 0.4,0.4 - 0.5,0.5 - 0.6,0.6 - 0.75,0.75 - 0.95,0.95 - 1.15,1.15 - 1.4,1.4 - 1.75,1.75 - 2.1,2.1 - 2.5,2.5 - 3.05,3.05 - 3.7,3.7 - 4.9,4.9 - 30, +Cross-section (x10^{-40} cm^2/nucleon) ,6.00219,4.09609,4.03629,1.42874,2.04991,2.07719,1.49898,0.996676,0.840758,0.639527,0.554949,0.358252,0.218325,0.142894,0.00979575, +Total uncertainty (x10^{-40} cm^2/nucleon) ,2.45468,1.95662,1.60286,1.10449,0.983034,0.756749,0.566309,0.429652,0.391714,0.293628,0.262227,0.191345,0.14961,0.111234,0.00700262, + +Total covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.2 - 0.3,6.02544,3.37956,2.33963,1.48007,1.39671,1.04734,0.763537,0.491028,0.395778,0.271223,0.215529,0.141024,0.0819894,0.0551337,0.00408224, +0.3 - 0.4,3.37956,3.82836,2.20522,1.33999,1.21731,0.913469,0.669836,0.407187,0.3162,0.217825,0.179152,0.117365,0.0684402,0.042407,0.00325518, +0.4 - 0.5,2.33963,2.20522,2.56916,1.27532,1.01187,0.780501,0.55201,0.342492,0.264388,0.182936,0.150716,0.09926,0.0573644,0.0348901,0.00275383, +0.5 - 0.6,1.48007,1.33999,1.27532,1.2199,0.820302,0.518522,0.343151,0.218163,0.161865,0.109887,0.0861519,0.0521064,0.025543,0.014459,0.00102911, +0.6 - 0.75,1.39671,1.21731,1.01187,0.820302,0.966356,0.588714,0.350089,0.230964,0.183968,0.12824,0.104903,0.0669942,0.039196,0.0253063,0.00174027, +0.75 - 0.95,1.04734,0.913469,0.780501,0.518522,0.588714,0.572669,0.337337,0.218422,0.17562,0.124931,0.104407,0.0687328,0.0446936,0.0295173,0.00196936, +0.95 - 1.15,0.763537,0.669836,0.55201,0.343151,0.350089,0.337337,0.320706,0.193254,0.138531,0.0980831,0.0831357,0.0566617,0.0380999,0.0246917,0.00167039, +1.15 - 1.4,0.491028,0.407187,0.342492,0.218163,0.230964,0.218422,0.193254,0.1846,0.143536,0.0929683,0.0786633,0.0529493,0.0382831,0.0264657,0.00167813, +1.4 - 1.75,0.395778,0.3162,0.264388,0.161865,0.183968,0.17562,0.138531,0.143536,0.15344,0.103375,0.084212,0.0557067,0.0413352,0.0291033,0.00183275, +1.75 - 2.1,0.271223,0.217825,0.182936,0.109887,0.12824,0.124931,0.0980831,0.0929683,0.103375,0.0862174,0.0719576,0.0462843,0.0336415,0.0232995,0.00145077, +2.1 - 2.5,0.215529,0.179152,0.150716,0.0861519,0.104903,0.104407,0.0831357,0.0786633,0.084212,0.0719576,0.068763,0.0464179,0.0335714,0.0226452,0.0013869, +2.5 - 3.05,0.141024,0.117365,0.09926,0.0521064,0.0669942,0.0687328,0.0566617,0.0529493,0.0557067,0.0462843,0.0464179,0.036613,0.0269211,0.0180082,0.00105119, +3.05 - 3.7,0.0819894,0.0684402,0.0573644,0.025543,0.039196,0.0446936,0.0380999,0.0382831,0.0413352,0.0336415,0.0335714,0.0269211,0.0223832,0.0159023,0.000916336, +3.7 - 4.9,0.0551337,0.042407,0.0348901,0.014459,0.0253063,0.0295173,0.0246917,0.0264657,0.0291033,0.0232995,0.0226452,0.0180082,0.0159023,0.0123731,0.000730148, +4.9 - 30,0.00408224,0.00325518,0.00275383,0.00102911,0.00174027,0.00196936,0.00167039,0.00167813,0.00183275,0.00145077,0.0013869,0.00105119,0.000916336,0.000730148,4.90367e-05, + +Statistical covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.2 - 0.3,2.21764,0.383934,0.0343195,0.0134278,0.0240902,-0.000377967,0.00135127,0.00355882,0.00524426,0.00530182,0.000236326,0.000813799,0.000347674,0.000595237,-1.49344e-05, +0.3 - 0.4,0.383934,1.15807,0.224536,0.0582239,0.0413437,0.0072672,0.00811876,0.00169607,-0.00097357,0.000693963,0.00185387,0.00168675,0.00117248,0.00123023,7.67475e-05, +0.4 - 0.5,0.0343195,0.224536,0.894594,0.242969,0.039088,0.0257529,0.0146956,0.00692064,0.00164145,0.000832928,0.00254752,0.00301885,0.00254108,0.00194674,0.00015191, +0.5 - 0.6,0.0134278,0.0582239,0.242969,0.417835,0.12941,0.0266498,0.0146831,0.00540294,0.00498611,0.0037956,0.00346441,0.00178837,0.000784618,0.000585247,8.94209e-05, +0.6 - 0.75,0.0240902,0.0413437,0.039088,0.12941,0.31515,0.102757,0.0225316,0.00506018,0.00547675,0.00464951,0.00379725,0.00318307,0.00187224,0.00127643,7.43005e-05, +0.75 - 0.95,-0.000377967,0.0072672,0.0257529,0.0266498,0.102757,0.170669,0.0562747,0.017486,0.00822041,0.00569912,0.00359888,0.0021804,0.00106431,0.000692482,5.08637e-05, +0.95 - 1.15,0.00135127,0.00811876,0.0146956,0.0146831,0.0225316,0.0562747,0.102711,0.0413086,0.0111593,0.00575009,0.00415513,0.0025227,0.00158168,0.000971869,6.31273e-05, +1.15 - 1.4,0.00355882,0.00169607,0.00692064,0.00540294,0.00506018,0.017486,0.0413086,0.0548867,0.0242691,0.00762795,0.00409538,0.00142166,0.000974367,0.000665662,4.11185e-05, +1.4 - 1.75,0.00524426,-0.00097357,0.00164145,0.00498611,0.00547675,0.00822041,0.0111593,0.0242691,0.0323248,0.0173175,0.00876985,0.00291771,0.00149717,0.000745252,4.51513e-05, +1.75 - 2.1,0.00530182,0.000693963,0.000832928,0.0037956,0.00464951,0.00569912,0.00575009,0.00762795,0.0173175,0.0205979,0.0133786,0.00503096,0.00235411,0.00101999,6.36513e-05, +2.1 - 2.5,0.000236326,0.00185387,0.00254752,0.00346441,0.00379725,0.00359888,0.00415513,0.00409538,0.00876985,0.0133786,0.0146815,0.00785585,0.00378441,0.00138328,6.50676e-05, +2.5 - 3.05,0.000813799,0.00168675,0.00301885,0.00178837,0.00318307,0.0021804,0.0025227,0.00142166,0.00291771,0.00503096,0.00785585,0.00808335,0.00441563,0.00183085,5.54734e-05, +3.05 - 3.7,0.000347674,0.00117248,0.00254108,0.000784618,0.00187224,0.00106431,0.00158168,0.000974367,0.00149717,0.00235411,0.00378441,0.00441563,0.00369187,0.00220458,8.80148e-05, +3.7 - 4.9,0.000595237,0.00123023,0.00194674,0.000585247,0.00127643,0.000692482,0.000971869,0.000665662,0.000745252,0.00101999,0.00138328,0.00183085,0.00220458,0.00198969,0.00010676, +4.9 - 30,-1.49344e-05,7.67475e-05,0.00015191,8.94209e-05,7.43005e-05,5.08637e-05,6.31273e-05,4.11185e-05,4.51513e-05,6.36513e-05,6.50676e-05,5.54734e-05,8.80148e-05,0.00010676,9.45319e-06, + +Flux covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.2 - 0.3,1.65891,1.32377,1.1827,0.673044,0.708659,0.612414,0.428265,0.300204,0.249038,0.19258,0.165359,0.108113,0.0699248,0.0462459,0.00299805, +0.3 - 0.4,1.32377,1.06205,0.950041,0.543363,0.572994,0.494172,0.345466,0.242617,0.201357,0.155813,0.133886,0.0877292,0.0571856,0.0380177,0.00246336, +0.4 - 0.5,1.1827,0.950041,0.85263,0.486702,0.515301,0.445852,0.312389,0.219845,0.182961,0.141841,0.121995,0.0799584,0.0521367,0.0347087,0.0022533, +0.5 - 0.6,0.673044,0.543363,0.486702,0.28615,0.296254,0.253395,0.177558,0.1248,0.101898,0.0775182,0.0654784,0.0419193,0.0261231,0.0166379,0.00109459, +0.6 - 0.75,0.708659,0.572994,0.515301,0.296254,0.314718,0.271485,0.189989,0.134017,0.111403,0.0863019,0.0742308,0.0487856,0.0322122,0.0216414,0.00140561, +0.75 - 0.95,0.612414,0.494172,0.445852,0.253395,0.271485,0.236002,0.165697,0.117211,0.0982369,0.0765572,0.0661141,0.043627,0.0289093,0.0195039,0.00126758, +0.95 - 1.15,0.428265,0.345466,0.312389,0.177558,0.189989,0.165697,0.116748,0.082757,0.0694152,0.0540277,0.0465251,0.0305468,0.0199705,0.0133196,0.000869181, +1.15 - 1.4,0.300204,0.242617,0.219845,0.1248,0.134017,0.117211,0.082757,0.0589639,0.0497315,0.0387821,0.0333905,0.0219518,0.0143708,0.00957386,0.000624196, +1.4 - 1.75,0.249038,0.201357,0.182961,0.101898,0.111403,0.0982369,0.0694152,0.0497315,0.0427813,0.0339232,0.0296094,0.0197902,0.0133153,0.00908309,0.000586589, +1.75 - 2.1,0.19258,0.155813,0.141841,0.0775182,0.0863019,0.0765572,0.0540277,0.0387821,0.0339232,0.0273429,0.0242198,0.0164564,0.0113911,0.00796459,0.000510285, +2.1 - 2.5,0.165359,0.133886,0.121995,0.0654784,0.0742308,0.0661141,0.0465251,0.0333905,0.0296094,0.0242198,0.0217558,0.0150154,0.0106858,0.00764319,0.000486611, +2.5 - 3.05,0.108113,0.0877292,0.0799584,0.0419193,0.0487856,0.043627,0.0305468,0.0219518,0.0197902,0.0164564,0.0150154,0.0105918,0.00784747,0.00576497,0.000363672, +3.05 - 3.7,0.0699248,0.0571856,0.0521367,0.0261231,0.0322122,0.0289093,0.0199705,0.0143708,0.0133153,0.0113911,0.0106858,0.00784747,0.00627654,0.00482838,0.000299368, +3.7 - 4.9,0.0462459,0.0380177,0.0347087,0.0166379,0.0216414,0.0195039,0.0133196,0.00957386,0.00908309,0.00796459,0.00764319,0.00576497,0.00482838,0.00382603,0.000235719, +4.9 - 30,0.00299805,0.00246336,0.0022533,0.00109459,0.00140561,0.00126758,0.000869181,0.000624196,0.000586589,0.000510285,0.000486611,0.000363672,0.000299368,0.000235719,1.47423e-05, + +Theory cross-section covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.2 - 0.3,1.70349,1.43761,0.903738,0.712263,0.56474,0.361843,0.261972,0.155514,0.122353,0.0644043,0.0492916,0.0341221,0.015789,0.0123769,0.00109727, +0.3 - 0.4,1.43761,1.2497,0.805233,0.649184,0.512667,0.32609,0.234967,0.139096,0.107445,0.0574342,0.0431436,0.0292754,0.0130065,0.00970998,0.000866042, +0.4 - 0.5,0.903738,0.805233,0.558284,0.462335,0.366423,0.230889,0.154771,0.0901726,0.064932,0.0346405,0.0248008,0.0147622,0.00426516,0.0026325,0.000313367, +0.5 - 0.6,0.712263,0.649184,0.462335,0.406392,0.321583,0.192998,0.119984,0.067242,0.0411259,0.0192673,0.012251,0.0051287,-0.00257375,-0.00243311,-1.73631e-05, +0.6 - 0.75,0.56474,0.512667,0.366423,0.321583,0.266196,0.167639,0.105493,0.0703533,0.0515193,0.0290156,0.0229157,0.0126371,0.00480626,0.00283948,0.000307195, +0.75 - 0.95,0.361843,0.32609,0.230889,0.192998,0.167639,0.116643,0.0794869,0.0622363,0.0547097,0.0344049,0.028987,0.0183219,0.011577,0.00784302,0.000573184, +0.95 - 1.15,0.261972,0.234967,0.154771,0.119984,0.105493,0.0794869,0.0640364,0.0516291,0.0494196,0.033372,0.0283236,0.0198294,0.0139466,0.00983359,0.000663301, +1.15 - 1.4,0.155514,0.139096,0.0901726,0.067242,0.0703533,0.0622363,0.0516291,0.0544212,0.0588804,0.0402129,0.0356473,0.0248692,0.0192392,0.0136603,0.000900878, +1.4 - 1.75,0.122353,0.107445,0.064932,0.0411259,0.0515193,0.0547097,0.0494196,0.0588804,0.0692529,0.04688,0.0418343,0.0297999,0.024046,0.0172234,0.00111843, +1.75 - 2.1,0.0644043,0.0574342,0.0346405,0.0192673,0.0290156,0.0344049,0.033372,0.0402129,0.04688,0.0341402,0.0308877,0.0221514,0.0177609,0.0126871,0.000814344, +2.1 - 2.5,0.0492916,0.0431436,0.0248008,0.012251,0.0229157,0.028987,0.0283236,0.0356473,0.0418343,0.0308877,0.0285613,0.0204138,0.0164321,0.0117713,0.000758466, +2.5 - 3.05,0.0341221,0.0292754,0.0147622,0.0051287,0.0126371,0.0183219,0.0198294,0.0248692,0.0297999,0.0221514,0.0204138,0.0149482,0.0121189,0.00873892,0.000558705, +3.05 - 3.7,0.015789,0.0130065,0.00426516,-0.00257375,0.00480626,0.011577,0.0139466,0.0192392,0.024046,0.0177609,0.0164321,0.0121189,0.0100279,0.00725342,0.000460796, +3.7 - 4.9,0.0123769,0.00970998,0.0026325,-0.00243311,0.00283948,0.00784302,0.00983359,0.0136603,0.0172234,0.0126871,0.0117713,0.00873892,0.00725342,0.00527101,0.000335225, +4.9 - 30,0.00109727,0.000866042,0.000313367,-1.73631e-05,0.000307195,0.000573184,0.000663301,0.000900878,0.00111843,0.000814344,0.000758466,0.000558705,0.000460796,0.000335225,2.15345e-05, + +FSI covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.2 - 0.3,0.143378,0.0882159,0.0484019,0.00423882,0.00807049,0.0217372,0.0288744,0.0142943,0.00580036,0.00606668,0.00611352,0.0045098,0.00489919,0.00284122,0.000221555, +0.3 - 0.4,0.0882159,0.18744,0.101953,0.00324918,0.00632895,0.0217843,0.0390362,0.00119734,-0.00887329,-0.00467293,-0.00128166,-0.000170466,5.01063e-05,-0.00381255,1.34856e-05, +0.4 - 0.5,0.0484019,0.101953,0.1011,0.00872419,0.00677218,0.0150346,0.0254166,0.00123531,-0.00444769,-0.00152367,0.000971842,0.00223711,0.00145966,-0.00184619,9.83175e-05, +0.5 - 0.6,0.00423882,0.00324918,0.00872419,0.0181917,0.00695563,-0.00218616,-0.00296107,-0.0017797,-0.000278145,0.000821305,0.000267656,-0.000217351,-0.000191913,-0.000276302,-1.12864e-05, +0.6 - 0.75,0.00807049,0.00632895,0.00677218,0.00695563,0.00418596,0.000536252,0.000626657,0.000307571,0.000331567,0.0007686,0.00060705,0.000311907,0.000291891,3.31879e-05,6.77506e-06, +0.75 - 0.95,0.0217372,0.0217843,0.0150346,-0.00218616,0.000536252,0.0085638,0.00977121,0.002988,0.000506428,0.000798275,0.00126952,0.00141577,0.00141995,0.000610231,6.83313e-05, +0.95 - 1.15,0.0288744,0.0390362,0.0254166,-0.00296107,0.000626657,0.00977121,0.01592,0.00389264,-0.000684917,0.00027608,0.00153336,0.00192495,0.00171833,0.000229897,7.38537e-05, +1.15 - 1.4,0.0142943,0.00119734,0.00123531,-0.0017797,0.000307571,0.002988,0.00389264,0.00416911,0.00229456,0.0018434,0.00189818,0.00167667,0.00150583,0.00117289,6.39166e-05, +1.4 - 1.75,0.00580036,-0.00887329,-0.00444769,-0.000278145,0.000331567,0.000506428,-0.000684917,0.00229456,0.00235498,0.00164357,0.00118446,0.00086599,0.000803867,0.000941821,3.49677e-05, +1.75 - 2.1,0.00606668,-0.00467293,-0.00152367,0.000821305,0.0007686,0.000798275,0.00027608,0.0018434,0.00164357,0.00169162,0.00141565,0.00105772,0.000889806,0.000813253,3.54135e-05, +2.1 - 2.5,0.00611352,-0.00128166,0.000971842,0.000267656,0.00060705,0.00126952,0.00153336,0.00189818,0.00118446,0.00141565,0.00147755,0.00121232,0.000983591,0.000728666,3.83441e-05, +2.5 - 3.05,0.0045098,-0.000170466,0.00223711,-0.000217351,0.000311907,0.00141577,0.00192495,0.00167667,0.00086599,0.00105772,0.00121232,0.00113782,0.000908834,0.000598345,3.5817e-05, +3.05 - 3.7,0.00489919,5.01063e-05,0.00145966,-0.000191913,0.000291891,0.00141995,0.00171833,0.00150583,0.000803867,0.000889806,0.000983591,0.000908834,0.000785333,0.00054569,3.13078e-05, +3.7 - 4.9,0.00284122,-0.00381255,-0.00184619,-0.000276302,3.31879e-05,0.000610231,0.000229897,0.00117289,0.000941821,0.000813253,0.000728666,0.000598345,0.00054569,0.000532446,2.31035e-05, +4.9 - 30,0.000221555,1.34856e-05,9.83175e-05,-1.12864e-05,6.77506e-06,6.83313e-05,7.38537e-05,6.39166e-05,3.49677e-05,3.54135e-05,3.83441e-05,3.5817e-05,3.13078e-05,2.31035e-05,1.44083e-06, + +Detector covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.2 - 0.3,0.302028,0.146038,0.170471,0.0770955,0.0911473,0.0517214,0.0430748,0.0174572,0.0133426,0.00287009,-0.00547128,-0.00653492,-0.00897133,-0.00692564,-0.000219706, +0.3 - 0.4,0.146038,0.171103,0.123454,0.0859711,0.0839735,0.0641544,0.042248,0.0225815,0.0172446,0.00855743,0.00154991,-0.00115564,-0.00297455,-0.00273835,-0.000164458, +0.4 - 0.5,0.170471,0.123454,0.162555,0.0745911,0.084284,0.0629723,0.0447375,0.0243183,0.0193014,0.00714513,0.000400831,-0.000716535,-0.00303826,-0.00255165,-6.30716e-05, +0.5 - 0.6,0.0770955,0.0859711,0.0745911,0.0913283,0.0660997,0.0476655,0.0338866,0.0224985,0.014133,0.00848431,0.0046904,0.00348734,0.00140094,-5.48002e-05,-0.000126251, +0.6 - 0.75,0.0911473,0.0839735,0.084284,0.0660997,0.066106,0.0462968,0.0314485,0.0212253,0.015238,0.00750409,0.00335246,0.00207651,1.33812e-05,-0.000484228,-5.3611e-05, +0.75 - 0.95,0.0517214,0.0641544,0.0629723,0.0476655,0.0462968,0.0407915,0.0261069,0.0185007,0.0139467,0.00747109,0.00443719,0.00318774,0.00172302,0.000867656,9.40904e-06, +0.95 - 1.15,0.0430748,0.042248,0.0447375,0.0338866,0.0314485,0.0261069,0.0212901,0.0136666,0.00922199,0.00465726,0.00259855,0.00183773,0.000882855,0.000336766,9.28469e-07, +1.15 - 1.4,0.0174572,0.0225815,0.0243183,0.0224985,0.0212253,0.0185007,0.0136666,0.0121596,0.00836021,0.00450195,0.00363201,0.00302994,0.00219293,0.00139295,4.80193e-05, +1.4 - 1.75,0.0133426,0.0172446,0.0193014,0.014133,0.015238,0.0139467,0.00922199,0.00836021,0.00672624,0.00361094,0.002814,0.00233282,0.00167289,0.00110971,4.76046e-05, +1.75 - 2.1,0.00287009,0.00855743,0.00714513,0.00848431,0.00750409,0.00747109,0.00465726,0.00450195,0.00361094,0.00244488,0.00205583,0.00158782,0.00124563,0.00081452,2.70765e-05, +2.1 - 2.5,-0.00547128,0.00154991,0.000400831,0.0046904,0.00335246,0.00443719,0.00259855,0.00363201,0.002814,0.00205583,0.00228681,0.00192058,0.00168553,0.00111872,3.84127e-05, +2.5 - 3.05,-0.00653492,-0.00115564,-0.000716535,0.00348734,0.00207651,0.00318774,0.00183773,0.00302994,0.00233282,0.00158782,0.00192058,0.0018518,0.00163032,0.0010751,3.75188e-05, +3.05 - 3.7,-0.00897133,-0.00297455,-0.00303826,0.00140094,1.33812e-05,0.00172302,0.000882855,0.00219293,0.00167289,0.00124563,0.00168553,0.00163032,0.0016016,0.00107019,3.68491e-05, +3.7 - 4.9,-0.00692564,-0.00273835,-0.00255165,-5.48002e-05,-0.000484228,0.000867656,0.000336766,0.00139295,0.00110971,0.00081452,0.00111872,0.0010751,0.00107019,0.000753928,2.93407e-05, +4.9 - 30,-0.000219706,-0.000164458,-6.30716e-05,-0.000126251,-5.3611e-05,9.40904e-06,9.28469e-07,4.80193e-05,4.76046e-05,2.70765e-05,3.84127e-05,3.75188e-05,3.68491e-05,2.93407e-05,1.86595e-06, diff --git a/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-MuPiCos.csv b/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-MuPiCos.csv new file mode 100644 index 0000000..a7e8133 --- /dev/null +++ b/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-MuPiCos.csv @@ -0,0 +1,69 @@ +cos #theta_{#mu, #pi} ,-1 - 0.15,0.15 - 0.25,0.25 - 0.4,0.4 - 0.5,0.5 - 0.6,0.6 - 0.7,0.7 - 0.8,0.8 - 0.9,0.9 - 1, +Cross-section (x10^{-40} cm^2/nucleon) ,0.831876,2.20197,2.80025,2.72983,3.37434,4.38678,5.92413,6.49835,5.39871, +Total uncertainty (x10^{-40} cm^2/nucleon) ,0.313028,1.31679,1.42395,1.94439,1.89345,1.97106,2.15786,2.49482,2.54384, + +Total covariance matrix (x10^{-40} cm^2/nucleon)^2 +-1 - 0.15,0.0979866,0.274387,0.281859,0.366445,0.356146,0.361017,0.406446,0.458509,0.411862, +0.15 - 0.25,0.274387,1.73394,1.30506,1.59708,1.4667,1.40771,1.46143,1.63457,1.5055, +0.25 - 0.4,0.281859,1.30506,2.02763,2.04199,1.80148,1.7364,1.8482,2.0962,1.88066, +0.4 - 0.5,0.366445,1.59708,2.04199,3.78064,2.84647,2.59852,2.66748,2.98897,2.85181, +0.5 - 0.6,0.356146,1.4667,1.80148,2.84647,3.58514,2.84135,2.79827,3.21364,3.08367, +0.6 - 0.7,0.361017,1.40771,1.7364,2.59852,2.84135,3.88507,3.28349,3.56828,3.49636, +0.7 - 0.8,0.406446,1.46143,1.8482,2.66748,2.79827,3.28349,4.65637,4.20313,3.97737, +0.8 - 0.9,0.458509,1.63457,2.0962,2.98897,3.21364,3.56828,4.20313,6.22415,4.95495, +0.9 - 1,0.411862,1.5055,1.88066,2.85181,3.08367,3.49636,3.97737,4.95495,6.47114, + +Statistical covariance matrix (x10^{-40} cm^2/nucleon)^2 +-1 - 0.15,0.0353557,0.0366747,0.00957142,0.0121726,0.00996652,0.0097827,0.0121651,0.00929814,0.0114284, +0.15 - 0.25,0.0366747,0.674202,0.133977,0.0362856,0.0261893,0.0394686,0.0248584,0.0124818,0.0377918, +0.25 - 0.4,0.00957142,0.133977,0.614614,0.156956,0.0668591,0.0455306,0.0479041,0.0786629,0.0186212, +0.4 - 0.5,0.0121726,0.0362856,0.156956,0.906544,0.278518,0.135077,0.144997,0.0934321,0.0930444, +0.5 - 0.6,0.00996652,0.0261893,0.0668591,0.278518,0.924188,0.31401,0.126361,0.0659929,0.0697498, +0.6 - 0.7,0.0097827,0.0394686,0.0455306,0.135077,0.31401,1.06099,0.279463,0.146784,0.151831, +0.7 - 0.8,0.0121651,0.0248584,0.0479041,0.144997,0.126361,0.279463,1.18374,0.260822,0.144059, +0.8 - 0.9,0.00929814,0.0124818,0.0786629,0.0934321,0.0659929,0.146784,0.260822,1.42325,0.28263, +0.9 - 1,0.0114284,0.0377918,0.0186212,0.0930444,0.0697498,0.151831,0.144059,0.28263,1.57251, + +Flux covariance matrix (x10^{-40} cm^2/nucleon)^2 +-1 - 0.15,0.029611,0.0943709,0.121205,0.131754,0.154627,0.179122,0.226764,0.256843,0.243322, +0.15 - 0.25,0.0943709,0.303355,0.388903,0.420041,0.490942,0.563525,0.709913,0.799239,0.75138, +0.25 - 0.4,0.121205,0.388903,0.500098,0.545182,0.638001,0.735938,0.928917,1.04972,0.992804, +0.4 - 0.5,0.131754,0.420041,0.545182,0.617922,0.724461,0.851967,1.08143,1.24129,1.19994, +0.5 - 0.6,0.154627,0.490942,0.638001,0.724461,0.852416,1.00581,1.27977,1.47237,1.42792, +0.6 - 0.7,0.179122,0.563525,0.735938,0.851967,1.00581,1.20467,1.54123,1.78848,1.75242, +0.7 - 0.8,0.226764,0.709913,0.928917,1.08143,1.27977,1.54123,1.97734,2.3014,2.26381, +0.8 - 0.9,0.256843,0.799239,1.04972,1.24129,1.47237,1.78848,2.3014,2.6979,2.67683, +0.9 - 1,0.243322,0.75138,0.992804,1.19994,1.42792,1.75242,2.26381,2.67683,2.68842, + +Theory cross-section covariance matrix (x10^{-40} cm^2/nucleon)^2 +-1 - 0.15,0.0241014,0.121734,0.131268,0.200667,0.177673,0.159112,0.144282,0.158254,0.149447, +0.15 - 0.25,0.121734,0.67221,0.715707,1.08201,0.91239,0.766732,0.672343,0.726664,0.676276, +0.25 - 0.4,0.131268,0.715707,0.818939,1.24184,1.00689,0.879208,0.797483,0.829597,0.787725, +0.4 - 0.5,0.200667,1.08201,1.24184,2.05799,1.63889,1.4923,1.31916,1.39857,1.33933, +0.5 - 0.6,0.177673,0.91239,1.00689,1.63889,1.51686,1.38328,1.27669,1.41456,1.33883, +0.6 - 0.7,0.159112,0.766732,0.879208,1.4923,1.38328,1.36525,1.30101,1.44446,1.39989, +0.7 - 0.8,0.144282,0.672343,0.797483,1.31916,1.27669,1.30101,1.30675,1.44526,1.41855, +0.8 - 0.9,0.158254,0.726664,0.829597,1.39857,1.41456,1.44446,1.44526,1.64604,1.63026, +0.9 - 1,0.149447,0.676276,0.787725,1.33933,1.33883,1.39989,1.41855,1.63026,1.67592, + +FSI covariance matrix (x10^{-40} cm^2/nucleon)^2 +-1 - 0.15,0.00115454,0.00223117,0.00304235,0.00333953,-0.000940044,0.000936132,0.00300322,0.00649101,0.00512684, +0.15 - 0.25,0.00223117,0.0206758,0.0123977,0.00184128,-0.00955669,-0.00535513,-0.0069231,0.0121968,0.0171346, +0.25 - 0.4,0.00304235,0.0123977,0.0318681,0.0356002,0.0317911,0.0152953,0.00514136,0.0433829,0.0426215, +0.4 - 0.5,0.00333953,0.00184128,0.0356002,0.105363,0.116008,0.0213565,0.0256648,0.120583,0.135885, +0.5 - 0.6,-0.000940044,-0.00955669,0.0317911,0.116008,0.175393,0.0163566,0.0138829,0.135485,0.14357, +0.6 - 0.7,0.000936132,-0.00535513,0.0152953,0.0213565,0.0163566,0.0843067,0.038392,0.0185867,0.0186472, +0.7 - 0.8,0.00300322,-0.0069231,0.00514136,0.0256648,0.0138829,0.038392,0.0522696,0.0317496,0.01793, +0.8 - 0.9,0.00649101,0.0121968,0.0433829,0.120583,0.135485,0.0185867,0.0317496,0.179526,0.180939, +0.9 - 1,0.00512684,0.0171346,0.0426215,0.135885,0.14357,0.0186472,0.01793,0.180939,0.246604, + +Detector covariance matrix (x10^{-40} cm^2/nucleon)^2 +-1 - 0.15,0.00776392,0.0193755,0.0167715,0.0185126,0.0148194,0.0120646,0.020232,0.0276217,0.00253803, +0.15 - 0.25,0.0193755,0.0635016,0.0540767,0.0569062,0.046739,0.0433365,0.061236,0.0839911,0.0229146, +0.25 - 0.4,0.0167715,0.0540767,0.0621138,0.0624098,0.057941,0.0604251,0.0687521,0.0948356,0.038891, +0.4 - 0.5,0.0185126,0.0569062,0.0624098,0.0928281,0.0885964,0.0978212,0.0962318,0.13509,0.0836054, +0.5 - 0.6,0.0148194,0.046739,0.057941,0.0885964,0.116287,0.121885,0.101569,0.125236,0.103605, +0.6 - 0.7,0.0120646,0.0433365,0.0604251,0.0978212,0.121885,0.169852,0.123388,0.169958,0.173569, +0.7 - 0.8,0.020232,0.061236,0.0687521,0.0962318,0.101569,0.123388,0.136268,0.163904,0.133021, +0.8 - 0.9,0.0276217,0.0839911,0.0948356,0.13509,0.125236,0.169958,0.163904,0.277434,0.184295, +0.9 - 1,0.00253803,0.0229146,0.038891,0.0836054,0.103605,0.173569,0.133021,0.184295,0.287675, diff --git a/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-PosPionCos.csv b/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-PosPionCos.csv new file mode 100644 index 0000000..7094b9d --- /dev/null +++ b/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-PosPionCos.csv @@ -0,0 +1,99 @@ +cos #theta_{#pi} ,0.3 - 0.57,0.57 - 0.68,0.68 - 0.75,0.75 - 0.79,0.79 - 0.83,0.83 - 0.86,0.86 - 0.89,0.89 - 0.91,0.91 - 0.93,0.93 - 0.95,0.95 - 0.97,0.97 - 0.98,0.98 - 0.99,0.99 - 1, +Cross-section (x10^{-40} cm^2/nucleon) ,3.75898,4.41144,6.61454,6.10742,8.25426,9.59524,11.2173,10.9576,10.85,12.9896,9.22953,6.47101,16.0661,17.7185, +Total uncertainty (x10^{-40} cm^2/nucleon) ,1.51153,1.94123,2.7424,2.59101,3.19936,3.55985,4.15182,4.42377,5.03002,5.64086,5.49408,6.69312,9.55249,12.9048, + +Total covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.3 - 0.57,2.28472,2.14364,2.91724,2.57577,3.22937,3.45342,4.14768,4.28718,4.94703,5.37834,4.67523,5.53363,7.7741,9.70198, +0.57 - 0.68,2.14364,3.76835,4.03346,3.38354,4.14068,4.38673,5.22834,5.30977,6.11439,6.73776,5.66985,6.4973,9.64431,11.715, +0.68 - 0.75,2.91724,4.03346,7.52075,5.4836,6.28002,6.65569,7.65351,7.72572,9.1367,9.8909,8.54003,9.88068,14.5343,16.8967, +0.75 - 0.79,2.57577,3.38354,5.4836,6.71333,6.58513,6.03283,7.00306,7.27464,8.40766,9.29401,8.13632,9.45438,13.2538,16.0406, +0.79 - 0.83,3.22937,4.14068,6.28002,6.58513,10.2359,8.65526,9.21537,9.37644,10.7709,11.8707,10.9248,12.0727,17.334,22.1115, +0.83 - 0.86,3.45342,4.38673,6.65569,6.03283,8.65526,12.6726,11.0795,10.142,11.623,13.2853,11.7112,12.8211,19.3628,23.9791, +0.86 - 0.89,4.14768,5.22834,7.65351,7.00306,9.21537,11.0795,17.2376,14.1618,14.3979,15.5723,13.9843,15.8568,23.2633,29.4053, +0.89 - 0.91,4.28718,5.30977,7.72572,7.27464,9.37644,10.142,14.1618,19.5697,17.3231,16.2947,14.7041,16.5392,24.6091,31.615, +0.91 - 0.93,4.94703,6.11439,9.1367,8.40766,10.7709,11.623,14.3979,17.3231,25.3011,22.0157,17.6816,20.2511,29.9288,37.6494, +0.93 - 0.95,5.37834,6.73776,9.8909,9.29401,11.8707,13.2853,15.5723,16.2947,22.0157,31.8193,22.0333,22.9884,33.824,42.6513, +0.95 - 0.97,4.67523,5.66985,8.54003,8.13632,10.9248,11.7112,13.9843,14.7041,17.6816,22.0333,30.1849,25.6606,31.5316,40.4982, +0.97 - 0.98,5.53363,6.4973,9.88068,9.45438,12.0727,12.8211,15.8568,16.5392,20.2511,22.9884,25.6606,44.7978,43.7194,46.6712, +0.98 - 0.99,7.7741,9.64431,14.5343,13.2538,17.334,19.3628,23.2633,24.6091,29.9288,33.824,31.5316,43.7194,91.2501,77.4593, +0.99 - 1,9.70198,11.715,16.8967,16.0406,22.1115,23.9791,29.4053,31.615,37.6494,42.6513,40.4982,46.6712,77.4593,166.533, + +Statistical covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.3 - 0.57,0.770501,0.259454,0.129831,0.106977,0.157137,0.15525,0.232187,0.206328,0.19362,0.129825,0.0510722,0.248918,0.274093,0.29823, +0.57 - 0.68,0.259454,1.2459,0.437419,0.212844,0.191483,0.222903,0.305452,0.180864,0.259971,0.283525,0.093896,0.192023,0.334386,0.329178, +0.68 - 0.75,0.129831,0.437419,2.06299,0.734828,0.377953,0.322825,0.253143,0.0861096,0.209947,0.08939,0.133424,0.432213,0.840718,0.378175, +0.75 - 0.79,0.106977,0.212844,0.734828,2.37279,1.18217,0.347899,0.254285,0.287831,0.313134,0.309252,0.312609,0.596922,0.566698,0.569188, +0.79 - 0.83,0.157137,0.191483,0.377953,1.18217,3.15774,1.27723,0.451071,0.346499,0.266225,0.256989,0.611696,0.505801,0.538071,0.560318, +0.83 - 0.86,0.15525,0.222903,0.322825,0.347899,1.27723,4.27867,1.62087,0.48966,0.333045,0.423339,0.458448,0.43685,0.624068,0.535542, +0.86 - 0.89,0.232187,0.305452,0.253143,0.254285,0.451071,1.62087,5.63698,2.34049,0.742333,0.259192,0.434588,0.51196,0.582641,0.896642, +0.89 - 0.91,0.206328,0.180864,0.0861096,0.287831,0.346499,0.48966,2.34049,7.1074,3.01973,0.457009,0.541902,0.415387,0.751789,1.76445, +0.91 - 0.93,0.19362,0.259971,0.209947,0.313134,0.266225,0.333045,0.742333,3.01973,7.58496,3.05383,0.803548,0.931935,1.88123,1.57084, +0.93 - 0.95,0.129825,0.283525,0.08939,0.309252,0.256989,0.423339,0.259192,0.457009,3.05383,10.1492,2.88758,1.5905,1.91252,1.46949, +0.95 - 0.97,0.0510722,0.093896,0.133424,0.312609,0.611696,0.458448,0.434588,0.541902,0.803548,2.88758,11.1868,5.19552,2.87693,0.897222, +0.97 - 0.98,0.248918,0.192023,0.432213,0.596922,0.505801,0.43685,0.51196,0.415387,0.931935,1.5905,5.19552,19.3052,9.92481,2.91975, +0.98 - 0.99,0.274093,0.334386,0.840718,0.566698,0.538071,0.624068,0.582641,0.751789,1.88123,1.91252,2.87693,9.92481,37.1826,10.6523, +0.99 - 1,0.29823,0.329178,0.378175,0.569188,0.560318,0.535542,0.896642,1.76445,1.57084,1.46949,0.897222,2.91975,10.6523,62.0828, + +Flux covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.3 - 0.57,0.651443,0.779696,1.15672,1.10865,1.49106,1.69305,2.04525,2.08786,2.28301,2.74388,2.37091,2.45641,4.08239,5.31121, +0.57 - 0.68,0.779696,0.933555,1.38454,1.32706,1.78528,2.02702,2.44983,2.50074,2.73374,3.28614,2.83934,2.94153,4.8937,6.37123, +0.68 - 0.75,1.15672,1.38454,2.05907,1.97496,2.65246,3.01297,3.63196,3.7026,4.04945,4.86236,4.1918,4.31602,7.17694,9.28248, +0.75 - 0.79,1.10865,1.32706,1.97496,1.89614,2.54637,2.89211,3.48215,3.54787,3.87894,4.65912,4.01259,4.12046,6.85674,8.85393, +0.79 - 0.83,1.49106,1.78528,2.65246,2.54637,3.42534,3.88912,4.68718,4.7783,5.22118,6.27721,5.41024,5.56919,9.28362,12.034, +0.83 - 0.86,1.69305,2.02702,3.01297,2.89211,3.88912,4.41743,5.32242,5.42558,5.92963,7.12591,6.13905,6.31444,10.5285,13.6297, +0.86 - 0.89,2.04525,2.44983,3.63196,3.48215,4.68718,5.32242,6.43701,6.5724,7.18031,8.63386,7.45949,7.73063,12.8888,16.7997, +0.89 - 0.91,2.08786,2.50074,3.7026,3.54787,4.7783,5.42558,6.5724,6.72098,7.34516,8.83474,7.65102,7.97833,13.2751,17.3766, +0.91 - 0.93,2.28301,2.73374,4.04945,3.87894,5.22118,5.92963,7.18031,7.34516,8.03827,9.66352,8.3768,8.7548,14.5168,18.9986, +0.93 - 0.95,2.74388,3.28614,4.86236,4.65912,6.27721,7.12591,8.63386,8.83474,9.66352,11.6289,10.0859,10.5578,17.5184,22.9857, +0.95 - 0.97,2.37091,2.83934,4.1918,4.01259,5.41024,6.13905,7.45949,7.65102,8.3768,10.0859,8.78682,9.29599,15.352,20.2897, +0.97 - 0.98,2.45641,2.94153,4.31602,4.12046,5.56919,6.31444,7.73063,7.97833,8.7548,10.5578,9.29599,10.0959,16.5094,22.2093, +0.98 - 0.99,4.08239,4.8937,7.17694,6.85674,9.28362,10.5285,12.8888,13.2751,14.5168,17.5184,15.352,16.5094,27.3199,36.6557, +0.99 - 1,5.31121,6.37123,9.28248,8.85393,12.034,13.6297,16.7997,17.3766,18.9986,22.9857,20.2897,22.2093,36.6557,49.9373, + +Theory cross-section covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.3 - 0.57,0.690363,0.96463,1.3914,1.13203,1.41424,1.40247,1.67346,1.78088,2.14715,2.1623,2.0125,2.43778,3.20983,3.92997, +0.57 - 0.68,0.96463,1.38985,1.97547,1.59252,1.99123,1.95026,2.26649,2.40407,2.86486,2.86676,2.61316,3.13458,4.1068,5.12796, +0.68 - 0.75,1.3914,1.97547,2.89289,2.35505,2.97363,2.95118,3.41366,3.62587,4.40271,4.38853,4.00171,4.76412,6.4214,7.83111, +0.75 - 0.79,1.13203,1.59252,2.35505,1.96153,2.48845,2.45925,2.87772,3.04121,3.69142,3.7081,3.42199,4.07894,5.37116,6.51521, +0.79 - 0.83,1.41424,1.99123,2.97363,2.48845,3.19697,3.18961,3.68967,3.89969,4.75347,4.77228,4.37715,5.15784,6.92175,8.37799, +0.83 - 0.86,1.40247,1.95026,2.95118,2.45925,3.18961,3.45461,3.76207,3.9413,4.96571,5.18846,4.65495,5.39551,7.79957,9.55216, +0.86 - 0.89,1.67346,2.26649,3.41366,2.87772,3.68967,3.76207,4.55755,4.80104,5.88588,6.00964,5.6649,6.81696,9.10676,10.9072, +0.89 - 0.91,1.78088,2.40407,3.62587,3.04121,3.89969,3.9413,4.80104,5.15379,6.26503,6.32545,5.96643,7.2615,9.72179,11.599, +0.91 - 0.93,2.14715,2.86486,4.40271,3.69142,4.75347,4.96571,5.88588,6.26503,7.91005,8.06154,7.57298,9.02624,12.5508,14.8009, +0.93 - 0.95,2.1623,2.86676,4.38853,3.7081,4.77228,5.18846,6.00964,6.32545,8.06154,8.51418,7.94509,9.44836,13.2926,15.951, +0.95 - 0.97,2.0125,2.61316,4.00171,3.42199,4.37715,4.65495,5.6649,5.96643,7.57298,7.94509,7.64399,9.22048,12.4647,14.7711, +0.97 - 0.98,2.43778,3.13458,4.76412,4.07894,5.15784,5.39551,6.81696,7.2615,9.02624,9.44836,9.22048,11.5946,15.03,17.7902, +0.98 - 0.99,3.20983,4.1068,6.4214,5.37116,6.92175,7.79957,9.10676,9.72179,12.5508,13.2926,12.4647,15.03,21.9753,26.1092, +0.99 - 1,3.92997,5.12796,7.83111,6.51521,8.37799,9.55216,10.9072,11.599,14.8009,15.951,14.7711,17.7902,26.1092,31.8108, + +FSI covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.3 - 0.57,0.0597428,0.0408611,0.0743962,0.0643375,0.0420381,0.0692942,0.048407,0.0480138,0.0928961,0.146632,0.167866,0.0373467,-0.000886219,0.499352, +0.57 - 0.68,0.0408611,0.0517463,0.056451,0.0544142,0.0127988,0.0373651,0.0298416,0.0189707,0.0123498,0.0761491,0.031391,-0.0559868,-0.0195885,0.16291, +0.68 - 0.75,0.0743962,0.056451,0.143048,0.0942895,0.0471971,0.135296,0.0711391,0.0310884,0.102425,0.197049,0.100358,-0.0263065,-0.019497,0.27725, +0.75 - 0.79,0.0643375,0.0544142,0.0942895,0.123764,0.0899617,0.0742885,0.0694207,0.0488169,0.0704215,0.184593,0.204283,0.0910346,0.0312629,0.536103, +0.79 - 0.83,0.0420381,0.0127988,0.0471971,0.0899617,0.192135,0.0701159,0.112046,0.0614687,0.176175,0.217324,0.362713,0.372325,0.126858,1.14296, +0.83 - 0.86,0.0692942,0.0373651,0.135296,0.0742885,0.0701159,0.251219,0.0762224,0.00608293,0.0494223,0.192757,0.290081,0.15655,-0.102415,0.154278, +0.86 - 0.89,0.048407,0.0298416,0.0711391,0.0694207,0.112046,0.0762224,0.144193,0.0447327,0.131069,0.198445,0.182627,0.145351,0.0903902,0.666762, +0.89 - 0.91,0.0480138,0.0189707,0.0310884,0.0488169,0.0614687,0.00608293,0.0447327,0.104757,0.148052,0.162666,0.255723,0.137698,0.0857401,0.81816, +0.91 - 0.93,0.0928961,0.0123498,0.102425,0.0704215,0.176175,0.0494223,0.131069,0.148052,0.966495,0.517853,0.56909,0.479587,0.0905317,2.36044, +0.93 - 0.95,0.146632,0.0761491,0.197049,0.184593,0.217324,0.192757,0.198445,0.162666,0.517853,0.663966,0.660992,0.435307,0.0669563,1.92993, +0.95 - 0.97,0.167866,0.031391,0.100358,0.204283,0.362713,0.290081,0.182627,0.255723,0.56909,0.660992,2.17969,1.37289,-0.0113998,3.88382, +0.97 - 0.98,0.0373467,-0.0559868,-0.0263065,0.0910346,0.372325,0.15655,0.145351,0.137698,0.479587,0.435307,1.37289,1.59204,0.34697,3.09139, +0.98 - 0.99,-0.000886219,-0.0195885,-0.019497,0.0312629,0.126858,-0.102415,0.0903902,0.0857401,0.0905317,0.0669563,-0.0113998,0.34697,1.21253,1.05994, +0.99 - 1,0.499352,0.16291,0.27725,0.536103,1.14296,0.154278,0.666762,0.81816,2.36044,1.92993,3.88382,3.09139,1.05994,14.4215, + +Detector covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.3 - 0.57,0.112675,0.0990013,0.164885,0.16378,0.124891,0.133346,0.148384,0.164097,0.230355,0.195701,0.0728885,0.353175,0.208677,-0.336775, +0.57 - 0.68,0.0990013,0.147303,0.179576,0.1967,0.159884,0.149182,0.176732,0.205123,0.243471,0.225191,0.0920582,0.285155,0.329011,-0.276254, +0.68 - 0.75,0.164885,0.179576,0.362738,0.324477,0.228783,0.233424,0.283602,0.28005,0.372175,0.353573,0.112743,0.394637,0.114732,-0.872351, +0.75 - 0.79,0.16378,0.1967,0.324477,0.359116,0.278183,0.259283,0.319483,0.348914,0.453751,0.432937,0.184847,0.56703,0.427946,-0.433819, +0.79 - 0.83,0.124891,0.159884,0.228783,0.278183,0.263681,0.229191,0.275399,0.290484,0.353801,0.34687,0.163025,0.467578,0.463739,-0.00373126, +0.83 - 0.86,0.133346,0.149182,0.233424,0.259283,0.229191,0.270634,0.297935,0.27936,0.345195,0.354786,0.168643,0.517766,0.513073,0.107337, +0.86 - 0.89,0.148384,0.176732,0.283602,0.319483,0.275399,0.297935,0.461857,0.403094,0.45833,0.471161,0.242687,0.651924,0.59469,0.135051, +0.89 - 0.91,0.164097,0.205123,0.28005,0.348914,0.290484,0.27936,0.403094,0.482794,0.545096,0.514804,0.289032,0.746303,0.774652,0.0568009, +0.91 - 0.93,0.230355,0.243471,0.372175,0.453751,0.353801,0.345195,0.45833,0.545096,0.801279,0.718929,0.359142,1.05855,0.88939,-0.0812549, +0.93 - 0.95,0.195701,0.225191,0.353573,0.432937,0.34687,0.354786,0.471161,0.514804,0.718929,0.863145,0.453805,0.956451,1.03345,0.315237, +0.95 - 0.97,0.0728885,0.0920582,0.112743,0.184847,0.163025,0.168643,0.242687,0.289032,0.359142,0.453805,0.387677,0.575761,0.849428,0.656356, +0.97 - 0.98,0.353175,0.285155,0.394637,0.56703,0.467578,0.517766,0.651924,0.746303,1.05855,0.956451,0.575761,2.21014,1.90825,0.6606, +0.98 - 0.99,0.208677,0.329011,0.114732,0.427946,0.463739,0.513073,0.59469,0.774652,0.88939,1.03345,0.849428,1.90825,3.55973,2.98213, +0.99 - 1,-0.336775,-0.276254,-0.872351,-0.433819,-0.00373126,0.107337,0.135051,0.0568009,-0.0812549,0.315237,0.656356,0.6606,2.98213,8.28047, diff --git a/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-PosPionMom.csv b/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-PosPionMom.csv new file mode 100644 index 0000000..8dfbdbb --- /dev/null +++ b/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-PosPionMom.csv @@ -0,0 +1,81 @@ +p_{#pi} / GeV,0.2 - 0.3,0.3 - 0.35,0.35 - 0.4,0.4 - 0.5,0.5 - 0.6,0.6 - 0.7,0.7 - 0.85,0.85 - 1.1,1.1 - 1.4,1.4 - 1.85,1.85 - 30, +Cross-section (x10^{-40} cm^2/nucleon) ,15.5198,10.5405,6.9743,5.64417,2.18121,1.89273,1.89662,1.82126,0.975227,0.327762,-0.00151933, +Total uncertainty (x10^{-40} cm^2/nucleon) ,4.39636,3.4865,2.54191,1.84612,1.02185,0.891946,0.850967,0.755682,0.561903,0.562197,0.00478422, + +Total covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.2 - 0.3,19.3279,13.0228,7.88526,5.64588,2.01762,1.7779,1.75863,1.85486,1.19514,0.954796,0.00363868, +0.3 - 0.35,13.0228,12.1557,7.3547,4.64695,1.71825,1.45709,1.3712,1.39409,0.841429,0.632875,0.00276086, +0.35 - 0.4,7.88526,7.3547,6.46132,3.5759,1.26354,1.01057,0.925939,0.920147,0.552107,0.405106,0.00177347, +0.4 - 0.5,5.64588,4.64695,3.5759,3.40815,1.28267,0.940167,0.849881,0.794,0.520606,0.418085,0.00175337, +0.5 - 0.6,2.01762,1.71825,1.26354,1.28267,1.04418,0.689936,0.498525,0.395818,0.26123,0.227262,0.0011108, +0.6 - 0.7,1.7779,1.45709,1.01057,0.940167,0.689936,0.795568,0.592087,0.43943,0.273583,0.215854,0.000716399, +0.7 - 0.85,1.75863,1.3712,0.925939,0.849881,0.498525,0.592087,0.724145,0.530176,0.327818,0.254802,0.000533009, +0.85 - 1.1,1.85486,1.39409,0.920147,0.794,0.395818,0.43943,0.530176,0.571056,0.350144,0.268583,0.000572176, +1.1 - 1.4,1.19514,0.841429,0.552107,0.520606,0.26123,0.273583,0.327818,0.350144,0.315735,0.273236,0.000747932, +1.4 - 1.85,0.954796,0.632875,0.405106,0.418085,0.227262,0.215854,0.254802,0.268583,0.273236,0.316065,0.0012426, +1.85 - 30,0.00363868,0.00276086,0.00177347,0.00175337,0.0011108,0.000716399,0.000533009,0.000572176,0.000747932,0.0012426,2.28888e-05, + +Statistical covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.2 - 0.3,4.75001,1.94362,0.402706,0.198204,0.0532706,0.045148,0.0175615,0.0227826,0.00918063,0.00802053,0.000332032, +0.3 - 0.35,1.94362,2.79322,1.20265,0.229318,0.0711387,0.0715466,0.0387607,0.0309189,0.0112315,0.0118603,0.000380173, +0.35 - 0.4,0.402706,1.20265,2.125,0.514517,0.127252,0.0610375,0.0265231,0.0281432,0.0184767,0.0132239,0.000277254, +0.4 - 0.5,0.198204,0.229318,0.514517,1.03828,0.309161,0.110443,0.0477411,0.0213846,0.016142,0.00709354,9.67627e-05, +0.5 - 0.6,0.0532706,0.0711387,0.127252,0.309161,0.459051,0.210634,0.0671866,0.0232071,0.00655847,0.00271881,4.30183e-05, +0.6 - 0.7,0.045148,0.0715466,0.0610375,0.110443,0.210634,0.32631,0.131373,0.0357384,0.00765805,0.0029561,0.000112132, +0.7 - 0.85,0.0175615,0.0387607,0.0265231,0.0477411,0.0671866,0.131373,0.211507,0.0638991,0.012509,0.00345472,0.000111284, +0.85 - 1.1,0.0227826,0.0309189,0.0281432,0.0213846,0.0232071,0.0357384,0.0638991,0.105574,0.0263812,0.00511999,0.000135072, +1.1 - 1.4,0.00918063,0.0112315,0.0184767,0.016142,0.00655847,0.00765805,0.012509,0.0263812,0.0417532,0.0114241,5.12137e-05, +1.4 - 1.85,0.00802053,0.0118603,0.0132239,0.00709354,0.00271881,0.0029561,0.00345472,0.00511999,0.0114241,0.0176131,9.59791e-05, +1.85 - 30,0.000332032,0.000380173,0.000277254,9.67627e-05,4.30183e-05,0.000112132,0.000111284,0.000135072,5.12137e-05,9.59791e-05,2.5981e-06, + +Flux covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.2 - 0.3,8.51255,5.94331,4.07286,3.26846,1.46027,1.30768,1.31032,1.26582,0.824347,0.600006,0.00158933, +0.3 - 0.35,5.94331,4.16759,2.86947,2.28813,1.02219,0.911053,0.905995,0.870174,0.562389,0.401629,0.000995166, +0.35 - 0.4,4.07286,2.86947,1.99154,1.57695,0.706056,0.626028,0.616222,0.587146,0.375755,0.26195,0.000586481, +0.4 - 0.5,3.26846,2.28813,1.57695,1.26654,0.567797,0.508183,0.507375,0.487693,0.31553,0.22661,0.00056763, +0.5 - 0.6,1.46027,1.02219,0.706056,0.567797,0.255879,0.22914,0.228626,0.2193,0.142185,0.102691,0.000258965, +0.6 - 0.7,1.30768,0.911053,0.626028,0.508183,0.22914,0.206642,0.208221,0.200936,0.131292,0.0966203,0.000260637, +0.7 - 0.85,1.31032,0.905995,0.616222,0.507375,0.228626,0.208221,0.213239,0.207932,0.137612,0.104289,0.000309039, +0.85 - 1.1,1.26582,0.870174,0.587146,0.487693,0.2193,0.200936,0.207932,0.204451,0.136449,0.105433,0.000331454, +1.1 - 1.4,0.824347,0.562389,0.375755,0.31553,0.142185,0.131292,0.137612,0.136449,0.0924079,0.0735821,0.000249176, +1.4 - 1.85,0.600006,0.401629,0.26195,0.22661,0.102691,0.0966203,0.104289,0.105433,0.0735821,0.0622672,0.000239782, +1.85 - 30,0.00158933,0.000995166,0.000586481,0.00056763,0.000258965,0.000260637,0.000309039,0.000331454,0.000249176,0.000239782,2.67386e-07, + +Theory cross-section covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.2 - 0.3,3.38624,3.29543,2.13616,1.65185,0.727809,0.654712,0.63408,0.612455,0.441027,0.435121,0.00152907, +0.3 - 0.35,3.29543,3.59026,2.23424,1.66946,0.676545,0.590887,0.550291,0.518158,0.318571,0.282685,0.00107859, +0.35 - 0.4,2.13616,2.23424,1.44682,1.07044,0.460883,0.404895,0.369162,0.342081,0.200338,0.171149,0.000619175, +0.4 - 0.5,1.65185,1.66946,1.07044,0.829417,0.359087,0.319142,0.307385,0.292649,0.202895,0.196476,0.000709644, +0.5 - 0.6,0.727809,0.676545,0.460883,0.359087,0.188923,0.16445,0.156426,0.145808,0.101138,0.101251,0.000367472, +0.6 - 0.7,0.654712,0.590887,0.404895,0.319142,0.16445,0.147373,0.142483,0.134907,0.0975526,0.0991861,0.000347875, +0.7 - 0.85,0.63408,0.550291,0.369162,0.307385,0.156426,0.142483,0.148535,0.14665,0.121065,0.131965,0.000464307, +0.85 - 1.1,0.612455,0.518158,0.342081,0.292649,0.145808,0.134907,0.14665,0.149925,0.131912,0.148414,0.00051521, +1.1 - 1.4,0.441027,0.318571,0.200338,0.202895,0.101138,0.0975526,0.121065,0.131912,0.146221,0.177191,0.000619736, +1.4 - 1.85,0.435121,0.282685,0.171149,0.196476,0.101251,0.0991861,0.131965,0.148414,0.177191,0.222181,0.000778792, +1.85 - 30,0.00152907,0.00107859,0.000619175,0.000709644,0.000367472,0.000347875,0.000464307,0.00051521,0.000619736,0.000778792,6.531e-07, + +FSI covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.2 - 0.3,2.25732,1.62501,1.12099,0.430341,-0.268135,-0.250856,-0.172411,-0.00650149,-0.0466394,-0.08587,-0.000493789, +0.3 - 0.35,1.62501,1.26187,0.809208,0.322562,-0.166667,-0.155907,-0.106294,0.019573,-0.0218633,-0.0665245,-0.000359448, +0.35 - 0.4,1.12099,0.809208,0.635641,0.243656,-0.131807,-0.129364,-0.0880272,-0.00431944,-0.0181348,-0.0376385,-0.00019323, +0.4 - 0.5,0.430341,0.322562,0.243656,0.110607,-0.0356861,-0.0382169,-0.0219011,0.00927292,-0.00139646,-0.00973678,-1.76684e-05, +0.5 - 0.6,-0.268135,-0.166667,-0.131807,-0.0356861,0.0549826,0.0453545,0.0319715,0.0118147,0.010411,0.0121011,9.3148e-05, +0.6 - 0.7,-0.250856,-0.155907,-0.129364,-0.0382169,0.0453545,0.0436986,0.0317316,0.0127467,0.0108453,0.0119964,9.29192e-05, +0.7 - 0.85,-0.172411,-0.106294,-0.0880272,-0.0219011,0.0319715,0.0317316,0.0296204,0.0154142,0.0103146,0.0103814,9.08959e-05, +0.85 - 1.1,-0.00650149,0.019573,-0.00431944,0.00927292,0.0118147,0.0127467,0.0154142,0.020002,0.00877014,0.00394688,5.09451e-05, +1.1 - 1.4,-0.0466394,-0.0218633,-0.0181348,-0.00139646,0.010411,0.0108453,0.0103146,0.00877014,0.00644057,0.0045935,4.6124e-05, +1.4 - 1.85,-0.08587,-0.0665245,-0.0376385,-0.00973678,0.0121011,0.0119964,0.0103814,0.00394688,0.0045935,0.00866186,6.51304e-05, +1.85 - 30,-0.000493789,-0.000359448,-0.00019323,-1.76684e-05,9.3148e-05,9.29192e-05,9.08959e-05,5.09451e-05,4.6124e-05,6.51304e-05,1.38416e-07, + +Detector covariance matrix (x10^{-40} cm^2/nucleon)^2 +0.2 - 0.3,0.421829,0.215406,0.152535,0.0970178,0.0444076,0.0212123,-0.0309198,-0.0396978,-0.0327722,-0.00248106,0.000682042, +0.3 - 0.35,0.215406,0.342744,0.239137,0.137471,0.115043,0.0395092,-0.0175521,-0.0447361,-0.0288989,0.00322537,0.000666379, +0.35 - 0.4,0.152535,0.239137,0.262325,0.170331,0.101158,0.0479773,0.00205884,-0.0329042,-0.024328,-0.00357834,0.000483785, +0.4 - 0.5,0.0970178,0.137471,0.170331,0.163314,0.082311,0.0406164,0.00928116,-0.0169996,-0.0125654,-0.00235878,0.000397006, +0.5 - 0.6,0.0444076,0.115043,0.101158,0.082311,0.0853424,0.0403584,0.0143145,-0.00431139,0.000937211,0.00850001,0.000348197, +0.6 - 0.7,0.0212123,0.0395092,0.0479773,0.0406164,0.0403584,0.0715451,0.0782779,0.0551018,0.0262352,0.00509561,-9.71642e-05, +0.7 - 0.85,-0.0309198,-0.0175521,0.00205884,0.00928116,0.0143145,0.0782779,0.121243,0.0962801,0.0463171,0.00471166,-0.000442518, +0.85 - 1.1,-0.0396978,-0.0447361,-0.0329042,-0.0169996,-0.00431139,0.0551018,0.0962801,0.0911039,0.0466321,0.00566874,-0.000460506, +1.1 - 1.4,-0.0327722,-0.0288989,-0.024328,-0.0125654,0.000937211,0.0262352,0.0463171,0.0466321,0.0289123,0.00644496,-0.000218318, +1.4 - 1.85,-0.00248106,0.00322537,-0.00357834,-0.00235878,0.00850001,0.00509561,0.00471166,0.00566874,0.00644496,0.0053422,6.29131e-05, +1.85 - 30,0.000682042,0.000666379,0.000483785,0.000397006,0.000348197,-9.71642e-05,-0.000442518,-0.000460506,-0.000218318,6.29131e-05,1.62657e-06, diff --git a/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-flux.csv b/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-flux.csv new file mode 100644 index 0000000..12ccb0a --- /dev/null +++ b/data/T2K/CC1pip/H2O/raw/nd280data-numu-cc1pi-xs-on-h2o-2015-flux.csv @@ -0,0 +1,205 @@ +This flux is only valid for the T2K 2015 numu CC analyses. + Do not use this flux for any other analysis! + +numu energy (GeV),Flux (x10^9/cm^2/50 MeV/10^21 POT) +0 - 0.05,17.3236 +0.05 - 0.1,70.5838 +0.1 - 0.15,136.54 +0.15 - 0.2,213.195 +0.2 - 0.25,330.754 +0.25 - 0.3,496.546 +0.3 - 0.35,710.158 +0.35 - 0.4,937.42 +0.4 - 0.45,1189.63 +0.45 - 0.5,1485.69 +0.5 - 0.55,1676.95 +0.55 - 0.6,1702.39 +0.6 - 0.65,1594.87 +0.65 - 0.7,1448 +0.7 - 0.75,1231.48 +0.75 - 0.8,990.102 +0.8 - 0.85,743.135 +0.85 - 0.9,538.147 +0.9 - 0.95,392.772 +0.95 - 1,299.485 +1 - 1.05,237.773 +1.05 - 1.1,199.044 +1.1 - 1.15,166.665 +1.15 - 1.2,143.281 +1.2 - 1.25,124.359 +1.25 - 1.3,108.177 +1.3 - 1.35,97.6027 +1.35 - 1.4,87.6458 +1.4 - 1.45,79.5737 +1.45 - 1.5,73.2719 +1.5 - 1.55,66.0646 +1.55 - 1.6,61.0045 +1.6 - 1.65,58.1264 +1.65 - 1.7,52.0861 +1.7 - 1.75,47.6112 +1.75 - 1.8,44.6106 +1.8 - 1.85,44.7897 +1.85 - 1.9,40.9587 +1.9 - 1.95,37.5609 +1.95 - 2,36.3828 +2 - 2.05,34.7729 +2.05 - 2.1,31.8944 +2.1 - 2.15,31.6005 +2.15 - 2.2,29.7859 +2.2 - 2.25,28.776 +2.25 - 2.3,26.3434 +2.3 - 2.35,25.7645 +2.35 - 2.4,24.2905 +2.4 - 2.45,23.6616 +2.45 - 2.5,22.998 +2.5 - 2.55,21.2117 +2.55 - 2.6,20.8018 +2.6 - 2.65,20.5774 +2.65 - 2.7,19.618 +2.7 - 2.75,19.4021 +2.75 - 2.8,18.5659 +2.8 - 2.85,18.5528 +2.85 - 2.9,17.9447 +2.9 - 2.95,17.9124 +2.95 - 3,17.3667 +3 - 3.05,17.1234 +3.05 - 3.1,16.5265 +3.1 - 3.15,16.7722 +3.15 - 3.2,16.1229 +3.2 - 3.25,15.9705 +3.25 - 3.3,15.0647 +3.3 - 3.35,15.658 +3.35 - 3.4,15.0378 +3.4 - 3.45,14.925 +3.45 - 3.5,15.3665 +3.5 - 3.55,14.5644 +3.55 - 3.6,14.2712 +3.6 - 3.65,14.152 +3.65 - 3.7,13.8062 +3.7 - 3.75,13.4611 +3.75 - 3.8,13.4421 +3.8 - 3.85,13.0398 +3.85 - 3.9,13.1213 +3.9 - 3.95,13.3731 +3.95 - 4,12.7653 +4 - 4.05,12.7726 +4.05 - 4.1,12.2768 +4.1 - 4.15,11.8036 +4.15 - 4.2,11.9137 +4.2 - 4.25,11.8011 +4.25 - 4.3,11.418 +4.3 - 4.35,11.171 +4.35 - 4.4,10.7351 +4.4 - 4.45,10.3275 +4.45 - 4.5,10.2154 +4.5 - 4.55,10.0034 +4.55 - 4.6,9.88578 +4.6 - 4.65,9.36901 +4.65 - 4.7,9.24396 +4.7 - 4.75,8.96211 +4.75 - 4.8,8.48882 +4.8 - 4.85,8.34707 +4.85 - 4.9,8.06611 +4.9 - 4.95,7.84197 +4.95 - 5,7.71859 +5 - 5.05,7.33848 +5.05 - 5.1,7.39578 +5.1 - 5.15,7.04482 +5.15 - 5.2,6.5924 +5.2 - 5.25,6.44634 +5.25 - 5.3,6.22296 +5.3 - 5.35,6.39629 +5.35 - 5.4,5.90975 +5.4 - 5.45,5.60463 +5.45 - 5.5,5.5555 +5.5 - 5.55,5.52665 +5.55 - 5.6,5.14914 +5.6 - 5.65,5.07993 +5.65 - 5.7,4.7359 +5.7 - 5.75,4.72476 +5.75 - 5.8,4.65416 +5.8 - 5.85,4.47267 +5.85 - 5.9,4.172 +5.9 - 5.95,4.22631 +5.95 - 6,4.15436 +6 - 6.05,3.92751 +6.05 - 6.1,3.82787 +6.1 - 6.15,3.73595 +6.15 - 6.2,3.57355 +6.2 - 6.25,3.50491 +6.25 - 6.3,3.47952 +6.3 - 6.35,3.36754 +6.35 - 6.4,3.32162 +6.4 - 6.45,3.12865 +6.45 - 6.5,3.13427 +6.5 - 6.55,3.11486 +6.55 - 6.6,2.98978 +6.6 - 6.65,3.07694 +6.65 - 6.7,2.73355 +6.7 - 6.75,2.69624 +6.75 - 6.8,2.74501 +6.8 - 6.85,2.78693 +6.85 - 6.9,2.57832 +6.9 - 6.95,2.36285 +6.95 - 7,2.41834 +7 - 7.05,2.43496 +7.05 - 7.1,2.45949 +7.1 - 7.15,2.33894 +7.15 - 7.2,2.18869 +7.2 - 7.25,2.11124 +7.25 - 7.3,2.10709 +7.3 - 7.35,2.28189 +7.35 - 7.4,2.13326 +7.4 - 7.45,2.05019 +7.45 - 7.5,2.03695 +7.5 - 7.55,1.97061 +7.55 - 7.6,1.90194 +7.6 - 7.65,1.83961 +7.65 - 7.7,1.80181 +7.7 - 7.75,1.76634 +7.75 - 7.8,1.66998 +7.8 - 7.85,1.79548 +7.85 - 7.9,1.64515 +7.9 - 7.95,1.59435 +7.95 - 8,1.52813 +8 - 8.05,1.53988 +8.05 - 8.1,1.5293 +8.1 - 8.15,1.42326 +8.15 - 8.2,1.45955 +8.2 - 8.25,1.44051 +8.25 - 8.3,1.3372 +8.3 - 8.35,1.33896 +8.35 - 8.4,1.2961 +8.4 - 8.45,1.28455 +8.45 - 8.5,1.18504 +8.5 - 8.55,1.21251 +8.55 - 8.6,1.23189 +8.6 - 8.65,1.19574 +8.65 - 8.7,1.12321 +8.7 - 8.75,1.09386 +8.75 - 8.8,1.17989 +8.8 - 8.85,1.11887 +8.85 - 8.9,1.06332 +8.9 - 8.95,1.10144 +8.95 - 9,1.01173 +9 - 9.05,1.04331 +9.05 - 9.1,0.986983 +9.1 - 9.15,0.930276 +9.15 - 9.2,0.867586 +9.2 - 9.25,0.848748 +9.25 - 9.3,0.900556 +9.3 - 9.35,0.839153 +9.35 - 9.4,0.906183 +9.4 - 9.45,0.819893 +9.45 - 9.5,0.783552 +9.5 - 9.55,0.812781 +9.55 - 9.6,0.759209 +9.6 - 9.65,0.773793 +9.65 - 9.7,0.753598 +9.7 - 9.75,0.742824 +9.75 - 9.8,0.782052 +9.8 - 9.85,0.629918 +9.85 - 9.9,0.712533 +9.9 - 9.95,0.638262 +9.95 - 10,0.630286 + > 10,26.2124 diff --git a/src/ANL/ANL_CC1npip_Evt_1DQ2_nu.cxx b/src/ANL/ANL_CC1npip_Evt_1DQ2_nu.cxx index 39019f8..1aa0519 100644 --- a/src/ANL/ANL_CC1npip_Evt_1DQ2_nu.cxx +++ b/src/ANL/ANL_CC1npip_Evt_1DQ2_nu.cxx @@ -1,86 +1,86 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "ANL_CC1npip_Evt_1DQ2_nu.h" // The constructor //******************************************************************** ANL_CC1npip_Evt_1DQ2_nu::ANL_CC1npip_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { -//******************************************************************** - +//******************************************************************** + fName = "ANL_CC1npip_Evt_1DQ2_nu"; fPlotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); Number of events"; EnuMin = 0; EnuMax = 1.5; fIsDiag = true; fIsRawEvents = true; fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pip_on_n/ANL_CC1pip_on_n_noEvents_Q2_14GeV_bin_firstQ2gone.txt"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } // Setup Covariance fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = (this->fEventHist->Integral()/double(fNEvents))*(16./8.); // NEUT + this->fScaleFactor = (GetEventHistogram()->Integral()/double(fNEvents))*(16./8.); // NEUT }; //******************************************************************** void ANL_CC1npip_Evt_1DQ2_nu::FillEventVariables(FitEvent *event) { //******************************************************************** if (event->NumFSParticle(2112) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pn = event->GetHMFSParticle(2112)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pn, Ppip); double q2CCpip; - + // ANL has a M(pi, p) < 1.4 GeV cut imposed (also no cut measurement but not useful for delta tuning) if (hadMass < 1400) q2CCpip = -1*(Pnu-Pmu).Mag2()/1.E6; else q2CCpip = -1.0; fXVar = q2CCpip; return; }; //******************************************************************** bool ANL_CC1npip_Evt_1DQ2_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1npip_Evt_1DcosmuStar_nu.cxx b/src/ANL/ANL_CC1npip_Evt_1DcosmuStar_nu.cxx index b768ba6..ae4d8c0 100644 --- a/src/ANL/ANL_CC1npip_Evt_1DcosmuStar_nu.cxx +++ b/src/ANL/ANL_CC1npip_Evt_1DcosmuStar_nu.cxx @@ -1,86 +1,86 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "ANL_CC1npip_Evt_1DcosmuStar_nu.h" // The constructor ANL_CC1npip_Evt_1DcosmuStar_nu::ANL_CC1npip_Evt_1DcosmuStar_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { fName = "ANL_CC1npip_Evt_1DcosmuStar_nu"; fPlotTitles = "; cos(#theta*); Number of events"; EnuMin = 0; EnuMax = 1.5; fIsDiag = true; fIsRawEvents = true; fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pip_on_n/ANL_CC1npip_cosmuStar.csv"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")/(fNEvents+0.)*16./8.; + this->fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*16./8.; }; void ANL_CC1npip_Evt_1DcosmuStar_nu::FillEventVariables(FitEvent *event) { if (event->NumISParticle(2112) == 0 || // Initial state particles event->NumFSParticle(2112) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) { // Final state particles return; } TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pin = event->GetHMISParticle(2112)->fP; TLorentzVector Pn = event->GetHMFSParticle(2112)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pn, Ppip); double cosmuStar = -999; // Now need to boost into center-of-mass frame TLorentzVector CMS = Pnu + Pin; // Boost the muon backwards Pmu.Boost(-CMS.BoostVector()); // Boost the neutrino forwards Pnu.Boost(CMS.BoostVector()); // ANL has a M(pi, p) < 1.4 GeV cut imposed // Find angle in CMS frame if (hadMass < 1400) cosmuStar = cos(FitUtils::th(Pmu, Pnu)); fXVar = cosmuStar; return; }; bool ANL_CC1npip_Evt_1DcosmuStar_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1npip_Evt_1Dppi_nu.cxx b/src/ANL/ANL_CC1npip_Evt_1Dppi_nu.cxx index 8e5c84e..77e1c42 100644 --- a/src/ANL/ANL_CC1npip_Evt_1Dppi_nu.cxx +++ b/src/ANL/ANL_CC1npip_Evt_1Dppi_nu.cxx @@ -1,78 +1,78 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "ANL_CC1npip_Evt_1Dppi_nu.h" // The constructor ANL_CC1npip_Evt_1Dppi_nu::ANL_CC1npip_Evt_1Dppi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "ANL_CC1npip_Evt_1Dppi_nu"; fPlotTitles = "; p_{#pi} (MeV); Number of events"; EnuMin = 0; EnuMax = 1.5; fIsDiag = true; fIsRawEvents = true; fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // ANL ppi has Enu < 1.5 GeV, W < 1.4 GeV this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pip_on_n/ANL_ppi_CC1npip.csv"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")/double(fNEvents)*(16./8.); }; void ANL_CC1npip_Evt_1Dppi_nu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(2112) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pn = event->GetHMFSParticle(2112)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pn, Ppip); double ppip; - + // This measurement has a 1.4 GeV M(Npi) constraint if (hadMass < 1400) ppip = FitUtils::p(Ppip)*1000.; else ppip = -1.0; fXVar = ppip; return; } bool ANL_CC1npip_Evt_1Dppi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.cxx index 0787983..250edd2 100644 --- a/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.cxx +++ b/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.cxx @@ -1,93 +1,134 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ +/** + * Radecky et al. Phys Rev D, 3rd series, volume 25, number 5, 1 March 1982, p 1161-1173 +*/ + #include "ANL_CC1npip_XSec_1DEnu_nu.h" // The constructor -ANL_CC1npip_XSec_1DEnu_nu::ANL_CC1npip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ +ANL_CC1npip_XSec_1DEnu_nu::ANL_CC1npip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) : wTrueCut(2.0), UseCorrectedData(true) { // Measurement Details fName = "ANL_CC1npip_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu} (GeV^{2}); #sigma (cm^{2}/nucleon)"; EnuMin = 0.; EnuMax = 1.5; fIsDiag = true; fNormError = 0.20; - Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); + fDefaultTypes = "FIX/DIAG"; + fAllowedTypes = "FIX,FREE,SHAPE/DIAG/UNCORR/W14/W16/NOW"; + // User can specify "UNCORR" for uncorrected data + // Default is to use correction + if (type.find("UNCORR") != std::string::npos) { + UseCorrectedData = false; + fName += "_uncorr"; + } else { + UseCorrectedData = true; + fName += "_corr"; + } + + // User can specify "W14" for W < 1.4 GeV cut + // "W16" for W < 1.6 GeV cut + // The default is W < 2.0 + if (type.find("W14") != std::string::npos) { + wTrueCut = 1.4; + fName += "_w14"; + } else if (type.find("W16") != std::string::npos) { + wTrueCut = 1.6; + fName += "_w16"; + } else { + // In the case + wTrueCut = 10.0; + fName += "_noW"; + } + + Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); + + // Now read in different data depending on what the user has specified + std::string DataLocation = GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pip_on_n/"; + + // If we're using corrected data + if (UseCorrectedData) { + if (wTrueCut == 1.4) { + DataLocation += "anl82corr-numu-n-to-mu-n-piplus-lowW_edges.txt"; + } else if (wTrueCut == 10.0) { + DataLocation += "anl82corr-numu-n-to-mu-n-piplus-noW_edges.txt"; + } else { + ERR(FTL) << "Can not run ANL CC1pi+1n W < 1.6 GeV with CORRECTION, because the data DOES NOT EXIST" << std::endl; + ERR(FTL) << "Correction exists for W < 1.4 GeV and no W cut data ONLY" << std::endl; + exit(-1); + } + + // If we're using raw uncorrected data + } else { + + if (wTrueCut == 1.4) { + DataLocation += "anl82-numu-cc1npip-14Wcut.txt"; + } else if (wTrueCut == 1.6) { + DataLocation += "anl82-numu-cc1npip-16Wcut.txt"; + } else if (wTrueCut == 10.0) { + DataLocation += "anl82-numu-cc1npip-noWcut.txt"; + } else { + ERR(FTL) << "Can only run W = 1.4, 1.6 and no W cut" << std::endl; + ERR(FTL) << "You specified: " << wTrueCut << std::endl; + exit(-1); + } + } + // Setup Plots - this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pip_on_n/anl82corr-numu-n-to-mu-n-piplus-lowW_edges.txt"); + this->SetDataValues(DataLocation); this->SetupDefaultHist(); - + // Setup Covariance fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); // NEUT (16./8. from /nucleus -> /nucleon scaling for nucleon interactions) + + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); // NEUT (16./8. from /nucleus -> /nucleon scaling for nucleon interactions) }; void ANL_CC1npip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { - if (event->NumFSParticle(2112) == 0 || - event->NumFSParticle(211) == 0 || - event->NumFSParticle(13) == 0) + if (event->NumFSParticle(2112) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) { return; + } TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pn = event->GetHMFSParticle(2112)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pn, Ppip); double Enu = -1.0; - if (hadMass < 1400) Enu = Pnu.E()/1.E3; - fXVar = Enu; + // ANL has a W cuts at 1.4, 1.6 and no w cut + // This is set by user, or defaults to 2.0 + if (hadMass/1000. < wTrueCut) { + Enu = Pnu.E()/1.E3; + } return; }; bool ANL_CC1npip_XSec_1DEnu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax); } -/* -void ANL_CC1npip_XSec_1DEnu_nu::FillHistograms() { - - if (makeHadronicMassHist) { - hadMassHist->Fill(hadMass); - } - - Measurement1D::FillHistograms(); - -} - - -void ANL_CC1npip_XSec_1DEnu_nu::ScaleEvents() { - - PlotUtils::FluxUnfoldedScaling(fMCHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(fMCFine, fFluxHist); - - fMCHist->Scale(fScaleFactor); - fMCFine->Scale(fScaleFactor); - - return; -} -*/ - diff --git a/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.h b/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.h index 62e2b97..ed72006 100644 --- a/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.h +++ b/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.h @@ -1,38 +1,40 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #ifndef ANL_CC1NPIP_XSEC_1DENU_NU_H_SEEN #define ANL_CC1NPIP_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1npip_XSec_1DEnu_nu : public Measurement1D { public: ANL_CC1npip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); virtual ~ANL_CC1npip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); - //void ScaleEvents(); bool isSignal(FitEvent *event); - //void FillHistograms(); private: + // What W cut are we imposing + double wTrueCut; + // Are we using corrected data? + bool UseCorrectedData; }; #endif diff --git a/src/ANL/ANL_CC1pi0_Evt_1DQ2_nu.cxx b/src/ANL/ANL_CC1pi0_Evt_1DQ2_nu.cxx index 1d76f28..6c88832 100644 --- a/src/ANL/ANL_CC1pi0_Evt_1DQ2_nu.cxx +++ b/src/ANL/ANL_CC1pi0_Evt_1DQ2_nu.cxx @@ -1,100 +1,100 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "ANL_CC1pi0_Evt_1DQ2_nu.h" // The constructor ANL_CC1pi0_Evt_1DQ2_nu::ANL_CC1pi0_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "ANL_CC1pi0_Evt_1DQ2_nu"; fPlotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); Number of events"; EnuMin = 0; EnuMax = 1.5; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fIsRawEvents = true; fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pi0_on_n/ANL_CC1pi0_on_n_noEvents_Q2_14GeV_bin_firstQ2gone.txt"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")/(fNEvents+0.)*16./8.; + this->fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*16./8.; }; void ANL_CC1pi0_Evt_1DQ2_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pp, Ppi0); double q2CCpi0 = -1.0; - + // ANL has a M(pi, p) < 1.4 GeV cut imposed if (hadMass < 1400) q2CCpi0 = -1*(Pnu-Pmu).Mag2()/1.E6; fXVar = q2CCpi0; return; }; bool ANL_CC1pi0_Evt_1DQ2_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 111, 2212, EnuMin, EnuMax); } /* void ANL_CC1pi0_Evt_1DQ2_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC1pi0_Evt_1DQ2_nu::ScaleEvents() { - - // PlotUtils::FluxUnfoldedScaling(fMCHist, fFluxHist); - //PlotUtils::FluxUnfoldedScaling(fMCFine, fFluxHist); + + // PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram()); + //PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram()); fMCHist->Scale(fScaleFactor); fMCFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC1pi0_Evt_1DcosmuStar_nu.cxx b/src/ANL/ANL_CC1pi0_Evt_1DcosmuStar_nu.cxx index 9dcab59..1f8c7b8 100644 --- a/src/ANL/ANL_CC1pi0_Evt_1DcosmuStar_nu.cxx +++ b/src/ANL/ANL_CC1pi0_Evt_1DcosmuStar_nu.cxx @@ -1,86 +1,86 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "ANL_CC1pi0_Evt_1DcosmuStar_nu.h" // The constructor ANL_CC1pi0_Evt_1DcosmuStar_nu::ANL_CC1pi0_Evt_1DcosmuStar_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "ANL_CC1pi0_Evt_1DcosmuStar_nu"; fPlotTitles = "; cos(#theta*); Number of events"; EnuMin = 0; EnuMax = 1.5; fIsDiag = true; fIsRawEvents = true; fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pi0_on_n/ANL_CC1pi0_cosmuStar.csv"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")/(fNEvents+0.)*16./8.; + this->fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*16./8.; }; void ANL_CC1pi0_Evt_1DcosmuStar_nu::FillEventVariables(FitEvent *event) { - + if (event->NumISParticle(2112) == 0 || event->NumFSParticle(2212) == 0 || event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pin = event->GetHMISParticle(2112)->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pp, Ppi0); double cosmuStar = -999; // Now need to boost into center-of-mass frame TLorentzVector CMS = Pnu + Pin; // Boost the muon backwards Pmu.Boost(-CMS.BoostVector()); // Boost the neutrino forwards Pnu.Boost(CMS.BoostVector()); - + // ANL has a M(pi, p) < 1.4 GeV cut imposed // Find angle in CMS frame if (hadMass < 1400) cosmuStar = cos(FitUtils::th(Pmu, Pnu)); fXVar = cosmuStar; return; }; bool ANL_CC1pi0_Evt_1DcosmuStar_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 111, 2212, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.cxx index 66347fb..30c139c 100644 --- a/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.cxx +++ b/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.cxx @@ -1,94 +1,132 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ +/** + * Radecky et al. Phys Rev D, 3rd series, volume 25, number 5, 1 March 1982, p 1161-1173 +*/ + #include "ANL_CC1pi0_XSec_1DEnu_nu.h" // The constructor ANL_CC1pi0_XSec_1DEnu_nu::ANL_CC1pi0_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "ANL_CC1pi0_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/neutron)"; EnuMin = 0.; EnuMax = 1.5; fIsDiag = true; fNormError = 0.20; + fDefaultTypes = "FIX/DIAG"; + fAllowedTypes = "FIX,FREE,SHAPE/DIAG/UNCORR/W14/W16/NOW"; + + // User can specify "UNCORR" for uncorrected data + // Default is to use correction + if (type.find("UNCORR") != std::string::npos) { + UseCorrectedData = false; + fName += "_uncorr"; + } else { + UseCorrectedData = true; + fName += "_corr"; + } + + // User can specify "W14" for W < 1.4 GeV cut + // "W16" for W < 1.6 GeV cut + // The default is no W cut (10 GeV) + if (type.find("W14") != std::string::npos) { + wTrueCut = 1.4; + fName += "_w14"; + } else if (type.find("W16") != std::string::npos) { + wTrueCut = 1.6; + fName += "_w16"; + } else { + wTrueCut = 10.0; + fName += "_noW"; + } + Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); - this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pi0_on_n/anl82corr-numu-n-to-mu-p-pi0-lowW_edges.txt"); + // Now read in different data depending on what the user has specified + std::string DataLocation = GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pi0_on_n/"; + + // If we're using corrected data + if (UseCorrectedData) { + if (wTrueCut == 1.4) { + DataLocation += "anl82corr-numu-n-to-mu-p-pi0-lowW_edges.txt"; + } else if (wTrueCut == 10.0) { + DataLocation += "anl82corr-numu-n-to-mu-p-pi0-noW_edges.txt"; + } else { + ERR(FTL) << "Can not run ANL CC1pi01n W < 1.6 GeV with CORRECTION, because the data DOES NOT EXIST" << std::endl; + ERR(FTL) << "Correction exists for W < 1.4 GeV and no W cut data ONLY" << std::endl; + exit(-1); + } + + // If we're using raw uncorrected data + } else { + + if (wTrueCut == 1.4) { + DataLocation += "anl82-numu-cc1pi0-14Wcut.txt"; + } else if (wTrueCut == 1.6) { + DataLocation += "anl82-numu-cc1pi0-16Wcut.txt"; + } else if (wTrueCut == 10.0) { + DataLocation += "anl82-numu-cc1pi0-noWcut.txt"; + } else { + ERR(FTL) << "Can only run W = 1.4, 1.6 and no W cut" << std::endl; + ERR(FTL) << "You specified: " << wTrueCut << std::endl; + exit(-1); + } + } + + this->SetDataValues(DataLocation); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents+0.)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents+0.)*(16./8.); }; void ANL_CC1pi0_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { - if (event->NumFSParticle(2212) == 0 || - event->NumFSParticle(111) == 0 || - event->NumFSParticle(13) == 0) + if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) { return; + } TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pp, Ppi0); double Enu = -1.0; - if (hadMass < 1400) Enu = Pnu.E()/1.E3; + if (hadMass/1000. < wTrueCut) { + Enu = Pnu.E()/1.E3; + } fXVar = Enu; return; }; bool ANL_CC1pi0_XSec_1DEnu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 111, 2212, EnuMin, EnuMax); } - -/* -void ANL_CC1pi0_XSec_1DEnu_nu::FillHistograms() { - - if (makeHadronicMassHist) { - hadMassHist->Fill(hadMass); - } - - Measurement1D::FillHistograms(); - - return; -} - - -void ANL_CC1pi0_XSec_1DEnu_nu::ScaleEvents() { - - PlotUtils::FluxUnfoldedScaling(fMCHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(fMCFine, fFluxHist); - - fMCHist->Scale(fScaleFactor); - fMCFine->Scale(fScaleFactor); - - return; -} -*/ diff --git a/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.h b/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.h index 180cf1b..0703d25 100644 --- a/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.h +++ b/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.h @@ -1,39 +1,41 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #ifndef ANL_CC1PI0_XSEC_1DENU_NU_H_SEEN #define ANL_CC1PI0_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1pi0_XSec_1DEnu_nu : public Measurement1D { public: ANL_CC1pi0_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); virtual ~ANL_CC1pi0_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); - //void ScaleEvents(); bool isSignal(FitEvent *event); - //void FillHistograms(); private: + // Are we using corrected data? + bool UseCorrectedData; + // What W cut are we imposing + double wTrueCut; }; #endif diff --git a/src/ANL/ANL_CC1ppip_Evt_1DQ2_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1DQ2_nu.cxx index 287d13d..8b95145 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1DQ2_nu.cxx +++ b/src/ANL/ANL_CC1ppip_Evt_1DQ2_nu.cxx @@ -1,104 +1,104 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ -/** +/** * Radecky et al. Phys Rev D, 3rd series, volume 25, number 5, 1 March 1982, p 1161-1173 */ #include "ANL_CC1ppip_Evt_1DQ2_nu.h" // The constructor ANL_CC1ppip_Evt_1DQ2_nu::ANL_CC1ppip_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "ANL_CC1ppip_Evt_1DQ2_nu"; fPlotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); Number of events"; EnuMin = 0; EnuMax = 6.0; fIsDiag = true; fIsRawEvents = true; fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pip_on_p/ANL_CC1pip_on_p_noEvents_Q2_14GeV_bin_firstQ2gone.txt"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")/(fNEvents+0.)*16./8.; + this->fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*16./8.; }; void ANL_CC1ppip_Evt_1DQ2_nu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pp, Ppip); double q2CCpip = -1.0; - + // ANL has a M(pi, p) < 1.4 GeV cut imposed if (hadMass < 1400) q2CCpip = -1*(Pnu-Pmu).Mag2()/1.E6; fXVar = q2CCpip; return; }; bool ANL_CC1ppip_Evt_1DQ2_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } /* void ANL_CC1ppip_Evt_1DQ2_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC1ppip_Evt_1DQ2_nu::ScaleEvents() { - - PlotUtils::FluxUnfoldedScaling(fMCHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(fMCFine, fFluxHist); + + PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram()); fMCHist->Scale(fScaleFactor); fMCFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC1ppip_Evt_1DcosmuStar_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1DcosmuStar_nu.cxx index ef959e6..0ff7c2b 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1DcosmuStar_nu.cxx +++ b/src/ANL/ANL_CC1ppip_Evt_1DcosmuStar_nu.cxx @@ -1,90 +1,90 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ -/** +/** * Radecky et al. Phys Rev D, 3rd series, Vol 25, No 5, 1 March 1982, p 1161-1173 */ #include "ANL_CC1ppip_Evt_1DcosmuStar_nu.h" // The constructor ANL_CC1ppip_Evt_1DcosmuStar_nu::ANL_CC1ppip_Evt_1DcosmuStar_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "ANL_CC1ppip_Evt_1DcosmuStar_nu"; fPlotTitles = "; cos(#theta*); Number of events"; EnuMin = 0; EnuMax = 6.0; fIsDiag = true; fIsRawEvents = true; fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pip_on_p/ANL_CC1pip_on_p_noEvents_cosmuStar_1982.csv"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")/(fNEvents+0.)*16./8.; + this->fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*16./8.; }; void ANL_CC1ppip_Evt_1DcosmuStar_nu::FillEventVariables(FitEvent *event) { - + if (event->NumISParticle(2212) == 0 || event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pin = event->GetHMISParticle(2212)->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pp, Ppip); double cosmuStar = -999; // Now need to boost into center-of-mass frame TLorentzVector CMS = Pnu + Pin; // Boost the muon backwards Pmu.Boost(-CMS.BoostVector()); // Boost the neutrino forwards Pnu.Boost(CMS.BoostVector()); - + // ANL has a M(pi, p) < 1.4 GeV cut imposed // Find angle in CMS frame if (hadMass < 1400) cosmuStar = cos(FitUtils::th(Pmu, Pnu)); fXVar = cosmuStar; return; }; bool ANL_CC1ppip_Evt_1DcosmuStar_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1ppip_Evt_1DcosthAdler_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1DcosthAdler_nu.cxx index 093584b..dcb5dc6 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1DcosthAdler_nu.cxx +++ b/src/ANL/ANL_CC1ppip_Evt_1DcosthAdler_nu.cxx @@ -1,121 +1,121 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ -/** +/** * Radecky et al. Phys Rev D, 3rd series, Vol 25, No 5, 1 March 1982, p 1161-1173 */ #include "ANL_CC1ppip_Evt_1DcosthAdler_nu.h" // The constructor ANL_CC1ppip_Evt_1DcosthAdler_nu::ANL_CC1ppip_Evt_1DcosthAdler_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "ANL_CC1ppip_Evt_1DcosthAdler_nu"; fPlotTitles = "; cos#theta_{Adler}; Number of events"; EnuMin = 0; EnuMax = 6.0; fIsDiag = true; fIsRawEvents = true; fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pip_on_p/ANL_CC1pip_on_p_noEvents_costhAdler_1982.csv"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")/(fNEvents+0.)*16./8.; + this->fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*16./8.; }; void ANL_CC1ppip_Evt_1DcosthAdler_nu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; // Get the hadronic mass double hadMass = FitUtils::MpPi(Pp, Ppip); // Need to boost pion and muon into resonance rest-frame to get phi (e.g. see F. Sanchez arxiv 1511.00501v2) // // Get the resonance 4-vector TLorentzVector Pres = Ppip + Pp; // Boost in/outgoing particles into rest frame Ppip.Boost(-Pres.BoostVector()); Pmu.Boost(-Pres.BoostVector()); Pnu.Boost(Pres.BoostVector()); // Define the vectors TVector3 PpipVect = Ppip.Vect(); TVector3 PnuVect = Pnu.Vect(); TVector3 PmuVect = Pmu.Vect(); // Define the z-direction; should be same as Pres TVector3 zVect = (PnuVect-PmuVect); zVect *= 1/double(zVect.Mag()); // Then finally construct phi as the angle between pion projection and x axis double cosThAdler = -999; // ANL has a M(pi, p) < 1.4 GeV cut imposed if (hadMass < 1400) cosThAdler = cos(PpipVect.Angle(zVect)); fXVar = cosThAdler; return; }; bool ANL_CC1ppip_Evt_1DcosthAdler_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } /* void ANL_CC1ppip_Evt_1DcosthAdler_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC1ppip_Evt_1DcosthAdler_nu::ScaleEvents() { - - PlotUtils::FluxUnfoldedScaling(fMCHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(fMCFine, fFluxHist); + + PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram()); fMCHist->Scale(fScaleFactor); fMCFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC1ppip_Evt_1Dphi_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1Dphi_nu.cxx index 3f6ce02..0e1d43e 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1Dphi_nu.cxx +++ b/src/ANL/ANL_CC1ppip_Evt_1Dphi_nu.cxx @@ -1,152 +1,152 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ -/** +/** * Radecky et al. Phys Rev D, 3rd series, Vol 25, No 5, 1 March 1982, p 1161-1173 */ #include "ANL_CC1ppip_Evt_1Dphi_nu.h" // The constructor ANL_CC1ppip_Evt_1Dphi_nu::ANL_CC1ppip_Evt_1Dphi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "ANL_CC1ppip_Evt_1Dphi_nu"; fPlotTitles = "; #phi_{Adler}; Number of events"; EnuMin = 0; EnuMax = 6.0; fIsDiag = true; fIsRawEvents = true; fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pip_on_p/ANL_CC1pip_on_p_noEvents_phiAdler_1982.csv"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); TRandom3 rand; - this->fScaleFactor = this->fEventHist->Integral("width")/(fNEvents+0.)*16./8.; + this->fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*16./8.; }; void ANL_CC1ppip_Evt_1Dphi_nu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; // Get the hadronic mass double hadMass = FitUtils::MpPi(Pp, Ppip); // Need to boost pion and muon into resonance rest-frame to get phi (e.g. see F. Sanchez arxiv 1511.00501v2) // // Get the resonance 4-vector TLorentzVector Pres = Ppip + Pp; // Boost the outgoing and incoming particles into the resonance frame Pnu.Boost(Pres.BoostVector()); Pmu.Boost(-Pres.BoostVector()); Ppip.Boost(-Pres.BoostVector()); // Get the vectors from the 4-vector TVector3 PmuVect = Pmu.Vect(); TVector3 PnuVect = Pnu.Vect(); TVector3 PresVect = Pres.Vect(); TVector3 PpipVect = Ppip.Vect(); // Define the z-direction TVector3 zVect = (PnuVect-PmuVect); zVect *= 1/double(zVect.Mag()); // Define y direction as being z (resonance direction) x pmu* TVector3 yVect = zVect.Cross(PmuVect); // Normalise yVector yVect *= 1/double(yVect.Mag()); // define x direction as being y X z TVector3 xVect = yVect.Cross(zVect); // Normalise zVector xVect *= 1/double(xVect.Mag()); // Project pion onto z axis TVector3 PpipVectZ = zVect * PpipVect.Dot(zVect); // Then subtract this vector off the pion vector TVector3 PpipVectPlane = PpipVect - PpipVectZ; // Then finally construct phi as the angle between pion projection and x axis double phi = -999; - + // ANL has a M(pi, p) < 1.4 GeV cut imposed if (hadMass < 1400) { if (PpipVectPlane.Y() > 0) { phi = (180./M_PI)*PpipVectPlane.Angle(xVect); } else if (PpipVectPlane.Y() < 0) { phi = (180./M_PI)*(2*M_PI-PpipVectPlane.Angle(xVect)); } else if (PpipVectPlane.Y() == 0) { double randNo = rand.Rndm(); if (randNo > 0.5) { phi = (180./M_PI)*PpipVectPlane.Angle(xVect); } else { phi = (180./M_PI)*(2*M_PI-PpipVectPlane.Angle(xVect)); } } - } + } fXVar = phi; return; }; bool ANL_CC1ppip_Evt_1Dphi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } /* void ANL_CC1ppip_Evt_1Dphi_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC1ppip_Evt_1Dphi_nu::ScaleEvents() { - - PlotUtils::FluxUnfoldedScaling(fMCHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(fMCFine, fFluxHist); + + PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram()); fMCHist->Scale(fScaleFactor); fMCFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC1ppip_Evt_1Dppi_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1Dppi_nu.cxx index a2a3f47..f8313af 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1Dppi_nu.cxx +++ b/src/ANL/ANL_CC1ppip_Evt_1Dppi_nu.cxx @@ -1,80 +1,80 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ -/** +/** * Derrick et al. Phys Rev D, Vol 23, Number 3, 1 Feb 1981, p 569-575 */ #include "ANL_CC1ppip_Evt_1Dppi_nu.h" // The constructor ANL_CC1ppip_Evt_1Dppi_nu::ANL_CC1ppip_Evt_1Dppi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { fName = "ANL_CC1ppip_Evt_1Dppi_nu"; fPlotTitles = "; p_{#pi} (MeV); Number of events"; EnuMin = 0; EnuMax = 1.5; // Different EnuMax here, see M. Derrick et al, Phys Rev D, V23 N3, p572, Fig 2 fIsDiag = true; fIsRawEvents = true; fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pip_on_p/ANL_CC1pip_on_p_noEvents_ppi.csv"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")/(fNEvents+0.)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*(16./8.); }; void ANL_CC1ppip_Evt_1Dppi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pp, Ppip); double ppip = -1.0; // This has a hadMass constraint of 1.4 GeV if (hadMass < 1400) ppip = FitUtils::p(Ppip)*1000.; fXVar = ppip; return; }; bool ANL_CC1ppip_Evt_1Dppi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1ppip_Evt_1Dthpr_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1Dthpr_nu.cxx index 4a71e96..c374606 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1Dthpr_nu.cxx +++ b/src/ANL/ANL_CC1ppip_Evt_1Dthpr_nu.cxx @@ -1,80 +1,80 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ -/** +/** * Derrick et al. Phys Rev D, Vol 23, Number 3, 1 Feb 1981, p 569-575 */ #include "ANL_CC1ppip_Evt_1Dthpr_nu.h" // The constructor ANL_CC1ppip_Evt_1Dthpr_nu::ANL_CC1ppip_Evt_1Dthpr_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "ANL_CC1ppip_Evt_1Dthpr_nu"; fPlotTitles = "; cos #theta_{p}; Number of events"; EnuMin = 0; EnuMax = 1.5; // Different EnuMax for cos(thpr), see Derrick et al, Phys Rev D V23 N3, p572 fig 3 fIsDiag = true; fIsRawEvents = true; fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // ANL ppi has Enu < 1.5 GeV, W < 1.4 GeV this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pip_on_p/ANL_CC1pip_on_p_noEvents_thProt.csv"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } - + fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")/((fNEvents+0.))*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")/((fNEvents+0.))*(16./8.); }; void ANL_CC1ppip_Evt_1Dthpr_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pp, Ppip); double costhpr = -999; - + // This measurement has M(Npi) = W < 1.4GeV if (hadMass < 1400) costhpr = cos(FitUtils::th(Pnu,Pp)); fXVar = costhpr; return; }; bool ANL_CC1ppip_Evt_1Dthpr_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.cxx index 1ced1b2..bfd44ca 100644 --- a/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.cxx +++ b/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.cxx @@ -1,98 +1,135 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ -/** +/** * Radecky et al. Phys Rev D, 3rd series, volume 25, number 5, 1 March 1982, p 1161-1173 */ + #include "ANL_CC1ppip_XSec_1DEnu_nu.h" // The constructor -ANL_CC1ppip_XSec_1DEnu_nu::ANL_CC1ppip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ +ANL_CC1ppip_XSec_1DEnu_nu::ANL_CC1ppip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) : wTrueCut(2.0), UseCorrectedData(true) { fName = "ANL_CC1ppip_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/nucleon)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fNormError = 0.20; // normalisation error on ANL BNL flux + fDefaultTypes = "FIX/DIAG"; + fAllowedTypes = "FIX,FREE,SHAPE/DIAG/UNCORR/W14/W16/NOW"; + + // User can specify "UNCORR" for uncorrected data + // Default is to use correction + if (type.find("UNCORR") != std::string::npos) { + UseCorrectedData = false; + fName += "_uncorr"; + } else { + UseCorrectedData = true; + fName += "_corr"; + } + + // User can specify "W14" for W < 1.4 GeV cut + // "W16" for W < 1.6 GeV cut + // The default is no W cut + if (type.find("W14") != std::string::npos) { + wTrueCut = 1.4; + fName += "_w14"; + } else if (type.find("W16") != std::string::npos) { + wTrueCut = 1.6; + fName += "_w16"; + } else { + wTrueCut = 10.0; + fName += "_noW"; + } + Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); - this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pip_on_p/anl82corr-numu-p-to-mu-p-piplus-lowW_edges.txt"); + // Now read in different data depending on what the user has specified + std::string DataLocation = GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pip_on_p/"; + + // If we're using corrected data + if (UseCorrectedData) { + if (wTrueCut == 1.4) { + DataLocation += "anl82corr-numu-p-to-mu-p-piplus-lowW_edges.txt"; + } else if (wTrueCut == 10.0) { + DataLocation += "anl82corr-numu-p-to-mu-p-piplus-noW_edges.txt"; + } else { + ERR(FTL) << "Can not run ANL CC1pi+1p W < 1.6 GeV with CORRECTION, because the data DOES NOT EXIST" << std::endl; + ERR(FTL) << "Correction exists for W < 1.4 GeV and no W cut data ONLY" << std::endl; + exit(-1); + } + + // If we're using raw uncorrected data + } else { + + if (wTrueCut == 1.4) { + DataLocation += "anl82-numu-cc1ppip-14Wcut.txt"; + } else if (wTrueCut == 1.6) { + DataLocation += "anl82-numu-cc1ppip-16Wcut.txt"; + } else if (wTrueCut == 10.0) { + DataLocation += "anl82-numu-cc1ppip-noWcut.txt"; + } else { + ERR(FTL) << "Can only run W = 1.4, 1.6 and no W cut" << std::endl; + ERR(FTL) << "You specified: " << wTrueCut << std::endl; + exit(-1); + } + } + + this->SetDataValues(DataLocation); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void ANL_CC1ppip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { - if (event->NumFSParticle(2212) == 0 || - event->NumFSParticle(211) == 0 || - event->NumFSParticle(13) == 0) + if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) { return; + } TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pp, Ppip); double Enu = -1.0; - - // ANL has a M(pi, p) < 1.4 GeV cut imposed - if (hadMass < 1400) Enu = Pnu.E()/1.E3; + + // ANL has a W cuts at 1.4, 1.6 and no w cut + // This is set by user, or defaults to 2.0 + if (hadMass/1000. < wTrueCut) { + Enu = Pnu.E()/1.E3; + } fXVar = Enu; return; } bool ANL_CC1ppip_XSec_1DEnu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } - -/* -void ANL_CC1ppip_XSec_1DEnu_nu::FillHistograms() { - - if (makeHadronicMassHist) { - hadMassHist->Fill(hadMass); - } - - Measurement1D::FillHistograms(); - -} - - -void ANL_CC1ppip_XSec_1DEnu_nu::ScaleEvents() { - - PlotUtils::FluxUnfoldedScaling(fMCHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(fMCFine, fFluxHist); - - fMCHist->Scale(fScaleFactor); - fMCFine->Scale(fScaleFactor); - - return; -} -*/ diff --git a/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.h b/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.h index a51c354..6abaffc 100644 --- a/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.h +++ b/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.h @@ -1,41 +1,42 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #ifndef ANL_CC1PPIP_XSEC_1DENU_NU_H_SEEN #define ANL_CC1PPIP_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1ppip_XSec_1DEnu_nu : public Measurement1D { public: ANL_CC1ppip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); virtual ~ANL_CC1ppip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); - //void ScaleEvents(); - //void FillHistograms(); - private: + // What W cut are we imposing + double wTrueCut; + // Are we using corrected data? + bool UseCorrectedData; }; #endif diff --git a/src/ANL/ANL_CC1ppip_XSec_1DQ2_nu.cxx b/src/ANL/ANL_CC1ppip_XSec_1DQ2_nu.cxx index 4e2cd25..b35f116 100644 --- a/src/ANL/ANL_CC1ppip_XSec_1DQ2_nu.cxx +++ b/src/ANL/ANL_CC1ppip_XSec_1DQ2_nu.cxx @@ -1,72 +1,72 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ -/** +/** * Radecky et al. Phys Rev D, 3rd series, volume 25, number 5, 1 March 1982, p 1161-1173 */ #include "ANL_CC1ppip_XSec_1DQ2_nu.h" // The constructor ANL_CC1ppip_XSec_1DQ2_nu::ANL_CC1ppip_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ - + fName = "ANL_CC1ppip_XSec_1DQ2_nu"; fPlotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); d#sigma/dQ_{CC#pi^{+}}^{2} (cm^{2}/GeV^{2}/proton)"; EnuMin = 0.5; EnuMax = 6; fIsDiag = true; fNormError = 0.20; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC1pip_on_p/ANL_CC1pip_on_p_dSigdQ2_W14_1982.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/((fNEvents+0.)*TotalIntegratedFlux("width"))*16./8.; + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/((fNEvents+0.)*TotalIntegratedFlux("width"))*16./8.; }; void ANL_CC1ppip_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pp, Ppip); double q2CCpip = -1.0; // I use the W < 1.4GeV cut ANL data to isolate single pion // there is also a W < 1.6 GeV and an uncut spectrum ANL 1982 if (hadMass < 1400) q2CCpip = -1*(Pnu-Pmu).Mag2()/1.E6; fXVar = q2CCpip; return; }; bool ANL_CC1ppip_XSec_1DQ2_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.cxx b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.cxx index 08368b4..0c591c8 100644 --- a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.cxx @@ -1,100 +1,100 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ /** * D.Day et al, "Study of \nud charged-current two-pion production in the threshold region", Physical Review D, Volume 28, Number 11, 1 December 1983 \n * Derrick, Musgrave, Ammar, Day, Kafka and Mann, "Two- and three-pion productin by \nu\mud recations nears threshold: The implication for nucleon-decay experiments", Physical Review D, Vol 30, Number 7, 1 October 1984 */ #include "ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.h" // The constructor ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu::ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu"; fPlotTitles = "; p_{#mu} (GeV); Number of events (area norm.)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fIsRawEvents = true; fNormError = 0.20; // normalisation error on ANL BNL flux fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // there's also _unweight rather than weight data file this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC2pi/1pim1pip/CC2pi_1pim1pip_pMu_weight.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); for (int i = 0; i < fDataHist->GetNbinsX()+1; ++i) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0) return; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double pmu = FitUtils::p(Pmu); this->fXVar = pmu; return; } // Signal asks for 1pi-, 1pi+, 1mu-, 1p bool ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, -211, 2212}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } /* void ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(mcHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(mcFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(mcHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); mcHist->Scale(fScaleFactor); mcFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.cxx b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.cxx index c25fe38..b20bca2 100644 --- a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.cxx @@ -1,100 +1,100 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ /** * D.Day et al, "Study of \nud charged-current two-pion production in the threshold region", Physical Review D, Volume 28, Number 11, 1 December 1983 \n * Derrick, Musgrave, Ammar, Day, Kafka and Mann, "Two- and three-pion productin by \nu\mud recations nears threshold: The implication for nucleon-decay experiments", Physical Review D, Vol 30, Number 7, 1 October 1984 */ #include "ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.h" // The constructor ANL_CC2pi_1pim1pip_Evt_1Dppim_nu::ANL_CC2pi_1pim1pip_Evt_1Dppim_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "ANL_CC2pi_1pim1pip_Evt_1Dppim_nu"; fPlotTitles = "; p_{#pi-} (GeV); Number of events (area norm.)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fIsRawEvents = true; fNormError = 0.20; // normalisation error on ANL BNL flux fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // there's also _unweight rather than weight data file this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC2pi/1pim1pip/CC2pi_1pim1pip_ppim_weight.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); for (int i = 0; i < fDataHist->GetNbinsX()+1; ++i) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void ANL_CC2pi_1pim1pip_Evt_1Dppim_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(-211) == 0) return; TLorentzVector Ppim = event->GetHMFSParticle(-211)->fP; double ppim = FitUtils::p(Ppim); this->fXVar = ppim; return; } // Signal asks for 1pi-, 1pi+, 1mu-, 1p bool ANL_CC2pi_1pim1pip_Evt_1Dppim_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, -211, 2212}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } /* void ANL_CC2pi_1pim1pip_Evt_1Dppim_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC2pi_1pim1pip_Evt_1Dppim_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(mcHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(mcFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(mcHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); mcHist->Scale(fScaleFactor); mcFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.cxx b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.cxx index cb76d96..140769c 100644 --- a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.cxx @@ -1,100 +1,100 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ /** * D.Day et al, "Study of \nud charged-current two-pion production in the threshold region", Physical Review D, Volume 28, Number 11, 1 December 1983 \n * Derrick, Musgrave, Ammar, Day, Kafka and Mann, "Two- and three-pion productin by \nu\mud recations nears threshold: The implication for nucleon-decay experiments", Physical Review D, Vol 30, Number 7, 1 October 1984 */ #include "ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.h" // The constructor ANL_CC2pi_1pim1pip_Evt_1Dppip_nu::ANL_CC2pi_1pim1pip_Evt_1Dppip_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "ANL_CC2pi_1pim1pip_Evt_1Dppip_nu"; fPlotTitles = "; p_{#pi+} (GeV); Number of events (area norm.)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fIsRawEvents = true; fNormError = 0.20; // normalisation error on ANL BNL flux fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // there's also _unweight rather than weight data file this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC2pi/1pim1pip/CC2pi_1pim1pip_ppip_weight.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); for (int i = 0; i < fDataHist->GetNbinsX()+1; ++i) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void ANL_CC2pi_1pim1pip_Evt_1Dppip_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(211) == 0) return; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double ppip = FitUtils::p(Ppip); this->fXVar = ppip; return; } // Signal asks for 1pi-, 1pi+, 1mu-, 1p bool ANL_CC2pi_1pim1pip_Evt_1Dppip_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, -211, 2212}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } /* void ANL_CC2pi_1pim1pip_Evt_1Dppip_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC2pi_1pim1pip_Evt_1Dppip_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(mcHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(mcFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(mcHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); mcHist->Scale(fScaleFactor); mcFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.cxx b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.cxx index 1755377..b0e2422 100644 --- a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.cxx @@ -1,100 +1,100 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ /** * D.Day et al, "Study of \nud charged-current two-pion production in the threshold region", Physical Review D, Volume 28, Number 11, 1 December 1983 \n * Derrick, Musgrave, Ammar, Day, Kafka and Mann, "Two- and three-pion productin by \nu\mud recations nears threshold: The implication for nucleon-decay experiments", Physical Review D, Vol 30, Number 7, 1 October 1984 */ #include "ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.h" // The constructor ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu::ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu"; fPlotTitles = "; p_{prot} (GeV); Number of events (area norm.)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fIsRawEvents = true; fNormError = 0.20; // normalisation error on ANL BNL flux fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // there's also _unweight rather than weight data file this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC2pi/1pim1pip/CC2pi_1pim1pip_pProt_weight.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); for (int i = 0; i < fDataHist->GetNbinsX()+1; ++i) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0) return; TLorentzVector Pprot = event->GetHMFSParticle(2212)->fP; double pprot = FitUtils::p(Pprot); this->fXVar = pprot; return; } // Signal asks for 1pi-, 1pi+, 1mu-, 1p bool ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, -211, 2212}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } /* void ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(mcHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(mcFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(mcHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); mcHist->Scale(fScaleFactor); mcFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.cxx index b80c92f..edc1da9 100644 --- a/src/ANL/ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.cxx @@ -1,95 +1,95 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ /** * D.Day et al, "Study of \nud charged-current two-pion production in the threshold region", Physical Review D, Volume 28, Number 11, 1 December 1983 \n * Derrick, Musgrave, Ammar, Day, Kafka and Mann, "Two- and three-pion productin by \nu\mud recations nears threshold: The implication for nucleon-decay experiments", Physical Review D, Vol 30, Number 7, 1 October 1984 */ #include "ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.h" // The constructor ANL_CC2pi_1pim1pip_XSec_1DEnu_nu::ANL_CC2pi_1pim1pip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "ANL_CC2pi_1pim1pip_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/nucleon)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fNormError = 0.20; // normalisation error on ANL BNL flux fIsEnu1D = true; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC2pi/1pim1pip/CC2pi_1pim1pip1p_xsec.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // Need to multiply the data by a factor because of the way the data is scanned (e.g. 1E-38) // fDataHist->Scale(1.E-41); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void ANL_CC2pi_1pim1pip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { TLorentzVector Pnu = event->GetNeutrinoIn()->fP; double Enu = Pnu.E()/1000.; // No hadronic mass cut or similar here so very simple FillEventVariables this->fXVar = Enu; return; } // Signal asks for 1pi-, 1pi+, 1mu-, 1p bool ANL_CC2pi_1pim1pip_XSec_1DEnu_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, -211, 2212}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } /* void ANL_CC2pi_1pim1pip_XSec_1DEnu_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC2pi_1pim1pip_XSec_1DEnu_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(mcHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(mcFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(mcHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); mcHist->Scale(fScaleFactor); mcFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.cxx index 841a025..114cb77 100644 --- a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.cxx @@ -1,100 +1,100 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ /** * D.Day et al, "Study of \nud charged-current two-pion production in the threshold region", Physical Review D, Volume 28, Number 11, 1 December 1983 \n * Derrick, Musgrave, Ammar, Day, Kafka and Mann, "Two- and three-pion productin by \nu\mud recations nears threshold: The implication for nucleon-decay experiments", Physical Review D, Vol 30, Number 7, 1 October 1984 */ #include "ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.h" // The constructor ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu::ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu"; fPlotTitles = "; p_{#mu} (GeV); Number of events (area norm.)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fIsRawEvents = true; fNormError = 0.20; // normalisation error on ANL BNL flux fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // there's also _unweight rather than weight data file this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC2pi/1pip1pi0/CC2pi_1pip1pi0_pMu_weight.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); for (int i = 0; i < fDataHist->GetNbinsX()+1; ++i) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0) return; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double pmu = FitUtils::p(Pmu); this->fXVar = pmu; return; } // Signal asks for 1pi0, 1pi+, 1mu-, 1p bool ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, 111, 2212}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } /* void ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(mcHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(mcFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(mcHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); mcHist->Scale(fScaleFactor); mcFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.cxx index 6add980..ddca715 100644 --- a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.cxx @@ -1,100 +1,100 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ /** * D.Day et al, "Study of \nud charged-current two-pion production in the threshold region", Physical Review D, Volume 28, Number 11, 1 December 1983 \n * Derrick, Musgrave, Ammar, Day, Kafka and Mann, "Two- and three-pion productin by \nu\mud recations nears threshold: The implication for nucleon-decay experiments", Physical Review D, Vol 30, Number 7, 1 October 1984 */ #include "ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.h" // The constructor ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu::ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu"; fPlotTitles = "; p_{#pi0} (GeV); Number of events (area norm.)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fIsRawEvents = true; fNormError = 0.20; // normalisation error on ANL BNL flux fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // there's also _unweight rather than weight data file this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC2pi/1pip1pi0/CC2pi_1pip1pi0_ppi0_weight.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); for (int i = 0; i < fDataHist->GetNbinsX()+1; ++i) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(111) == 0) return; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; double ppi0 = FitUtils::p(Ppi0); this->fXVar = ppi0; return; } // Signal asks for 1pi0, 1pi+, 1mu-, 1p bool ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, 111, 2212}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } /* void ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(mcHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(mcFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(mcHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); mcHist->Scale(fScaleFactor); mcFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.cxx index 36aed91..51fa183 100644 --- a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.cxx @@ -1,100 +1,100 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ /** * D.Day et al, "Study of \nud charged-current two-pion production in the threshold region", Physical Review D, Volume 28, Number 11, 1 December 1983 \n * Derrick, Musgrave, Ammar, Day, Kafka and Mann, "Two- and three-pion productin by \nu\mud recations nears threshold: The implication for nucleon-decay experiments", Physical Review D, Vol 30, Number 7, 1 October 1984 */ #include "ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.h" // The constructor ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu::ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu"; fPlotTitles = "; p_{#pi+} (GeV); Number of events (area norm.)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fIsRawEvents = true; fNormError = 0.20; // normalisation error on ANL BNL flux fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // there's also _unweight rather than weight data file this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC2pi/1pip1pi0/CC2pi_1pip1pi0_ppip_weight.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); for (int i = 0; i < fDataHist->GetNbinsX()+1; ++i) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(211) == 0) return; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double ppip = FitUtils::p(Ppip); this->fXVar = ppip; return; } // Signal asks for 1pi0, 1pi+, 1mu-, 1p bool ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, 111, 2212}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } /* void ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(mcHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(mcFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(mcHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); mcHist->Scale(fScaleFactor); mcFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.cxx index 33f162c..5778ed7 100644 --- a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.cxx @@ -1,100 +1,100 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ /** * D.Day et al, "Study of \nud charged-current two-pion production in the threshold region", Physical Review D, Volume 28, Number 11, 1 December 1983 \n * Derrick, Musgrave, Ammar, Day, Kafka and Mann, "Two- and three-pion productin by \nu\mud recations nears threshold: The implication for nucleon-decay experiments", Physical Review D, Vol 30, Number 7, 1 October 1984 */ #include "ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.h" // The constructor ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu::ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu"; fPlotTitles = "; p_{prot} (GeV); Number of events (area norm.)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fIsRawEvents = true; fNormError = 0.20; // normalisation error on ANL BNL flux fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // there's also _unweight rather than weight data file this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC2pi/1pip1pi0/CC2pi_1pip1pi0_pProt_weight.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); for (int i = 0; i < fDataHist->GetNbinsX()+1; ++i) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0) return; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; double pprot = FitUtils::p(Pp); this->fXVar = pprot; return; } // Signal asks for 1pi0, 1pi+, 1mu-, 1p bool ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, 111, 2212}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } /* void ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(mcHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(mcFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(mcHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); mcHist->Scale(fScaleFactor); mcFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.cxx index 650bcbd..e8326a1 100644 --- a/src/ANL/ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.cxx @@ -1,94 +1,94 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ /** * D.Day et al, "Study of \nud charged-current two-pion production in the threshold region", Physical Review D, Volume 28, Number 11, 1 December 1983 \n * Derrick, Musgrave, Ammar, Day, Kafka and Mann, "Two- and three-pion productin by \nu\mud recations nears threshold: The implication for nucleon-decay experiments", Physical Review D, Vol 30, Number 7, 1 October 1984 */ #include "ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.h" // The constructor ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu::ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/nucleon)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fNormError = 0.20; // normalisation error on ANL BNL flux Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC2pi/1pip1pi0/CC2pi_1pip1pi01p_xsec.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // Need to multiply the data by a factor because of the way the data is scanned (e.g. 1E-38) //fDataHist->Scale(1.E-41); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { TLorentzVector Pnu = event->GetNeutrinoIn()->fP; double Enu = Pnu.E()/1000.; // No hadronic mass cut or similar here so very simple FillEventVariables this->fXVar = Enu; return; } // Signal asks for 1pi+, 1pi0, 1mu-, 1p bool ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, 111, 2212}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } /* void ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(mcHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(mcFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(mcHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); mcHist->Scale(fScaleFactor); mcFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.cxx index a594389..be3b613 100644 --- a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.cxx @@ -1,100 +1,100 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ /** * D.Day et al, "Study of \nud charged-current two-pion production in the threshold region", Physical Review D, Volume 28, Number 11, 1 December 1983 \n * Derrick, Musgrave, Ammar, Day, Kafka and Mann, "Two- and three-pion productin by \nu\mud recations nears threshold: The implication for nucleon-decay experiments", Physical Review D, Vol 30, Number 7, 1 October 1984 */ #include "ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.h" // The constructor ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu::ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu"; fPlotTitles = "; p_{#mu} (GeV); Number of events (area norm.)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fIsRawEvents = true; fNormError = 0.20; // normalisation error on ANL BNL flux fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // there's also _unweight rather than weight data file this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC2pi/1pip1pip/CC2pi_1pip1pip1n_pMu_weight.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); for (int i = 0; i < fDataHist->GetNbinsX()+1; ++i) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0) return; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double pmu = FitUtils::p(Pmu); this->fXVar = pmu; return; } // Signal asks for 2pi+, 1mu-, 1n bool ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, 211, 2112}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } /* void ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(mcHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(mcFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(mcHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); mcHist->Scale(fScaleFactor); mcFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.cxx index d6aeb8c..7a8c5d4 100644 --- a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.cxx @@ -1,100 +1,100 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ /** * D.Day et al, "Study of \nud charged-current two-pion production in the threshold region", Physical Review D, Volume 28, Number 11, 1 December 1983 \n * Derrick, Musgrave, Ammar, Day, Kafka and Mann, "Two- and three-pion productin by \nu\mud recations nears threshold: The implication for nucleon-decay experiments", Physical Review D, Vol 30, Number 7, 1 October 1984 */ #include "ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.h" // The constructor ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu::ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu"; fPlotTitles = "; p_{n} (GeV); Number of events (area norm.)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fIsRawEvents = true; fNormError = 0.20; // normalisation error on ANL BNL flux fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // there's also _unweight rather than weight data file this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC2pi/1pip1pip/CC2pi_1pip1pip1n_pNeutron_weight.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); for (int i = 0; i < fDataHist->GetNbinsX()+1; ++i) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2112) == 0) return; TLorentzVector Pneutron = event->GetHMFSParticle(2112)->fP; double pneut = FitUtils::p(Pneutron); this->fXVar = pneut; return; } // Signal asks for 2pi+, 1mu-, 1n bool ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, 211, 2112}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } /* void ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(mcHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(mcFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(mcHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); mcHist->Scale(fScaleFactor); mcFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.cxx index c0c3352..833bd1c 100644 --- a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.cxx @@ -1,100 +1,100 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ /** * D.Day et al, "Study of \nud charged-current two-pion production in the threshold region", Physical Review D, Volume 28, Number 11, 1 December 1983 \n * Derrick, Musgrave, Ammar, Day, Kafka and Mann, "Two- and three-pion productin by \nu\mud recations nears threshold: The implication for nucleon-decay experiments", Physical Review D, Vol 30, Number 7, 1 October 1984 */ #include "ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.h" // The constructor ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu::ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu"; fPlotTitles = "; p_{#pi high} (GeV); Number of events (area norm.)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fIsRawEvents = true; fNormError = 0.20; // normalisation error on ANL BNL flux fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // there's also _unweight rather than weight data file this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC2pi/1pip1pip/CC2pi_1pip1pip1n_pHigh_weight.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); for (int i = 0; i < fDataHist->GetNbinsX()+1; ++i) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(211) == 0) return; TLorentzVector Ppip_high = event->GetHMFSParticle(211)->fP; double ppip_highest = FitUtils::p(Ppip_high); this->fXVar = ppip_highest; return; } // Signal asks for 2pi+, 1mu-, 1n bool ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, 211, 2112}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } /* void ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(mcHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(mcFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(mcHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); mcHist->Scale(fScaleFactor); mcFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.cxx index 8ae70fd..a5b89bb 100644 --- a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.cxx @@ -1,110 +1,110 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ /** * D.Day et al, "Study of \nud charged-current two-pion production in the threshold region", Physical Review D, Volume 28, Number 11, 1 December 1983 \n * Derrick, Musgrave, Ammar, Day, Kafka and Mann, "Two- and three-pion productin by \nu\mud recations nears threshold: The implication for nucleon-decay experiments", Physical Review D, Vol 30, Number 7, 1 October 1984 */ #include "ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.h" // The constructor ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu::ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu"; fPlotTitles = "; p_{#pi low} (GeV); Number of events (area norm.)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fIsRawEvents = true; fNormError = 0.20; // normalisation error on ANL BNL flux fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // there's also _unweight rather than weight data file this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC2pi/1pip1pip/CC2pi_1pip1pip1n_pLow_weight.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); for (int i = 0; i < fDataHist->GetNbinsX()+1; ++i) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu::FillEventVariables(FitEvent *event) { // Because we're looking for a low momentum particle, let's initalise this to a very high momentum particle TLorentzVector Ppip_low(1E5,1E5,1E5,1E5); // Loop over the particle stack to find relevant particles // start at 2 because 0=nu, 1=nucleon, by NEUT default for (UInt_t j = 2; j < event->Npart(); ++j){ if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fNEUTStatusCode != 0 && (event->PartInfo(j)->fNEUTStatusCode != 2)) continue; //move on if NOT ALIVE and NOT NORMAL int PID = (event->PartInfo(j))->fPID; // Select highest momentum positive pion if (PID == 211 && event->PartInfo(j)->fP.E() < Ppip_low.E()) { Ppip_low = event->PartInfo(j)->fP; } } double ppip_lowest = FitUtils::p(Ppip_low); this->fXVar = ppip_lowest; return; } // Signal asks for 2pi+, 1mu-, 1n bool ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, 211, 2112}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } /* void ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(mcHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(mcFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(mcHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); mcHist->Scale(fScaleFactor); mcFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.cxx index d268df1..6b40312 100644 --- a/src/ANL/ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.cxx @@ -1,95 +1,95 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ /** * D.Day et al, "Study of \nud charged-current two-pion production in the threshold region", Physical Review D, Volume 28, Number 11, 1 December 1983 \n * Derrick, Musgrave, Ammar, Day, Kafka and Mann, "Two- and three-pion productin by \nu\mud recations nears threshold: The implication for nucleon-decay experiments", Physical Review D, Vol 30, Number 7, 1 October 1984 */ #include "ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.h" // The constructor ANL_CC2pi_1pip1pip_XSec_1DEnu_nu::ANL_CC2pi_1pip1pip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "ANL_CC2pi_1pip1pip_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/nucleon)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fNormError = 0.20; // normalisation error on ANL BNL flux Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/CC2pi/1pip1pip/CC2pi_1pip1pip1n_xsec.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // Need to multiply the data by a factor because of the way the data is scanned (e.g. 1E-38) //fDataHist->Scale(1.E-41); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void ANL_CC2pi_1pip1pip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { TLorentzVector Pnu = event->GetNeutrinoIn()->fP; double Enu = Pnu.E()/1000.; // No hadronic mass cut or similar here so very simple FillEventVariables this->fXVar = Enu; return; } // Signal asks for 2pi+, 1mu-, 1n bool ANL_CC2pi_1pip1pip_XSec_1DEnu_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, 211, 2112}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } /* void ANL_CC2pi_1pip1pip_XSec_1DEnu_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void ANL_CC2pi_1pip1pip_XSec_1DEnu_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(mcHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(mcFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(mcHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); mcHist->Scale(fScaleFactor); mcFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CCQE_Evt_1DQ2_nu.cxx b/src/ANL/ANL_CCQE_Evt_1DQ2_nu.cxx index 595e3bc..8bc6095 100755 --- a/src/ANL/ANL_CCQE_Evt_1DQ2_nu.cxx +++ b/src/ANL/ANL_CCQE_Evt_1DQ2_nu.cxx @@ -1,223 +1,223 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "ANL_CCQE_Evt_1DQ2_nu.h" //******************************************************************** /// @brief ANL CCQE Q2 Measurement on Free Nucleons (Ref: PRD16 3103) /// /// @details Q2 Extracted assuming numu CCQE scattering of free nucleons. ANL_CCQE_Evt_1DQ2_nu::ANL_CCQE_Evt_1DQ2_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ -//******************************************************************** +//******************************************************************** - // Measurement Details + // Measurement Details fName = name; EnuMin = 0.; EnuMax = 6.; applyQ2correction = type.find("Q2CORR") != std::string::npos; applyEnucorrection = type.find("ENUCORR") != std::string::npos; fDefaultTypes="SHAPE/DIAG"; fAllowedTypes="SHAPE/DIAG/Q2CORR/MASK"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); fIsDiag = true; fIsRawEvents = true; // In future read most of these from a card file if (!name.compare("ANL_CCQE_Evt_1DQ2_nu_PRL31")){ this->SetDataFromDatabase("ANL/ANL_CCQE_Data_PRL31_844.root", "ANL_1DQ2_Data"); applyEnucorrection = false; - EnuMax = 3.0; // Move EnuMax down + EnuMax = 3.0; // Move EnuMax down } else if (!name.compare("ANL_CCQE_Evt_1DQ2_nu_PRD16")){ applyEnucorrection = false; this->SetDataFromDatabase("ANL/ANL_CCQE_Data_PRD16_3103.root", "ANL_1DQ2_Data"); } else { this->SetDataFromDatabase("ANL/ANL_Data_PRD26_537.root","ANL_1DQ2_Data"); - } + } // Setup Histograms this->SetupDefaultHist(); if (applyQ2correction){ this->CorrectionHist = PlotUtils::GetTH1DFromFile(GeneralUtils::GetTopLevelDir() + "/data/ANL/ANL_CCQE_Data_PRL31_844.root","ANL_1DQ2_Correction"); this->fMCHist_NoCorr = (TH1D*) this->fMCHist->Clone(); this->fMCHist_NoCorr->SetNameTitle( (this->fName + "_NOCORR").c_str(),(this->fName + "_NOCORR").c_str()); } if (applyEnucorrection){ this->EnuRatePlot = PlotUtils::GetTH1DFromFile(GeneralUtils::GetTopLevelDir() + "/data/ANL/ANL_Data_PRD26_537.root","ANL_1DEnu_Rate"); this->EnuvsQ2Plot = PlotUtils::MergeIntoTH2D(fDataHist, EnuRatePlot, "Events"); this->EnuFluxUnfoldPlot = (TH1D*)this->EnuRatePlot->Clone(); for (int i = 0; i < this->EnuFluxUnfoldPlot->GetNbinsX(); i++) this->EnuFluxUnfoldPlot->SetBinContent(i+1,1.0); - PlotUtils::FluxUnfoldedScaling(EnuFluxUnfoldPlot, fFluxHist); + PlotUtils::FluxUnfoldedScaling(EnuFluxUnfoldPlot, GetFluxHistogram()); } - + // Setup Covariance // fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); // covar = StatUtils::GetInvert(fFullCovar); - // this->fEventHist->Scale(fDataHist->Integral()/fEventHist->Integral()); - this->fScaleFactor = (this->fDataHist->Integral("width")/(fNEvents+0.)); + // GetEventHistogram()->Scale(fDataHist->Integral()/GetEventHistogram()->Integral()); + this->fScaleFactor = (this->fDataHist->Integral("width")/(fNEvents+0.)); // Set starting scale factor scaleF = -1.0; - + }; //******************************************************************** /// @details Extract q2qe from event assuming quasi-elastic scattering void ANL_CCQE_Evt_1DQ2_nu::FillEventVariables(FitEvent *event){ -//******************************************************************** +//******************************************************************** if (event->NumFSParticle(13) == 0) return; // Fill histogram with reconstructed Q2 Distribution q2qe = 0.0; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; ThetaMu = Pnu.Vect().Angle(Pmu.Vect()); q2qe = FitUtils::Q2QErec(Pmu, cos(ThetaMu), 0.,true); - + fXVar = q2qe; return; }; //******************************************************************** /// @brief Signal is defined as True CCQE numu scattering /// @details cut 1: CCQE event /// @details cut 2: numu event /// @details cut 3: EnuMin < Enu < EnuMax /// @details cut 4: Q2 non-zero bool ANL_CCQE_Evt_1DQ2_nu::isSignal(FitEvent *event){ //******************************************************************** if (!SignalDef::isCCQE(event, 14, EnuMin, EnuMax)) return false; // Q2 cut if (q2qe <= 0) return false; return true; }; //******************************************************************** /// @details Reset the histogram uncorrect void ANL_CCQE_Evt_1DQ2_nu::ResetAll(){ //******************************************************************** Measurement1D::ResetAll(); this->fMCHist->Reset(); if (applyEnucorrection) this->EnuvsQ2Plot->Reset(); if (applyQ2correction) this->fMCHist_NoCorr->Reset(); } -//******************************************************************** +//******************************************************************** /// @details Apply additional event weights for free nucleon measurements void ANL_CCQE_Evt_1DQ2_nu::FillHistograms(){ -//******************************************************************** +//******************************************************************** if (applyEnucorrection) this->EnuvsQ2Plot->Fill(fXVar, Enu, Weight); - + if (applyQ2correction){ this->fMCHist_NoCorr->Fill(fXVar, Weight); if (fXVar < 0.225) this->Weight *= this->CorrectionHist->Interpolate(fXVar); } Measurement1D::FillHistograms(); } -//******************************************************************** +//******************************************************************** void ANL_CCQE_Evt_1DQ2_nu::ScaleEvents(){ -//******************************************************************** +//******************************************************************** if (applyEnucorrection){ - this->EnuvsQ2Plot->Scale(fEventHist->Integral()/(fNEvents+0.)); + this->EnuvsQ2Plot->Scale(GetEventHistogram()->Integral()/(fNEvents+0.)); for (int j = 0; j < EnuvsQ2Plot->GetNbinsY(); j++){ for (int i = 0; i < EnuvsQ2Plot->GetNbinsX(); i++){ this->EnuvsQ2Plot->SetBinContent(i+1,j+1, this->EnuvsQ2Plot->GetBinContent(i+1,j+1) * EnuFluxUnfoldPlot->GetBinContent(j+1)); } } } this->fMCHist->Scale(fScaleFactor); this->fMCFine->Scale(fScaleFactor); if (applyQ2correction) this->fMCHist_NoCorr->Scale(fScaleFactor); // Scale to match data scaleF = PlotUtils::GetDataMCRatio(fDataHist, fMCHist, fMaskHist); this->fMCHist->Scale(scaleF); this->fMCFine->Scale(scaleF); if (applyQ2correction){ scaleF = PlotUtils::GetDataMCRatio(fDataHist, fMCHist_NoCorr, fMaskHist); this->fMCHist_NoCorr->Scale(scaleF); } - + } -//******************************************************************** +//******************************************************************** /// @brief Include Q2 Correction plots into data write void ANL_CCQE_Evt_1DQ2_nu::Write(std::string drawOpt){ -//******************************************************************** +//******************************************************************** Measurement1D::Write(drawOpt); if (applyQ2correction){ this->CorrectionHist->Write(); this->fMCHist_NoCorr->Write(); } if (applyEnucorrection){ this->EnuvsQ2Plot->Write(); ((TH1D*)this->EnuvsQ2Plot->ProjectionX())->Write(); ((TH1D*)this->EnuvsQ2Plot->ProjectionY())->Write(); EnuFluxUnfoldPlot->Write(); EnuRatePlot->Write(); } return; } diff --git a/src/ANL/ANL_CCQE_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CCQE_XSec_1DEnu_nu.cxx index dbe69a7..8e55f14 100644 --- a/src/ANL/ANL_CCQE_XSec_1DEnu_nu.cxx +++ b/src/ANL/ANL_CCQE_XSec_1DEnu_nu.cxx @@ -1,105 +1,105 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "ANL_CCQE_XSec_1DEnu_nu.h" ANL_CCQE_XSec_1DEnu_nu::ANL_CCQE_XSec_1DEnu_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ // Measurement Details - fName = name; + fName = name; EnuMin = 0.; EnuMax = 6.; fIsDiag = true; applyQ2correction = type.find("Q2CORR") != std::string::npos; fDefaultTypes = "FIX/DIAG"; fAllowedTypes = "FIX,FREE,SHAPE/DIAG/Q2CORR/ENUCORR"; - Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); + Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); LOG(SAM) << "SETTING DATA"<<std::endl; // Setup Plots if (!name.compare("ANL_CCQE_XSec_1DEnu_nu_PRL31")){ SetDataFromDatabase("ANL/ANL_CCQE_Data_PRL31_844.root", "ANL_1DEnu_Data"); EnuMax = 3.0; // Move EnuMax down - } else { + } else { SetDataFromDatabase("ANL/ANL_CCQE_Data_PRD16_3103.root", "ANL_1DEnu_fluxtuned_Data"); } SetupDefaultHist(); if (applyQ2correction){ CorrectionHist = PlotUtils::GetTH1DFromFile(GeneralUtils::GetTopLevelDir() + "/data/ANL/ANL_CCQE_Data_PRL31_844.root","ANL_1DQ2_Correction"); } // Setup Covariance fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - + // Different generators require slightly different rescaling factors. - fScaleFactor = (fEventHist->Integral("width")*2.0/1.0*1E-38/(fNEvents+0.)); // NEUT + fScaleFactor = (GetEventHistogram()->Integral("width")*2.0/1.0*1E-38/(fNEvents+0.)); // NEUT }; /// @details Extract Enu and totcrs from event assuming quasi-elastic scattering void ANL_CCQE_XSec_1DEnu_nu::FillEventVariables(FitEvent *event){ if (event->NumFSParticle(13) == 0) return; // Get Q2 - double q2qe = 0.0; + double q2qe = 0.0; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; ThetaMu = Pnu.Vect().Angle(Pmu.Vect()); q2qe = FitUtils::Q2QErec(Pmu, cos(ThetaMu), 0.,true); Enu_rec = FitUtils::EnuQErec(Pmu, cos(ThetaMu), 0.,true); - + fXVar = Enu_rec; // We save q2 into fYVar incase correction is applied fYVar = q2qe; return; }; /// Signal is true CCQE scattering \n /// \item Cut 1: numu event /// \item Cut 2: Mode == 1 /// \item Cut 3: EnuMin < Enu < EnuMax bool ANL_CCQE_XSec_1DEnu_nu::isSignal(FitEvent *event){ return SignalDef::isCCQE(event, 14, EnuMin, EnuMax); }; -//! If Q2 correction is applied the CorrectionHist is interpolated +//! If Q2 correction is applied the CorrectionHist is interpolated //! using the Q2QE value saved in fYVar void ANL_CCQE_XSec_1DEnu_nu::FillHistograms(){ if (applyQ2correction){ if (fYVar < CorrectionHist->GetXaxis()->GetXmin()) Weight *= CorrectionHist->Interpolate(fYVar); } Measurement1D::FillHistograms(); } diff --git a/src/ANL/ANL_NC1npip_Evt_1Dppi_nu.cxx b/src/ANL/ANL_NC1npip_Evt_1Dppi_nu.cxx index 22c3b66..ecb5d1d 100644 --- a/src/ANL/ANL_NC1npip_Evt_1Dppi_nu.cxx +++ b/src/ANL/ANL_NC1npip_Evt_1Dppi_nu.cxx @@ -1,72 +1,72 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "ANL_NC1npip_Evt_1Dppi_nu.h" -/** +/** * M. Derrick et al., "Study of single-pion production by weak neutral currents in low-energy \nu d interactions", Physical Review D, Volume 23, Number 3, 569, 1 February 1981 */ ANL_NC1npip_Evt_1Dppi_nu::ANL_NC1npip_Evt_1Dppi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "ANL_NC1npip_Evt_1Dppi_nu"; fPlotTitles = "; p_{#pi} (MeV); Number of events"; fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // There are two different measurements here; _weight and _unweight // See publication for information this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/NC1npip/ANL_ppi_NC1npip_weight.csv"); //this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/NC1npip/ANL_ppi_NC1npip_weight.csv"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")/((fNEvents+0.)*fFluxHist->Integral("width"))*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")/((fNEvents+0.)*GetFluxHistogram()->Integral("width"))*(16./8.); }; void ANL_NC1npip_Evt_1Dppi_nu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(2112) == 0 || event->NumFSParticle(211) == 0) return; TLorentzVector Pn = event->GetHMFSParticle(2112)->fP;; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP;; double hadMass = FitUtils::MpPi(Pn, Ppip); double ppip = -1.0; - + // ANL has a M(pi, p) < 1.4 GeV cut imposed if (hadMass < 1400) ppip = FitUtils::p(Ppip)*1000.; fXVar = ppip; return; }; bool ANL_NC1npip_Evt_1Dppi_nu::isSignal(FitEvent *event) { return SignalDef::isNC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_NC1ppim_Evt_1DcosmuStar_nu.cxx b/src/ANL/ANL_NC1ppim_Evt_1DcosmuStar_nu.cxx index 2ec2555..55d346a 100644 --- a/src/ANL/ANL_NC1ppim_Evt_1DcosmuStar_nu.cxx +++ b/src/ANL/ANL_NC1ppim_Evt_1DcosmuStar_nu.cxx @@ -1,79 +1,79 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "ANL_NC1ppim_Evt_1DcosmuStar_nu.h" -/** +/** * M. Derrick et al., "Study of the reaction \nu n \rightarrow \nu p \pi^-", Physics Letters, Volume 92B, Number 3,4, 363, 19 May 1980 */ ANL_NC1ppim_Evt_1DcosmuStar_nu::ANL_NC1ppim_Evt_1DcosmuStar_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "ANL_NC1ppim_Evt_1DcosmuStar_nu"; fPlotTitles = "; cos*_{#mu}; Number of events"; EnuMin = 0.3; EnuMax = 1.5; fIsDiag = true; fIsRawEvents = true; fIsEnu1D = false; fDefaultTypes="EVT/SHAPE/DIAG"; fAllowedTypes="EVT/SHAPE/DIAG"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/NC1ppim/ANL_NC1ppim_cosMuStar.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // Set Poisson errors on data points (number of events weighted) for (int i = 0; i < fDataHist->GetNbinsX()+1; ++i) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } - this->fScaleFactor = this->fEventHist->Integral("width")/((fNEvents+0.)*fFluxHist->Integral("width"))*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")/((fNEvents+0.)*GetFluxHistogram()->Integral("width"))*(16./8.); }; void ANL_NC1ppim_Evt_1DcosmuStar_nu::FillEventVariables(FitEvent *event) { - + if (event->NumISParticle(2112) == 0 || event->NumFSParticle(2212) == 0 || event->NumFSParticle(-211) == 0 || event->NumFSParticle(14) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pin = event->GetHMISParticle(2112)->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppim = event->GetHMFSParticle(-211)->fP; TLorentzVector PnuOut = event->GetHMFSParticle(14)->fP; // Boost into centre of mass frame TLorentzVector CMS = Pnu + Pin; // Boost outgoing neutrino backwards CMS PnuOut.Boost(-CMS.BoostVector()); // Boost incoming neutrino forwards by CMS Pnu.Boost(CMS.BoostVector()); double cosmuStar = cos(FitUtils::th(PnuOut, Pnu)); this->fXVar = cosmuStar; return; }; bool ANL_NC1ppim_Evt_1DcosmuStar_nu::isSignal(FitEvent *event) { return SignalDef::isNC1pi3Prong(event, 14, -211, 2212, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_NC1ppim_XSec_1DEnu_nu.cxx b/src/ANL/ANL_NC1ppim_XSec_1DEnu_nu.cxx index a23d613..9326b61 100644 --- a/src/ANL/ANL_NC1ppim_XSec_1DEnu_nu.cxx +++ b/src/ANL/ANL_NC1ppim_XSec_1DEnu_nu.cxx @@ -1,62 +1,62 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "ANL_NC1ppim_XSec_1DEnu_nu.h" -/** +/** * M. Derrick et al., "Study of the reaction \nu n \rightarrow \nu p \pi^-", Physics Letters, Volume 92B, Number 3,4, 363, 19 May 1980 */ ANL_NC1ppim_XSec_1DEnu_nu::ANL_NC1ppim_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "ANL_NC1ppim_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu};#sigma(E_{#nu}) (cm^{2}/nucleon)"; EnuMin = 0.3; EnuMax = 1.5; fIsDiag = true; fIsRawEvents = false; fIsEnu1D = true; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/ANL/NC1ppim/ANL_NC1ppim_Enu_xsec.csv"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // Scale to cross-section // PDAWG: Removed this scaling because it doesn't seem consistent. // fDataHist->Scale(1.E-41); - this->fScaleFactor = this->fEventHist->Integral("width") * 1E-38 /(fNEvents+0)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width") * 1E-38 /(fNEvents+0)*(16./8.); }; void ANL_NC1ppim_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { // Very simple here! double Enu = event->GetNeutrinoIn()->fP.E()/1000.; this->fXVar = Enu; return; }; bool ANL_NC1ppim_XSec_1DEnu_nu::isSignal(FitEvent *event) { return SignalDef::isNC1pi3Prong(event, 14, -211, 2212, EnuMin, EnuMax); } diff --git a/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dpmu_antinu.cxx b/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dpmu_antinu.cxx index 7a15734..66a1b47 100644 --- a/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dpmu_antinu.cxx +++ b/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dpmu_antinu.cxx @@ -1,41 +1,41 @@ #include "ArgoNeuT_CCInc_XSec_1Dpmu_antinu.h" //******************************************************************** ArgoNeuT_CCInc_XSec_1Dpmu_antinu::ArgoNeuT_CCInc_XSec_1Dpmu_antinu( std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) //******************************************************************** { fName = "ArgoNeuT_CCInc_XSec_1Dpmu_antinu"; fDefaultTypes = "FIX/DIAG/CHI2"; fPlotTitles = "; p_{#mu} (GeV); d#sigma/dp_{#mu} (cm^{2} Ar^{-1} GeV^{-1})"; EnuMin = 0; EnuMax = 50; fIsDiag = true; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); SetDataValues(GeneralUtils::GetTopLevelDir() + "/data/ArgoNeuT/CCInc_dsig_dmumom_nubar.dat"); fDataHist->Scale(1E-38); fDataTrue->Scale(1E-38); SetupDefaultHist(); - fScaleFactor = fEventHist->Integral("width") * double(1E-38) / double(fNEvents) * + fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) * (40.0 /*Data is /Ar */) / TotalIntegratedFlux("width"); }; void ArgoNeuT_CCInc_XSec_1Dpmu_antinu::FillEventVariables(FitEvent *event) { FitParticle* pmu = event->GetHMFSParticle(-13); if (pmu) fXVar = pmu->fP.Vect().Mag()/1000.0; return; }; //******************************************************************** bool ArgoNeuT_CCInc_XSec_1Dpmu_antinu::isSignal(FitEvent *event) //******************************************************************** { return SignalDef::isCCINC(event, -14, EnuMin, EnuMax); } diff --git a/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dpmu_nu.cxx b/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dpmu_nu.cxx index dab84b2..cf7094e 100644 --- a/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dpmu_nu.cxx +++ b/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dpmu_nu.cxx @@ -1,59 +1,59 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "ArgoNeuT_CCInc_XSec_1Dpmu_nu.h" //******************************************************************** ArgoNeuT_CCInc_XSec_1Dpmu_nu::ArgoNeuT_CCInc_XSec_1Dpmu_nu( std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) //******************************************************************** { fName = "ArgoNeuT_CCInc_XSec_1Dpmu_nu"; fDefaultTypes = "FIX/DIAG/CHI2"; fPlotTitles = "; p_{#mu} (GeV); d#sigma/dp_{#mu} (cm^{2} Ar^{-1} GeV^{-1})"; EnuMin = 0; EnuMax = 50; fIsDiag = true; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); SetDataValues(GeneralUtils::GetTopLevelDir() + "/data/ArgoNeuT/CCInc_dsig_dmumom_nu.dat"); fDataHist->Scale(1E-38); fDataTrue->Scale(1E-38); SetupDefaultHist(); - fScaleFactor = fEventHist->Integral("width") * double(1E-38) / double(fNEvents) * + fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) * (40.0 /*Data is /Ar */) / TotalIntegratedFlux("width"); }; void ArgoNeuT_CCInc_XSec_1Dpmu_nu::FillEventVariables(FitEvent *event) { FitParticle* pmu = event->GetHMFSParticle(13); if (pmu) fXVar = pmu->fP.Vect().Mag()/1000.0; return; }; //******************************************************************** bool ArgoNeuT_CCInc_XSec_1Dpmu_nu::isSignal(FitEvent *event) //******************************************************************** { return SignalDef::isCCINC(event, 14, EnuMin, EnuMax); } diff --git a/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dthetamu_antinu.cxx b/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dthetamu_antinu.cxx index a333c83..4817f49 100644 --- a/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dthetamu_antinu.cxx +++ b/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dthetamu_antinu.cxx @@ -1,42 +1,42 @@ #include "ArgoNeuT_CCInc_XSec_1Dthetamu_antinu.h" //******************************************************************** ArgoNeuT_CCInc_XSec_1Dthetamu_antinu::ArgoNeuT_CCInc_XSec_1Dthetamu_antinu( std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) //******************************************************************** { fName = "ArgoNeuT_CCInc_XSec_1Dthetamu_antinu"; fDefaultTypes = "FIX/DIAG/CHI2"; fPlotTitles = "; theta_{#mu} (degrees); d#sigma/d#theta_{#mu} (cm^{2} Ar^{-1} " "degrees^{-1})"; EnuMin = 0; EnuMax = 50; fIsDiag = true; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); SetDataValues(GeneralUtils::GetTopLevelDir() + "/data/ArgoNeuT/CCInc_dsig_dthetamu_nubar.dat"); fDataHist->Scale(1E-38); fDataTrue->Scale(1E-38); SetupDefaultHist(); - fScaleFactor = fEventHist->Integral("width") * double(1E-38) / double(fNEvents) * + fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) * (40.0 /*Data is /Ar */) / TotalIntegratedFlux("width"); }; void ArgoNeuT_CCInc_XSec_1Dthetamu_antinu::FillEventVariables(FitEvent *event) { FitParticle* pmu = event->GetHMFSParticle(-13); if (pmu) fXVar = 180.*pmu->fP.Vect().Theta()/TMath::Pi(); return; }; //******************************************************************** bool ArgoNeuT_CCInc_XSec_1Dthetamu_antinu::isSignal(FitEvent *event) //******************************************************************** { return SignalDef::isCCINC(event, -14, EnuMin, EnuMax); } diff --git a/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dthetamu_nu.cxx b/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dthetamu_nu.cxx index 2de3b0d..b8df3a1 100644 --- a/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dthetamu_nu.cxx +++ b/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dthetamu_nu.cxx @@ -1,42 +1,42 @@ #include "ArgoNeuT_CCInc_XSec_1Dthetamu_nu.h" //******************************************************************** ArgoNeuT_CCInc_XSec_1Dthetamu_nu::ArgoNeuT_CCInc_XSec_1Dthetamu_nu( std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) //******************************************************************** { fName = "ArgoNeuT_CCInc_XSec_1Dthetamu_nu"; fDefaultTypes = "FIX/DIAG/CHI2"; fPlotTitles = "; theta_{#mu} (degrees); d#sigma/d#theta_{#mu} (cm^{2} Ar^{-1} " "degrees^{-1})"; EnuMin = 0; EnuMax = 50; fIsDiag = true; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); SetDataValues(GeneralUtils::GetTopLevelDir() + "/data/ArgoNeuT/CCInc_dsig_dthetamu_nu.dat"); fDataHist->Scale(1E-38); fDataTrue->Scale(1E-38); SetupDefaultHist(); - fScaleFactor = fEventHist->Integral("width") * double(1E-38) / double(fNEvents) * + fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) * (40.0 /*Data is /Ar */) / TotalIntegratedFlux("width"); }; void ArgoNeuT_CCInc_XSec_1Dthetamu_nu::FillEventVariables(FitEvent *event) { FitParticle* pmu = event->GetHMFSParticle(13); if (pmu) fXVar = 180.*pmu->fP.Vect().Theta()/TMath::Pi(); return; }; //******************************************************************** bool ArgoNeuT_CCInc_XSec_1Dthetamu_nu::isSignal(FitEvent *event) //******************************************************************** { return SignalDef::isCCINC(event, 14, EnuMin, EnuMax); } diff --git a/src/BEBC/BEBC_CC1npim_XSec_1DEnu_antinu.cxx b/src/BEBC/BEBC_CC1npim_XSec_1DEnu_antinu.cxx index 637f0e8..5ec8b9e 100644 --- a/src/BEBC/BEBC_CC1npim_XSec_1DEnu_antinu.cxx +++ b/src/BEBC/BEBC_CC1npim_XSec_1DEnu_antinu.cxx @@ -1,69 +1,69 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BEBC_CC1npim_XSec_1DEnu_antinu.h" // The constructor BEBC_CC1npim_XSec_1DEnu_antinu::BEBC_CC1npim_XSec_1DEnu_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "BEBC_CC1npim_XSec_1DEnu_antinu"; fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/neutron)"; EnuMin = 5.; EnuMax = 200.; fIsDiag = true; fNormError = 0.20; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BEBC/theses/BEBC_theses_ANU_CC1pi-_nFin_W14.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void BEBC_CC1npim_XSec_1DEnu_antinu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(2112) == 0 || event->NumFSParticle(-211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pn = event->GetHMFSParticle(2112)->fP; TLorentzVector Ppim = event->GetHMFSParticle(-211)->fP; double hadMass = FitUtils::MpPi(Pn, Ppim); double Enu = -1.0; if (hadMass < 1400) Enu = Pnu.E()/1.E3; fXVar = Enu; return; }; bool BEBC_CC1npim_XSec_1DEnu_antinu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, -14, -211, 2112, EnuMin, EnuMax); } diff --git a/src/BEBC/BEBC_CC1npim_XSec_1DQ2_antinu.cxx b/src/BEBC/BEBC_CC1npim_XSec_1DQ2_antinu.cxx index 879f15c..9ae0e47 100644 --- a/src/BEBC/BEBC_CC1npim_XSec_1DQ2_antinu.cxx +++ b/src/BEBC/BEBC_CC1npim_XSec_1DQ2_antinu.cxx @@ -1,88 +1,88 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BEBC_CC1npim_XSec_1DQ2_antinu.h" // The constructor BEBC_CC1npim_XSec_1DQ2_antinu::BEBC_CC1npim_XSec_1DQ2_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "BEBC_CC1npim_XSec_1DQ2_antinu"; fPlotTitles = "; Q^{2} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/GeV^{2}/neutron)"; EnuMin = 5.; EnuMax = 200.; fIsDiag = true; fNormError = 0.20; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BEBC/Dfill/BEBC_Dfill_CC1pi-_on_n_W14_edit.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); hadMassHist = new TH1D((fName+"_Wrec").c_str(),(fName+"_Wrec").c_str(), 100, 1000, 2000); hadMassHist->SetTitle((fName+"; W_{rec} (GeV/c^{2}); Area norm. # of events").c_str()); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/((fNEvents+0.)*this->TotalIntegratedFlux("width"))*16./8.; + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/((fNEvents+0.)*this->TotalIntegratedFlux("width"))*16./8.; }; void BEBC_CC1npim_XSec_1DQ2_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2112) == 0 || event->NumFSParticle(-211) == 0 || event->NumFSParticle(-13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pn = event->GetHMFSParticle(2112)->fP; TLorentzVector Ppim = event->GetHMFSParticle(-211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(-13)->fP; hadMass = FitUtils::MpPi(Pn, Ppim); double q2CCpip = -1.0; if (hadMass < 1400) q2CCpip = -1*(Pnu-Pmu).Mag2()/1.E6; fXVar = q2CCpip; return; }; bool BEBC_CC1npim_XSec_1DQ2_antinu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, -14, -211, 2112, EnuMin, EnuMax); } void BEBC_CC1npim_XSec_1DQ2_antinu::FillHistograms() { Measurement1D::FillHistograms(); hadMassHist->Fill(hadMass); return; } void BEBC_CC1npim_XSec_1DQ2_antinu::Write(std::string drawOpt) { - + Measurement1D::Write(drawOpt); hadMassHist->Scale(1/hadMassHist->Integral()); hadMassHist->Write(); return; } diff --git a/src/BEBC/BEBC_CC1npip_XSec_1DEnu_nu.cxx b/src/BEBC/BEBC_CC1npip_XSec_1DEnu_nu.cxx index ff8d183..6b4fd6f 100644 --- a/src/BEBC/BEBC_CC1npip_XSec_1DEnu_nu.cxx +++ b/src/BEBC/BEBC_CC1npip_XSec_1DEnu_nu.cxx @@ -1,65 +1,65 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BEBC_CC1npip_XSec_1DEnu_nu.h" // The constructor BEBC_CC1npip_XSec_1DEnu_nu::BEBC_CC1npip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "BEBC_CC1npip_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/neutron)"; EnuMin = 5.; EnuMax = 200.; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fNormError = 0.20; // normalisation error on ANL BNL flux Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BEBC/theses/BEBC_theses_CC1pip_on_n_W14.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void BEBC_CC1npip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2112) == 0 || event->NumFSParticle(211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pn = event->GetHMFSParticle(2112)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double hadMass = FitUtils::MpPi(Pn, Ppip); double Enu = -1.0; if (hadMass < 1400) Enu = Pnu.E()/1.E3; fXVar = Enu; return; }; bool BEBC_CC1npip_XSec_1DEnu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax); } diff --git a/src/BEBC/BEBC_CC1npip_XSec_1DQ2_nu.cxx b/src/BEBC/BEBC_CC1npip_XSec_1DQ2_nu.cxx index 478ff08..08cb539 100644 --- a/src/BEBC/BEBC_CC1npip_XSec_1DQ2_nu.cxx +++ b/src/BEBC/BEBC_CC1npip_XSec_1DQ2_nu.cxx @@ -1,89 +1,89 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BEBC_CC1npip_XSec_1DQ2_nu.h" // The constructor BEBC_CC1npip_XSec_1DQ2_nu::BEBC_CC1npip_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "BEBC_CC1npip_XSec_1DQ2_nu"; fPlotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/GeV^{2}/neutron)"; EnuMin = 5; EnuMax = 200; fIsDiag = true; fNormError = 0.20; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BEBC/Dfill/BEBC_Dfill_CC1pi+_on_n_W14_edit.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); hadMassHist = new TH1D((fName+"_Wrec").c_str(),(fName+"_Wrec").c_str(), 100, 1000, 2000); hadMassHist->SetTitle((fName+"; W_{rec} (GeV/c^{2}); Area norm. # of events").c_str()); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/((fNEvents+0.)*this->TotalIntegratedFlux("width"))*16./8.; + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/((fNEvents+0.)*this->TotalIntegratedFlux("width"))*16./8.; }; void BEBC_CC1npip_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(2112) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pn = event->GetHMFSParticle(2112)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; hadMass = FitUtils::MpPi(Pn, Ppip); double q2CCpip = -1.0; - + // BEBC has a 1.1GeV < M(pi, p) < 1.4 GeV cut imposed (also no cut measurement but not useful for delta tuning) if (hadMass < 1400) q2CCpip = -1*(Pnu-Pmu).Mag2()/1.E6; fXVar = q2CCpip; return; }; bool BEBC_CC1npip_XSec_1DQ2_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax); } void BEBC_CC1npip_XSec_1DQ2_nu::FillHistograms() { Measurement1D::FillHistograms(); hadMassHist->Fill(hadMass); return; } void BEBC_CC1npip_XSec_1DQ2_nu::Write(std::string drawOpt) { - + Measurement1D::Write(drawOpt); hadMassHist->Scale(1/hadMassHist->Integral()); hadMassHist->Write(); return; } diff --git a/src/BEBC/BEBC_CC1pi0_XSec_1DEnu_nu.cxx b/src/BEBC/BEBC_CC1pi0_XSec_1DEnu_nu.cxx index 65f7fd1..fe05fd5 100644 --- a/src/BEBC/BEBC_CC1pi0_XSec_1DEnu_nu.cxx +++ b/src/BEBC/BEBC_CC1pi0_XSec_1DEnu_nu.cxx @@ -1,67 +1,67 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BEBC_CC1pi0_XSec_1DEnu_nu.h" // The constructor BEBC_CC1pi0_XSec_1DEnu_nu::BEBC_CC1pi0_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "BEBC_CC1pi0_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/neutron)"; EnuMin = 5.; EnuMax = 200.; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fNormError = 0.20; // normalisation error on ANL BNL flux Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BEBC/theses/BEBC_theses_CC1pi0_W14.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); //this->fScaleFactor = double(1.0E-38)/double(fNEvents)*(16./8.); }; void BEBC_CC1pi0_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(111) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; double hadMass = FitUtils::MpPi(Pp, Ppi0); double Enu = -1.0; if (hadMass < 1400) Enu = Pnu.E()/1.E3; fXVar = Enu; return; }; bool BEBC_CC1pi0_XSec_1DEnu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 111, 2212, EnuMin, EnuMax); } diff --git a/src/BEBC/BEBC_CC1pi0_XSec_1DQ2_nu.cxx b/src/BEBC/BEBC_CC1pi0_XSec_1DQ2_nu.cxx index 003ba13..855573e 100644 --- a/src/BEBC/BEBC_CC1pi0_XSec_1DQ2_nu.cxx +++ b/src/BEBC/BEBC_CC1pi0_XSec_1DQ2_nu.cxx @@ -1,88 +1,88 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BEBC_CC1pi0_XSec_1DQ2_nu.h" // The constructor BEBC_CC1pi0_XSec_1DQ2_nu::BEBC_CC1pi0_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "BEBC_CC1pi0_XSec_1DQ2_nu"; fPlotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/GeV^{2}/neutron)"; EnuMin = 5.; EnuMax = 200.; fIsDiag = true; fNormError = 0.20; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BEBC/Dfill/BEBC_Dfill_CC1pi0_on_n_W14_edit.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); hadMassHist = new TH1D((fName+"_Wrec").c_str(),(fName+"_Wrec").c_str(), 100, 1000, 2000); hadMassHist->SetTitle((fName+"; W_{rec} (GeV/c^{2}); Area norm. # of events").c_str()); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/((fNEvents+0.)*this->TotalIntegratedFlux("width"))*16./8.; + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/((fNEvents+0.)*this->TotalIntegratedFlux("width"))*16./8.; }; void BEBC_CC1pi0_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; hadMass = FitUtils::MpPi(Pp, Ppi0); double q2CCpi0 = -1.0; - + if (hadMass < 1400) q2CCpi0 = -1*(Pnu-Pmu).Mag2()/1.E6; fXVar = q2CCpi0; return; }; bool BEBC_CC1pi0_XSec_1DQ2_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 111, 2212, EnuMin, EnuMax); } void BEBC_CC1pi0_XSec_1DQ2_nu::FillHistograms() { Measurement1D::FillHistograms(); hadMassHist->Fill(hadMass); return; } void BEBC_CC1pi0_XSec_1DQ2_nu::Write(std::string drawOpt) { - + Measurement1D::Write(drawOpt); hadMassHist->Scale(1/hadMassHist->Integral()); hadMassHist->Write(); return; } diff --git a/src/BEBC/BEBC_CC1ppim_XSec_1DEnu_antinu.cxx b/src/BEBC/BEBC_CC1ppim_XSec_1DEnu_antinu.cxx index 418fcc9..72ea5f0 100644 --- a/src/BEBC/BEBC_CC1ppim_XSec_1DEnu_antinu.cxx +++ b/src/BEBC/BEBC_CC1ppim_XSec_1DEnu_antinu.cxx @@ -1,68 +1,68 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BEBC_CC1ppim_XSec_1DEnu_antinu.h" // The constructor BEBC_CC1ppim_XSec_1DEnu_antinu::BEBC_CC1ppim_XSec_1DEnu_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "BEBC_CC1ppim_XSec_1DEnu_antinu"; fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/proton)"; EnuMin = 5.; EnuMax = 200.; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fNormError = 0.20; // normalisation error on ANL BNL flux Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BEBC/theses/BEBC_theses_ANU_CC1pi-_pFin_W14.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void BEBC_CC1ppim_XSec_1DEnu_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(-211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppim = event->GetHMFSParticle(-211)->fP; double hadMass = FitUtils::MpPi(Pp, Ppim); double Enu = -1.0; if (hadMass < 1400) Enu = Pnu.E()/1.E3; fXVar = Enu; return; }; bool BEBC_CC1ppim_XSec_1DEnu_antinu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, -14, -211, 2212, EnuMin, EnuMax); } diff --git a/src/BEBC/BEBC_CC1ppim_XSec_1DQ2_antinu.cxx b/src/BEBC/BEBC_CC1ppim_XSec_1DQ2_antinu.cxx index f6d3fcd..6c403b2 100644 --- a/src/BEBC/BEBC_CC1ppim_XSec_1DQ2_antinu.cxx +++ b/src/BEBC/BEBC_CC1ppim_XSec_1DQ2_antinu.cxx @@ -1,88 +1,88 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BEBC_CC1ppim_XSec_1DQ2_antinu.h" // The constructor BEBC_CC1ppim_XSec_1DQ2_antinu::BEBC_CC1ppim_XSec_1DQ2_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "BEBC_CC1ppim_XSec_1DQ2_antinu"; fPlotTitles = "; Q^{2} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/GeV^{2}/proton)"; EnuMin = 5.; EnuMax = 200.; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fNormError = 0.20; // normalisation error on ANL BNL flux Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BEBC/Dfill/BEBC_Dfill_CC1pi-_on_p_W14_edit.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); hadMassHist = new TH1D((fName+"_Wrec").c_str(),(fName+"_Wrec").c_str(), 100, 1000, 2000); hadMassHist->SetTitle((fName+"; W_{rec} (GeV/c^{2}); Area norm. # of events").c_str()); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/((fNEvents+0.)*this->TotalIntegratedFlux("width"))*16./8.; + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/((fNEvents+0.)*this->TotalIntegratedFlux("width"))*16./8.; }; void BEBC_CC1ppim_XSec_1DQ2_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(-211) == 0 || event->NumFSParticle(-13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppim = event->GetHMFSParticle(-211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(-13)->fP; hadMass = FitUtils::MpPi(Pp, Ppim); double q2CCpip = -1.0; if (hadMass < 1400) q2CCpip = -1*(Pnu-Pmu).Mag2()/1.E6; fXVar = q2CCpip; return; }; bool BEBC_CC1ppim_XSec_1DQ2_antinu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, -14, -211, 2212, EnuMin, EnuMax); } void BEBC_CC1ppim_XSec_1DQ2_antinu::FillHistograms() { Measurement1D::FillHistograms(); hadMassHist->Fill(hadMass); return; } void BEBC_CC1ppim_XSec_1DQ2_antinu::Write(std::string drawOpt) { Measurement1D::Write(drawOpt); hadMassHist->Scale(1/hadMassHist->Integral()); hadMassHist->Write(); return; } diff --git a/src/BEBC/BEBC_CC1ppip_XSec_1DEnu_nu.cxx b/src/BEBC/BEBC_CC1ppip_XSec_1DEnu_nu.cxx index 5fa1316..2137252 100644 --- a/src/BEBC/BEBC_CC1ppip_XSec_1DEnu_nu.cxx +++ b/src/BEBC/BEBC_CC1ppip_XSec_1DEnu_nu.cxx @@ -1,67 +1,67 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BEBC_CC1ppip_XSec_1DEnu_nu.h" // The constructor BEBC_CC1ppip_XSec_1DEnu_nu::BEBC_CC1ppip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "BEBC_CC1ppip_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/proton)"; EnuMin = 5.; EnuMax = 200.; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fNormError = 0.20; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BEBC/theses/BEBC_theses_CC1pip_on_p_W14.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void BEBC_CC1ppip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double hadMass = FitUtils::MpPi(Pp, Ppip); double Enu = -1.0; if (hadMass < 1400) Enu = Pnu.E()/1.E3; fXVar = Enu; return; }; bool BEBC_CC1ppip_XSec_1DEnu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } diff --git a/src/BEBC/BEBC_CC1ppip_XSec_1DQ2_nu.cxx b/src/BEBC/BEBC_CC1ppip_XSec_1DQ2_nu.cxx index c8cbfc9..6c451ba 100644 --- a/src/BEBC/BEBC_CC1ppip_XSec_1DQ2_nu.cxx +++ b/src/BEBC/BEBC_CC1ppip_XSec_1DQ2_nu.cxx @@ -1,91 +1,91 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BEBC_CC1ppip_XSec_1DQ2_nu.h" // The constructor BEBC_CC1ppip_XSec_1DQ2_nu::BEBC_CC1ppip_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "BEBC_CC1ppip_XSec_1DQ2_nu"; fPlotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/GeV^{2}/proton)"; EnuMin = 5; EnuMax = 200; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fNormError = 0.20; // normalisation error on ANL BNL flux Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BEBC/Dfill/BEBC_Dfill_CC1pi+_on_p_W14_edit.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); hadMassHist = new TH1D((fName+"_Wrec").c_str(),(fName+"_Wrec").c_str(), 100, 1000, 2000); hadMassHist->SetTitle((fName+"; W_{rec} (GeV/c^{2}); Area norm. # of events").c_str()); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/((fNEvents+0.)*this->TotalIntegratedFlux("width"))*16./8.; + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/((fNEvents+0.)*this->TotalIntegratedFlux("width"))*16./8.; }; void BEBC_CC1ppip_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; hadMass = FitUtils::MpPi(Pp, Ppip); double q2CCpip = -1.0; - + // BEBC has a M(pi, p) < 1.4 GeV cut imposed only on this channel if (hadMass < 1400) q2CCpip = -1*(Pnu-Pmu).Mag2()/1.E6; fXVar = q2CCpip; return; }; bool BEBC_CC1ppip_XSec_1DQ2_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } void BEBC_CC1ppip_XSec_1DQ2_nu::FillHistograms() { Measurement1D::FillHistograms(); hadMassHist->Fill(hadMass); return; } void BEBC_CC1ppip_XSec_1DQ2_nu::Write(std::string drawOpt) { - + Measurement1D::Write(drawOpt); hadMassHist->Scale(1/hadMassHist->Integral()); hadMassHist->Write(); return; } diff --git a/src/BEBC/BEBC_CCQE_XSec_1DQ2_nu.cxx b/src/BEBC/BEBC_CCQE_XSec_1DQ2_nu.cxx index d0c14fa..dd21074 100755 --- a/src/BEBC/BEBC_CCQE_XSec_1DQ2_nu.cxx +++ b/src/BEBC/BEBC_CCQE_XSec_1DQ2_nu.cxx @@ -1,163 +1,163 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BEBC_CCQE_XSec_1DQ2_nu.h" //******************************************************************** /// @brief BEBC CCQE Q2 Measurement on Free Nucleons (Ref: Nuc.Phys.B.343 285) /// /// @details Q2 Extracted assuming numu CCQE scattering of free nucleons. BEBC_CCQE_XSec_1DQ2_nu::BEBC_CCQE_XSec_1DQ2_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ -//******************************************************************** +//******************************************************************** - // Measurement Details + // Measurement Details fName = name; EnuMin = 0.; EnuMax = 200.; applyQ2correction = type.find("Q2CORR") != std::string::npos; fIsDiag = true; fIsRawEvents = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // In future read most of these from a card file - this->SetDataFromDatabase("BEBC/BEBC_CCQE_Data_NPB343_285.root", "BEBC_1DQ2_Data"); + this->SetDataFromDatabase("BEBC/BEBC_CCQE_Data_NPB343_285.root", "BEBC_1DQ2_Data"); this->SetupDefaultHist(); if (applyQ2correction){ this->CorrectionHist = PlotUtils::GetTH1DFromFile(GeneralUtils::GetTopLevelDir() + "/data/ANL/ANL_CCQE_Data_PRL31_844.root","ANL_XSec_1DQ2_Correction"); this->fMCHist_NoCorr = (TH1D*) this->fMCHist->Clone(); this->fMCHist_NoCorr->SetNameTitle( (this->fName + "_NOCORR").c_str(),(this->fName + "_NOCORR").c_str()); } - + // Setup Covariance fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // Generate events on H2 to get the normalisation right. - this->fScaleFactor = (this->fEventHist->Integral("width")/(fNEvents+0.))*1E-38 / (this->TotalIntegratedFlux("width")); // NEUT + this->fScaleFactor = (GetEventHistogram()->Integral("width")/(fNEvents+0.))*1E-38 / (this->TotalIntegratedFlux("width")); // NEUT // Set starting scale factor scaleF = -1.0; - + }; //******************************************************************** /// @details Extract q2qe from event assuming quasi-elastic scattering void BEBC_CCQE_XSec_1DQ2_nu::FillEventVariables(FitEvent *event){ -//******************************************************************** +//******************************************************************** if (event->NumFSParticle(13) == 0) return; // Fill histogram with reconstructed Q2 Distribution q2qe = 0.0; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; ThetaMu = Pnu.Vect().Angle(Pmu.Vect()); q2qe = FitUtils::Q2QErec(Pmu, cos(ThetaMu), 0.,true); fXVar = q2qe; return; }; //******************************************************************** /// @brief Signal is defined as True CCQE numu scattering /// @details cut 1: numu event /// @details cut 2: EnuMin < Enu < EnuMax /// @details cut 3: Q2 non-zero bool BEBC_CCQE_XSec_1DQ2_nu::isSignal(FitEvent *event){ //******************************************************************** if (!SignalDef::isCCQE(event, 14, EnuMin, EnuMax)) return false; if (q2qe <= 0) return false; return true; }; //******************************************************************** /// @details Reset the histogram uncorrect void BEBC_CCQE_XSec_1DQ2_nu::ResetAll(){ //******************************************************************** Measurement1D::ResetAll(); this->fMCHist->Reset(); if (applyQ2correction) this->fMCHist_NoCorr->Reset(); } -//******************************************************************** +//******************************************************************** /// @details Apply additional event weights for free nucleon measurements void BEBC_CCQE_XSec_1DQ2_nu::FillHistograms(){ -//******************************************************************** +//******************************************************************** + - if (applyQ2correction){ this->fMCHist_NoCorr->Fill(fXVar, Weight); if (fXVar < 0.225) this->Weight *= this->CorrectionHist->Interpolate(fXVar); } Measurement1D::FillHistograms(); } -//******************************************************************** +//******************************************************************** void BEBC_CCQE_XSec_1DQ2_nu::ScaleEvents(){ -//******************************************************************** +//******************************************************************** Measurement1D::ScaleEvents(); if (applyQ2correction) this->fMCHist_NoCorr->Scale(this->fScaleFactor, "width"); return; } -//******************************************************************** +//******************************************************************** void BEBC_CCQE_XSec_1DQ2_nu::ApplyNormScale(double norm){ //******************************************************************** Measurement1D::ApplyNormScale(norm); if (norm == 0.0) scaleF = 0.0; else scaleF = 1.0/norm; - + if (applyQ2correction) this->fMCHist_NoCorr->Scale(scaleF); return; } - -//******************************************************************** + +//******************************************************************** /// @brief Include Q2 Correction plots into data write void BEBC_CCQE_XSec_1DQ2_nu::Write(std::string drawOpt){ -//******************************************************************** +//******************************************************************** Measurement1D::Write(drawOpt); if (applyQ2correction){ this->CorrectionHist->Write(); this->fMCHist_NoCorr->Write(); } - + return; } diff --git a/src/BNL/BNL_CC1npip_Evt_1DQ2_nu.cxx b/src/BNL/BNL_CC1npip_Evt_1DQ2_nu.cxx index a1b3515..0f9984e 100644 --- a/src/BNL/BNL_CC1npip_Evt_1DQ2_nu.cxx +++ b/src/BNL/BNL_CC1npip_Evt_1DQ2_nu.cxx @@ -1,94 +1,94 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BNL_CC1npip_Evt_1DQ2_nu.h" // The constructor BNL_CC1npip_Evt_1DQ2_nu::BNL_CC1npip_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "BNL_CC1npip_Evt_1DQ2_nu"; fPlotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); Number of events"; EnuMin = 0.; EnuMax = 3.; fIsDiag = true; fIsRawEvents = true; fAllowedTypes += "EVT"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BNL/CC1pip_on_n/BNL_CC1pip_on_n_noEvents_q2_noWcut_firstQ2gone.txt"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")/(fNEvents+0.)*16./8.; + this->fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*16./8.; }; void BNL_CC1npip_Evt_1DQ2_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; // No hadronic mass constraint in BNL CC1n1pi+ // This Q2 is Q2 true double q2CCpip = -1*(Pnu-Pmu).Mag2()/1.E6; fXVar = q2CCpip; return; }; bool BNL_CC1npip_Evt_1DQ2_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax); } /* void BNL_CC1npip_Evt_1DQ2_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void BNL_CC1npip_Evt_1DQ2_nu::ScaleEvents() { - - PlotUtils::FluxUnfoldedScaling(fMCHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(fMCFine, fFluxHist); + + PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram()); fMCHist->Scale(fScaleFactor); fMCFine->Scale(fScaleFactor); return; } */ diff --git a/src/BNL/BNL_CC1npip_XSec_1DEnu_nu.cxx b/src/BNL/BNL_CC1npip_XSec_1DEnu_nu.cxx index 515157f..bc00535 100644 --- a/src/BNL/BNL_CC1npip_XSec_1DEnu_nu.cxx +++ b/src/BNL/BNL_CC1npip_XSec_1DEnu_nu.cxx @@ -1,93 +1,93 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BNL_CC1npip_XSec_1DEnu_nu.h" // The constructor BNL_CC1npip_XSec_1DEnu_nu::BNL_CC1npip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "BNL_CC1npip_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/neutron)"; EnuMin = 0.; EnuMax = 3.0; fIsDiag = true; fNormError = 0.15; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BNL/CC1pip_on_n/BNL_CC1pip_on_n_1986.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/((fNEvents+0.))*16./8.; + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/((fNEvents+0.))*16./8.; }; void BNL_CC1npip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { TLorentzVector Pnu = event->GetNeutrinoIn()->fP; // No W cut for BNL CC1pi+ on neutron (I'm happy if you can find it!!!) double Enu = Pnu.E()/1000.; fXVar = Enu; return; }; bool BNL_CC1npip_XSec_1DEnu_nu::isSignal(FitEvent *event) { // BNL has somewhat tricky signal definition for the selection: // P_visible = visible 4-momentum, so the three tracks total momentum // P_visible > 150 MeV/c2 // Theta_Pvis_nu (angle between visible momentum and neutrino direction) < 50 degrees // At least one negative track leaves chamber without interacting or stops consistent with muon // THESE ARE NOT IMPLEMENTED BUT SHOULD BE KNOWN BY ANYONE WHO FITS THIS DATA! (see Kitagaki et al. 2556) // // The only actual restriction seems to be the final state particles. There's no mention of E_nu restrictions either (events span to 10GeV in fig 2, Kitagaki) // There's a mention of uncertainity in the neutrino flux for Enu > 6.0 GeV return SignalDef::isCC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax); } /* void BNL_CC1npip_XSec_1DEnu_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void BNL_CC1npip_XSec_1DEnu_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(fMCHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(fMCFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram()); fMCHist->Scale(fScaleFactor); fMCFine->Scale(fScaleFactor); return; } */ diff --git a/src/BNL/BNL_CC1pi0_Evt_1DQ2_nu.cxx b/src/BNL/BNL_CC1pi0_Evt_1DQ2_nu.cxx index 2b9de79..69572ac 100644 --- a/src/BNL/BNL_CC1pi0_Evt_1DQ2_nu.cxx +++ b/src/BNL/BNL_CC1pi0_Evt_1DQ2_nu.cxx @@ -1,70 +1,70 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BNL_CC1pi0_Evt_1DQ2_nu.h" // The constructor BNL_CC1pi0_Evt_1DQ2_nu::BNL_CC1pi0_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "BNL_CC1pi0_Evt_1DQ2_nu"; fPlotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); Number of events"; EnuMin = 0; EnuMax = 6.0; fIsDiag = true; fIsRawEvents = true; fAllowedTypes += "EVT"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BNL/CC1pi0_on_n/BNL_CC1pi0_on_n_noEvents_q2_noWcut_bin_firstQ2gone.txt"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")/(fNEvents+0.)*16./8.; + this->fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*16./8.; }; void BNL_CC1pi0_Evt_1DQ2_nu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; - // No W cut on BNL CC1pi0 + // No W cut on BNL CC1pi0 // Want true Q2 double q2CCpi0 = -1*(Pnu-Pmu).Mag2()/1.E6; fXVar = q2CCpi0; return; }; bool BNL_CC1pi0_Evt_1DQ2_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 111, 2212, EnuMin, EnuMax); } diff --git a/src/BNL/BNL_CC1pi0_XSec_1DEnu_nu.cxx b/src/BNL/BNL_CC1pi0_XSec_1DEnu_nu.cxx index 6e36cb1..6598dc4 100644 --- a/src/BNL/BNL_CC1pi0_XSec_1DEnu_nu.cxx +++ b/src/BNL/BNL_CC1pi0_XSec_1DEnu_nu.cxx @@ -1,84 +1,84 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BNL_CC1pi0_XSec_1DEnu_nu.h" // The constructor BNL_CC1pi0_XSec_1DEnu_nu::BNL_CC1pi0_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "BNL_CC1pi0_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/neutron)"; EnuMin = 0.; EnuMax = 6.0; fIsDiag = true; fNormError = 0.15; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // THIS IS DEFINITELY DODGY WITH THE "CORRECTION"; EnuMax for BNL definitely stops at 3GeV because of flux uncertainties, although correction goes to 6! this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BNL/CC1pi0_on_n/BNL_CC1pi0_on_n_1986.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/(fNEvents+0.)*16./8.; + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/(fNEvents+0.)*16./8.; }; void BNL_CC1pi0_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { TLorentzVector Pnu = event->GetNeutrinoIn()->fP; //BNL doesn't have a W cut for CC1pi0 sadly (I'm super happy if you can find it!) double Enu = Pnu.E()/1000.; - + fXVar = Enu; return; } bool BNL_CC1pi0_XSec_1DEnu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 111, 2212, EnuMin, EnuMax); } /* void BNL_CC1pi0_XSec_1DEnu_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void BNL_CC1pi0_XSec_1DEnu_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(fMCHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(fMCFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram()); fMCHist->Scale(fScaleFactor); fMCFine->Scale(fScaleFactor); return; } */ diff --git a/src/BNL/BNL_CC1ppip_Evt_1DQ2_nu.cxx b/src/BNL/BNL_CC1ppip_Evt_1DQ2_nu.cxx index a5ef126..5706b25 100644 --- a/src/BNL/BNL_CC1ppip_Evt_1DQ2_nu.cxx +++ b/src/BNL/BNL_CC1ppip_Evt_1DQ2_nu.cxx @@ -1,100 +1,100 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BNL_CC1ppip_Evt_1DQ2_nu.h" // The constructor BNL_CC1ppip_Evt_1DQ2_nu::BNL_CC1ppip_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { fName = "BNL_CC1ppip_Evt_1DQ2_nu"; fPlotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); Number of events"; EnuMin = 0; EnuMax = 3.; fIsDiag = true; fIsRawEvents = true; fAllowedTypes += "EVT"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BNL/CC1pip_on_p/BNL_CC1pip_on_p_noEvents_q2_w14_enu05to6_finebin_firstQ2gone.txt"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")/(fNEvents+0.)*16./8.; + this->fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*16./8.; }; void BNL_CC1ppip_Evt_1DQ2_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pp, Ppip); double q2CCpip = -1.0; // BNL has a M(pi, p) < 1.4 GeV cut imposed only on this channel if (hadMass < 1400) q2CCpip = -1*(Pnu-Pmu).Mag2()/1.E6; fXVar = q2CCpip; return; }; bool BNL_CC1ppip_Evt_1DQ2_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212,EnuMin,EnuMax); } /* void BNL_CC1ppip_Evt_1DQ2_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void BNL_CC1ppip_Evt_1DQ2_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(fMCHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(fMCFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram()); fMCHist->Scale(fScaleFactor); fMCFine->Scale(fScaleFactor); return; } */ diff --git a/src/BNL/BNL_CC1ppip_Evt_1DcosthAdler_nu.cxx b/src/BNL/BNL_CC1ppip_Evt_1DcosthAdler_nu.cxx index 03762b2..c66c1c0 100644 --- a/src/BNL/BNL_CC1ppip_Evt_1DcosthAdler_nu.cxx +++ b/src/BNL/BNL_CC1ppip_Evt_1DcosthAdler_nu.cxx @@ -1,118 +1,118 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BNL_CC1ppip_Evt_1DcosthAdler_nu.h" // The constructor BNL_CC1ppip_Evt_1DcosthAdler_nu::BNL_CC1ppip_Evt_1DcosthAdler_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "BNL_CC1ppip_Evt_1DcosthAdler_nu"; fPlotTitles = "; cos#theta_{Adler}; Number of events"; EnuMin = 0; EnuMax = 6.0; fIsDiag = true; fIsRawEvents = true; fAllowedTypes += "EVT"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BNL/CC1pip_on_p/BNL_CC1ppip_W14_cosThAdler.csv"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")/(fNEvents+0.)*16./8.; + this->fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*16./8.; }; void BNL_CC1ppip_Evt_1DcosthAdler_nu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; - + // Get the hadronic mass double hadMass = FitUtils::MpPi(Pp, Ppip); // Need to boost pion and muon into resonance rest-frame to get phi (e.g. see F. Sanchez arxiv 1511.00501v2) // // Get the resonance 4-vector TLorentzVector Pres = Ppip + Pp; Ppip.Boost(-Pres.BoostVector()); Pmu.Boost(-Pres.BoostVector()); Pnu.Boost(Pres.BoostVector()); // Define the vectors TVector3 PpipVect = Ppip.Vect(); TVector3 PnuVect = Pnu.Vect(); TVector3 PmuVect = Pmu.Vect(); // Define the z-direction; should be same as Pres TVector3 zVect = (PnuVect-PmuVect); zVect *= 1/double(zVect.Mag()); // Then finally construct phi as the angle between pion projection and x axis double cosThAdler = -999; - + // BNL has a M(pi, p) < 1.4 GeV cut imposed if (hadMass < 1400) { cosThAdler = cos(PpipVect.Angle(zVect)); } fXVar = cosThAdler; return; }; bool BNL_CC1ppip_Evt_1DcosthAdler_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212,EnuMin,EnuMax); } /* void BNL_CC1ppip_Evt_1DcosthAdler_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void BNL_CC1ppip_Evt_1DcosthAdler_nu::ScaleEvents() { - - PlotUtils::FluxUnfoldedScaling(fMCHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(fMCFine, fFluxHist); + + PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram()); fMCHist->Scale(fScaleFactor); fMCFine->Scale(fScaleFactor); return; } */ diff --git a/src/BNL/BNL_CC1ppip_Evt_1Dphi_nu.cxx b/src/BNL/BNL_CC1ppip_Evt_1Dphi_nu.cxx index 96c040a..dad974b 100644 --- a/src/BNL/BNL_CC1ppip_Evt_1Dphi_nu.cxx +++ b/src/BNL/BNL_CC1ppip_Evt_1Dphi_nu.cxx @@ -1,147 +1,147 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BNL_CC1ppip_Evt_1Dphi_nu.h" // The constructor BNL_CC1ppip_Evt_1Dphi_nu::BNL_CC1ppip_Evt_1Dphi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "BNL_CC1ppip_Evt_1Dphi_nu"; fPlotTitles = "; #phi_{Adler}; Number of events"; EnuMin = 0; EnuMax = 6.0; fIsDiag = true; fIsRawEvents = true; fAllowedTypes += "EVT"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BNL/CC1pip_on_p/BNL_CC1ppip_W14_phiAdler.csv"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); TRandom3 rand; - this->fScaleFactor = this->fEventHist->Integral("width")/(fNEvents+0.)*16./8.; + this->fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*16./8.; }; void BNL_CC1ppip_Evt_1Dphi_nu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; - + // Get the hadronic mass double hadMass = FitUtils::MpPi(Pp, Ppip); // Need to boost pion and muon into resonance rest-frame to get phi (e.g. see F. Sanchez arxiv 1511.00501v2) // // Get the resonance 4-vector TLorentzVector Pres = Ppip + Pp; // Boost the pion 4-vector into the resonance 4-vector rest-frame Ppip.Boost(Pres.BoostVector()); Pmu.Boost(-Pres.BoostVector()); Pp.Boost(-Pres.BoostVector()); // Get the vectors from the 4-vector TVector3 PmuVect = Pmu.Vect(); TVector3 PnuVect = Pnu.Vect(); TVector3 PresVect = Pres.Vect(); TVector3 PpipVect = Ppip.Vect(); // Define y direction as being z (resonance direction) x pmu* TVector3 zVect = (PnuVect-PmuVect); zVect *= 1/double(zVect.Mag()); TVector3 yVect = zVect.Cross(PmuVect); // Normalise yVector yVect *= 1/double(yVect.Mag()); // define x direction as being y X z TVector3 xVect = yVect.Cross(zVect); // Normalise zVector xVect *= 1/double(xVect.Mag()); // Project pion onto z axis TVector3 PpipVectZ = zVect * PpipVect.Dot(zVect); // Then subtract this vector off the pion vector TVector3 PpipVectPlane = PpipVect - PpipVectZ; // Then finally construct phi as the angle between pion projection and x axis double phi = -999; - + // BNL has a M(pi, p) < 1.4 GeV cut imposed if (hadMass < 1400) { if (PpipVectPlane.Y() > 0) { phi = (180./M_PI)*PpipVectPlane.Angle(xVect); } else if (PpipVectPlane.Y() < 0) { phi = (180./M_PI)*(2*M_PI-PpipVectPlane.Angle(xVect)); } else if (PpipVectPlane.Y() == 0) { double randNo = rand.Rndm(); if (randNo > 0.5) { phi = (180./M_PI)*PpipVectPlane.Angle(xVect); } else { phi = (180./M_PI)*(2*M_PI-PpipVectPlane.Angle(xVect)); } } } fXVar = phi; return; }; bool BNL_CC1ppip_Evt_1Dphi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212,EnuMin,EnuMax); } /* void BNL_CC1ppip_Evt_1Dphi_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void BNL_CC1ppip_Evt_1Dphi_nu::ScaleEvents() { - - PlotUtils::FluxUnfoldedScaling(fMCHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(fMCFine, fFluxHist); + + PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram()); fMCHist->Scale(fScaleFactor); fMCFine->Scale(fScaleFactor); return; } */ diff --git a/src/BNL/BNL_CC1ppip_XSec_1DEnu_nu.cxx b/src/BNL/BNL_CC1ppip_XSec_1DEnu_nu.cxx index 2a6ace3..65efbc7 100644 --- a/src/BNL/BNL_CC1ppip_XSec_1DEnu_nu.cxx +++ b/src/BNL/BNL_CC1ppip_XSec_1DEnu_nu.cxx @@ -1,88 +1,88 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BNL_CC1ppip_XSec_1DEnu_nu.h" // The constructor BNL_CC1ppip_XSec_1DEnu_nu::BNL_CC1ppip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "BNL_CC1ppip_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/proton)"; EnuMin = 0.; EnuMax = 3.0; fIsDiag = true; fNormError = 0.15; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/BNL/CC1pip_on_p/BNL_CC1pip_on_p_W14_1986_corr_edges.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/((fNEvents+0.))*16./8.; + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/((fNEvents+0.))*16./8.; // D2 = 1 proton, 1 neutron }; void BNL_CC1ppip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pp, Ppip); double Enu = -1.0; // Found a corrected one but only reliable to ~3GeV if (hadMass < 1400) Enu = Pnu.E()/1000.; fXVar = Enu; return; }; bool BNL_CC1ppip_XSec_1DEnu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } /* void BNL_CC1ppip_XSec_1DEnu_nu::FillHistograms() { if (makeHadronicMassHist) { hadMassHist->Fill(hadMass); } Measurement1D::FillHistograms(); } void BNL_CC1ppip_XSec_1DEnu_nu::ScaleEvents() { - PlotUtils::FluxUnfoldedScaling(fMCHist, fFluxHist); - PlotUtils::FluxUnfoldedScaling(fMCFine, fFluxHist); + PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram()); + PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram()); fMCHist->Scale(fScaleFactor); fMCFine->Scale(fScaleFactor); return; } */ diff --git a/src/BNL/BNL_CCQE_Evt_1DQ2_nu.cxx b/src/BNL/BNL_CCQE_Evt_1DQ2_nu.cxx index bc94678..e0099c9 100755 --- a/src/BNL/BNL_CCQE_Evt_1DQ2_nu.cxx +++ b/src/BNL/BNL_CCQE_Evt_1DQ2_nu.cxx @@ -1,181 +1,181 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BNL_CCQE_Evt_1DQ2_nu.h" //******************************************************************** /// @brief BNL CCQE Enu Measurement on Free Nucleons (Ref:PRD23 2499) /// -/// @details Enu Extracted assuming numu CCQE scattering of free nucleons. +/// @details Enu Extracted assuming numu CCQE scattering of free nucleons. //******************************************************************** BNL_CCQE_Evt_1DQ2_nu::BNL_CCQE_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ -//******************************************************************** +//******************************************************************** // Measurement Details fName = "BNL_CCQE_Evt_1DQ2_nu"; EnuMin = 0.; EnuMax = 10.; applyQ2correction = type.find("Q2CORR") != std::string::npos; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); - + // override input options fIsDiag = true; fIsRawEvents =true; EnuVsQ2 = new TH2D("EnuVsQ2","EnuVsQ2",25,0.0,10.0,60,0.0,3.0); //Setup Plots this->SetDataFromDatabase("BNL/BNL_Data_PRD23_2499.root", "BNL_1DQ2_Data"); this->SetupDefaultHist(); // Get correction hist if (applyQ2correction){ LOG(SAM) <<"Retrieving Q2 Correction"<<std::endl; this->CorrectionHist = PlotUtils::GetTH1DFromFile(GeneralUtils::GetTopLevelDir() + "/data/ANL/ANL_CCQE_Data_PRL31_844.root","ANL_1DQ2_Correction"); LOG(SAM) << "Creating fMCHist NoCORR"<<std::endl; this->fMCHist_NoCorr = (TH1D*) this->fMCHist->Clone(); this->fMCHist_NoCorr->SetNameTitle( (this->fName + "_NOCORR").c_str(),(this->fName + "_NOCORR").c_str()); } - + // Setup Covariance fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); LOG(SAM)<<"Setting up scaling"<<std::endl; // Setup Scaling - this->fEventHist->Scale(this->fDataHist->Integral()/this->fEventHist->Integral()); - + GetEventHistogram()->Scale(this->fDataHist->Integral()/GetEventHistogram()->Integral()); + // Different generators require slightly different rescaling factors. - this->fScaleFactor = (this->fEventHist->Integral()/(fNEvents+0.)); + this->fScaleFactor = (GetEventHistogram()->Integral()/(fNEvents+0.)); scaleF = -1.0; }; -//******************************************************************** -/// @details Reset the histogram uncorrect +//******************************************************************** +/// @details Reset the histogram uncorrect void BNL_CCQE_Evt_1DQ2_nu::ResetAll(){ -//******************************************************************** +//******************************************************************** Measurement1D::ResetAll(); this->fMCHist->Reset(); this->fMCFine->Reset(); EnuVsQ2->Reset(); if (applyQ2correction) this->fMCHist_NoCorr->Reset(); } //******************************************************************** -/// @details Extract Enu and totcrs from event assuming quasi-elastic scattering +/// @details Extract Enu and totcrs from event assuming quasi-elastic scattering void BNL_CCQE_Evt_1DQ2_nu::FillEventVariables(FitEvent *event){ -//******************************************************************** +//******************************************************************** if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; ThetaMu = Pnu.Vect().Angle(Pmu.Vect()); q2qe = FitUtils::Q2QErec(Pmu, cos(ThetaMu), 0.,true); fXVar = q2qe; return; }; //******************************************************************** bool BNL_CCQE_Evt_1DQ2_nu::isSignal(FitEvent *event){ //******************************************************************** if (!SignalDef::isCCQE(event, 14, EnuMin, EnuMax)) return false; if (q2qe <= 0) return false; return true; }; -//******************************************************************** +//******************************************************************** /// @details Apply Q2 scaling to weight if required void BNL_CCQE_Evt_1DQ2_nu::FillHistograms(){ -//******************************************************************** +//******************************************************************** if (Signal){ if (applyQ2correction){ this->fMCHist_NoCorr->Fill(fXVar,Weight); if (fXVar < 0.225) this->Weight *= this->CorrectionHist->Interpolate(fXVar); } - + EnuVsQ2->Fill(Enu,fXVar, Weight); } if (Signal) Measurement1D::FillHistograms(); LOG(DEB) <<"fXVar = "<<fXVar<<" "<<Weight<<std::endl; return; } //******************************************************************** /// @details Apply scaling to uncorrected fMCHist_NoCorr and scale to match data void BNL_CCQE_Evt_1DQ2_nu::ScaleEvents(){ //******************************************************************** this->fMCHist->Scale(fScaleFactor); this->fMCFine->Scale(fScaleFactor); if (applyQ2correction) this->fMCHist_NoCorr->Scale(fScaleFactor); // Scale to match data scaleF = PlotUtils::GetDataMCRatio(fDataHist, fMCHist, fMaskHist); - + this->fMCHist->Scale(scaleF); this->fMCFine->Scale(scaleF); if (applyQ2correction){ scaleF = PlotUtils::GetDataMCRatio(fDataHist, fMCHist_NoCorr, fMaskHist); this->fMCHist_NoCorr->Scale(scaleF); } - + return; } -//******************************************************************** -/// @brief Include Q2 Correction plots into data write +//******************************************************************** +/// @brief Include Q2 Correction plots into data write void BNL_CCQE_Evt_1DQ2_nu::Write(std::string drawOpt){ -//******************************************************************** +//******************************************************************** Measurement1D::Write(drawOpt); EnuVsQ2->Write(); if (applyQ2correction){ this->CorrectionHist->Write(); this->fMCHist_NoCorr->Write(); } return; } diff --git a/src/BNL/BNL_CCQE_XSec_1DEnu_nu.cxx b/src/BNL/BNL_CCQE_XSec_1DEnu_nu.cxx index 63e2a43..4449624 100644 --- a/src/BNL/BNL_CCQE_XSec_1DEnu_nu.cxx +++ b/src/BNL/BNL_CCQE_XSec_1DEnu_nu.cxx @@ -1,91 +1,91 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "BNL_CCQE_XSec_1DEnu_nu.h" //******************************************************************** /// @brief BNL CCQE Enu Measurement on Free Nucleons (Ref:PRD23 2499) /// -/// @details Enu Extracted assuming numu CCQE scattering of free nucleons. -//******************************************************************** +/// @details Enu Extracted assuming numu CCQE scattering of free nucleons. +//******************************************************************** BNL_CCQE_XSec_1DEnu_nu::BNL_CCQE_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ -//******************************************************************** +//******************************************************************** // Measurement Details fName = "BNL_CCQE_XSec_1DEnu_nu"; EnuMin = 0.; EnuMax = 6.; fIsDiag = true; applyQ2correction = type.find("Q2CORR") != std::string::npos; SetupMeasurement(inputfile, type, rw, fakeDataFile); - + // Setup Plots this->SetDataFromDatabase("BNL/BNL_Data_PRD23_2499.root", "BNL_1DEnu_Data"); this->SetupDefaultHist(); // Get Correction Hist if (applyQ2correction){ this->CorrectionHist = PlotUtils::GetTH1DFromFile(GeneralUtils::GetTopLevelDir() + "/data/ANL/ANL_CCQE_Data_PRL31_844.root","ANL_1DQ2_Correction"); } // Setup Covariance fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = (this->fEventHist->Integral("width")*(2.0/1.0)*1E-38/(fNEvents+0.)); - + this->fScaleFactor = (GetEventHistogram()->Integral("width")*(2.0/1.0)*1E-38/(fNEvents+0.)); + }; //******************************************************************** ///@details Fill Enu for the event void BNL_CCQE_XSec_1DEnu_nu::FillEventVariables(FitEvent *event){ -//******************************************************************** +//******************************************************************** if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; ThetaMu = Pnu.Vect().Angle(Pmu.Vect()); Enu_rec = FitUtils::EnuQErec(Pmu, cos(ThetaMu), 0.,true); - + fXVar = Enu_rec; return; }; //******************************************************************** bool BNL_CCQE_XSec_1DEnu_nu::isSignal(FitEvent *event){ -//******************************************************************** +//******************************************************************** return SignalDef::isCCQE(event, 14, EnuMin, EnuMax); }; -//******************************************************************** -/// @details Apply Q2 scaling to weight if required +//******************************************************************** +/// @details Apply Q2 scaling to weight if required void BNL_CCQE_XSec_1DEnu_nu::FillHistograms(){ -//******************************************************************** - +//******************************************************************** + if (applyQ2correction){ this->Weight *= this->CorrectionHist->Interpolate(q2qe); } Measurement1D::FillHistograms(); } diff --git a/src/FCN/SampleList.cxx b/src/FCN/SampleList.cxx index cb05569..95d0b85 100644 --- a/src/FCN/SampleList.cxx +++ b/src/FCN/SampleList.cxx @@ -1,553 +1,581 @@ #include "SampleList.h" //! Functions to make it easier for samples to be created and handled. namespace SampleUtils { //! Create a given sample given its name, file, type, fakdata(fkdt) file and the //! current rw engine and push it back into the list fChain. bool LoadSample(std::list<MeasurementBase*>* fChain, std::string name, std::string file, std::string type, std::string fkdt, FitWeight* rw) { /* ANL CCQE Samples */ if (!name.compare("ANL_CCQE_XSec_1DEnu_nu") || !name.compare("ANL_CCQE_XSec_1DEnu_nu_PRL31") || !name.compare("ANL_CCQE_XSec_1DEnu_nu_PRD16")) { fChain->push_back(new ANL_CCQE_XSec_1DEnu_nu(name, file, rw, type, fkdt)); } else if (!name.compare("ANL_CCQE_Evt_1DQ2_nu") || !name.compare("ANL_CCQE_Evt_1DQ2_nu_PRL31") || !name.compare("ANL_CCQE_Evt_1DQ2_nu_PRD16")) { fChain->push_back(new ANL_CCQE_Evt_1DQ2_nu(name, file, rw, type, fkdt)); /* ANL CC1ppip samples */ } else if (!name.compare("ANL_CC1ppip_XSec_1DEnu_nu")) { fChain->push_back(new ANL_CC1ppip_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC1ppip_XSec_1DQ2_nu")) { fChain->push_back(new ANL_CC1ppip_XSec_1DQ2_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC1ppip_Evt_1DQ2_nu")) { fChain->push_back(new ANL_CC1ppip_Evt_1DQ2_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC1ppip_Evt_1Dppi_nu")) { fChain->push_back(new ANL_CC1ppip_Evt_1Dppi_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC1ppip_Evt_1Dthpr_nu")) { fChain->push_back(new ANL_CC1ppip_Evt_1Dthpr_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC1ppip_Evt_1DcosmuStar_nu")) { fChain->push_back(new ANL_CC1ppip_Evt_1DcosmuStar_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC1ppip_Evt_1DcosthAdler_nu")) { fChain->push_back( new ANL_CC1ppip_Evt_1DcosthAdler_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC1ppip_Evt_1Dphi_nu")) { fChain->push_back(new ANL_CC1ppip_Evt_1Dphi_nu(file, rw, type, fkdt)); /* ANL CC1npip sample */ } else if (!name.compare("ANL_CC1npip_XSec_1DEnu_nu")) { fChain->push_back(new ANL_CC1npip_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC1npip_Evt_1DQ2_nu")) { fChain->push_back(new ANL_CC1npip_Evt_1DQ2_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC1npip_Evt_1Dppi_nu")) { fChain->push_back(new ANL_CC1npip_Evt_1Dppi_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC1npip_Evt_1DcosmuStar_nu")) { fChain->push_back(new ANL_CC1npip_Evt_1DcosmuStar_nu(file, rw, type, fkdt)); /* ANL CC1pi0 sample */ } else if (!name.compare("ANL_CC1pi0_XSec_1DEnu_nu")) { fChain->push_back(new ANL_CC1pi0_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC1pi0_Evt_1DQ2_nu")) { fChain->push_back(new ANL_CC1pi0_Evt_1DQ2_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC1pi0_Evt_1DcosmuStar_nu")) { fChain->push_back(new ANL_CC1pi0_Evt_1DcosmuStar_nu(file, rw, type, fkdt)); /* ANL NC1npip sample */ } else if (!name.compare("ANL_NC1npip_Evt_1Dppi_nu")) { fChain->push_back(new ANL_NC1npip_Evt_1Dppi_nu(file, rw, type, fkdt)); /* ANL NC1ppim sample */ } else if (!name.compare("ANL_NC1ppim_XSec_1DEnu_nu")) { fChain->push_back(new ANL_NC1ppim_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_NC1ppim_Evt_1DcosmuStar_nu")) { fChain->push_back(new ANL_NC1ppim_Evt_1DcosmuStar_nu(file, rw, type, fkdt)); /* ANL CC2pi sample */ } else if (!name.compare("ANL_CC2pi_1pim1pip_XSec_1DEnu_nu")) { fChain->push_back(new ANL_CC2pi_1pim1pip_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu")) { fChain->push_back(new ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC2pi_1pim1pip_Evt_1Dppip_nu")) { fChain->push_back(new ANL_CC2pi_1pim1pip_Evt_1Dppip_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC2pi_1pim1pip_Evt_1Dppim_nu")) { fChain->push_back(new ANL_CC2pi_1pim1pip_Evt_1Dppim_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu")) { fChain->push_back(new ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC2pi_1pip1pip_XSec_1DEnu_nu")) { fChain->push_back(new ANL_CC2pi_1pip1pip_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu")) { fChain->push_back(new ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu")) { fChain->push_back(new ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu")) { fChain->push_back(new ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu")) { fChain->push_back(new ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu")) { fChain->push_back(new ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu")) { fChain->push_back(new ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu")) { fChain->push_back(new ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu")) { fChain->push_back(new ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu(file, rw, type, fkdt)); } else if (!name.compare("ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu")) { fChain->push_back(new ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu(file, rw, type, fkdt)); } else if (!name.compare("ArgoNeuT_CCInc_XSec_1Dpmu_antinu")) { fChain->push_back( new ArgoNeuT_CCInc_XSec_1Dpmu_antinu(file, rw, type, fkdt)); } else if (!name.compare("ArgoNeuT_CCInc_XSec_1Dpmu_nu")) { fChain->push_back(new ArgoNeuT_CCInc_XSec_1Dpmu_nu(file, rw, type, fkdt)); } else if (!name.compare("ArgoNeuT_CCInc_XSec_1Dthetamu_antinu")) { fChain->push_back( new ArgoNeuT_CCInc_XSec_1Dthetamu_antinu(file, rw, type, fkdt)); } else if (!name.compare("ArgoNeuT_CCInc_XSec_1Dthetamu_nu")) { fChain->push_back( new ArgoNeuT_CCInc_XSec_1Dthetamu_nu(file, rw, type, fkdt)); /* BNL Samples */ } else if (!name.compare("BNL_CCQE_XSec_1DEnu_nu")) { fChain->push_back(new BNL_CCQE_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("BNL_CCQE_Evt_1DQ2_nu")) { fChain->push_back(new BNL_CCQE_Evt_1DQ2_nu(file, rw, type, fkdt)); /* BNL CC1ppip samples */ } else if (!name.compare("BNL_CC1ppip_XSec_1DEnu_nu")) { fChain->push_back(new BNL_CC1ppip_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("BNL_CC1ppip_Evt_1DQ2_nu")) { fChain->push_back(new BNL_CC1ppip_Evt_1DQ2_nu(file, rw, type, fkdt)); } else if (!name.compare("BNL_CC1ppip_Evt_1DcosthAdler_nu")) { fChain->push_back( new BNL_CC1ppip_Evt_1DcosthAdler_nu(file, rw, type, fkdt)); } else if (!name.compare("BNL_CC1ppip_Evt_1Dphi_nu")) { fChain->push_back(new BNL_CC1ppip_Evt_1Dphi_nu(file, rw, type, fkdt)); /* BNL CC1npip samples */ } else if (!name.compare("BNL_CC1npip_XSec_1DEnu_nu")) { fChain->push_back(new BNL_CC1npip_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("BNL_CC1npip_Evt_1DQ2_nu")) { fChain->push_back(new BNL_CC1npip_Evt_1DQ2_nu(file, rw, type, fkdt)); /* BNL CC1pi0 samples */ } else if (!name.compare("BNL_CC1pi0_XSec_1DEnu_nu")) { fChain->push_back(new BNL_CC1pi0_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("BNL_CC1pi0_Evt_1DQ2_nu")) { fChain->push_back(new BNL_CC1pi0_Evt_1DQ2_nu(file, rw, type, fkdt)); /* FNAL Samples */ } else if (!name.compare("FNAL_CCQE_Evt_1DQ2_nu")) { fChain->push_back(new FNAL_CCQE_Evt_1DQ2_nu(file, rw, type, fkdt)); /* FNAL CC1ppip */ } else if (!name.compare("FNAL_CC1ppip_XSec_1DEnu_nu")) { fChain->push_back(new FNAL_CC1ppip_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("FNAL_CC1ppip_XSec_1DQ2_nu")) { fChain->push_back(new FNAL_CC1ppip_XSec_1DQ2_nu(file, rw, type, fkdt)); } else if (!name.compare("FNAL_CC1ppip_Evt_1DQ2_nu")) { fChain->push_back(new FNAL_CC1ppip_Evt_1DQ2_nu(file, rw, type, fkdt)); /* FNAL CC1ppim */ // } else if (!name.compare("FNAL_CC1ppim_XSec_1DEnu_antinu")) { // fChain->push_back(new FNAL_CC1ppim_XSec_1DEnu_antinu(file, rw, type, // fkdt)); /* BEBC Samples */ } else if (!name.compare("BEBC_CCQE_XSec_1DQ2_nu")) { fChain->push_back(new BEBC_CCQE_XSec_1DQ2_nu(name, file, rw, type, fkdt)); /* BEBC CC1ppip samples */ } else if (!name.compare("BEBC_CC1ppip_XSec_1DEnu_nu")) { fChain->push_back(new BEBC_CC1ppip_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("BEBC_CC1ppip_XSec_1DQ2_nu")) { fChain->push_back(new BEBC_CC1ppip_XSec_1DQ2_nu(file, rw, type, fkdt)); /* BEBC CC1npip samples */ } else if (!name.compare("BEBC_CC1npip_XSec_1DEnu_nu")) { fChain->push_back(new BEBC_CC1npip_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("BEBC_CC1npip_XSec_1DQ2_nu")) { fChain->push_back(new BEBC_CC1npip_XSec_1DQ2_nu(file, rw, type, fkdt)); /* BEBC CC1pi0 samples */ } else if (!name.compare("BEBC_CC1pi0_XSec_1DEnu_nu")) { fChain->push_back(new BEBC_CC1pi0_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("BEBC_CC1pi0_XSec_1DQ2_nu")) { fChain->push_back(new BEBC_CC1pi0_XSec_1DQ2_nu(file, rw, type, fkdt)); /* BEBC CC1npim samples */ } else if (!name.compare("BEBC_CC1npim_XSec_1DEnu_antinu")) { fChain->push_back(new BEBC_CC1npim_XSec_1DEnu_antinu(file, rw, type, fkdt)); } else if (!name.compare("BEBC_CC1npim_XSec_1DQ2_antinu")) { fChain->push_back(new BEBC_CC1npim_XSec_1DQ2_antinu(file, rw, type, fkdt)); /* BEBC CC1ppim samples */ } else if (!name.compare("BEBC_CC1ppim_XSec_1DEnu_antinu")) { fChain->push_back(new BEBC_CC1ppim_XSec_1DEnu_antinu(file, rw, type, fkdt)); } else if (!name.compare("BEBC_CC1ppim_XSec_1DQ2_antinu")) { fChain->push_back(new BEBC_CC1ppim_XSec_1DQ2_antinu(file, rw, type, fkdt)); /* GGM CC1ppip samples */ } else if (!name.compare("GGM_CC1ppip_XSec_1DEnu_nu")) { fChain->push_back(new GGM_CC1ppip_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("GGM_CC1ppip_Evt_1DQ2_nu")) { fChain->push_back(new GGM_CC1ppip_Evt_1DQ2_nu(file, rw, type, fkdt)); /* MiniBooNE Samples */ /* CCQE */ } else if (!name.compare("MiniBooNE_CCQE_XSec_1DQ2_nu") || !name.compare("MiniBooNE_CCQELike_XSec_1DQ2_nu")) { fChain->push_back( new MiniBooNE_CCQE_XSec_1DQ2_nu(name, file, rw, type, fkdt)); } else if (!name.compare("MiniBooNE_CCQE_XSec_1DQ2_antinu") || !name.compare("MiniBooNE_CCQELike_XSec_1DQ2_antinu") || !name.compare("MiniBooNE_CCQE_CTarg_XSec_1DQ2_antinu")) { fChain->push_back( new MiniBooNE_CCQE_XSec_1DQ2_antinu(name, file, rw, type, fkdt)); } else if (!name.compare("MiniBooNE_CCQE_XSec_2DTcos_nu") || !name.compare("MiniBooNE_CCQELike_XSec_2DTcos_nu")) { fChain->push_back( new MiniBooNE_CCQE_XSec_2DTcos_nu(name, file, rw, type, fkdt)); } else if (!name.compare("MiniBooNE_CCQE_XSec_2DTcos_antinu") || !name.compare("MiniBooNE_CCQELike_XSec_2DTcos_antinu")) { fChain->push_back( new MiniBooNE_CCQE_XSec_2DTcos_antinu(name, file, rw, type, fkdt)); /* MiniBooNE CC1pi+ */ // 1D } else if (!name.compare("MiniBooNE_CC1pip_XSec_1DEnu_nu")) { fChain->push_back(new MiniBooNE_CC1pip_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("MiniBooNE_CC1pip_XSec_1DQ2_nu")) { fChain->push_back(new MiniBooNE_CC1pip_XSec_1DQ2_nu(file, rw, type, fkdt)); } else if (!name.compare("MiniBooNE_CC1pip_XSec_1DTpi_nu")) { fChain->push_back(new MiniBooNE_CC1pip_XSec_1DTpi_nu(file, rw, type, fkdt)); } else if (!name.compare("MiniBooNE_CC1pip_XSec_1DTu_nu")) { fChain->push_back(new MiniBooNE_CC1pip_XSec_1DTu_nu(file, rw, type, fkdt)); // 2D } else if (!name.compare("MiniBooNE_CC1pip_XSec_2DQ2Enu_nu")) { fChain->push_back( new MiniBooNE_CC1pip_XSec_2DQ2Enu_nu(file, rw, type, fkdt)); } else if (!name.compare("MiniBooNE_CC1pip_XSec_2DTpiCospi_nu")) { fChain->push_back( new MiniBooNE_CC1pip_XSec_2DTpiCospi_nu(file, rw, type, fkdt)); } else if (!name.compare("MiniBooNE_CC1pip_XSec_2DTpiEnu_nu")) { fChain->push_back( new MiniBooNE_CC1pip_XSec_2DTpiEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("MiniBooNE_CC1pip_XSec_2DTuCosmu_nu")) { fChain->push_back( new MiniBooNE_CC1pip_XSec_2DTuCosmu_nu(file, rw, type, fkdt)); } else if (!name.compare("MiniBooNE_CC1pip_XSec_2DTuEnu_nu")) { fChain->push_back( new MiniBooNE_CC1pip_XSec_2DTuEnu_nu(file, rw, type, fkdt)); /* MiniBooNE CC1pi0 */ } else if (!name.compare("MiniBooNE_CC1pi0_XSec_1DEnu_nu")) { fChain->push_back(new MiniBooNE_CC1pi0_XSec_1DEnu_nu(file, rw, type, fkdt)); } else if (!name.compare("MiniBooNE_CC1pi0_XSec_1DQ2_nu")) { fChain->push_back(new MiniBooNE_CC1pi0_XSec_1DQ2_nu(file, rw, type, fkdt)); } else if (!name.compare("MiniBooNE_CC1pi0_XSec_1DTu_nu")) { fChain->push_back(new MiniBooNE_CC1pi0_XSec_1DTu_nu(file, rw, type, fkdt)); } else if (!name.compare("MiniBooNE_CC1pi0_XSec_1Dcosmu_nu")) { fChain->push_back( new MiniBooNE_CC1pi0_XSec_1Dcosmu_nu(file, rw, type, fkdt)); } else if (!name.compare("MiniBooNE_CC1pi0_XSec_1Dcospi0_nu")) { fChain->push_back( new MiniBooNE_CC1pi0_XSec_1Dcospi0_nu(file, rw, type, fkdt)); } else if (!name.compare("MiniBooNE_CC1pi0_XSec_1Dppi0_nu")) { fChain->push_back( new MiniBooNE_CC1pi0_XSec_1Dppi0_nu(file, rw, type, fkdt)); /* MiniBooNE NCEL */ } else if (!name.compare("MiniBooNE_NCEL_XSec_Treco_nu")) { ERR(FTL) << "MiniBooNE_NCEL_XSec_Treco_nu not implemented in current interface." << std::endl; throw 5; // fChain->push_back(new MiniBooNE_NCEL_XSec_Treco_nu(file, rw, type, // fkdt)); /* MINERvA Samples */ } else if (!name.compare("MINERvA_CCQE_XSec_1DQ2_nu") || !name.compare("MINERvA_CCQE_XSec_1DQ2_nu_20deg") || !name.compare("MINERvA_CCQE_XSec_1DQ2_nu_oldflux") || !name.compare("MINERvA_CCQE_XSec_1DQ2_nu_20deg_oldflux")) { fChain->push_back( new MINERvA_CCQE_XSec_1DQ2_nu(name, file, rw, type, fkdt)); } else if (!name.compare("MINERvA_CCQE_XSec_1DQ2_antinu") || !name.compare("MINERvA_CCQE_XSec_1DQ2_antinu_20deg") || !name.compare("MINERvA_CCQE_XSec_1DQ2_antinu_oldflux") || !name.compare("MINERvA_CCQE_XSec_1DQ2_antinu_20deg_oldflux")) { fChain->push_back( new MINERvA_CCQE_XSec_1DQ2_antinu(name, file, rw, type, fkdt)); } else if (!name.compare("MINERvA_CCQE_XSec_1DQ2_joint_oldflux") || !name.compare("MINERvA_CCQE_XSec_1DQ2_joint_20deg_oldflux") || !name.compare("MINERvA_CCQE_XSec_1DQ2_joint") || !name.compare("MINERvA_CCQE_XSec_1DQ2_joint_20deg")){ fChain->push_back(new MINERvA_CCQE_XSec_1DQ2_joint(name, file, rw, type, fkdt)); } else if (!name.compare("MINERvA_CC0pi_XSec_1DEe_nue")) { fChain->push_back(new MINERvA_CC0pi_XSec_1DEe_nue(file, rw, type, fkdt)); } else if (!name.compare("MINERvA_CC0pi_XSec_1DQ2_nue")) { fChain->push_back(new MINERvA_CC0pi_XSec_1DQ2_nue(file, rw, type, fkdt)); } else if (!name.compare("MINERvA_CC0pi_XSec_1DThetae_nue")) { fChain->push_back( new MINERvA_CC0pi_XSec_1DThetae_nue(file, rw, type, fkdt)); } else if (!name.compare("MINERvA_CC0pi_XSec_1DQ2_nu_proton")) { fChain->push_back( new MINERvA_CC0pi_XSec_1DQ2_nu_proton(file, rw, type, fkdt)); /* CC1pi+ */ // DONE } else if (!name.compare("MINERvA_CC1pip_XSec_1DTpi_nu") || !name.compare("MINERvA_CC1pip_XSec_1DTpi_nu_20deg")) { fChain->push_back(new MINERvA_CC1pip_XSec_1DTpi_nu(name, file, rw, type, fkdt)); // DONE } else if (!name.compare("MINERvA_CC1pip_XSec_1Dth_nu") || !name.compare("MINERvA_CC1pip_XSec_1Dth_nu_20deg")) { fChain->push_back(new MINERvA_CC1pip_XSec_1Dth_nu(name, file, rw, type, fkdt)); /* CCNpi+ */ // DONE } else if (!name.compare("MINERvA_CCNpip_XSec_1Dth_nu") || !name.compare("MINERvA_CCNpip_XSec_1Dth_nu_2015") || !name.compare("MINERvA_CCNpip_XSec_1Dth_nu_2016") || !name.compare("MINERvA_CCNpip_XSec_1Dth_nu_20deg") || !name.compare("MINERvA_CCNpip_XSec_1Dth_nu_20deg_2015") || !name.compare("MINERvA_CCNpip_XSec_1Dth_nu_20deg_2016")) { fChain->push_back(new MINERvA_CCNpip_XSec_1Dth_nu(name, file, rw, type, fkdt)); // Done } else if (!name.compare("MINERvA_CCNpip_XSec_1DTpi_nu") || !name.compare("MINERvA_CCNpip_XSec_1DTpi_nu_2015") || !name.compare("MINERvA_CCNpip_XSec_1DTpi_nu_2016") || !name.compare("MINERvA_CCNpip_XSec_1DTpi_nu_20deg") || !name.compare("MINERvA_CCNpip_XSec_1DTpi_nu_20deg_2015") || !name.compare("MINERvA_CCNpip_XSec_1DTpi_nu_20deg_2016") ) { fChain->push_back(new MINERvA_CCNpip_XSec_1DTpi_nu(name, file, rw, type, fkdt)); // Done } else if (!name.compare("MINERvA_CCNpip_XSec_1Dthmu_nu")) { fChain->push_back(new MINERvA_CCNpip_XSec_1Dthmu_nu(file, rw, type, fkdt)); // Done } else if (!name.compare("MINERvA_CCNpip_XSec_1Dpmu_nu")) { fChain->push_back(new MINERvA_CCNpip_XSec_1Dpmu_nu(file, rw, type, fkdt)); // Done } else if (!name.compare("MINERvA_CCNpip_XSec_1DQ2_nu")) { fChain->push_back(new MINERvA_CCNpip_XSec_1DQ2_nu(file, rw, type, fkdt)); // Done } else if (!name.compare("MINERvA_CCNpip_XSec_1DEnu_nu")) { fChain->push_back(new MINERvA_CCNpip_XSec_1DEnu_nu(file, rw, type, fkdt)); /* CC1pi0 */ // Done } else if (!name.compare("MINERvA_CC1pi0_XSec_1Dth_antinu")) { fChain->push_back( new MINERvA_CC1pi0_XSec_1Dth_antinu(name, file, rw, type, fkdt)); // DODGY TPI/PPI DATASET, COME BACK TOO } else if (!name.compare("MINERvA_CC1pi0_XSec_1Dppi0_antinu") || !name.compare("MINERvA_CC1pi0_XSec_1Dppi0_antinu_2015")) { fChain->push_back( new MINERvA_CC1pi0_XSec_1Dppi0_antinu(file, rw, type, fkdt)); } else if (!name.compare("MINERvA_CC1pi0_XSec_1DTpi0_antinu") || !name.compare("MINERvA_CC1pi0_XSec_1DTpi0_antinu_2016") ){ fChain->push_back( new MINERvA_CC1pi0_XSec_1DTpi0_antinu(file, rw, type, fkdt)); // Done } else if (!name.compare("MINERvA_CC1pi0_XSec_1DQ2_antinu")) { fChain->push_back( new MINERvA_CC1pi0_XSec_1DQ2_antinu(file, rw, type, fkdt)); // Done } else if (!name.compare("MINERvA_CC1pi0_XSec_1Dthmu_antinu")) { fChain->push_back( new MINERvA_CC1pi0_XSec_1Dthmu_antinu(file, rw, type, fkdt)); // Done } else if (!name.compare("MINERvA_CC1pi0_XSec_1Dpmu_antinu")) { fChain->push_back( new MINERvA_CC1pi0_XSec_1Dpmu_antinu(file, rw, type, fkdt)); // Done } else if (!name.compare("MINERvA_CC1pi0_XSec_1DEnu_antinu")) { fChain->push_back( new MINERvA_CC1pi0_XSec_1DEnu_antinu(file, rw, type, fkdt)); /* CCINC */ } else if (!name.compare("MINERvA_CCinc_XSec_2DEavq3_nu")) { fChain->push_back(new MINERvA_CCinc_XSec_2DEavq3_nu(file, rw, type, fkdt)); } else if (!name.compare("MINERvA_CCinc_XSec_1Dx_ratio_C12_CH") || !name.compare("MINERvA_CCinc_XSec_1Dx_ratio_Fe56_CH") || !name.compare("MINERvA_CCinc_XSec_1Dx_ratio_Pb208_CH")) { fChain->push_back( new MINERvA_CCinc_XSec_1Dx_ratio(name, file, rw, type, fkdt)); } else if (!name.compare("MINERvA_CCinc_XSec_1DEnu_ratio_C12_CH") || !name.compare("MINERvA_CCinc_XSec_1DEnu_ratio_Fe56_CH") || !name.compare("MINERvA_CCinc_XSec_1DEnu_ratio_Pb208_CH")) { fChain->push_back( new MINERvA_CCinc_XSec_1DEnu_ratio(name, file, rw, type, fkdt)); /* T2K Samples */ } else if (!name.compare("T2K_CC0pi_XSec_2DPcos_nu") || !name.compare("T2K_CC0pi_XSec_2DPcos_nu_I") || !name.compare("T2K_CC0pi_XSec_2DPcos_nu_II")) { fChain->push_back(new T2K_CC0pi_XSec_2DPcos_nu(name, file, rw, type)); + /* T2K CC1pi+ CH samples + */ + // Comment these out for now because we don't have the proper data + /* } else if (!name.compare("T2K_CC1pip_CH_XSec_1Dpmu_nu")) { fChain->push_back(new T2K_CC1pip_CH_XSec_1Dpmu_nu(file, rw, type, fkdt)); } else if (!name.compare("T2K_CC1pip_CH_XSec_1Dppi_nu")) { fChain->push_back(new T2K_CC1pip_CH_XSec_1Dppi_nu(file, rw, type, fkdt)); } else if (!name.compare("T2K_CC1pip_CH_XSec_1DQ2_nu")) { fChain->push_back(new T2K_CC1pip_CH_XSec_1DQ2_nu(file, rw, type, fkdt)); } else if (!name.compare("T2K_CC1pip_CH_XSec_1Dq3_nu")) { fChain->push_back(new T2K_CC1pip_CH_XSec_1Dq3_nu(file, rw, type, fkdt)); } else if (!name.compare("T2K_CC1pip_CH_XSec_1Dthmupi_nu")) { fChain->push_back(new T2K_CC1pip_CH_XSec_1Dthmupi_nu(file, rw, type, fkdt)); } else if (!name.compare("T2K_CC1pip_CH_XSec_1Dthpi_nu")) { fChain->push_back(new T2K_CC1pip_CH_XSec_1Dthpi_nu(file, rw, type, fkdt)); } else if (!name.compare("T2K_CC1pip_CH_XSec_1Dthq3pi_nu")) { fChain->push_back(new T2K_CC1pip_CH_XSec_1Dthq3pi_nu(file, rw, type, fkdt)); } else if (!name.compare("T2K_CC1pip_CH_XSec_1DWrec_nu")) { fChain->push_back(new T2K_CC1pip_CH_XSec_1DWrec_nu(file, rw, type, fkdt)); */ /* + T2K CC1pi+ H2O samples + */ + } else if (!name.compare("T2K_CC1pip_H2O_XSec_1DEnuDelta_nu")) { + fChain->push_back(new T2K_CC1pip_H2O_XSec_1DEnuDelta_nu(file, rw, type, fkdt)); + + } else if (!name.compare("T2K_CC1pip_H2O_XSec_1DEnuMB_nu")) { + fChain->push_back(new T2K_CC1pip_H2O_XSec_1DEnuMB_nu(file, rw, type, fkdt)); + + } else if (!name.compare("T2K_CC1pip_H2O_XSec_1Dcosmu_nu")) { + fChain->push_back(new T2K_CC1pip_H2O_XSec_1Dcosmu_nu(file, rw, type, fkdt)); + + } else if (!name.compare("T2K_CC1pip_H2O_XSec_1Dcosmupi_nu")) { + fChain->push_back(new T2K_CC1pip_H2O_XSec_1Dcosmupi_nu(file, rw, type, fkdt)); + + } else if (!name.compare("T2K_CC1pip_H2O_XSec_1Dcospi_nu")) { + fChain->push_back(new T2K_CC1pip_H2O_XSec_1Dcospi_nu(file, rw, type, fkdt)); + + } else if (!name.compare("T2K_CC1pip_H2O_XSec_1Dpmu_nu")) { + fChain->push_back(new T2K_CC1pip_H2O_XSec_1Dpmu_nu(file, rw, type, fkdt)); + + } else if (!name.compare("T2K_CC1pip_H2O_XSec_1Dppi_nu")) { + fChain->push_back(new T2K_CC1pip_H2O_XSec_1Dppi_nu(file, rw, type, fkdt)); + + /* T2K CC0pi + np CH samples */ } else if (!name.compare("T2K_CC0pinp_STV_XSec_1Ddpt_nu")) { fChain->push_back(new T2K_CC0pinp_STV_XSec_1Ddpt_nu(file, rw, type, fkdt)); /* K2K Samples */ /* NC1pi0 */ } else if (!name.compare("K2K_NC1pi0_Evt_1Dppi0_nu")) { fChain->push_back(new K2K_NC1pi0_Evt_1Dppi0_nu(file, rw, type, fkdt)); /* Fake Studies */ } else if (name.find("ExpMultDist_CCQE_XSec_1D") != std::string::npos && name.find("_FakeStudy") != std::string::npos) { fChain->push_back( new ExpMultDist_CCQE_XSec_1DVar_FakeStudy(name, file, rw, type, fkdt)); } else if (name.find("ExpMultDist_CCQE_XSec_2D") != std::string::npos && name.find("_FakeStudy") != std::string::npos) { fChain->push_back( new ExpMultDist_CCQE_XSec_2DVar_FakeStudy(name, file, rw, type, fkdt)); } else if (name.find("GenericFlux_") != std::string::npos) { fChain->push_back(new GenericFlux_Tester(name, file, rw, type, fkdt)); } else if (name.find("MCStudy_KaonPreSelection") != std::string::npos) { fChain->push_back(new MCStudy_KaonPreSelection(name, file, rw, type, fkdt)); } else if (name.find("MuonValidation_") != std::string::npos) { fChain->push_back(new MCStudy_MuonValidation(name, file, rw, type, fkdt)); } else { ERR(FTL) << "Error: No such sample: " << name << std::endl; exit(-1); return false; } // Return if sample was loaded correctly; return true; } } diff --git a/src/FCN/SampleList.h b/src/FCN/SampleList.h index cc6bb15..a34585a 100644 --- a/src/FCN/SampleList.h +++ b/src/FCN/SampleList.h @@ -1,216 +1,231 @@ #ifndef _SAMPLE_LIST_H_ #define _SAMPLE_LIST_H_ /*! * \addtogroup FCN * @{ */ #include "ANL_CCQE_Evt_1DQ2_nu.h" #include "ANL_CCQE_XSec_1DEnu_nu.h" // ANL CC1ppip #include "ANL_CC1ppip_Evt_1DQ2_nu.h" #include "ANL_CC1ppip_Evt_1DcosmuStar_nu.h" #include "ANL_CC1ppip_Evt_1DcosmuStar_nu.h" #include "ANL_CC1ppip_Evt_1DcosthAdler_nu.h" #include "ANL_CC1ppip_Evt_1Dphi_nu.h" #include "ANL_CC1ppip_Evt_1Dppi_nu.h" #include "ANL_CC1ppip_Evt_1Dthpr_nu.h" #include "ANL_CC1ppip_XSec_1DEnu_nu.h" #include "ANL_CC1ppip_XSec_1DQ2_nu.h" // ANL CC1npip #include "ANL_CC1npip_Evt_1DQ2_nu.h" #include "ANL_CC1npip_Evt_1DcosmuStar_nu.h" #include "ANL_CC1npip_Evt_1Dppi_nu.h" #include "ANL_CC1npip_XSec_1DEnu_nu.h" // ANL CC1pi0 #include "ANL_CC1pi0_Evt_1DQ2_nu.h" #include "ANL_CC1pi0_Evt_1DcosmuStar_nu.h" #include "ANL_CC1pi0_XSec_1DEnu_nu.h" // ANL NC1npip (mm, exotic!) #include "ANL_NC1npip_Evt_1Dppi_nu.h" // ANL NC1ppim (mm, exotic!) #include "ANL_NC1ppim_XSec_1DEnu_nu.h" #include "ANL_NC1ppim_Evt_1DcosmuStar_nu.h" // ANL CC2pi 1pim1pip (mm, even more exotic!) #include "ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.h" #include "ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.h" #include "ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.h" #include "ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.h" #include "ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.h" - +// ANL CC2pi 1pip1pip (mm, even more exotic!) #include "ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.h" #include "ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.h" #include "ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.h" #include "ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.h" #include "ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.h" - +// ANL CC2pi 1pip1pi0 (mm, even more exotic!) #include "ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.h" #include "ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.h" #include "ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.h" #include "ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.h" #include "ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.h" +// ArgoNeuT CC-inclusive #include "ArgoNeuT_CCInc_XSec_1Dpmu_antinu.h" #include "ArgoNeuT_CCInc_XSec_1Dpmu_nu.h" #include "ArgoNeuT_CCInc_XSec_1Dthetamu_antinu.h" #include "ArgoNeuT_CCInc_XSec_1Dthetamu_nu.h" // BNL CCQE #include "BNL_CCQE_Evt_1DQ2_nu.h" #include "BNL_CCQE_XSec_1DEnu_nu.h" // BNL CC1ppip #include "BNL_CC1ppip_Evt_1DQ2_nu.h" #include "BNL_CC1ppip_Evt_1DQ2_nu.h" #include "BNL_CC1ppip_Evt_1DcosthAdler_nu.h" #include "BNL_CC1ppip_Evt_1Dphi_nu.h" #include "BNL_CC1ppip_XSec_1DEnu_nu.h" // BNL CC1npip #include "BNL_CC1npip_Evt_1DQ2_nu.h" #include "BNL_CC1npip_XSec_1DEnu_nu.h" // BNL CC1pi0 #include "BNL_CC1pi0_Evt_1DQ2_nu.h" #include "BNL_CC1pi0_XSec_1DEnu_nu.h" // FNAL CCQE #include "FNAL_CCQE_Evt_1DQ2_nu.h" // FNAL CC1ppip #include "FNAL_CC1ppip_Evt_1DQ2_nu.h" #include "FNAL_CC1ppip_XSec_1DEnu_nu.h" #include "FNAL_CC1ppip_XSec_1DQ2_nu.h" // FNAL CC1ppim //#include "FNAL_CC1ppim_XSec_1DEnu_antinu.h" // BEBC CCQE #include "BEBC_CCQE_XSec_1DQ2_nu.h" // BEBC CC1ppip #include "BEBC_CC1ppip_XSec_1DEnu_nu.h" #include "BEBC_CC1ppip_XSec_1DQ2_nu.h" // BEBC CC1npip #include "BEBC_CC1npip_XSec_1DEnu_nu.h" #include "BEBC_CC1npip_XSec_1DQ2_nu.h" // BEBC CC1pi0 #include "BEBC_CC1pi0_XSec_1DEnu_nu.h" #include "BEBC_CC1pi0_XSec_1DQ2_nu.h" // BEBC CC1npim #include "BEBC_CC1npim_XSec_1DEnu_antinu.h" #include "BEBC_CC1npim_XSec_1DQ2_antinu.h" // BEBC CC1ppim #include "BEBC_CC1ppim_XSec_1DEnu_antinu.h" #include "BEBC_CC1ppim_XSec_1DQ2_antinu.h" // GGM CC1ppip #include "GGM_CC1ppip_Evt_1DQ2_nu.h" #include "GGM_CC1ppip_XSec_1DEnu_nu.h" // MiniBooNE CCQE #include "MiniBooNE_CCQE_XSec_1DQ2_nu.h" #include "MiniBooNE_CCQE_XSec_1DQ2_antinu.h" #include "MiniBooNE_CCQE_XSec_2DTcos_antinu.h" #include "MiniBooNE_CCQE_XSec_2DTcos_antinu.h" #include "MiniBooNE_CCQE_XSec_2DTcos_nu.h" -// MiniBooNE CC1pi+ +// MiniBooNE CC1pi+ 1D #include "MiniBooNE_CC1pip_XSec_1DEnu_nu.h" #include "MiniBooNE_CC1pip_XSec_1DQ2_nu.h" #include "MiniBooNE_CC1pip_XSec_1DTpi_nu.h" #include "MiniBooNE_CC1pip_XSec_1DTu_nu.h" - +// MiniBooNE CC1pi+ 2D #include "MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.h" #include "MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.h" #include "MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.h" #include "MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.h" #include "MiniBooNE_CC1pip_XSec_2DTuEnu_nu.h" // MiniBooNE CC1pi0 #include "MiniBooNE_CC1pi0_XSec_1DEnu_nu.h" #include "MiniBooNE_CC1pi0_XSec_1DQ2_nu.h" #include "MiniBooNE_CC1pi0_XSec_1DTu_nu.h" #include "MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.h" #include "MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.h" #include "MiniBooNE_CC1pi0_XSec_1Dppi0_nu.h" +// MiniBooNE NC1pi0 //#include "MiniBooNE_NCpi0_XSec_1Dppi0_nu.h" // MiniBooNE NCEL // #include "MiniBooNE_NCEL_XSec_Treco_nu.h" // MINERvA CCQE #include "MINERvA_CCQE_XSec_1DQ2_antinu.h" #include "MINERvA_CCQE_XSec_1DQ2_joint.h" #include "MINERvA_CCQE_XSec_1DQ2_nu.h" + // MINERvA CC0pi #include "MINERvA_CC0pi_XSec_1DEe_nue.h" #include "MINERvA_CC0pi_XSec_1DQ2_nu_proton.h" #include "MINERvA_CC0pi_XSec_1DQ2_nue.h" #include "MINERvA_CC0pi_XSec_1DThetae_nue.h" // MINERvA CC1pi+ #include "MINERvA_CC1pip_XSec_1DTpi_20deg_nu.h" #include "MINERvA_CC1pip_XSec_1DTpi_nu.h" #include "MINERvA_CC1pip_XSec_1Dth_20deg_nu.h" #include "MINERvA_CC1pip_XSec_1Dth_nu.h" + // MINERvA CCNpi+ #include "MINERvA_CCNpip_XSec_1Dth_nu.h" #include "MINERvA_CCNpip_XSec_1DTpi_nu.h" #include "MINERvA_CCNpip_XSec_1Dpmu_nu.h" #include "MINERvA_CCNpip_XSec_1Dthmu_nu.h" #include "MINERvA_CCNpip_XSec_1DQ2_nu.h" #include "MINERvA_CCNpip_XSec_1DEnu_nu.h" + // MINERvA CC1pi0 #include "MINERvA_CC1pi0_XSec_1Dth_antinu.h" #include "MINERvA_CC1pi0_XSec_1Dppi0_antinu.h" #include "MINERvA_CC1pi0_XSec_1DTpi0_antinu.h" #include "MINERvA_CC1pi0_XSec_1Dthmu_antinu.h" #include "MINERvA_CC1pi0_XSec_1Dpmu_antinu.h" #include "MINERvA_CC1pi0_XSec_1DQ2_antinu.h" #include "MINERvA_CC1pi0_XSec_1DEnu_antinu.h" // MINERvA CCINC #include "MINERvA_CCinc_XSec_2DEavq3_nu.h" #include "MINERvA_CCinc_XSec_1Dx_ratio.h" #include "MINERvA_CCinc_XSec_1DEnu_ratio.h" // T2K CC0pi #include "T2K_CC0pi_XSec_2DPcos_nu.h" + // T2K CC1pi+ on CH #include "T2K_CC1pip_CH_XSec_1Dpmu_nu.h" #include "T2K_CC1pip_CH_XSec_1Dppi_nu.h" #include "T2K_CC1pip_CH_XSec_1Dthpi_nu.h" #include "T2K_CC1pip_CH_XSec_1Dthmupi_nu.h" #include "T2K_CC1pip_CH_XSec_1DQ2_nu.h" #include "T2K_CC1pip_CH_XSec_1Dq3_nu.h" #include "T2K_CC1pip_CH_XSec_1Dthq3pi_nu.h" #include "T2K_CC1pip_CH_XSec_1DWrec_nu.h" + +// T2K CC1pi+ on H2O +#include "T2K_CC1pip_H2O_XSec_1DEnuDelta_nu.h" +#include "T2K_CC1pip_H2O_XSec_1DEnuMB_nu.h" +#include "T2K_CC1pip_H2O_XSec_1Dcosmu_nu.h" +#include "T2K_CC1pip_H2O_XSec_1Dcosmupi_nu.h" +#include "T2K_CC1pip_H2O_XSec_1Dcospi_nu.h" +#include "T2K_CC1pip_H2O_XSec_1Dpmu_nu.h" +#include "T2K_CC1pip_H2O_XSec_1Dppi_nu.h" + // T2K STV CC0pi #include "T2K_CC0pinp_STV_XSec_1Ddpt_nu.h" // K2K NC1pi0 #include "K2K_NC1pi0_Evt_1Dppi0_nu.h" - // MC Studies #include "ExpMultDist_CCQE_XSec_1DVar_FakeStudy.h" #include "ExpMultDist_CCQE_XSec_2DVar_FakeStudy.h" #include "GenericFlux_Tester.h" #include "MCStudy_KaonPreSelection.h" #include "MCStudy_MuonValidation.h" #include "FitWeight.h" //! Functions to make it easier for samples to be created and handled. namespace SampleUtils { //! Create a given sample given its name, file, type, fakdata(fkdt) file and the //! current rw engine and push it back into the list fChain. bool LoadSample(std::list<MeasurementBase*>* fChain, std::string name, std::string file, std::string type, std::string fkdt, FitWeight* rw); } /*! @} */ #endif diff --git a/src/FNAL/FNAL_CC1ppip_Evt_1DQ2_nu.cxx b/src/FNAL/FNAL_CC1ppip_Evt_1DQ2_nu.cxx index 0ac1a0b..4556e9e 100644 --- a/src/FNAL/FNAL_CC1ppip_Evt_1DQ2_nu.cxx +++ b/src/FNAL/FNAL_CC1ppip_Evt_1DQ2_nu.cxx @@ -1,74 +1,74 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "FNAL_CC1ppip_Evt_1DQ2_nu.h" // The constructor FNAL_CC1ppip_Evt_1DQ2_nu::FNAL_CC1ppip_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "FNAL_CC1ppip_Evt_1DQ2_nu"; fPlotTitles = "; Q^{2}_{CC1#pi} (GeV^{2}); Number of events"; EnuMin = 10; EnuMax = 100; fIsDiag = true; fIsRawEvents = true; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/FNAL/CC1pip_on_p/FNAL_cc1ppip_nEvent_Q2_w14_bin_edit.txt"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")/(fNEvents+0.)*16./8.; + this->fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*16./8.; }; void FNAL_CC1ppip_Evt_1DQ2_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pp, Ppip); double q2CCpip = -1.0; - + // FNAL has a M(pi, p) < 1.4 GeV cut imposed only on this channel if (hadMass < 1400) q2CCpip = -1*(Pnu-Pmu).Mag2()/1.E6; fXVar = q2CCpip; return; }; bool FNAL_CC1ppip_Evt_1DQ2_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } diff --git a/src/FNAL/FNAL_CC1ppip_XSec_1DEnu_nu.cxx b/src/FNAL/FNAL_CC1ppip_XSec_1DEnu_nu.cxx index 2edaf9e..f7e89cf 100644 --- a/src/FNAL/FNAL_CC1ppip_XSec_1DEnu_nu.cxx +++ b/src/FNAL/FNAL_CC1ppip_XSec_1DEnu_nu.cxx @@ -1,64 +1,64 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "FNAL_CC1ppip_XSec_1DEnu_nu.h" // The constructor FNAL_CC1ppip_XSec_1DEnu_nu::FNAL_CC1ppip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "FNAL_CC1ppip_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/proton)"; EnuMin = 10.0; EnuMax = 100.0; fIsDiag = true; fNormError = 0.20; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/FNAL/CC1pip_on_p/fnal78-numu-p-to-mu-p-piplus-lowW_edges.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void FNAL_CC1ppip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double hadMass = FitUtils::MpPi(Pp, Ppip); double Enu = -1.0; if (hadMass < 1400) Enu = Pnu.E()/1.E3; fXVar = Enu; return; } bool FNAL_CC1ppip_XSec_1DEnu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } diff --git a/src/FNAL/FNAL_CC1ppip_XSec_1DQ2_nu.cxx b/src/FNAL/FNAL_CC1ppip_XSec_1DQ2_nu.cxx index 9422df7..57edb0d 100644 --- a/src/FNAL/FNAL_CC1ppip_XSec_1DQ2_nu.cxx +++ b/src/FNAL/FNAL_CC1ppip_XSec_1DQ2_nu.cxx @@ -1,68 +1,68 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "FNAL_CC1ppip_XSec_1DQ2_nu.h" // The constructor FNAL_CC1ppip_XSec_1DQ2_nu::FNAL_CC1ppip_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "FNAL_CC1ppip_XSec_1DQ2_nu"; fPlotTitles = "; Q^{2}_{CC1#pi} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/GeV^{2}/proton)"; EnuMin = 10; EnuMax = 100; fIsDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance fNormError = 0.20; // normalisation error on ANL BNL flux Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/FNAL/CC1pip_on_p/FNAL_cc1ppip_dsigdQ2_W14_edit.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = (this->fEventHist->Integral("width")/TotalIntegratedFlux("width"))*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = (GetEventHistogram()->Integral("width")/TotalIntegratedFlux("width"))*double(1E-38)/double(fNEvents)*(16./8.); }; void FNAL_CC1ppip_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pp, Ppip); double q2CCpip = -1.0; - + // FNAL has a M(pi, p) < 1.4 GeV cut imposed only on this channel if (hadMass < 1400) q2CCpip = -1*(Pnu-Pmu).Mag2()/1.E6; fXVar = q2CCpip; return; }; bool FNAL_CC1ppip_XSec_1DQ2_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } diff --git a/src/FNAL/FNAL_CCQE_Evt_1DQ2_nu.cxx b/src/FNAL/FNAL_CCQE_Evt_1DQ2_nu.cxx index bacb838..a03ed4c 100755 --- a/src/FNAL/FNAL_CCQE_Evt_1DQ2_nu.cxx +++ b/src/FNAL/FNAL_CCQE_Evt_1DQ2_nu.cxx @@ -1,159 +1,159 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "FNAL_CCQE_Evt_1DQ2_nu.h" //******************************************************************** /// @brief FNAL CCQE Q2 Measurement on Free Nucleons (Ref: PRD16 3103) /// /// @details Q2 Extracted assuming numu CCQE scattering of free nucleons. FNAL_CCQE_Evt_1DQ2_nu::FNAL_CCQE_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ -//******************************************************************** +//******************************************************************** - // Measurement Details + // Measurement Details fName = "FNAL_CCQE_Evt_1DQ2_nu"; EnuMin = 0.; EnuMax = 200.; applyQ2correction = type.find("Q2CORR") != std::string::npos; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); fIsDiag = true; fIsRawEvents = true; this->SetDataFromDatabase("FNAL/FNAL_CCQE_Data_PRD29_436.root", "FNAL_CCQE_Data_1DQ2"); this->SetupDefaultHist(); if (applyQ2correction){ this->CorrectionHist = PlotUtils::GetTH1DFromFile(GeneralUtils::GetTopLevelDir() + "/data/ANL/ANL_CCQE_Data_PRL31_844.root","ANL_1DQ2_Correction"); this->fMCHist_NoCorr = (TH1D*) this->fMCHist->Clone(); this->fMCHist_NoCorr->SetNameTitle( (this->fName + "_NOCORR").c_str(),(this->fName + "_NOCORR").c_str()); } // Mask out the first bin if required this->SetBinMask(GeneralUtils::GetTopLevelDir() + "/data/FNAL/FNAL_CCQE_BinMask_PRD29_436.dat"); - + // Setup Covariance fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // Different generators require slightly different rescaling factors. - this->fScaleFactor = (this->fEventHist->Integral()/(fNEvents+0.)); // NEUT + this->fScaleFactor = (GetEventHistogram()->Integral()/(fNEvents+0.)); // NEUT // Set starting scale factor scaleF = -1.0; - + }; //******************************************************************** /// @details Extract q2qe from event assuming quasi-elastic scattering void FNAL_CCQE_Evt_1DQ2_nu::FillEventVariables(FitEvent *event){ -//******************************************************************** +//******************************************************************** if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; ThetaMu = Pnu.Vect().Angle(Pmu.Vect()); q2qe = FitUtils::Q2QErec(Pmu, cos(ThetaMu), 0.,true); - + fXVar = q2qe; return; }; //******************************************************************** bool FNAL_CCQE_Evt_1DQ2_nu::isSignal(FitEvent *event){ //******************************************************************** if (!SignalDef::isCCQE(event, 14, EnuMin, EnuMax)) return false; if (q2qe <= 0) return false; return true; }; //******************************************************************** /// @details Reset the histogram uncorrect void FNAL_CCQE_Evt_1DQ2_nu::ResetAll(){ //******************************************************************** Measurement1D::ResetAll(); this->fMCHist->Reset(); if (applyQ2correction) this->fMCHist_NoCorr->Reset(); } -//******************************************************************** +//******************************************************************** /// @details Apply additional event weights for free nucleon measurements void FNAL_CCQE_Evt_1DQ2_nu::FillHistograms(){ -//******************************************************************** +//******************************************************************** + - if (applyQ2correction){ this->fMCHist_NoCorr->Fill(fXVar, Weight); if (fXVar < 0.225) this->Weight *= this->CorrectionHist->Interpolate(fXVar); } Measurement1D::FillHistograms(); } -//******************************************************************** +//******************************************************************** void FNAL_CCQE_Evt_1DQ2_nu::ScaleEvents(){ -//******************************************************************** +//******************************************************************** this->fMCHist->Scale(fScaleFactor); if (applyQ2correction) this->fMCHist_NoCorr->Scale(fScaleFactor); // Scale to match data scaleF = PlotUtils::GetDataMCRatio(fDataHist, fMCHist, fMaskHist); - + this->fMCHist->Scale(scaleF); this->fMCFine->Scale(scaleF); if (applyQ2correction){ scaleF = PlotUtils::GetDataMCRatio(fDataHist, fMCHist_NoCorr, fMaskHist); this->fMCHist_NoCorr->Scale(scaleF); } } -//******************************************************************** +//******************************************************************** /// @brief Include Q2 Correction plots into data write void FNAL_CCQE_Evt_1DQ2_nu::Write(std::string drawOpt){ -//******************************************************************** +//******************************************************************** Measurement1D::Write(drawOpt); if (applyQ2correction){ this->CorrectionHist->Write(); this->fMCHist_NoCorr->Write(); } - + return; } diff --git a/src/FitBase/FitEvent.cxx b/src/FitBase/FitEvent.cxx index 570492c..c4eafb3 100644 --- a/src/FitBase/FitEvent.cxx +++ b/src/FitBase/FitEvent.cxx @@ -1,879 +1,885 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "FitEvent.h" #include <iostream> #include "TObjArray.h" #ifdef __GENIE_ENABLED__ #include "Conventions/Units.h" #endif //*************************************************** // Refill all the particle vectors etc for the event void FitEvent::CalcKinematics() { //*************************************************** // HELLO SUBLIME #ifdef __NEUT_ENABLED__ if (fType == kNEUT) NeutKinematics(); #endif #ifdef __NUWRO_ENABLED__ if (fType == kNUWRO) NuwroKinematics(); #endif #ifdef __GENIE_ENABLED__ if (fType == kGENIE) GENIEKinematics(); #endif #ifdef __NUANCE_ENABLED__ if (fType == kNUANCE) NuanceKinematics(); #endif #ifdef __GiBUU_ENABLED__ if (fType == kGiBUU) GiBUUKinematics(); #endif return; }; //*************************************************** void FitEvent::ResetEvent() { //*************************************************** // Sort Event Info fMode = 9999; Mode = 9999; fEventNo = -1; fTotCrs = -1.0; fTargetA = -1; fTargetZ = -1; fTargetH = -1; fBound = false; fNParticles = 0; for (unsigned int i = 0; i < kMaxParticles; i++) { FitParticle* fp = fParticleList[i]; if (fp) delete fp; fParticleList[i] = NULL; } } // NEUT GENERATOR SPECIFIC #ifdef __NEUT_ENABLED__ //*************************************************** void FitEvent::SetEventAddress(NeutVect** tempevent) { //*************************************************** fType = kNEUT; fNeutVect = *tempevent; } //*************************************************** void FitEvent::NeutKinematics() { //*************************************************** ResetEvent(); // Get Event Info fMode = fNeutVect->Mode; Mode = fNeutVect->Mode; fEventNo = fNeutVect->EventNo; fTotCrs = fNeutVect->Totcrs; fTargetA = fNeutVect->TargetA; fTargetZ = fNeutVect->TargetZ; fTargetH = fNeutVect->TargetH; fBound = bool(fNeutVect->Ibound); // Check Particle Stack UInt_t npart = fNeutVect->Npart(); if (npart > kMaxParticles) { ERR(FTL) << "NEUT has too many particles" << std::endl; ERR(FTL) << "npart=" << npart << " kMax=" << kMaxParticles << std::endl; throw; } // Fill Particle Stack fNParticles = 0; for (UInt_t i = 0; i < npart; i++) { NeutPart* part = fNeutVect->PartInfo(i); // State int state = kUndefinedState; // fStatus == -1 means initial state if (part->fIsAlive == false && part->fStatus == -1) { state = kInitialState; // NEUT has a bit of a strange convention for fIsAlive and fStatus // combinations // for NC and neutrino particle isAlive true/false and status 2 means // final state particle // for other particles in NC status 2 means it's an FSI particle // for CC it means it was an FSI particle } else if (part->fStatus == 2) { // NC case is a little strange... The outgoing neutrino might be alive or // not alive. Remaining particles with status 2 are FSI particles that // reinteracted if (abs(fNeutVect->Mode) > 30 && (abs(part->fPID) == 14 || abs(part->fPID) == 12)) { state = kFinalState; // The usual CC case } else if (part->fIsAlive == true) { state = kFSIState; } } else if (part->fIsAlive == true && part->fStatus == 2 && (abs(part->fPID) == 14 || abs(part->fPID) == 12)) { state = kFinalState; } else if (part->fIsAlive == true && part->fStatus == 0) { state = kFinalState; } else if (part->fIsAlive == true) { ERR(WRN) << "Undefined NEUT state " << " Alive: " << part->fIsAlive << " Status: " << part->fStatus << " PDG: " << part->fPID << std::endl; throw; } // Remove Undefined // if (kRemoveUndefParticles && // state == kUndefinedState) continue; // Remove FSI // if (kRemoveFSIParticles && // state == kFSIState) continue; fParticleState[fNParticles] = state; // Mom fParticleMom[fNParticles][0] = part->fP.X(); fParticleMom[fNParticles][1] = part->fP.Y(); fParticleMom[fNParticles][2] = part->fP.Z(); fParticleMom[fNParticles][3] = part->fP.T(); // PDG fParticlePDG[fNParticles] = part->fPID; fNParticles++; } OrderStack(); return; }; #endif // NUWRO GENERATOR SPECIFIC #ifdef __NUWRO_ENABLED__ //*************************************************** void FitEvent::SetEventAddress(event** tempevent) { //*************************************************** fType = kNUWRO; fNuwroEvent = *(tempevent); return; } //*************************************************** void FitEvent::NuwroKinematics() { //*************************************************** ResetEvent(); // Sort Event Info fMode = GeneratorUtils::ConvertNuwroMode(fNuwroEvent); Mode = fMode; fEventNo = 0.0; fTotCrs = 0.0; fTargetA = fNuwroEvent->par.nucleus_p + fNuwroEvent->par.nucleus_n; fTargetZ = fNuwroEvent->par.nucleus_p; fTargetH = 0; fBound = (fTargetA) == 1; // Check Particle Stack UInt_t npart_in = fNuwroEvent->in.size(); UInt_t npart_out = fNuwroEvent->out.size(); UInt_t npart_post = fNuwroEvent->post.size(); UInt_t npart = npart_in + npart_out + npart_post; if (npart > kMaxParticles) { ERR(FTL) << "NUWRO has too many particles" << std::endl; ERR(FTL) << "npart=" << npart << " kMax=" << kMaxParticles << " in,out,post = " << npart_in << "," << npart_out << "," << npart_post << std::endl; throw; } // Incoming Particles fNParticles = 0; for (UInt_t i = 0; i < npart_in; i++) { particle* part = &fNuwroEvent->in[i]; fParticleMom[fNParticles][0] = part->p4().x; fParticleMom[fNParticles][1] = part->p4().y; fParticleMom[fNParticles][2] = part->p4().z; fParticleMom[fNParticles][3] = part->p4().t; fParticleState[fNParticles] = kInitialState; fParticlePDG[fNParticles] = part->pdg; fNParticles++; } // FSI Particles if (!kRemoveFSIParticles) { for (UInt_t i = 0; i < npart_out; i++) { particle* part = &fNuwroEvent->out[i]; fParticleMom[fNParticles][0] = part->p4().x; fParticleMom[fNParticles][1] = part->p4().y; fParticleMom[fNParticles][2] = part->p4().z; fParticleMom[fNParticles][3] = part->p4().t; fParticleState[fNParticles] = kFSIState; fParticlePDG[fNParticles] = part->pdg; fNParticles++; } } // Final Particles for (UInt_t i = 0; i < npart_post; i++) { particle* part = &fNuwroEvent->post[i]; fParticleMom[fNParticles][0] = part->p4().x; fParticleMom[fNParticles][1] = part->p4().y; fParticleMom[fNParticles][2] = part->p4().z; fParticleMom[fNParticles][3] = part->p4().t; fParticleState[fNParticles] = kFinalState; fParticlePDG[fNParticles] = part->pdg; fNParticles++; } OrderStack(); return; }; #endif //< NuWro ifdef // REQUIRED FUNCTIONS FOR GENIE #ifdef __GENIE_ENABLED__ //*************************************************** void FitEvent::SetEventAddress(NtpMCEventRecord** tempevent) { //*************************************************** fType = kGENIE; genie_event = *tempevent; }; //*************************************************** void FitEvent::GENIEKinematics() { - //*************************************************** +//*************************************************** ResetEvent(); + + if (!genie_event) return; + if (!genie_event->event) return; + genie_record = static_cast<GHepRecord*>(genie_event->event); // Extra Check for MEC if (genie_record->Summary()->ProcInfo().IsMEC()) { if (pdg::IsNeutrino(genie_record->Summary()->InitState().ProbePdg())) fMode = 2; else if (pdg::IsAntiNeutrino( genie_record->Summary()->InitState().ProbePdg())) fMode = -2; } else { fMode = utils::ghep::NeutReactionCode(genie_record); } // Set Event Info Mode = fMode; fEventNo = 0.0; fTotCrs = genie_record->XSec(); fTargetA = 0.0; fTargetZ = 0.0; fTargetH = 0; fBound = 0.0; InputWeight = (1E+38 / genie::units::cm2) * genie_record->XSec(); // Get N Particle Stack unsigned int npart = genie_record->GetEntries(); if (npart > kMaxParticles) { ERR(FTL) << "GENIE has too many particles" << std::endl; ERR(FTL) << "npart=" << npart << " kMax=" << kMaxParticles << std::endl; throw; } // Fill Particle Stack GHepParticle* p = 0; TObjArrayIter iter(genie_record); fNParticles = 0; /* kIStUndefined = -1, kIStInitialState = 0, / generator-level initial state / kIStStableFinalState = 1, / generator-level final state: particles to be tracked by detector-level MC / kIStIntermediateState = 2, kIStDecayedState = 3, kIStCorrelatedNucleon = 10, kIStNucleonTarget = 11, kIStDISPreFragmHadronicState = 12, kIStPreDecayResonantState = 13, kIStHadronInTheNucleus = 14, / hadrons inside the nucleus: marked for hadron transport modules to act on / kIStFinalStateNuclearRemnant = 15, / low energy nuclear fragments entering the record collectively as a 'hadronic blob' pseudo-particle / kIStNucleonClusterTarget = 16, // for composite nucleons before phase space decay */ // Loop over all particles while ((p = (dynamic_cast<genie::GHepParticle*>((iter).Next())))) { if (!p) continue; // State int state = kUndefinedState; switch (p->Status()) { case genie::kIStNucleonTarget: case genie::kIStInitialState: case genie::kIStCorrelatedNucleon: case genie::kIStNucleonClusterTarget: state = kInitialState; break; case genie::kIStStableFinalState: state = kFinalState; break; case genie::kIStHadronInTheNucleus: if (abs(fMode) == 2) state = kInitialState; else state = kFSIState; break; case genie::kIStPreDecayResonantState: case genie::kIStDISPreFragmHadronicState: case genie::kIStIntermediateState: state = kFSIState; break; case genie::kIStFinalStateNuclearRemnant: case genie::kIStUndefined: case genie::kIStDecayedState: default: break; } // Flag to remove nuclear part in genie if (p->Pdg() > 1000000) { if (state == kInitialState) state = kNuclearInitial; else if (state == kFinalState) state = kNuclearRemnant; } // if (kRemoveGenieNuclear && // (state == kNuclearInitial || state == kNuclearRemnant)){ // continue; //} // Remove Undefined // if (kRemoveUndefParticles && // state == kUndefinedState) continue; // Remove FSI // if (kRemoveFSIParticles && // state == kFSIState) continue; fParticleState[fNParticles] = state; // Mom fParticleMom[fNParticles][0] = p->Px() * 1.E3; fParticleMom[fNParticles][1] = p->Py() * 1.E3; fParticleMom[fNParticles][2] = p->Pz() * 1.E3; fParticleMom[fNParticles][3] = p->E() * 1.E3; // PDG fParticlePDG[fNParticles] = p->Pdg(); fNParticles++; + + if (fNParticles == kMaxParticles) break; } OrderStack(); LOG(DEB) << "GENIE Particle Stack" << std::endl; for (int i = 0; i < fNParticles; i++) { LOG(DEB) << "Particle " << i << ". " << fParticlePDG[i] << " " << fParticleMom[i][0] << " " << fParticleMom[i][1] << " " << fParticleMom[i][2] << " " << fParticleMom[i][3] << " " << fParticleState[i] << std::endl; } return; }; #endif //< GENIE ifdef // REQUIRED FUNCTIONS FOR GIBUU #ifdef __GiBUU_ENABLED__ //*************************************************** void FitEvent::SetEventAddress(GiBUUStdHepReader* tempevent) { //*************************************************** fType = kGiBUU; GiRead = tempevent; } //*************************************************** void FitEvent::GiBUUKinematics() { //*************************************************** ResetEvent(); LOG(DEB) << "Reading GiBUU Event: " << std::endl; LOG(DEB) << WriteGiBUUEvent(*GiRead) << std::endl; fMode = GiRead->GiBUU2NeutCode; Mode = fMode; fEventNo = 0.0; fTotCrs = 0; fTargetA = 0.0; fTargetZ = 0.0; fTargetH = 0; fBound = 0.0; // Extra GiBUU Input Weight InputWeight = GiRead->EvtWght; // Check Stack N int npart = GiRead->StdHepN; if ((uint)npart > kMaxParticles) { ERR(FTL) << "GiBUU has too many particles" << std::endl; ERR(FTL) << "npart=" << npart << " kMax=" << kMaxParticles << std::endl; throw; } // Create Stack fNParticles = 0; for (int i = 0; i < npart; i++) { // State int state = kUndefinedState; switch (GiRead->StdHepStatus[i]) { case 0: // Incoming case 11: // Struck nucleon state = kInitialState; break; case 1: // Good Final State state = kFinalState; break; default: // Other break; } // Set Nuclear States Flag if (GiRead->StdHepPdg[i] > 1000000) { if (state == kInitialState) state = kNuclearInitial; else if (state == kFinalState) state = kNuclearRemnant; continue; } // Remove Nuclear States // if (kRemoveGiBUUNuclear && // (state == kNuclearInitial || state == kNuclearRemnant)){ // continue; //} // Remove Undefined // if (kRemoveUndefParticles && // state == kUndefinedState) continue; // Remove FSI // if (kRemoveFSIParticles && // state == kFSIState) continue; // Set State fParticleState[fNParticles] = state; // Mom fParticleMom[fNParticles][0] = GiRead->StdHepP4[i][0] * 1.E3; fParticleMom[fNParticles][1] = GiRead->StdHepP4[i][1] * 1.E3; fParticleMom[fNParticles][2] = GiRead->StdHepP4[i][2] * 1.E3; fParticleMom[fNParticles][3] = GiRead->StdHepP4[i][3] * 1.E3; // PDG fParticlePDG[fNParticles] = GiRead->StdHepPdg[i]; fNParticles++; } OrderStack(); LOG(DEB) << "GiBUU Particle Stack" << std::endl; for (int i = 0; i < fNParticles; i++) { LOG(DEB) << "Particle " << i << ". " << fParticlePDG[i] << " " << fParticleMom[i][0] << " " << fParticleMom[i][1] << " " << fParticleMom[i][2] << " " << fParticleMom[i][3] << " " << fParticleState[i] << std::endl; } } #endif //< GiBUU ifdef //*************************************************** void FitEvent::OrderStack() { //*************************************************** // Copy current stack int oldpartpdg[kMaxParticles]; int oldpartstate[kMaxParticles]; double oldpartmom[kMaxParticles][4]; int npart = fNParticles; for (int i = 0; i < npart; i++) { oldpartpdg[i] = fParticlePDG[i]; oldpartstate[i] = fParticleState[i]; oldpartmom[i][0] = fParticleMom[i][0]; oldpartmom[i][1] = fParticleMom[i][1]; oldpartmom[i][2] = fParticleMom[i][2]; oldpartmom[i][3] = fParticleMom[i][3]; } // Now run loops for each particle fNParticles = 0; int stateorder[6] = {kInitialState, kFinalState, kFSIState, kNuclearInitial, kNuclearRemnant, kUndefinedState}; for (int s = 0; s < 6; s++) { for (int i = 0; i < npart; i++) { if (oldpartstate[i] != stateorder[s]) continue; fParticlePDG[fNParticles] = oldpartpdg[i]; fParticleState[fNParticles] = oldpartstate[i]; fParticleMom[fNParticles][0] = oldpartmom[i][0]; fParticleMom[fNParticles][1] = oldpartmom[i][1]; fParticleMom[fNParticles][2] = oldpartmom[i][2]; fParticleMom[fNParticles][3] = oldpartmom[i][3]; fNParticles++; } } LOG(DEB) << "Ordered stack" << std::endl; for (int i = 0; i < fNParticles; i++) { LOG(DEB) << "Particle " << i << ". " << fParticlePDG[i] << " " << fParticleMom[i][0] << " " << fParticleMom[i][1] << " " << fParticleMom[i][2] << " " << fParticleMom[i][3] << " " << fParticleState[i] << std::endl; } if (fNParticles != npart) { ERR(FTL) << "Dropped some particles when ordering the stack!" << std::endl; } return; } // REQUIRED FUNCTIONS FOR NUANCE #ifdef __NUANCE_ENABLED__ //*************************************************** void FitEvent::SetEventAddress(NuanceEvent** tempevent) { //*************************************************** fType = kNUANCE; nuance_event = *tempevent; } //*************************************************** void FitEvent::NuanceKinematics() { //*************************************************** ResetEvent(); fMode = GeneratorUtils::ConvertNuanceMode(nuance_event); Mode = fMode; fEventNo = 0.0; fTotCrs = 1.0; fTargetA = 0.0; fTargetZ = 0.0; fTargetH = 0; fBound = 0.0; // Fill particle Stack fNParticles = 0; // Check Particle Stack UInt_t npart = 2 + nuance_event->n_leptons + nuance_event->n_hadrons; if (npart > kMaxParticles) { ERR(FTL) << "NUANCE has too many particles" << std::endl; ERR(FTL) << "npart=" << npart << " kMax=" << kMaxParticles << std::endl; throw; } // Fill Neutrino fParticleState[0] = kInitialState; fParticleMom[0][0] = nuance_event->p_neutrino[0]; fParticleMom[0][1] = nuance_event->p_neutrino[1]; fParticleMom[0][2] = nuance_event->p_neutrino[2]; fParticleMom[0][3] = nuance_event->p_neutrino[3]; fParticlePDG[0] = nuance_event->neutrino; // Fill Target Nucleon fParticleState[1] = kInitialState; fParticleMom[1][0] = nuance_event->p_targ[0]; fParticleMom[1][1] = nuance_event->p_targ[1]; fParticleMom[1][2] = nuance_event->p_targ[2]; fParticleMom[1][3] = nuance_event->p_targ[3]; fParticlePDG[1] = nuance_event->target; fNParticles = 2; // Fill Outgoing Leptons for (int i = 0; i < nuance_event->n_leptons; i++) { fParticleState[fNParticles] = kFinalState; fParticleMom[fNParticles][0] = nuance_event->p_lepton[i][0]; fParticleMom[fNParticles][1] = nuance_event->p_lepton[i][1]; fParticleMom[fNParticles][2] = nuance_event->p_lepton[i][2]; fParticleMom[fNParticles][3] = nuance_event->p_lepton[i][3]; fParticlePDG[fNParticles] = nuance_event->lepton[i]; fNParticles++; } // Fill Outgoing Hadrons for (int i = 0; i < nuance_event->n_hadrons; i++) { fParticleState[fNParticles] = kFinalState; fParticleMom[fNParticles][0] = nuance_event->p_hadron[i][0]; fParticleMom[fNParticles][1] = nuance_event->p_hadron[i][1]; fParticleMom[fNParticles][2] = nuance_event->p_hadron[i][2]; fParticleMom[fNParticles][3] = nuance_event->p_hadron[i][3]; fParticlePDG[fNParticles] = nuance_event->hadron[i]; fNParticles++; } } #endif /* Read/Write own event class */ void FitEvent::SetBranchAddress(TChain* tn) { fType = kINPUTFITEVENT; tn->SetBranchAddress("Mode", &fMode); tn->SetBranchAddress("Mode", &Mode); tn->SetBranchAddress("EventNo", &fEventNo); tn->SetBranchAddress("TotCrs", &fTotCrs); tn->SetBranchAddress("TargetA", &fTargetA); tn->SetBranchAddress("TargetH", &fTargetH); tn->SetBranchAddress("Bound", &fBound); tn->SetBranchAddress("InputWeight", &InputWeight); tn->SetBranchAddress("NParticles", &fNParticles); tn->SetBranchAddress("ParticleState", fParticleState); tn->SetBranchAddress("ParticlePDG", fParticlePDG); tn->SetBranchAddress("ParticleMom", fParticleMom); } void FitEvent::AddBranchesToTree(TTree* tn) { tn->Branch("Mode", &fMode, "Mode/I"); tn->Branch("EventNo", &fEventNo, "EventNo/i"); tn->Branch("TotCrs", &fTotCrs, "TotCrs/D"); tn->Branch("TargetA", &fTargetA, "TargetA/I"); tn->Branch("TargetH", &fTargetH, "TargetH/I"); tn->Branch("Bound", &fBound, "Bound/O"); tn->Branch("InputWeight", &InputWeight, "InputWeight/D"); tn->Branch("NParticles", &fNParticles, "NParticles/I"); tn->Branch("ParticleState", fParticleState, "ParticleState[NParticles]/i"); tn->Branch("ParticlePDG", fParticlePDG, "ParticlePDG[NParticles]/I"); tn->Branch("ParticleMom", fParticleMom, "ParticleMom[NParticles][4]/D"); tn->SetAlias("Enu", "ParticleMom[0][4]"); } /* Event Access Functions */ //*************************************************** FitParticle* FitEvent::PartInfo(UInt_t i) { // Check Valid if (i > (UInt_t)fNParticles or i < 0) { ERR(FTL) << "Requesting particle beyond stack!" << std::endl; ERR(FTL) << "i = " << i << " N = " << fNParticles << std::endl; ERR(FTL) << "Mode = " << fMode << std::endl; throw; } // Check particle has been formed if (!fParticleList[i]) { fParticleList[i] = new FitParticle(fParticleMom[i][0], fParticleMom[i][1], fParticleMom[i][2], fParticleMom[i][3], fParticlePDG[i], fParticleState[i]); } return fParticleList[i]; } int FitEvent::GetNeutrinoInPos(void) const { for (UInt_t i = 0; i < NPart(); i++) { if (fParticleState[i] != kInitialState) continue; if (abs(fParticlePDG[i]) == 12 || abs(fParticlePDG[i]) == 14 || abs(fParticlePDG[i]) == 16) { return i; } } return -1; } int FitEvent::GetLeptonOutPos(void) const { for (UInt_t i = 0; i < NPart(); i++) { if (fParticleState[i] != kFinalState) continue; if (abs(fParticlePDG[i]) == 11 || abs(fParticlePDG[i]) == 13 || abs(fParticlePDG[i]) == 15) { return i; } } return -1; } FitParticle* FitEvent::GetBeamPart(void) { return PartInfo(GetBeamPartPos()); } FitParticle* FitEvent::GetNeutrinoIn(void) { return PartInfo(GetNeutrinoInPos()); } FitParticle* FitEvent::GetLeptonOut(void) { return PartInfo(GetLeptonOutPos()); } bool FitEvent::HasParticle(int pdg, int state) { bool found = false; for (int i = 0; i < fNParticles; i++) { if (state != -1 && fParticleState[i] != (uint)state) continue; if (fParticlePDG[i] == pdg) found = true; } return found; } int FitEvent::NumParticle(int pdg, int state) { int nfound = 0; for (int i = 0; i < fNParticles; i++) { // std::cout << "fParticlePDG[" << i << "] = " << fParticlePDG[i] << // std::endl; if (state != -1 and fParticleState[i] != (uint)state) continue; if (pdg == 0 or fParticlePDG[i] == pdg) nfound += 1; } return nfound; } int FitEvent::NumParticle(std::vector<int> pdg, int state) { int nfound = 0; for (int i = 0; i < fNParticles; i++) { if (state != -1 and fParticleState[i] != (uint)state) continue; if (std::find(pdg.begin(), pdg.end(), fParticlePDG[i]) != pdg.end()) nfound += 1; } return nfound; } int FitEvent::NumFSLeptons() { int nLeptons = 0; for (int i = 0; i < fNParticles; i++) { if (fParticleState[i] != kFinalState) continue; if (abs(fParticlePDG[i]) == 11 || abs(fParticlePDG[i]) == 13 || abs(fParticlePDG[i]) == 15) nLeptons += 1; } return nLeptons; } int FitEvent::NumFSMesons() { int nMesons = 0; for (int i = 0; i < fNParticles; i++) { if (fParticleState[i] != kFinalState) continue; if (abs(fParticlePDG[i]) >= 111 && abs(fParticlePDG[i]) <= 557) nMesons += 1; } return nMesons; } FitParticle* FitEvent::GetHMParticle(int pdg, int state) { double maxmom = -9999999.9; int maxind = -1; for (int i = 0; i < fNParticles; i++) { if (state != -1 and fParticleState[i] != (uint)state) continue; if (pdg == 0 or fParticlePDG[i] == pdg) { // Update Max Mom double mom = sqrt(fParticleMom[i][0] * fParticleMom[i][0] + fParticleMom[i][1] * fParticleMom[i][1] + fParticleMom[i][2] * fParticleMom[i][2]); if (fabs(mom) > maxmom) { maxmom = fabs(mom); maxind = i; } } } if (maxind == -1) { return NULL; } return PartInfo(maxind); } FitParticle* FitEvent::GetHMParticle(std::vector<int> pdg, int state) { double maxmom = -9999999.9; int maxind = -1; for (int i = 0; i < fNParticles; i++) { if (state != -1 and fParticleState[i] != (uint)state) continue; if (std::find(pdg.begin(), pdg.end(), fParticlePDG[i]) != pdg.end()) { // Update Max Mom double mom = sqrt(fParticleMom[i][0] * fParticleMom[i][0] + fParticleMom[i][1] * fParticleMom[i][1] + fParticleMom[i][2] * fParticleMom[i][2]); if (fabs(mom) > maxmom) { maxmom = fabs(mom); maxind = i; } } } if (maxind == -1) { return NULL; } return PartInfo(maxind); } void FitEvent::Print() { LOG(EVT) << "FitEvent print" << std::endl; LOG(EVT) << "Mode: " << fMode << std::endl; LOG(EVT) << "Particles: " << fNParticles << std::endl; LOG(EVT) << " -> Particle Stack " << std::endl; for (int i = 0; i < fNParticles; i++) { LOG(EVT) << " -> -> " << i << ". " << fParticlePDG[i] << " " << fParticleState[i] << " " << " Mom(" << fParticleMom[i][0] << ", " << fParticleMom[i][1] << ", " << fParticleMom[i][2] << ", " << fParticleMom[i][3] << ")." << std::endl; } return; } diff --git a/src/FitBase/GeneratorUtils.cxx b/src/FitBase/GeneratorUtils.cxx index c08f036..2a2c0dc 100644 --- a/src/FitBase/GeneratorUtils.cxx +++ b/src/FitBase/GeneratorUtils.cxx @@ -1,1057 +1,1066 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include <iostream> #include "GeneratorUtils.h" #include "FitLogger.h" + +namespace GeneratorUtils { + + const std::string NEUT_TreeName = "neuttree"; + const std::string NuWro_TreeName = "treeout"; + const std::string GENIE_TreeName = "gtree"; + const std::string GiBUU_TreeName = "giRooTracker"; +} + #ifdef __NEUT_ENABLED__ void GeneratorUtils::FillNeutCommons(NeutVect* nvect){ // WARNING: This has only been implemented for a neuttree and not GENIE // This should be kept in sync with T2KNIWGUtils::GetNIWGEvent(TTree) //NEUT version info. Can't get it to compile properly with this yet //neutversion_.corev = nvect->COREVer; //neutversion_.nucev = nvect->NUCEVer; //neutversion_.nuccv = nvect->NUCCVer; // Documentation: See nework.h nework_.modene = nvect->Mode; nework_.numne = nvect->Npart(); nemdls_.mdlqeaf = nvect->QEVForm; nemdls_.mdlqe = nvect->QEModel; nemdls_.mdlspi = nvect->SPIModel; nemdls_.mdldis = nvect->DISModel; nemdls_.mdlcoh = nvect->COHModel; neutcoh_.necohepi = nvect->COHModel; nemdls_.xmaqe = nvect->QEMA; nemdls_.xmvqe = nvect->QEMV; nemdls_.kapp = nvect->KAPPA; //nemdls_.sccfv = SCCFVdef; //nemdls_.sccfa = SCCFAdef; //nemdls_.fpqe = FPQEdef; nemdls_.xmaspi = nvect->SPIMA; nemdls_.xmvspi = nvect->SPIMV; nemdls_.xmares = nvect->RESMA; nemdls_.xmvres = nvect->RESMV; neut1pi_.xmanffres = nvect->SPIMA; neut1pi_.xmvnffres = nvect->SPIMV; neut1pi_.xmarsres = nvect->RESMA; neut1pi_.xmvrsres = nvect->RESMV; neut1pi_.neiff = nvect->SPIForm; neut1pi_.nenrtype = nvect->SPINRType; neut1pi_.rneca5i = nvect->SPICA5I; neut1pi_.rnebgscl = nvect->SPIBGScale; nemdls_.xmacoh = nvect->COHMA; nemdls_.rad0nu = nvect->COHR0; //nemdls_.fa1coh = nvect->COHA1err; //nemdls_.fb1coh = nvect->COHb1err; //neutdis_.nepdf = NEPDFdef; //neutdis_.nebodek = NEBODEKdef; neutcard_.nefrmflg = nvect->FrmFlg; neutcard_.nepauflg = nvect->PauFlg; neutcard_.nenefo16 = nvect->NefO16; neutcard_.nemodflg = nvect->ModFlg; //neutcard_.nenefmodl = 1; //neutcard_.nenefmodh = 1; //neutcard_.nenefkinh = 1; //neutpiabs_.neabspiemit = 1; nenupr_.iformlen = nvect->FormLen; neutpiless_.ipilessdcy = nvect->IPilessDcy; neutpiless_.rpilessdcy = nvect->RPilessDcy; neutpiless_.ipilessdcy = nvect->IPilessDcy; neutpiless_.rpilessdcy = nvect->RPilessDcy; neffpr_.fefqe = nvect->NuceffFactorPIQE; neffpr_.fefqeh = nvect->NuceffFactorPIQEH; neffpr_.fefinel = nvect->NuceffFactorPIInel; neffpr_.fefabs = nvect->NuceffFactorPIAbs; neffpr_.fefcx = nvect->NuceffFactorPICX; neffpr_.fefcxh = nvect->NuceffFactorPICXH; neffpr_.fefcoh = nvect->NuceffFactorPICoh; neffpr_.fefqehf = nvect->NuceffFactorPIQEHKin; neffpr_.fefcxhf = nvect->NuceffFactorPICXKin; neffpr_.fefcohf = nvect->NuceffFactorPIQELKin; for ( int i = 0; i<nework_.numne; i++ ) { nework_.ipne[i] = nvect->PartInfo(i)->fPID; nework_.pne[i][0] = (float)nvect->PartInfo(i)->fP.X()/1000; // VC(NE)WORK in M(G)eV nework_.pne[i][1] = (float)nvect->PartInfo(i)->fP.Y()/1000; // VC(NE)WORK in M(G)eV nework_.pne[i][2] = (float)nvect->PartInfo(i)->fP.Z()/1000; // VC(NE)WORK in M(G)eV } // fsihist.h // neutroot fills a dummy object for events with no FSI to prevent memory leak when // reading the TTree, so check for it here if ( (int)nvect->NfsiVert() == 1 ) { // An event with FSI must have at least two vertices // if (nvect->NfsiPart()!=1 || nvect->Fsiprob!=-1) // ERR(WRN) << "T2KNeutUtils::fill_neut_commons(TTree) NfsiPart!=1 or Fsiprob!=-1 when NfsiVert==1" << endl; fsihist_.nvert = 0; fsihist_.nvcvert = 0; fsihist_.fsiprob = 1; } else { // Real FSI event fsihist_.nvert = (int)nvect->NfsiVert(); for (int ivert=0; ivert<fsihist_.nvert; ivert++) { fsihist_.iflgvert[ivert] = nvect->FsiVertInfo(ivert)->fVertID; fsihist_.posvert[ivert][0] = (float)nvect->FsiVertInfo(ivert)->fPos.X(); fsihist_.posvert[ivert][1] = (float)nvect->FsiVertInfo(ivert)->fPos.Y(); fsihist_.posvert[ivert][2] = (float)nvect->FsiVertInfo(ivert)->fPos.Z(); } fsihist_.nvcvert = nvect->NfsiPart(); for (int ip=0; ip<fsihist_.nvcvert; ip++) { fsihist_.abspvert[ip] = (float)nvect->FsiPartInfo(ip)->fMomLab; fsihist_.abstpvert[ip] = (float)nvect->FsiPartInfo(ip)->fMomNuc; fsihist_.ipvert[ip] = nvect->FsiPartInfo(ip)->fPID; fsihist_.iverti[ip] = nvect->FsiPartInfo(ip)->fVertStart; fsihist_.ivertf[ip] = nvect->FsiPartInfo(ip)->fVertEnd; fsihist_.dirvert[ip][0] = (float)nvect->FsiPartInfo(ip)->fDir.X(); fsihist_.dirvert[ip][1] = (float)nvect->FsiPartInfo(ip)->fDir.Y(); fsihist_.dirvert[ip][2] = (float)nvect->FsiPartInfo(ip)->fDir.Z(); } fsihist_.fsiprob = nvect->Fsiprob; } neutcrscom_.crsx = nvect->Crsx; neutcrscom_.crsy = nvect->Crsy; neutcrscom_.crsz = nvect->Crsz; neutcrscom_.crsphi = nvect->Crsphi; neutcrscom_.crsq2 = nvect->Crsq2; neuttarget_.numbndn = nvect->TargetA - nvect->TargetZ; neuttarget_.numbndp = nvect->TargetZ; neuttarget_.numfrep = nvect->TargetH; neuttarget_.numatom = nvect->TargetA; posinnuc_.ibound = nvect->Ibound; // put empty nucleon FSI history (since it is not saved in the NeutVect format) //Comment out as NEUT does not have the necessary proton FSI information yet // nucleonfsihist_.nfnvert = 0; // nucleonfsihist_.nfnstep = 0; } #endif #ifdef __NIWG_ENABLED__ niwg::rew::NIWGEvent * GeneratorUtils::GetNIWGEvent(NeutVect* nvect) { niwg::rew::NIWGEvent * fDummyNIWGEvent = NULL; fDummyNIWGEvent = new niwg::rew::NIWGEvent(); fDummyNIWGEvent->detid = 1; // MiniBooNE (apply CCQE LowE variations) fDummyNIWGEvent->neutmode = nvect->Mode; fDummyNIWGEvent->targetA = nvect->TargetA; fDummyNIWGEvent->recenu_ccqe_sk = -1; if (nvect->Ibound==0) fDummyNIWGEvent->targetA = 1;//RT: identifies as H, rather than O16 // Fill initial particle stack for (int ip=0; ip<nvect->Npart(); ++ip) { niwg::rew::NIWGPartStack fDummyPartStack; fDummyPartStack.p = (nvect->PartInfo(ip)->fP)*0.001; // Convert to GeV fDummyPartStack.pdg = nvect->PartInfo(ip)->fPID; fDummyPartStack.chase = nvect->PartInfo(ip)->fIsAlive; fDummyPartStack.parent = nvect->ParentIdx(ip)-1; // WARNING: this needs to be tested with a NeutRoot file fDummyNIWGEvent->part_stack.push_back(fDummyPartStack); } fDummyNIWGEvent->CalcKinematics(); return fDummyNIWGEvent; } #endif // neut enabled #ifdef __NUWRO_ENABLED__ //*************************************************** int GeneratorUtils::ConvertNuwroMode (event * e) //*************************************************** { Int_t proton_pdg, neutron_pdg, pion_pdg, pion_plus_pdg, pion_minus_pdg, lambda_pdg, eta_pdg, kaon_pdg, kaon_plus_pdg; proton_pdg = 2212; eta_pdg = 221; neutron_pdg = 2112; pion_pdg = 111; pion_plus_pdg = 211; pion_minus_pdg = -211; //O_16_pdg = 100069; // oznacznie z Neuta lambda_pdg = 3122; kaon_pdg = 311; kaon_plus_pdg = 321; if (e->flag.qel) // kwiazielastyczne oddziaływanie { if (e->flag.anty) // jeśli jest to oddziaływanie z antyneutrinem { if (e->flag.cc) return -1; else { if (e->nof (proton_pdg)) return -51; else if (e->nof (neutron_pdg)) return -52; // sprawdzam dodatkowo ? } } else // oddziaływanie z neutrinem { if (e->flag.cc) return 1; else { if (e->nof (proton_pdg)) return 51; else if (e->nof (neutron_pdg)) return 52; } } } if (e->flag.mec){ if (e->flag.anty) return -2; else return 2; } if (e->flag.res) //rezonansowa produkcja: pojedynczy pion, pojed.eta, kaon, multipiony { Int_t liczba_pionow, liczba_kaonow; liczba_pionow = e->nof (pion_pdg) + e->nof (pion_plus_pdg) + e->nof (pion_minus_pdg); liczba_kaonow = e->nof (kaon_pdg) + e->nof (kaon_pdg); if (liczba_pionow > 1 || liczba_pionow == 0) // multipiony { if (e->flag.anty) { if (e->flag.cc) return -21; else return -41; } else { if (e->flag.cc) return 21; else return 41; } } if (liczba_pionow == 1) { if (e->flag.anty) // jeśli jest to oddziaływanie z antyneutrinem { if (e->flag.cc) { if (e->nof (neutron_pdg) && e->nof (pion_minus_pdg)) return -11; if (e->nof (neutron_pdg) && e->nof (pion_pdg)) return -12; if (e->nof (proton_pdg) && e->nof (pion_minus_pdg)) return -13; } else { if (e->nof (proton_pdg)) { if (e->nof (pion_minus_pdg)) return -33; else if (e->nof (pion_pdg)) return -32; } else if (e->nof (neutron_pdg)) { if (e->nof (pion_plus_pdg)) return -34; else if (e->nof (pion_pdg)) return -31; } } } else // oddziaływanie z neutrinem { if (e->flag.cc) { if (e->nof (proton_pdg) && e->nof (pion_plus_pdg)) return 11; if (e->nof (proton_pdg) && e->nof (pion_pdg)) return 12; if (e->nof (neutron_pdg) && e->nof (pion_plus_pdg)) return 13; } else { if (e->nof (proton_pdg)) { if (e->nof (pion_minus_pdg)) return 33; else if (e->nof (pion_pdg)) return 32; } else if (e->nof (neutron_pdg)) { if (e->nof (pion_plus_pdg)) return 34; else if (e->nof (pion_pdg)) return 31; } } } } if (e->nof (eta_pdg)) // produkcja rezonansowa ety { if (e->flag.anty) // jeśli jest to oddziaływanie z antyneutrinem { if (e->flag.cc) return -22; else { if (e->nof (neutron_pdg)) return -42; else if (e->nof (proton_pdg)) return -43; // sprawdzam dodatkowo ? } } else // oddziaływanie z neutrinem { if (e->flag.cc) return 22; else { if (e->nof (neutron_pdg)) return 42; else if (e->nof (proton_pdg)) return 43; } } } if (e->nof (lambda_pdg) == 1 && liczba_kaonow == 1) // produkcja rezonansowa kaonu { if (e->flag.anty) // jeśli jest to oddziaływanie z antyneutrinem { if (e->flag.cc && e->nof (kaon_pdg)) return -23; else { if (e->nof (kaon_pdg)) return -44; else if (e->nof (kaon_plus_pdg)) return -45; } } else // oddziaływanie z neutrinem { if (e->flag.cc && e->nof (kaon_plus_pdg)) return 23; else { if (e->nof (kaon_pdg)) return 44; else if (e->nof (kaon_plus_pdg)) return 45; } } } } if (e->flag.coh) // koherentne oddziaływanie tylko na O(16) { Int_t _target; _target = e->par.nucleus_p + e->par.nucleus_n; // liczba masowa O(16) if (_target == 16) { if (e->flag.anty) // jeśli jest to oddziaływanie z antyneutrinem { if (e->flag.cc && e->nof (pion_minus_pdg)) return -16; else if (e->nof (pion_pdg)) return -36; } else // oddziaływanie z neutrinem { if (e->flag.cc && e->nof (pion_plus_pdg)) return 16; else if (e->nof (pion_pdg)) return 36; } } } // gleboko nieelastyczne rozpraszanie if (e->flag.dis) { if (e->flag.anty) { if (e->flag.cc) return -26; else return -46; } else { if (e->flag.cc) return 26; else return 46; } } return 9999; } #endif #ifdef __NUANCE_ENABLED__ int GeneratorUtils::ConvertNuanceMode(NuanceEvent * evt){ int ch = evt->channel; int sg = 1; if (evt->neutrino < 0) sg = -1; switch(ch){ // 1 NUANCE CCQE -> NEUT CCQE 1 case 1: return sg*1; // 2 NUANCE NCEL -> NEUT NCEL 51,52 -> Set from whether target is p or n case 2: if (evt->target == 2212) return sg*51; else return sg*52; // 3 NUANCE CCPIP -> NEUT CCPIP 11 case 3: return sg*11; // 4 NUANCE CCPI0 -> NEUT CCPI0 = 12 case 4: return sg*12; // 5 NUANCE CCPIPn -> NEUT CCPIPn 13 case 5: return sg*13; // 6 NUANCE NCpPI0 -> NEUT NCpPI0 32 case 6: return sg*32; // 7 NUANCE NCpPI+ -> NEUT NCpPI+ 34 case 7: return sg*34; // 8 NUANCE NCnPI0 -> NEUT NCnPI0 31 case 8: return sg*31; // 9 NUANCE NCnPIM -> NEUT NCnPIM 33 case 9: return sg*33; // 10 NUANCE CCPIP -> NEUT CCPIP -11 case 10: return sg*11; // 11 NUANCE CCPI0 -> NEUT CCPI0 -12 case 11: return sg*12; // 12 NUANCE CCPIPn -> NEUT CCPIPn 13 case 12: return sg*13; // 13 NUANCE NCpPI0 -> NEUT NCnPI0 -32 case 13: return sg*32; // 14 NUANCE NCpPI+ -> NEUT NCpPI+ -34 case 14: return sg*34; // 15 NUANCE NCnPI0 -> NEUT NCnPI0 -31 case 15: return sg*31; // 16 NUANCE NCnPIM -> NEUT NCnPIM -33 case 16: return sg*33; // 17 NUANCE -> NEUT 21 CC MULTIPI case 17: return sg*21; // 18 NUANCE -> NEUT 21 CC MULTIPI case 18: return sg*21; // 19 NUANCE -> NEUT 21 CC MULTIPI case 19: return sg*21; // 20 NUANCE -> NEUT 21 CC MULTIPI case 20: return sg*21; // 21 NUANCE -> NEUT 21 CC MULTIPI case 21: return sg*21; // 22 NUANCE -> NEUT 41 NC MULTIPI case 22: return sg*41; // 23 NUANCE -> NEUT 41 NC MULTIPI case 23: return sg*41; // 24 NUANCE -> NEUT 41 NC MULTIPI case 24: return sg*41; // 25 NUANCE -> NEUT 41 NC MULTIPI case 25: return sg*41; // 26 NUANCE -> NEUT 41 NC MULTIPI case 26: return sg*41; // 27 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) case 27: return sg*41; // 28 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV) case 28: return sg*21; // 29 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV) case 29: return sg*21; // 30 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV) case 30: return sg*21; // 31 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV) case 31: return sg*21; // 32 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV) case 32: return sg*21; // 33 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) case 33: return sg*41; // 34 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) case 34: return sg*41; // 35 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) case 35: return sg*41; // 36 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) case 36: return sg*41; // 37 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) case 37: return sg*41; // 38 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV) case 38: return sg*41; // 39 NUANCE -> NEUT 22 case 39: return sg*22; // 40 NUANCE -> NEUT 22 case 40: return sg*22; // 41 NUANCE -> NEUT 22 case 41: return sg*22; // 42 NUANCE -> NEUT 43 case 42: return sg*43; // 43 NUANCE -> NEUT 43 case 43: return sg*43; // 44 NUANCE -> NUET 42 case 44: return sg*42; // 45 NUANCE -> NEUT -42 case 45: return sg*42; // 46 NUANCE -> NEUT -22 case 46: return sg*22; // 47 NUANCE -> NEUT -22 case 47: return sg*22; // 48 NUANCE -> NEUT -22 case 48: return sg*22; // 49 NUANCE -> NEUT -43 case 49: return sg*43; // 50 NUANCE -> NEUT -43 case 50: return sg*43; // 51 NUANCE -> NEUT -42 case 51: return sg*42; // 52 NUANCE -> NEUT -42 case 52: return sg*42; // 53 NUANCE -> NEUT 23 CC 1K case 53: return sg*23; // 54 NUANCE -> NEUT 23 CC 1K case 54: return sg*23; // 55 NUANCE -> NEUT 23 CC 1K case 55: return sg*23; // 56 NUANCE -> NEUT 45 NC 1K case 56: return sg*45; // 57 NUANCE -> NEUT 44 NC 1K case 57: return sg*44; // 58 NUANCE -> NEUT 44 NC 1K case 58: return sg*44; // 59 NUANCE -> NEUT 44 NC 1K case 59: return sg*44; // 60 NUANCE -> NEUT -23 CC 1K case 60: return sg*23; // 61 NUANCE -> NEUT -23 CC 1K case 61: return sg*23; // 62 NUANCE -> NEUT -23 CC 1K case 62: return sg*23; // 63 NUANCE -> NEUT -23 CC 1K case 63: return sg*23; // 64 NUANCE -> NEUT -44 NC 1K case 64: return sg*44; // 65 NUANCE -> NEUT -44 NC 1K case 65: return sg*44; // 66 NUANCE -> NEUT -45 NC 1K case 66: return sg*45; // 67 NUANCE -> NEUT 22 CC1eta case 67: return sg*22; // 68 NUANCE -> NEUT 43 NC p eta case 68: return sg*43; // 69 NUANCE -> NEUT 43 NC n eta case 69: return sg*43; // 70 NUANCE -> NEUT -22 CC1eta case 70: return sg*22; // 71 NUANCE -> NEUT -43 NC p eta case 71: return sg*43; // 72 NUANCE -> NEUT 42 NC n eta case 72: return sg*42; // 73 NUANCE -> NEUT 21 CC Multi Pi case 73: return sg*21; // 74 NUANCE -> NEUT 41 NC Multi Pi case 74: return sg*41; // 75 NUANCE -> NEUT 41 NC Multi Pi case 75: return sg*41; // 76 NUANCE -> NEUT -21 CC Multi Pi case 76: return sg*21; // 77 NUANCE -> NEUT -41 NC Multi Pi case 77: return sg*41; // 78 NUANCE -> NEUT -41 NC Multi Pi case 78: return sg*41; // 79 NUANCE -> NEUT 21 CC Multi Pi case 79: return sg*21; // 80 NUANCE -> NEUT 21 CC Multi Pi case 80: return sg*21; // 81 NUANCE -> NEUT 41 NC Multi Pi case 81: return sg*41; // 82 NUANCE -> NEUT 41 NC Multi Pi case 82: return sg*41; // 83 NUANCE -> NEUT 41 NC Multi Pi case 83: return sg*41; // 84 NUANCE -> NEUT 41 NC Multi Pi case 84: return sg*84; // 85 NUANCE -> NEUT -21 CC Multi Pi case 85: return sg*21; // 86 NUANCE -> NEUT -21 CC Multi Pi case 86: return sg*21; // 87 NUANCE -> NEUT -41 CC Multi Pi case 87: return sg*41; // 88 NUANCE -> NEUT -41 case 88: return sg*41; // 89 NUANCE -> NEUT -41 case 89: return sg*41; // 90 NUANCE -> NEUT -41 case 90: return sg*41; // 91 NUANCE -> NEUT 26 CC DIS case 91: return sg*26; // 92 NUANCE -> NEUT 46 NC DIS case 92: return sg*46; // 93 NUANCE -> NEUT 17 1#gamma from #Delta case 93: return sg*17; // 94 NUANCE -> NEUT 39 1#gamma from #Delta case 94: return sg*39; // 95 -> UNKOWN NEUT MODE case 95: return sg*0; // 96 NUANCE -> NEUT 36 NC COH case 96: return sg*36; // 97 NUANCE -> NEUT 16 case 97: return sg*16; // 98 -> UNKNOWN NEUT MODE case 98: return sg*0; // 99 -> UNKNOWN NEUT MODE case 99: return sg*0; default: ERR(FTL) << "Unknown Nuance Channel ID = "<<ch<<std::endl; throw("Exiting."); return 0; } return 0; } #endif /* // Notes copied from NuanceChannels.pdf 1 NUANCE CCQE -> NEUT CCQE 1 CC, numu n --> mu- p Cabibbo-allowed quasi-elastic scattering from nucleons 2 NUANCE NCEL -> NEUT NCEL 51,52 -> Set from whether target is p or n NC, numu N --> num N, (N=n,p) (quasi)-elastic scattering from nucleons 3 NUANCE CCPIP -> NEUT CCPIP 11 CC, numu p --> mu- p pi+ resonant single pion production 4 NUANCE CCPI0 -> NEUT CCPI0 = 12 CC, numu n --> mu- p pi0 resonant single pion production 5 NUANCE CCPIPn -> NEUT CCPIPn 13 CC, numu n --> mu- n pi+ resonant single pion production 6 NUANCE NCpPI0 -> NEUT NCpPI0 32 NC, numu p --> numu p pi0 resonant single pion production 7 NUANCE NCpPI+ -> NEUT NCpPI+ 34 NC, numu p --> numu n pi+ resonant single pion production 8 NUANCE NCnPI0 -> NEUT NCnPI0 31 NC, numu n --> numu n pi0 resonant single pion production 9 NUANCE NCnPIM -> NEUT NCnPIM 33 NC, numu n --> numu p pi- resonant single pion production 10 NUANCE CCPIP -> NEUT CCPIP -11 CC, numubar p --> mu- p pi+ resonant single pion production 11 NUANCE CCPI0 -> NEUT CCPI0 -12 CC, numubar n --> mu- p pi0 resonant single pion production 12 NUANCE CCPIPn -> NEUT CCPIPn -13 CC, numubar n --> mu- n pi+ resonant single pion production 13 NUANCE NCpPI0 -> NEUT NCnPI0 -32 NC, numubar p --> numubar p pi0 resonant single pion production 14 NUANCE NCpPI+ -> NEUT NCpPI+ -34 NC, numubar p --> numubar n pi+ resonant single pion production 15 NUANCE NCnPI0 -> NEUT NCnPI0 -31 NC, numubar n --> numubar n pi0 resonant single pion production 16 NUANCE NCnPIM -> NEUT NCnPIM -33 NC, numubar n --> numubar p pi- resonant single pion production 17 NUANCE -> NEUT 21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi CC, numu p --> mu- Delta+ pi+ resonant processes involving more than a single pion 18 NUANCE -> NEUT 21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi CC, numu p --> mu- Delta++ pi0 resonant processes involving more than a single pion 19 NUANCE -> NEUT 21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi CC, numu n --> mu- Delta+ pi0 resonant processes involving more than a single pion 20 NUANCE -> NEUT 21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi CC, numu n --> mu- Delta0 pi+ resonant processes involving more than a single pion 21 NUANCE -> NEUT 21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi CC, numu n --> mu- Delta++ pi- resonant processes involving more than a single pion 22 NUANCE -> NEUT 41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" NC, numu p+ --> numu Delta+ pi0 resonant processes involving more than a single pion 23 NUANCE -> NEUT 41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" NC,numu p --> numu Delta0 pi+ resonant processes involving more than a single pion 24 NUANCE -> NEUT 41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" NC, numu p --> numu Delta++ pi- resonant processes involving more than a single pion 25 NUANCE -> NEUT 41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" NC, numu n --> numu Delta+ pi- resonant processes involving more than a single pion 26 NUANCE -> NEUT 41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" NC, numu n --> numu Delta0 pi0 resonant processes involving more than a single pion 27 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" NC, numubar n --> numubar Delta- pi+ resonant processes involving more than a single pion 28 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi CC, numubar p --> mu- Delta+ pi+ resonant processes involving more than a single pion 29 UANCE -> NEUT -21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi CC, numubar p --> mu- Delta++ pi0 resonant processes involving more than a single pion 30 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi CC, numubar n --> mu- Delta+ pi0 resonant processes involving more than a single pion 31 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi CC, numubar n --> mu- Delta0 pi+ resonant processes involving more than a single pion 32 NUANCE -> NEUT -21 CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi CC, numubar n --> mu- Delta++ pi- resonant processes involving more than a single pion 33 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" NC, numubar p+ --> numubar Delta+ pi0 resonant processes involving more than a single pion 34 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" NC,numubar p --> numubar Delta0 pi+ resonant processes involving more than a single pion 35 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" NC, numubar p --> numubar Delta++ pi- resonant processes involving more than a single pion 36 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" NC, numubar n --> numubar Delta+ pi- resonant processes involving more than a single pion 37 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" NC, numubar n --> numubar Delta0 pi0 resonant processes involving more than a single pion 38 NUANCE -> NEUT -41 "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi" NC, numubar n --> numubar Delta- pi+ resonant processes involving more than a single pion // RHO Production lumped in with eta production 22 CCeta 43 NCeta on p 42 NCeta on n 39 NUANCE -> NEUT 22 CC, numu p --> mu- p rho+(770) resonant processes involving more than a single pion 40 NUANCE -> NEUT 22 CC, numu n --> mu- p rho0(770) resonant processes involving more than a single pion 41 NUANCE -> NEUT 22 CC, numu n --> mu- n rho+(770) resonant processes involving more than a single pion 42 NUANCE -> NEUT 43 NC, numu p --> numu p rho0(770) resonant processes involving more than a single pion 43 NUANCE -> NEUT 43 NC, numu p --> numu n rho+(770) resonant processes involving more than a single pion 44 NUANCE -> NUET 42 NC, numu n --> numu n rho0(770) resonant processes involving more than a single pion 45 NUANCE -> NEUT -42 NC, numubar n --> numubar p rho-(770) resonant processes involving more than a single pion 46 NUANCE -> NEUT -22 CC, numubar p --> mu- p rho+(770) resonant processes involving more than a single pion 47 NUANCE -> NEUT -22 CC, numubar n --> mu- p rho0(770) resonant processes involving more than a single pion 48 NUANCE -> NEUT -22 CC, numubar n --> mu- n rho+(770) resonant processes involving more than a single pion 49 NUANCE -> NEUT -43 NC, numubar p --> numubar p rho0(770) resonant processes involving more than a single pion 50 NUANCE -> NEUT -43 NC, numubar p --> numubar n rho+(770) resonant processes involving more than a single pion 51 NUANCE -> NEUT -42 NC, numubar n --> numubar n rho0(770) resonant processes involving more than a single pion 52 NUANCE -> NEUT -42 NC, numubar n --> numubar p rho-(770) resonant processes involving more than a single pion 53 NUANCE -> NEUT 23 CC 1K: #nu_{l} n #rightarrow l^{-} #Lambda K^{+} CC, numu p --> mu- Sigma+ K+ resonant processes involving more than a single pion 54 NUANCE -> NEUT 23 CC 1K: #nu_{l} n #rightarrow l^{-} #Lambda K^{+} CC, numu n --> mu- Sigma0 K+ resonant processes involving more than a single pion 55 NUANCE -> NEUT 23 CC 1K: #nu_{l} n #rightarrow l^{-} #Lambda K^{+} CC, numu n --> mu- Sigma+ K0 resonant processes involving more than a single pion 56 NUANCE -> NEUT 45 NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{+} NC, numu p --> numu Sigma0 K+ resonant processes involving more than a single pion 57 NUANCE -> NEUT 44 NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{0} NC, numu p --> numu Sigma+ K0 resonant processes involving more than a single pion 58 NUANCE -> NEUT 44 NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{0} NC, numu n --> numu Sigma0 K0 resonant processes involving more than a single pion 59 NUANCE -> NEUT 45 NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{+} NC, numu n --> numu Sigma- K+ resonant processes involving more than a single pion 60 NUANCE -> NEUT -23 CC 1K: #nu_{l} n #rightarrow l^{-} #Lambda K^{+} CC, numubar p --> mu- Sigma+ K+ resonant processes involving more than a single pion 61 NUANCE -> NEUT -23 CC 1K: #nu_{l} n #rightarrow l^{-} #Lambda K^{+} CC, numubar n --> mu- Sigma0 K+ resonant processes involving more than a single pion 62 NUANCE -> NEUT -23 CC 1K: #nu_{l} n #rightarrow l^{-} #Lambda K^{+} CC, numubar n --> mu- Sigma+ K0 resonant processes involving more than a single pion 63 NUANCE -> NEUT -45 NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{+} NC, numubar p --> numubar Sigma0 K+ resonant processes involving more than a single pion 64 NUANCE -> NEUT -44 NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{0} NC, numubar p --> numubar Sigma+ K0 resonant processes involving more than a single pion 65 NUANCE -> NEUT -44 NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{0} NC, numubar n --> numubar Sigma0 K0 resonant processes involving more than a single pion 66 NUANCE -> NEUT -45 NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{+} NC, numubar n --> numubar Sigma- K+ resonant processes involving more than a single pion 67 NUANCE -> NEUT 22 ModeStack[22]->SetTitle("CC1#eta^{0} on n"); CC, numu n --> mu- p eta resonant processes involving more than a single pion 68 NUANCE -> NEUT 43 NC, numu p --> numu p eta resonant processes involving more than a single pion 69 NUANCE -> NEUT 42 NC, numu n --> numu n eta resonant processes involving more than a single pion 70 NUANCE -> NEUT -22 ModeStack[22]->SetTitle("CC1#eta^{0} on n"); CC, numubar n --> mu- p eta resonant processes involving more than a single pion 71 NUANCE -> NEUT -43 ModeStack[43]->SetTitle("NC1#eta^{0} on p"); NC, numubar p --> numubar p eta resonant processes involving more than a single pion 72 NUANCE -> NEUT -42 ModeStack[42]->SetTitle("NC1#eta^{0} on n"); NC, numubar n --> numubar n eta resonant processes involving more than a single pion 73 NUANCE -> NEUT 21 ModeStack[21]->SetTitle("Multi #pi (1.3 < W < 2.0)"); CC, numu n --> mu- K+ Lambda resonant processes involving more than a single pion 74 NUANCE -> NEUT 41 ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC, numu p --> numu K+ Lambda resonant processes involving more than a single pion 75 NUANCE -> NEUT 41 ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC, numu n --> numu K0 Lambda resonant processes involving more than a single pion 76 NUANCE -> NEUT -21 ModeStack[21]->SetTitle("Multi #pi (1.3 < W < 2.0)"); CC, numubar n --> mu- K+ Lambda resonant processes involving more than a single pion 77 NUANCE -> NEUT -41 ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC, numubar p --> numubar K+ Lambda resonant processes involving more than a single pion 78 NUANCE -> NEUT -41 ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC, numubar n --> numubar K0 Lambda resonant processes involving more than a single pion CC Multipi ModeStack[21]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC Multipi ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); 79 NUANCE -> NEUT 21 CC, numu n --> mu- p pi+ pi- two pion production 80 NUANCE -> NEUT 21 CC, numu n --> mu- p pi0 pi0 two pion production 81 NUANCE -> NEUT 41 NC, numu p --> numu p pi+ pi- two pion production 82 NUANCE -> NEUT 41 NC, numu p --> numu p pi0 pi0 two pion production 83 NUANCE -> NEUT 41 NC, numu n --> numu n pi+ pi- two pion production 84 NUANCE -> NEUT 41 NC, numu n --> numu n pi0 pi0 two pion production 85 NUANCE -> NEUT -21 CC, numubar n --> mu- p pi+ pi- two pion production 86 NUANCE -> NEUT -21 CC, numubar n --> mu- p pi0 pi0 two pion production 87 NUANCE -> NEUT -41 ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC, numubar p --> numubar p pi+ pi- two pion production 88 NUANCE -> NEUT -41 ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC, numubar p --> numubar p pi0 pi0 two pion production 89 NUANCE -> NEUT -41 ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC, numubar n --> numubar n pi+ pi- two pion production 90 NUANCE -> NEUT -41 ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); NC, numubar n --> numubar n pi0 pi0 two pion production 91 NUANCE -> NEUT 26 ModeStack[26]->SetTitle("DIS (W > 2.0)"); CC, numu N --> mu- X (where N=n,p) deep inelastic scattering (nu or nubar) 92 NUANCE -> NEUT 46 ModeStack[46]->SetTitle("DIS (W > 2.0)"); NC, numu N --> numu X (where N=n,p) deep inelastic scattering (nu or nubar) 93 NUANCE -> NEUT 17 1#gamma from #Delta: #nu_{l} n #rightarrow l^{-} p #gamma CC, numu n --> mu- p gamma Delta radiative decay, Delta --> N gamma (only in NUANCE versions v3 and and higher) 94 NUANCE -> NEUT 39 1#gamma from #Delta: #nu_{l} p #rightarrow #nu_{l} p #gamma neutModeID[15] = 38; neutModeName[15] = "ncngam"; neutModeTitle[15] = "1#gamma from #Delta: #nu_{l} n #rightarrow #nu_{l} n #gamma"; neutModeID[16] = 39; neutModeName[16] = "ncpgam"; neutModeTitle[16] = "1#gamma from #Delta: #nu_{l} p #rightarrow #nu_{l} p #gamma"; NC, numu N --> numu N gamma Delta radiative decay, Delta --> N gamma (only in NUANCE versions v3 and and higher) 95 -> UNKOWN NEUT MODE CC, numubar p --> mu+ Lambda, numubar n -- > mu+ Sigma-, numubar p --> mu+ Sigma0 Cabibbo-suppressed QE hyperon production from nucleons 96 NUANCE -> NEUT 36 neutModeID[14] = 36; neutModeName[14] = "nccoh"; neutModeTitle[14] = "NC coherent-#pi: #nu_{l} ^{16}O #rightarrow #nu_{l} ^{16}O #pi^{0}"; NC, numu A --> numu pi0 A coherent or diffractive pi0 production 97 NUANCE -> NEUT 16 neutModeID[4] = 16; neutModeName[4] = "cccoh"; neutModeTitle[4] = "CC coherent-#pi: #nu_{l} ^{16}O #rightarrow l^{-} ^{16}O #pi^{+}"; CC, numu A --> mu- pi+ A (or numubar A --> coherent or diffractive pi0 production 98 -> UNKNOWN NEUT MODE NC, numu e- --> numu e- (or numubar e- --> neutrino + electron elastic scattering 99 -> UNKNOWN NEUT MODE CC, numu e- --> mu- nue neutrino + electron inverse muon decay NEUT Modes: // CC Modes neutModeID[0] = 1; neutModeName[0] = "ccqe"; neutModeTitle[0] = "CCQE: #nu_{l} n #rightarrow l^{-} p"; neutModeID[1] = 11; neutModeName[1] = "ccppip"; neutModeTitle[1] = "CC 1#pi: #nu_{l} p #rightarrow l^{-} p #pi^{+}"; neutModeID[2] = 12; neutModeName[2] = "ccppi0"; neutModeTitle[2] = "CC 1#pi: #nu_{l} n #rightarrow l^{-} p #pi^{0}"; neutModeID[3] = 13; neutModeName[3] = "ccnpip"; neutModeTitle[3] = "CC 1#pi: #nu_{l} n #rightarrow l^{-} n #pi^{+}"; neutModeID[4] = 16; neutModeName[4] = "cccoh"; neutModeTitle[4] = "CC coherent-#pi: #nu_{l} ^{16}O #rightarrow l^{-} ^{16}O #pi^{+}"; neutModeID[5] = 17; neutModeName[5] = "ccgam"; neutModeTitle[5] = "1#gamma from #Delta: #nu_{l} n #rightarrow l^{-} p #gamma"; neutModeID[6] = 21; neutModeName[6] = "ccmpi"; neutModeTitle[6] = "CC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow l^{-} N' multi-#pi"; neutModeID[7] = 22; neutModeName[7] = "cceta"; neutModeTitle[7] = "CC 1#eta: #nu_{l} n #rightarrow l^{-} p #eta"; neutModeID[8] = 23; neutModeName[8] = "cck"; neutModeTitle[8] = "CC 1K: #nu_{l} n #rightarrow l^{-} #Lambda K^{+}"; neutModeID[9] = 26; neutModeName[9] = "ccdis"; neutModeTitle[9] = "CC DIS (2 GeV < W): #nu_{l} N #rightarrow l^{-} N' mesons"; neutModeID[10] = 31; neutModeName[10] = "ncnpi0"; neutModeTitle[10] = "NC 1#pi: #nu_{l} n #rightarrow #nu_{l} n #pi^{0}"; neutModeID[11] = 32; neutModeName[11] = "ncppi0"; neutModeTitle[11] = "NC 1#pi: #nu_{l} p #rightarrow #nu_{l} p #pi^{0}"; neutModeID[12] = 33; neutModeName[12] = "ncppim"; neutModeTitle[12] = "NC 1#pi: #nu_{l} n #rightarrow #nu_{l} p #pi^{-}"; neutModeID[13] = 34; neutModeName[13] = "ncnpip"; neutModeTitle[13] = "NC 1#pi: #nu_{l} p #rightarrow #nu_{l} n #pi^{+}"; neutModeID[14] = 36; neutModeName[14] = "nccoh"; neutModeTitle[14] = "NC coherent-#pi: #nu_{l} ^{16}O #rightarrow #nu_{l} ^{16}O #pi^{0}"; neutModeID[15] = 38; neutModeName[15] = "ncngam"; neutModeTitle[15] = "1#gamma from #Delta: #nu_{l} n #rightarrow #nu_{l} n #gamma"; neutModeID[16] = 39; neutModeName[16] = "ncpgam"; neutModeTitle[16] = "1#gamma from #Delta: #nu_{l} p #rightarrow #nu_{l} p #gamma"; neutModeID[17] = 41; neutModeName[17] = "ncmpi"; neutModeTitle[17] = "NC (1.3 < W < 2 GeV): #nu_{l} N #rightarrow #nu_{l} N multi-#pi"; neutModeID[18] = 42; neutModeName[18] = "ncneta"; neutModeTitle[18] = "NC 1#eta: #nu_{l} n #rightarrow #nu_{l} n #eta"; neutModeID[19] = 43; neutModeName[19] = "ncpeta"; neutModeTitle[19] = "NC 1#eta: #nu_{l} p #rightarrow #nu_{l} p #eta"; neutModeID[20] = 44; neutModeName[20] = "nck0"; neutModeTitle[20] = "NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{0}"; neutModeID[21] = 45; neutModeName[21] = "nckp"; neutModeTitle[21] = "NC 1K: #nu_{l} n #rightarrow #nu_{l} #Lambda K^{+}"; neutModeID[22] = 46; neutModeName[22] = "ncdis"; neutModeTitle[22] = "NC DIS (2 GeV < W): #nu_{l} N #rightarrow #nu_{l} N' mesons"; neutModeID[23] = 51; neutModeName[23] = "ncqep"; neutModeTitle[23] = "NC elastic: #nu_{l} p #rightarrow #nu_{l} p"; neutModeID[24] = 52; neutModeName[24] = "ncqen"; neutModeTitle[24] = "NC elastic: #nu_{l} n #rightarrow #nu_{l} n"; */ diff --git a/src/FitBase/GeneratorUtils.h b/src/FitBase/GeneratorUtils.h index e68d851..083fc9a 100644 --- a/src/FitBase/GeneratorUtils.h +++ b/src/FitBase/GeneratorUtils.h @@ -1,76 +1,80 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #ifndef GENERATOR_UTILS_H #define GENERATOR_UTILS_H #ifdef __NEUT_ENABLED__ #include "nefillverC.h" #include "necardC.h" #include "neutmodelC.h" #include "neutparamsC.h" #include "neworkC.h" #include "fsihistC.h" //Comment out as NEUT does not have the necessary proton FSI information yet #include "nucleonfsihistC.h" #include "neutcrsC.h" #include "neutvect.h" #include "neutpart.h" #include "neutfsipart.h" #include "neutfsivert.h" #include "neutnucfsivert.h" #include "neutnucfsistep.h" #include "neutrootTreeSingleton.h" #include "NModeDefn.h" #include "NSyst.h" #include "NFortFns.h" // Contains all the NEUT common blocks #endif #ifdef __NIWG_ENABLED__ #include "NIWGEvent.h" #include "NIWGSyst.h" #endif #ifdef __NUWRO_ENABLED__ #include "event1.h" #endif #include "NuanceEvent.h" namespace GeneratorUtils { + extern const std::string NEUT_TreeName; #ifdef __NEUT_ENABLED__ void FillNeutCommons(NeutVect* nvect); #endif #ifdef __NIWG_ENABLED__ niwg::rew::NIWGEvent* GetNIWGEvent(NeutVect* nvect); #endif + extern const std::string NuWro_TreeName; #ifdef __NUWRO_ENABLED__ int ConvertNuwroMode (event * e); #endif #ifdef __NUANCE_ENABLED__ int ConvertNuanceMode(NuanceEvent * evt); #endif + extern const std::string GENIE_TreeName; + extern const std::string GiBUU_TreeName; }; #endif diff --git a/src/FitBase/InputHandler.cxx b/src/FitBase/InputHandler.cxx index 0bc9122..86822e8 100644 --- a/src/FitBase/InputHandler.cxx +++ b/src/FitBase/InputHandler.cxx @@ -1,1363 +1,1413 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ -#include <csignal> #include "InputHandler.h" +#include <csignal> //**************************************************************************** InputHandler::InputHandler(std::string const& handle, InputUtils::InputType inpType, std::string const& inputs) { //**************************************************************************** LOG(SAM) << "Creating InputHandler for " << handle << "..." << std::endl; LOG(SAM) << " -> [" << inputs << "]" << std::endl; // Initial Setup fMaxEvents = FitPar::Config().GetParI("input.maxevents"); fIsExplicitJointInput = (inpType == InputUtils::kJOINT_Input); fIsJointInput = fIsExplicitJointInput || InputUtils::IsJointInput(inputs); fInputType = inpType; fEvent = new FitEvent(); fSignalEvent = new BaseFitEvt(); fInput = inputs; fInputFile = InputUtils::ExpandInputDirectories(inputs); fName = handle; LOG(SAM) << " -> Type = " << fInputType << (fIsJointInput ? " (Composite)" : "") << std::endl; LOG(SAM) << " -> Input = " << fInputFile << std::endl; // Automatically check what sort of event file it is if (fIsJointInput) { ReadJointFile(); } else { - fInputRootFile = new TFile(fInputFile.c_str(),"READ"); + fInputRootFile = new TFile(fInputFile.c_str(), "READ"); switch (fInputType) { // Setup the handler for each type case InputUtils::kNEUT_Input: { ReadNeutFile(); break; } case InputUtils::kNUWRO_Input: { ReadNuWroFile(); break; } case InputUtils::kGENIE_Input: { ReadGenieFile(); break; } case InputUtils::kGiBUU_Input: { ReadGiBUUFile(); break; } case InputUtils::kHIST_Input: { ReadHistogramFile(); break; } case InputUtils::kBNSPLN_Input: { ReadBinSplineFile(); break; } case InputUtils::kEVSPLN_Input: { ReadEventSplineFile(); break; } case InputUtils::kNUANCE_Input: { ReadNuanceFile(); break; } case InputUtils::kEMPTY_Input: { ReadEmptyEvents(); // For Validation break; } case InputUtils::kFEVENT_Input: { ReadFitEvents(); break; } default: { LOG(FTL) << " -> ERROR: Invalid Event File Type" << std::endl; fInputRootFile->ls(); throw; } } } // Setup MaxEvents After setup of ttree if (fMaxEvents > 1 && fMaxEvents < fNEvents) { LOG(SAM) << " -> Reading only " << fMaxEvents << " events from total." << std::endl; fNEvents = fMaxEvents; } fFluxList.push_back(fFluxHist); fEventList.push_back(this->fEventHist); fXSecList.push_back(this->fXSecHist); LOG(SAM) << " -> Finished handler initialisation." << std::endl; return; }; //******************************************************************** bool InputHandler::CanIGoFast() { //******************************************************************** if (fEventType == 6) { return true; } return false; } //******************************************************************** void InputHandler::ReadFitEvents() { //******************************************************************** fEventType = kINPUTFITEVENT; fFluxHist = (TH1D*)fInputRootFile->Get("nuisance_fluxhist"); fFluxHist->SetNameTitle((fName + "_FLUX").c_str(), (fName + "; E_{#nu} (GeV)").c_str()); fEventHist = (TH1D*)fInputRootFile->Get("nuisance_eventhist"); fEventHist->SetNameTitle((fName + "_EVT").c_str(), (fName + "; E_{#nu} (GeV); Event Rate").c_str()); fXSecHist = (TH1D*)fEventHist->Clone(); fXSecHist->Divide(fFluxHist); fXSecHist->SetNameTitle( (fName + "_XSEC").c_str(), (fName + "_XSEC;E_{#nu} (GeV); XSec (1#times10^{-38} cm^{2})").c_str()); tn = new TChain("nuisance_events", ""); tn->Add(Form("%s/nuisance_events", fInputFile.c_str())); // Assign nvect fNEvents = tn->GetEntries(); fEvent->SetBranchAddress(tn); // Print out what was read in LOG(SAM) << " -> Successfully Read FEvent file" << std::endl; return; } //******************************************************************** void InputHandler::ReadEmptyEvents() { //******************************************************************** fEventType = kEMPTY; // Set flux histograms to empty fFluxHist = new TH1D((fName + "_FLUX").c_str(), (fName + "_FLUX;E_{#nu};Flux").c_str(), 1, 0.0, 1.0); fFluxHist->SetBinContent(1, 1); // Set Event Hist to empty fEventHist = new TH1D((fName + "_EVT").c_str(), (fName + "_EVT;E_{#nu};Flux").c_str(), 1, 0.0, 1.0); fEventHist->SetBinContent(1, 1); // Set XSec hist to empty fXSecHist = new TH1D((fName + "_XSEC").c_str(), (fName + "_XSEC;E_{#nu};XSec").c_str(), 1, 0.0, 1.0); fXSecHist->SetBinContent(1, 1); fNEvents = 0; } //******************************************************************** void InputHandler::ReadEventSplineFile() { //******************************************************************** LOG(SAM) << " -> Setting up SPLINE inputs" << std::endl; // Event Type 7 SPLINES fEventType = 6; fFluxHist = (TH1D*)fInputRootFile->Get("FitFluxHist"); fFluxHist->SetNameTitle((fName + "_FLUX").c_str(), (fName + "; E_{#nu} (GeV)").c_str()); fEventHist = (TH1D*)fInputRootFile->Get("FitEventHist"); fEventHist->SetNameTitle((fName + "_EVT").c_str(), (fName + "; E_{#nu} (GeV); Event Rate").c_str()); fXSecHist = (TH1D*)fEventHist->Clone(); fXSecHist->Divide(fFluxHist); fXSecHist->SetNameTitle( (fName + "_XSEC").c_str(), (fName + "_XSEC;E_{#nu} (GeV); XSec (1#times10^{-38} cm^{2})").c_str()); tn = new TChain("FitEvents", ""); tn->Add(Form("%s/FitEvents", fInputFile.c_str())); // Setup Spline Stuff fSplineHead = new FitSplineHead(fInputRootFile, "FitSplineHead"); // Assign nvect fNEvents = tn->GetEntries(); fEvent->SetBranchAddress(tn); fEvent->SetSplineCoeffAddress(tn); fEvent->SetType(kEVTSPLINE); // Print out what was read in LOG(SAM) << " -> Successfully Read FEvent file" << std::endl; // Load Dial Coeffs into vector tn->GetEntry(0); int ncoeff = fEvent->GetNCoeff(); fSplineArray = new double*[fNEvents]; for (int i = 0; i < fNEvents; i++) { tn->GetEntry(i); // Copy Splines over fSplineArray[i] = new double[ncoeff]; for (int j = 0; j < fEvent->GetNCoeff(); j++) { fSplineArray[i][j] = fEvent->GetCoeff(j); } } LOG(DEB) << "Loaded all spline coeffs" << endl; // Set input.maxevents CALC Here before we load in splines if (fMaxEvents > 1 and fMaxEvents < fNEvents) { LOG(SAM) << " -> Reading only " << fMaxEvents << " events from total spline events." << std::endl; fNEvents = fMaxEvents; } // Print out what was read in LOG(SAM) << " -> Successfully Read SPLINE file" << std::endl; if (LOG_LEVEL(SAM)) PrintStartInput(); int cnt = 1; std::list<FitSpline*>::iterator spl_iter = this->fSplineHead->SplineObjects.begin(); for (; spl_iter != this->fSplineHead->SplineObjects.end(); spl_iter++) { FitSpline* spl = (*spl_iter); LOG(SAM) << " -> Spline " << cnt << ". " << spl->id << " " << spl->form << " " << "NDIM(" << spl->ndim << ") " << "NPAR(" << spl->npar << ") " << "PTS(" << spl->points << ") " << std::endl; cnt++; } } //******************************************************************** FitSplineHead* InputHandler::GetSplineHead() { //******************************************************************** return fSplineHead; } //******************************************************************** void InputHandler::SetupCache() { //******************************************************************** tn->SetCacheSize(FitPar::Config().GetParI("cachesize")); tn->AddBranchToCache("*", kTRUE); tn->StopCacheLearningPhase(); } //******************************************************************** void InputHandler::ReadJointFile() { //******************************************************************** std::vector<std::string> inputs; - if (fIsExplicitJointInput) { // Included for backwards compatibility. + if (fIsExplicitJointInput) { // Included for backwards compatibility. std::string line; std::ifstream card(fInputFile.c_str(), ifstream::in); LOG(FIT) << "Parsing input card: \'" << fInputFile << "\'" << endl; while (std::getline(card >> std::ws, line, '\n')) { if (line.empty()) { continue; } std::vector<std::string> file_descriptor = GeneralUtils::ParseToStr(line, ":"); if (file_descriptor.size() != 2) { ERR(FTL) << "Found JOINT card file line: \"" << line << "\", expected \"INPUTTYPE:File.root\"." << std::endl; throw; } InputUtils::InputType inpType = InputUtils::ParseInputType(file_descriptor[0]); if (!inputs.size()) { fInputType = inpType; LOG(SAM) << " -> InputHandler type: " << fInputType << std::endl; } else if (inpType != fInputType) { ERR(FTL) << "First input type in JOINT card was: " << fInputType << " but found: " << inpType << ", all files in a JOINT must be the same." << std::endl; throw; } LOG(SAM) << "\t -> Found input file: " << file_descriptor[1] << std::endl; inputs.push_back(file_descriptor[1]); } } else { LOG(SAM) << " -> Parsing list of inputs for composite input." << std::endl; inputs = GeneralUtils::ParseToStr(fInputFile, ","); inputs.front() = inputs.front().substr(1); - inputs.back() = inputs.back().substr(0,inputs.back().size()-1); + inputs.back() = inputs.back().substr(0, inputs.back().size() - 1); for (size_t inp_it = 0; inp_it < inputs.size(); ++inp_it) { LOG(SAM) << "\t -> Found input file: " << inputs[inp_it] << std::endl; } } // Loop over input and get the flux files // Using a temporary input handler to do this, which is a bit dodge. int count_low = 0; int temp_EventType = kUNKNOWN; for (size_t inp_it = 0; inp_it < inputs.size(); ++inp_it) { LOG(SAM) << "Creating temporary handler to read file: " << inputs.at(inp_it) << endl; // Create Temporary InputHandlers inside InputHandler temp_input(std::string(Form("temp_input_%li", inp_it)), fInputType, inputs.at(inp_it)); if (temp_EventType != temp_input.GetType() and inp_it > 0) { ERR(FTL) << "Can't use joint events with mismatched trees!" << std::endl; ERR(FTL) << "This should not have happened. Please report this as a bug " "along with your input card file." << std::endl; throw; } LOG(FIT) << "Getting objects from " << temp_input.fInputFile << endl; temp_EventType = temp_input.GetType(); TH1D* temp_flux = (TH1D*)temp_input.GetFluxHistogram()->Clone(); TH1D* temp_evts = (TH1D*)temp_input.GetEventHistogram()->Clone(); TH1D* temp_xsec = (TH1D*)temp_input.GetXSecHistogram()->Clone(); int temp_events = temp_input.GetNEvents(); temp_flux->SetName( (fName + "_" + temp_input.GetInputStateString() + "_FLUX").c_str()); temp_evts->SetName( (fName + "_" + temp_input.GetInputStateString() + "_EVT").c_str()); temp_xsec->SetName( (fName + "_" + temp_input.GetInputStateString() + "_XSEC").c_str()); fFluxList.push_back(temp_flux); fEventList.push_back(temp_evts); fXSecList.push_back(temp_xsec); fJointIndexLow.push_back(count_low); fJointIndexHigh.push_back(count_low + temp_events); fJointIndexHist.push_back((TH1D*)temp_evts->Clone()); count_low += temp_events; LOG(FIT) << "Temp input has " << temp_events << " events." << endl; if (inp_it == 0) { fFluxHist = (TH1D*)temp_flux->Clone(); fEventHist = (TH1D*)temp_evts->Clone(); } else { fFluxHist->Add(temp_flux); fEventHist->Add(temp_evts); } LOG(SAM) << "Added Input File " << inputs.at(inp_it) << std::endl << " which contained " << temp_events << " events." << std::endl; } // Now have all correctly normalised histograms all we need to do is setup the // TChains // Input Assumes all the same type std::string tree_name = ""; if (temp_EventType == kNEUT) { tree_name = "neuttree"; } else if (temp_EventType == kNUWRO) { tree_name = "treeout"; } else if (temp_EventType == kGENIE) { tree_name = "gtree"; } // Add up the TChains tn = new TChain(tree_name.c_str()); for (UInt_t i = 0; i < inputs.size(); i++) { // PARSE INPUT LOG(DEB) << "Adding new tchain " << inputs.at(i) << std::endl; tn->Add(inputs.at(i).c_str()); } // Setup Events fNEvents = tn->GetEntries(); if (temp_EventType == kNEUT) { #ifdef __NEUT_ENABLED__ fEventType = kNEUT; fNeutVect = NULL; tn->SetBranchAddress("vectorbranch", &fNeutVect); fEvent->SetEventAddress(&fNeutVect); #endif } else if (temp_EventType == kNUWRO) { #ifdef __NUWRO_ENABLED__ fEventType = kNUWRO; fNuwroEvent = NULL; tn->SetBranchAddress("e", &fNuwroEvent); fEvent->SetEventAddress(&fNuwroEvent); #endif } else if (temp_EventType == kGENIE) { #ifdef __GENIE_ENABLED__ fEventType = kGENIE; fGenieGHep = NULL; fGenieNtpl = NULL; tn->SetBranchAddress("gmcrec", &fGenieNtpl); fEvent->SetEventAddress(&fGenieNtpl); #endif } // Normalise event histogram PDFS for weights for (UInt_t i = 0; i < inputs.size(); i++) { TH1D* temp_hist = (TH1D*)fJointIndexHist.at(i)->Clone(); fJointIndexScale.push_back( double(fNEvents) / fEventHist->Integral("width") * fJointIndexHist.at(i)->Integral("width") / double(fJointIndexHigh.at(i) - fJointIndexLow.at(i))); temp_hist->Scale(double(fNEvents) / fEventHist->Integral("width")); temp_hist->Scale(fJointIndexHist.at(i)->Integral("width") / double(fJointIndexHigh.at(i))); fJointIndexHist.at(i) = temp_hist; } fEventHist->SetNameTitle((fName + "_EVT").c_str(), (fName + "_EVT").c_str()); fFluxHist->SetNameTitle((fName + "_FLUX").c_str(), (fName + "_FLUX").c_str()); fXSecHist = (TH1D*)fEventHist->Clone(); fXSecHist->Divide(fFluxHist); fXSecHist->SetNameTitle((fName + "_XSEC").c_str(), (fName + "_XSEC").c_str()); return; } //******************************************************************** void InputHandler::ReadNeutFile() { //******************************************************************** #ifdef __NEUT_ENABLED__ LOG(SAM) << " -> Setting up NEUT inputs" << std::endl; // Event Type 0 Neut fEventType = kNEUT; // Get flux histograms NEUT supplies fFluxHist = (TH1D*)fInputRootFile->Get( (PlotUtils::GetObjectWithName(fInputRootFile, "flux")).c_str()); - if (!fFluxHist){ + if (!fFluxHist) { ERR(FTL) << "No Flux Hist in NEUT ROOT file." << std::endl; throw; } fFluxHist->SetNameTitle((fName + "_FLUX").c_str(), (fName + "; E_{#nu} (GeV)").c_str()); fEventHist = (TH1D*)fInputRootFile->Get( (PlotUtils::GetObjectWithName(fInputRootFile, "evtrt")).c_str()); - if (!fEventHist){ - ERR(FTL) <<"No Event Hist in NEUT ROOT file." << std::endl; + if (!fEventHist) { + ERR(FTL) << "No Event Hist in NEUT ROOT file." << std::endl; throw; } fEventHist->SetNameTitle((fName + "_EVT").c_str(), (fName + "; E_{#nu} (GeV); Event Rate").c_str()); fXSecHist = (TH1D*)fEventHist->Clone(); fXSecHist->Divide(fFluxHist); fXSecHist->SetNameTitle( (fName + "_XSEC").c_str(), (fName + "_XSEC;E_{#nu} (GeV); XSec (1#times10^{-38} cm^{2})").c_str()); // Read in the file once only tn = new TChain("neuttree", ""); tn->Add(Form("%s/neuttree", fInputFile.c_str())); // Assign nvect fNEvents = tn->GetEntries(); fNeutVect = NULL; tn->SetBranchAddress("vectorbranch", &fNeutVect); // Make the custom event read in nvect when calling CalcKinematics fEvent->SetEventAddress(&fNeutVect); // Print out what was read in LOG(SAM) << " -> Successfully Read NEUT file" << std::endl; if (LOG_LEVEL(SAM)) { PrintStartInput(); } #else ERR(FTL) << "ERROR: Invalid Event File Provided" << std::endl; ERR(FTL) << "NEUT Input Not Enabled." << std::endl; ERR(FTL) << "Rebuild with --enable-neut or check FitBuild.h!" << std::endl; exit(-1); #endif return; } //******************************************************************** void InputHandler::ReadNuWroFile() { //******************************************************************** #ifdef __NUWRO_ENABLED__ LOG(SAM) << " -> Setting up Nuwro inputs" << std::endl; // Event Type 1 == NuWro fEventType = kNUWRO; // Setup the TChain for nuwro event tree tn = new TChain("treeout"); tn->AddFile(fInputFile.c_str()); // Get entries and fNuwroEvent fNEvents = tn->GetEntries(); fNuwroEvent = NULL; tn->SetBranchAddress("e", &fNuwroEvent); fEvent->SetEventAddress(&fNuwroEvent); // Check if we have saved an xsec histogram before fFluxHist = (TH1D*)fInputRootFile->Get( (PlotUtils::GetObjectWithName(fInputRootFile, "FluxHist")).c_str()); fEventHist = (TH1D*)fInputRootFile->Get( (PlotUtils::GetObjectWithName(fInputRootFile, "EvtHist")).c_str()); // Check if we are forcing plot generation (takes time) bool regenFlux = FitPar::Config().GetParB("input.regen_nuwro_plots"); if (regenFlux) LOG(SAM) << " -> Forcing NuWro XSec/Flux plots to be generated at the start. " << std::endl; // Already generated flux and event histograms if (fFluxHist and fEventHist and !regenFlux) { fXSecHist = (TH1D*)fInputRootFile->Get( (PlotUtils::GetObjectWithName(fInputRootFile, "xsec")).c_str()); fFluxHist->SetNameTitle((fName + "_FLUX").c_str(), (fName + "_FLUX").c_str()); fEventHist->SetNameTitle((fName + "_EVT").c_str(), (fName + "_EVT").c_str()); fXSecHist->SetNameTitle((fName + "_XSEC").c_str(), (fName + "_XSEC").c_str()); // Need to regenerate if not found } else { LOG(SAM) << " -> No NuWro XSec or Flux Histograms found, need to regenerate!" << std::endl; // Can grab flux histogram from the pars tn->GetEntry(0); int beamtype = fNuwroEvent->par.beam_type; if (beamtype == 0) { std::string fluxstring = fNuwroEvent->par.beam_energy; std::vector<double> fluxvals = GeneralUtils::ParseToDbl(fluxstring, " "); int pdg = fNuwroEvent->par.beam_particle; double Elow = double(fluxvals[0]) / 1000.0; double Ehigh = double(fluxvals[1]) / 1000.0; LOG(SAM) << " - Adding new nuwro flux " << "pdg: " << pdg << "Elow: " << Elow << "Ehigh: " << Ehigh << std::endl; fFluxHist = new TH1D("fluxplot", "fluxplot", fluxvals.size() - 2, Elow, Ehigh); for (UInt_t j = 2; j < fluxvals.size(); j++) { LOG(DEB) << "Flux bin:" << j << " = " << fluxvals[j] << endl; fFluxHist->SetBinContent(j - 1, fluxvals[j]); } } else if (beamtype == 1) { std::string fluxstring = fNuwroEvent->par.beam_content; std::vector<std::string> fluxlines = GeneralUtils::ParseToStr(fluxstring, "\n"); for (UInt_t i = 0; i < fluxlines.size(); i++) { std::vector<double> fluxvals = GeneralUtils::ParseToDbl(fluxlines[i], " "); int pdg = int(fluxvals[0]); double pctg = double(fluxvals[1]) / 100.0; double Elow = double(fluxvals[2]) / 1000.0; double Ehigh = double(fluxvals[3]) / 1000.0; LOG(DEB) << " - Adding new nuwro flux " << "pdg: " << pdg << "pctg: " << pctg << "Elow: " << Elow << "Ehigh: " << Ehigh << std::endl; TH1D* fluxplot = new TH1D("fluxplot", "fluxplot", fluxvals.size() - 4, Elow, Ehigh); for (UInt_t j = 4; j < fluxvals.size(); j++) { fluxplot->SetBinContent(j + 1, fluxvals[j]); } if (fFluxHist) fFluxHist->Add(fluxplot); else fFluxHist = (TH1D*)fluxplot->Clone(); } } fFluxHist->SetNameTitle("nuwro_flux", "nuwro_flux;E_{#nu} (GeV); Flux"); fEventHist = (TH1D*)fFluxHist->Clone(); fEventHist->Reset(); fEventHist->SetNameTitle("nuwro_evt", "nuwro_evt"); fXSecHist = (TH1D*)fFluxHist->Clone(); fXSecHist->Reset(); fXSecHist->SetNameTitle("nuwro_xsec", "nuwro_xsec"); // Start Processing LOG(SAM) << " -> Processing NuWro Input Flux for " << fNEvents << " events (This can take a while...) " << std::endl; double Enu = 0.0; double TotXSec = 0.0; double totaleventmode = 0.0; double totalevents = 0.0; // --- loop for (int i = 0; i < fNEvents; i++) { tn->GetEntry(i); if (i % 100000 == 0) LOG(SAM) << " i " << i << std::endl; // Get Variables Enu = fNuwroEvent->in[0].E() / 1000.0; TotXSec = fNuwroEvent->weight; // Fill a flux and xsec histogram fEventHist->Fill(Enu); fXSecHist->Fill(Enu, TotXSec); // Keep Tally totaleventmode += TotXSec; totalevents++; } LOG(SAM) << " -> Flux Processing Loop Finished." << std::endl; if (fEventHist->Integral() == 0.0) { ERR(FTL) << "NO EVENTS FOUND IN RANGE! " << std::endl; exit(-1); } // Sort out plot scaling double AvgXSec = (totaleventmode * 1.0E38 / (totalevents + 0.)); LOG(SAM) << " -> Average XSec = " << AvgXSec << std::endl; fEventHist->Scale(1.0 / fEventHist->Integral()); // Convert to PDF fEventHist->Scale(fFluxHist->Integral() * AvgXSec); // Convert to Proper Event Rate fXSecHist->Add(fEventHist); // Get Event Rate Plot fXSecHist->Divide(fFluxHist); // Make XSec Plot // fEventHist = (TH1D*)fFluxHist->Clone(); // fEventHist->Multiply(fXSecHist); // Clear over/underflows incase they mess with integrals later. fFluxHist->SetBinContent(0, 0.0); fFluxHist->SetBinContent(fFluxHist->GetNbinsX() + 2, 0.0); fEventHist->SetBinContent(0, 0.0); fEventHist->SetBinContent(fEventHist->GetNbinsX() + 2, 0.0); LOG(SAM) << " -> Finished making NuWro event plots. Saving them for next time..." << std::endl; TFile* temp_save_file = new TFile(fInputFile.c_str(), "UPDATE"); temp_save_file->cd(); fFluxHist->Write("FluxHist", TObject::kOverwrite); fEventHist->Write("EventHist", TObject::kOverwrite); fXSecHist->Write("XSecHist", TObject::kOverwrite); temp_save_file->ls(); temp_save_file->Close(); delete temp_save_file; fFluxHist->SetNameTitle((fName + "_FLUX").c_str(), (fName + "_FLUX").c_str()); fEventHist->SetNameTitle((fName + "_EVT").c_str(), (fName + "_EVT").c_str()); fXSecHist->SetNameTitle((fName + "_XSEC").c_str(), (fName + "_XSEC").c_str()); } // end regenerate histos // Print out what was read in LOG(SAM) << " -> Successfully Read NUWRO file" << std::endl; if (LOG_LEVEL(SAM)) PrintStartInput(); #else ERR(FTL) << "ERROR: Invalid Event File Provided" << std::endl; ERR(FTL) << "NuWro Input Not Enabled." << std::endl; ERR(FTL) << "Rebuild with --enable-nuwro or check FitBuild.h!" << std::endl; exit(-1); #endif return; } //******************************************************************** void InputHandler::ReadGenieFile() { //******************************************************************** #ifdef __GENIE_ENABLED__ // Event Type 5 GENIE fEventType = kGENIE; // Open Root File LOG(SAM) << "Reading event file " << fInputFile << std::endl; // Get flux histograms NEUT supplies fFluxHist = (TH1D*)fInputRootFile->Get( (PlotUtils::GetObjectWithName(fInputRootFile, "nuisance_flux")).c_str()); if (!fFluxHist) { ERR(FTL) << "GENIE FILE doesn't contain flux/xsec info" << std::endl; ERR(FTL) << "Run app/PrepareGENIE first" << std::endl; throw; } fFluxHist->SetNameTitle((fName + "_FLUX").c_str(), (fName + "; E_{#nu} (GeV)").c_str()); fEventHist = (TH1D*)fInputRootFile->Get( (PlotUtils::GetObjectWithName(fInputRootFile, "nuisance_events")) .c_str()); fEventHist->SetNameTitle((fName + "_EVT").c_str(), (fName + "; E_{#nu} (GeV); Event Rate").c_str()); fXSecHist = (TH1D*)fInputRootFile->Get( (PlotUtils::GetObjectWithName(fInputRootFile, "nuisance_xsec")).c_str()); fXSecHist->SetNameTitle((fName + "_XSEC").c_str(), (fName + "; E_{#nu} (GeV); Event Rate").c_str()); // Setup the TChain for GENIE event tree tn = new TChain("gtree"); tn->AddFile(fInputFile.c_str()); fNEvents = tn->GetEntries(); StopTalking(); fGenieGHep = NULL; fGenieNtpl = NULL; // NtpMCEventRecord * fGenieNtpl = 0; tree->SetBranchAddress(gmrec, // &fGenieNtpl); tn->SetBranchAddress("gmcrec", &fGenieNtpl); // Make the custom event read in nvect when calling CalcKinematics fEvent->SetEventAddress(&fGenieNtpl); // Set Titles fEventHist->SetNameTitle( (fName + "_EVT").c_str(), (fName + "_EVT;E_{#nu} (GeV); Events (1#times10^{-38})").c_str()); fXSecHist->SetNameTitle( (fName + "_XSEC").c_str(), (fName + "_XSEC;E_{#nu} (GeV); XSec (1#times10^{-38} cm^{2})").c_str()); StartTalking(); // Print out what was read in LOG(SAM) << " -> Successfully Read GENIE file" << std::endl; if (LOG_LEVEL(SAM)) PrintStartInput(); #else ERR(FTL) << "ERROR: Invalid Event File Provided" << std::endl; ERR(FTL) << "GENIE Input Not Enabled." << std::endl; ERR(FTL) << "Rebuild with --enable-genie or check FitBuild.h!" << std::endl; exit(-1); #endif return; } //******************************************************************** void InputHandler::ReadGiBUUFile() { //******************************************************************** #ifdef __GiBUU_ENABLED__ fEventType = kGiBUU; // Open Root File LOG(SAM) << "Opening event file " << fInputFile << std::endl; TFile* rootFile = new TFile(fInputFile.c_str(), "READ"); // Get flux histograms NEUT supplies TH1D* numuFlux = dynamic_cast<TH1D*>(rootFile->Get("numu_flux")); TH1D* numubFlux = dynamic_cast<TH1D*>(rootFile->Get("numub_flux")); TH1D* nueFlux = dynamic_cast<TH1D*>(rootFile->Get("nue_flux")); TH1D* nuebFlux = dynamic_cast<TH1D*>(rootFile->Get("nueb_flux")); // Replace local pointers with NULL dir'd clones. if (numuFlux) { numuFlux = static_cast<TH1D*>(numuFlux->Clone()); - numuFlux->Scale(1.0/numuFlux->Integral("width")); - std::cout << "GiBUU Flux: numuFlux, Width integral = " << numuFlux->Integral("width") << std::endl; + numuFlux->Scale(1.0 / numuFlux->Integral("width")); + std::cout << "GiBUU Flux: numuFlux, Width integral = " + << numuFlux->Integral("width") << std::endl; numuFlux->SetDirectory(NULL); numuFlux->SetNameTitle( (fName + "_numu_FLUX").c_str(), (fName + "; E_{#nu} (GeV); #Phi_{#nu} (A.U.)").c_str()); fFluxList.push_back(numuFlux); } if (numubFlux) { numubFlux = static_cast<TH1D*>(numubFlux->Clone()); - numubFlux->Scale(1.0/numubFlux->Integral("width")); - std::cout << "GiBUU Flux: numubFlux, Width integral = " << numubFlux->Integral("width") << std::endl; + numubFlux->Scale(1.0 / numubFlux->Integral("width")); + std::cout << "GiBUU Flux: numubFlux, Width integral = " + << numubFlux->Integral("width") << std::endl; numubFlux->SetDirectory(NULL); numubFlux->SetNameTitle( (fName + "_numub_FLUX").c_str(), (fName + "; E_{#nu} (GeV); #Phi_{#bar{#nu}} (A.U.)").c_str()); fFluxList.push_back(numubFlux); } if (nueFlux) { nueFlux = static_cast<TH1D*>(nueFlux->Clone()); - nueFlux->Scale(1.0/nueFlux->Integral("width")); - std::cout << "GiBUU Flux: nueFlux, Width integral = " << nueFlux->Integral("width") << std::endl; + nueFlux->Scale(1.0 / nueFlux->Integral("width")); + std::cout << "GiBUU Flux: nueFlux, Width integral = " + << nueFlux->Integral("width") << std::endl; nueFlux->SetDirectory(NULL); nueFlux->SetNameTitle( (fName + "_nue_FLUX").c_str(), (fName + "; E_{#nu} (GeV); #Phi_{#nu} (A.U.)").c_str()); fFluxList.push_back(nueFlux); } if (nuebFlux) { nuebFlux = static_cast<TH1D*>(nuebFlux->Clone()); - nuebFlux->Scale(1.0/nuebFlux->Integral("width")); - std::cout << "GiBUU Flux: nuebFlux, Width integral = " << nuebFlux->Integral("width") << std::endl; + nuebFlux->Scale(1.0 / nuebFlux->Integral("width")); + std::cout << "GiBUU Flux: nuebFlux, Width integral = " + << nuebFlux->Integral("width") << std::endl; nuebFlux->SetDirectory(NULL); nuebFlux->SetNameTitle( (fName + "_nueb_FLUX").c_str(), (fName + "; E_{#nu} (GeV); #Phi_{#bar{#nu}} (A.U.)").c_str()); fFluxList.push_back(nuebFlux); } rootFile->Close(); tn = new TChain("giRooTracker"); tn->AddFile(fInputFile.c_str()); GiBUUStdHepReader* giRead = new GiBUUStdHepReader(); giRead->SetBranchAddresses(tn); fEvent->SetEventAddress(giRead); bool IsNuBarDominant = false; size_t Found_nu = 0; size_t Found_nuMask = ((numuFlux ? 1 : 0) + (numubFlux ? 2 : 0) + (nueFlux ? 4 : 0) + (nuebFlux ? 8 : 0)); static const char* specNames[] = {"numu", "numubar", "nue", "nuebar"}; size_t nExpected = (Found_nuMask & (1 << 0)) + (Found_nuMask & (1 << 1)) + (Found_nuMask & (1 << 2)) + (Found_nuMask & (1 << 3)); size_t nFound = 0; std::string expectStr = ""; for (size_t sn_it = 0; sn_it < 4; ++sn_it) { if (Found_nuMask & (1 << sn_it)) { if (!nFound) { expectStr = "("; } expectStr += specNames[sn_it]; nFound++; if (nFound == nExpected) { expectStr += ")"; } else { expectStr += ", "; } } } LOG(SAM) << "Looking for dominant vector species in GiBUU file (" << fInputFile << ") expecting to find: " << expectStr << std::endl; size_t maskHW = GeneralUtils::GetHammingWeight(Found_nuMask); if (maskHW > 2) { LOG(SAM) << "We are looking for more than two species... this will have to " "loop through a large portion of the vector. Please be patient." << std::endl; } double SpeciesWeights[] = {0, 0, 0, 0}; Long64_t nevt = 0; fNEvents = tn->GetEntries(); fFluxHist = NULL; while ((Found_nu != Found_nuMask) && (nevt < fNEvents)) { if ((maskHW == 2) && fFluxHist) { // If we have found the dominant one can // now guess the other size_t OtherBit = GeneralUtils::GetFirstOnBit(Found_nuMask - Found_nu); SpeciesWeights[OtherBit] = 1 - giRead->SpeciesWght; Found_nu += (1 << OtherBit); LOG(SAM) << "\tGuessing other species weight as we are only expecting " "two species. Other species weight: " << SpeciesWeights[OtherBit] << std::endl; continue; } tn->GetEntry(nevt++); fEvent->CalcKinematics(); FitParticle* isnu = fEvent->GetHMISParticle(PhysConst::pdg_neutrinos); if (!isnu) { continue; } switch (isnu->fPID) { case 12: { if ((Found_nu & 4)) { continue; } Found_nu += 4; SpeciesWeights[2] = giRead->SpeciesWght; LOG(SAM) << "\tGiBUU File: " << fInputFile << " -- ev: " << nevt << " has IS nu (" << isnu->fPID << "), species weight: " << giRead->SpeciesWght << std::endl; - if ((giRead->SpeciesWght < 0.5)) { + if ((giRead->SpeciesWght < 0.5) && + (maskHW > 1)) { // If we only care about a single species, then + // species-weight might not be filled. continue; } fFluxHist = nueFlux; LOG(SAM) << "\tInput file: " << fInputFile << " determined to be nue dominated vector." << std::endl; break; } case -12: { if ((Found_nu & 8)) { continue; } Found_nu += 8; SpeciesWeights[3] = giRead->SpeciesWght; LOG(SAM) << "\tGiBUU File: " << fInputFile << " -- ev: " << nevt << " has IS nu (" << isnu->fPID << "), species weight: " << giRead->SpeciesWght << std::endl; - if (giRead->SpeciesWght < 0.5) { + if ((giRead->SpeciesWght < 0.5) && + (maskHW > 1)) { // If we only care about a single species, then + // species-weight might not be filled. continue; } IsNuBarDominant = true; fFluxHist = nuebFlux; LOG(SAM) << "\tInput file: " << fInputFile << " determined to be nuebar dominated vector." << std::endl; break; } case 14: { if ((Found_nu & 1)) { continue; } Found_nu += 1; SpeciesWeights[0] = giRead->SpeciesWght; LOG(SAM) << "\tGiBUU File: " << fInputFile << " -- ev: " << nevt << " has IS nu (" << isnu->fPID << "), species weight: " << giRead->SpeciesWght << std::endl; - if (giRead->SpeciesWght < 0.5) { + if ((giRead->SpeciesWght < 0.5) && + (maskHW > 1)) { // If we only care about a single species, then + // species-weight might not be filled. continue; } fFluxHist = numuFlux; LOG(SAM) << "\tInput file: " << fInputFile << " determined to be numu dominated vector." << std::endl; break; } case -14: { if ((Found_nu & 2)) { continue; } Found_nu += 2; SpeciesWeights[1] = giRead->SpeciesWght; LOG(SAM) << "\tGiBUU File: " << fInputFile << " -- ev: " << nevt << " has IS nu (" << isnu->fPID << "), species weight: " << giRead->SpeciesWght << std::endl; - if (giRead->SpeciesWght < 0.5) { + if ((giRead->SpeciesWght < 0.5) && + (maskHW > 1)) { // If we only care about a single species, then + // species-weight might not be filled. continue; } IsNuBarDominant = true; fFluxHist = numubFlux; LOG(SAM) << "\tInput file: " << fInputFile << " determined to be numubar dominated vector." << std::endl; break; } default: {} } } + if (Found_nu != Found_nuMask) { + ERR(FTL) << "Input GiBUU file (" << fInputFile + << ") appeared to not contain all the relevant incoming neutrino " + "species: Found (numu:" + << ((Found_nu & (1 << 0)) ? 1 : 0) + << ",numub:" << ((Found_nu & (1 << 1)) ? 1 : 0) + << ",nue:" << ((Found_nu & (1 << 2)) ? 1 : 0) + << ",nueb:" << ((Found_nu & (1 << 3)) ? 1 : 0) + << "), expected: (numu:" << ((Found_nuMask & (1 << 0)) ? 1 : 0) + << ",numub:" << ((Found_nuMask & (1 << 1)) ? 1 : 0) + << ",nue:" << ((Found_nuMask & (1 << 2)) ? 1 : 0) + << ",nueb:" << ((Found_nuMask & (1 << 3)) ? 1 : 0) << ")" + << std::endl; + throw; + } + + if (!fFluxHist) { + ERR(FTL) << "Couldn't find: " + << (IsNuBarDominant ? "nuXb_flux" : "nuX_flux") + << " in input file: " << fInputRootFile->GetName() << std::endl; + throw; + } + if (numuFlux) { - numuFlux->Scale(SpeciesWeights[0]); + if ((maskHW > 1) && !GeneralUtils::IsSmallNum(SpeciesWeights[0])) { + numuFlux->Scale(SpeciesWeights[0]); + } + TH1D* numuEvt = static_cast<TH1D*>(numuFlux->Clone((fName + "_numu_EVT").c_str())); numuEvt->Reset(); numuEvt->SetBinContent(1, SpeciesWeights[0] * double(fNEvents) / numuEvt->GetXaxis()->GetBinWidth(1)); TH1D* numuXSec = static_cast<TH1D*>(numuEvt->Clone((fName + "_numu_XSEC").c_str())); numuXSec->Divide(fFluxHist); numuXSec->SetTitle((fName + "; E_{#nu} (GeV);XSec").c_str()); } if (numubFlux) { - numubFlux->Scale(SpeciesWeights[1]); + if ((maskHW > 1) && !GeneralUtils::IsSmallNum(SpeciesWeights[1])) { + numubFlux->Scale(SpeciesWeights[1]); + } TH1D* numubEvt = static_cast<TH1D*>(numubFlux->Clone((fName + "_numub_EVT").c_str())); numubEvt->Reset(); numubEvt->SetBinContent(1, SpeciesWeights[1] * double(fNEvents) / numubEvt->GetXaxis()->GetBinWidth(1)); TH1D* numubXSec = static_cast<TH1D*>(numubEvt->Clone((fName + "_numub_XSEC").c_str())); numubXSec->Divide(fFluxHist); numubXSec->SetTitle((fName + "; E_{#nu} (GeV);XSec").c_str()); } if (nueFlux) { - nueFlux->Scale(SpeciesWeights[2]); + if ((maskHW > 1) && !GeneralUtils::IsSmallNum(SpeciesWeights[2])) { + nueFlux->Scale(SpeciesWeights[2]); + } TH1D* nueEvt = static_cast<TH1D*>(nueFlux->Clone((fName + "_nue_EVT").c_str())); nueEvt->Reset(); nueEvt->SetBinContent(1, SpeciesWeights[2] * double(fNEvents) / nueEvt->GetXaxis()->GetBinWidth(1)); TH1D* nueXSec = static_cast<TH1D*>(nueEvt->Clone((fName + "_nue_XSEC").c_str())); nueXSec->Divide(fFluxHist); nueXSec->SetTitle((fName + "; E_{#nu} (GeV);XSec").c_str()); } if (nuebFlux) { - nuebFlux->Scale(SpeciesWeights[3]); + if ((maskHW > 1) && !GeneralUtils::IsSmallNum(SpeciesWeights[3])) { + nuebFlux->Scale(SpeciesWeights[3]); + } TH1D* nuebEvt = static_cast<TH1D*>(nuebFlux->Clone((fName + "_nueb_EVT").c_str())); nuebEvt->Reset(); nuebEvt->SetBinContent(1, SpeciesWeights[3] * double(fNEvents) / nuebEvt->GetXaxis()->GetBinWidth(1)); TH1D* nuebXSec = static_cast<TH1D*>(nuebEvt->Clone((fName + "_nueb_XSEC").c_str())); nuebXSec->Divide(fFluxHist); nuebXSec->SetTitle((fName + "; E_{#nu} (GeV);XSec").c_str()); } tn->GetEntry(0); - if (Found_nu != Found_nuMask) { - ERR(FTL) << "Input GiBUU file (" << fInputFile - << ") appeared to not contain all the relevant incoming neutrino " - "species: Found (numu:" - << ((Found_nu & (1 << 0)) ? 1 : 0) - << ",numub:" << ((Found_nu & (1 << 1)) ? 1 : 0) - << ",nue:" << ((Found_nu & (1 << 2)) ? 1 : 0) - << ",nueb:" << ((Found_nu & (1 << 3)) ? 1 : 0) - << "), expected: (numu:" << ((Found_nuMask & (1 << 0)) ? 1 : 0) - << ",numub:" << ((Found_nuMask & (1 << 1)) ? 1 : 0) - << ",nue:" << ((Found_nuMask & (1 << 2)) ? 1 : 0) - << ",nueb:" << ((Found_nuMask & (1 << 3)) ? 1 : 0) << ")" - << std::endl; - throw; - } - - if (!fFluxHist) { - ERR(FTL) << "Couldn't find: " - << (IsNuBarDominant ? "nuXb_flux" : "nuX_flux") - << " in input file: " << fInputRootFile->GetName() << std::endl; - throw; - } - LOG(SAM) << "\tInput GiBUU file species weights: (numu:" << SpeciesWeights[0] << ",numub:" << SpeciesWeights[1] << ",nue:" << SpeciesWeights[2] << ",nueb:" << SpeciesWeights[3] << ")" << std::endl; fFluxHist->SetNameTitle( (fName + "_FLUX").c_str(), (fName + "; E_{#nu} (GeV);" + (IsNuBarDominant ? "#Phi_{#bar{#nu}} (A.U.)" : "#Phi_{#nu} (A.U.)")) .c_str()); fEventHist = static_cast<TH1D*>(fFluxHist->Clone((fName + "_EVT").c_str())); fEventHist->Reset(); - fEventHist->SetBinContent( - 1, double(fNEvents) / fEventHist->GetXaxis()->GetBinWidth(1)); + fEventHist->SetBinContent(1, double(fNEvents) * + TotalIntegratedFlux(0, 1.E5, "width") / + fEventHist->GetXaxis()->GetBinWidth(1)); fXSecHist = static_cast<TH1D*>(fEventHist->Clone((fName + "_XSEC").c_str())); fXSecHist->Divide(fFluxHist); fXSecHist->SetTitle((fName + "; E_{#nu} (GeV);XSec").c_str()); #else ERR(FTL) << "ERROR: Invalid Event File Provided" << std::endl; ERR(FTL) << "GiBUU Input Not Enabled." << std::endl; ERR(FTL) << "Rebuild with -DUSE_GiBUU=1." << std::endl; exit(-1); #endif } //******************************************************************** void InputHandler::ReadBinSplineFile() { //******************************************************************** // Bin Splines are saved as one event for each histogram bin. // So just read in as normal event splines and it'll all get sorted easily. } //******************************************************************** void InputHandler::ReadHistogramFile() { //******************************************************************** // Convert the raw histogram into a series of events with X variables // So we don't have to pass stuff upsteam } //******************************************************************** void InputHandler::ReadNuanceFile() { //******************************************************************** #ifdef __NUANCE_ENABLED__ // Read in Nuance output ROOT file (converted from hbook) LOG(SAM) << " Reading NUANCE " << std::endl; fEventType = kNUANCE; // Read in NUANCE Tree tn = new TChain("h3"); tn->AddFile(fInputFile.c_str()); // Get entries and fNuwroEvent fNEvents = tn->GetEntries(); fNuanceEvt = new NuanceEvent(); // SetBranchAddress for Nuance // tn->SetBranchAddress("cc",&fNuanceEvt->cc); // tn->SetBranchAddress("bound",&fNuanceEvt->bound); tn->SetBranchAddress("neutrino", &fNuanceEvt->neutrino); tn->SetBranchAddress("target", &fNuanceEvt->target); tn->SetBranchAddress("channel", &fNuanceEvt->channel); // tn->SetBranchAddress("iniQ", &fNuanceEvt->iniQ); // tn->SetBranchAddress("finQ", &fNuanceEvt->finQ); // tn->SetBranchAddress("lepton0", &fNuanceEvt->lepton0); // tn->SetBranchAddress("polar", &fNuanceEvt->polar); // tn->SetBranchAddress("qsq", &fNuanceEvt->qsq); // tn->SetBranchAddress("w", &fNuanceEvt->w); // tn->SetBranchAddress("x",&fNuanceEvt->x); // tn->SetBranchAddress("y",&fNuanceEvt->y); tn->SetBranchAddress("p_neutrino", &fNuanceEvt->p_neutrino); tn->SetBranchAddress("p_targ", &fNuanceEvt->p_targ); // tn->SetBranchAddress("vertex", &fNuanceEvt->vertex); // tn->SetBranchAddress("start",&fNuanceEvt->start); // tn->SetBranchAddress("depth",&fNuanceEvt->depth); // tn->SetBranchAddress("flux",&fNuanceEvt->flux); tn->SetBranchAddress("n_leptons", &fNuanceEvt->n_leptons); tn->SetBranchAddress("p_ltot", &fNuanceEvt->p_ltot); tn->SetBranchAddress("lepton", &fNuanceEvt->lepton); tn->SetBranchAddress("p_lepton", &fNuanceEvt->p_lepton); tn->SetBranchAddress("n_hadrons", &fNuanceEvt->n_hadrons); tn->SetBranchAddress("p_htot", &fNuanceEvt->p_htot); tn->SetBranchAddress("hadron", &fNuanceEvt->hadron); tn->SetBranchAddress("p_hadron", &fNuanceEvt->p_hadron); fEvent->SetEventAddress(&fNuanceEvt); double EnuMin = 0.0; // tn->GetMinimum("p_neutrino[3]"); double EnuMax = 1000.0; // tn->GetMaximum("p_neutrino[3]"); fFluxHist = new TH1D((fName + "_FLUX").c_str(), (fName + "_FLUX").c_str(), 100, EnuMin, EnuMax); for (int i = 0; i < fFluxHist->GetNbinsX(); i++) { fFluxHist->SetBinContent(i + 1, 1.0); } fFluxHist->Scale(1.0 / fFluxHist->Integral()); fEventHist = new TH1D((fName + "_EVT").c_str(), (fName + "_EVT").c_str(), 100, EnuMin, EnuMax); for (int i = 0; i < fFluxHist->GetNbinsX(); i++) { fEventHist->SetBinContent(i + 1, 1.0); } fEventHist->Scale(1.0 / fEventHist->Integral()); fXSecHist = (TH1D*)fEventHist->Clone(); fXSecHist->Divide(fFluxHist); // Print out what was read in LOG(SAM) << " -> Successfully Read NUANCE file" << std::endl; if (LOG_LEVEL(SAM)) PrintStartInput(); #else ERR(FTL) << "ERROR: Invalid Event File Provided" << std::endl; ERR(FTL) << "NUANCE Input Not Enabled." << std::endl; ERR(FTL) << "Rebuild with -DUSE_NUANCE=1!" << std::endl; exit(-1); #endif } //******************************************************************** void InputHandler::PrintStartInput() { //******************************************************************** LOG(SAM) << " -> Total events = " << fNEvents << std::endl; LOG(SAM) << " -> Energy Range = " << fFluxHist->GetXaxis()->GetXmin() << "-" << fFluxHist->GetXaxis()->GetXmax() << " GeV" << std::endl; LOG(SAM) << " -> Integrated Flux Hist = " << fFluxHist->Integral(0, fFluxHist->GetNbinsX(), "width") << std::endl; LOG(SAM) << " -> Integrated Event Hist = " << fEventHist->Integral(0, fEventHist->GetNbinsX(), "width") << std::endl; LOG(SAM) << " -> Integrated Inclusive XSec = " << (fEventHist->Integral(0, fEventHist->GetNbinsX(), "width") / fFluxHist->Integral(0, fFluxHist->GetNbinsX(), "width")) * 1E-38 << std::endl; LOG(SAM) << " -> Integrated XSec Hist = " << fXSecHist->Integral("width") << endl; if (fEventType == kEVTSPLINE) return; // Get First event info StopTalking(); tn->GetEntry(0); StartTalking(); fEvent->CalcKinematics(); LOG(SAM) << " -> Event 0. Neutrino PDG = " << fEvent->PartInfo(0)->fPID << std::endl; LOG(SAM) << " Target A = " << fEvent->GetTargetA() << std::endl; LOG(SAM) << " Target Z = " << fEvent->GetTargetZ() << std::endl; } //******************************************************************** std::string InputHandler::GetInputStateString() { //******************************************************************** tn->GetEntry(0); fEvent->CalcKinematics(); std::ostringstream state; state << "T" << fEventType << "_PDG" << fEvent->PartInfo(0)->fPID << "_Z" << fEvent->GetTargetZ() << "_A" << fEvent->GetTargetA(); return state.str(); } //******************************************************************** void InputHandler::ReadEvent(unsigned int i) { //******************************************************************** bool using_events = (fEventType == kNEUT || fEventType == kGENIE || fEventType == kNUWRO || fEventType == kEVTSPLINE || fEventType == kNUANCE || fEventType == kGiBUU); if (using_events) { tn->LoadTree(i); tn->GetEntry(i); fEvent->CalcKinematics(); fEvent->Index = i; fEventIndex = i; fEvent->InputWeight = GetInputWeight(i); } else { GetTreeEntry(i); } } //******************************************************************** void InputHandler::GetTreeEntry(const Long64_t i) { //******************************************************************** // If we're just reading from the input root file if (fEventType != kEVTSPLINE) { tn->GetEntry(i); } else { fEvent->FillCoeff(fSplineArray[i]); } fEventIndex = i; fEvent->InputWeight = GetInputWeight(i); } //******************************************************************** double InputHandler::GetInputWeight(const int entry) { //******************************************************************** if (fEventType == kGiBUU) { return fEvent->InputWeight; } // if (fEventType == kGENIE) { // return fEvent->InputWeight; // } if (!fIsJointInput) { return 1.0; } double weight = 1.0; // Find Histogram for (UInt_t j = 0; j < fJointIndexLow.size(); j++) { if (entry >= fJointIndexLow.at(j) and entry < fJointIndexHigh.at(j)) { weight *= fJointIndexScale.at(j); break; } } return weight; } //******************************************************************** int InputHandler::GetGenEvents() { //******************************************************************** if (fEventType == 6) return fSplineHead->ngen_events; else return GetNEvents(); } //******************************************************************** double InputHandler::TotalIntegratedFlux(double low, double high, std::string intOpt) { //******************************************************************** - if (fEventType == kGiBUU) { - return 1.0; + Int_t minBin = fFluxHist->GetXaxis()->FindFixBin(low); + Int_t maxBin = fFluxHist->GetXaxis()->FindFixBin(high); + + if ((fFluxHist->IsBinOverflow(minBin) && (low != -9999.9))) { + minBin = 1; } - int minBin = fFluxHist->GetXaxis()->FindBin(low); - int maxBin = fFluxHist->GetXaxis()->FindBin(high); + if ((fFluxHist->IsBinOverflow(maxBin) && (high != -9999.9))) { + maxBin = fFluxHist->GetXaxis()->GetNbins() + 1; + } - double integral = fFluxHist->Integral(minBin, maxBin + 1, intOpt.c_str()); - return integral; -}; + // If we are within a single bin + if (minBin == maxBin) { + // Get the contained fraction of the single bin's width + return ((high - low) / fFluxHist->GetXaxis()->GetBinWidth(minBin)) * + fFluxHist->Integral(minBin, minBin, intOpt.c_str()); + } + + double lowBinUpEdge = fFluxHist->GetXaxis()->GetBinUpEdge(minBin); + double highBinLowEdge = fFluxHist->GetXaxis()->GetBinLowEdge(maxBin); + + double lowBinfracIntegral = + ((lowBinUpEdge - low) / fFluxHist->GetXaxis()->GetBinWidth(minBin)) * + fFluxHist->Integral(minBin, minBin, intOpt.c_str()); + double highBinfracIntegral = + ((high - highBinLowEdge) / fFluxHist->GetXaxis()->GetBinWidth(maxBin)) * + fFluxHist->Integral(maxBin, maxBin, intOpt.c_str()); + + // If they are neighbouring bins + if ((minBin + 1) == maxBin) { + // Get the contained fraction of the two bin's width + return lowBinfracIntegral + highBinfracIntegral; + } + + // If there are filled bins between them + return lowBinfracIntegral + highBinfracIntegral + + fFluxHist->Integral(minBin + 1, maxBin - 1, intOpt.c_str()); +} //******************************************************************** double InputHandler::PredictedEventRate(double low, double high, std::string intOpt) { //******************************************************************** int minBin = fFluxHist->GetXaxis()->FindBin(low); int maxBin = fFluxHist->GetXaxis()->FindBin(high); return fEventHist->Integral(minBin, maxBin + 1, intOpt.c_str()); } diff --git a/src/FitBase/InputUtils.cxx b/src/FitBase/InputUtils.cxx index e6db14e..2a64a3c 100644 --- a/src/FitBase/InputUtils.cxx +++ b/src/FitBase/InputUtils.cxx @@ -1,85 +1,151 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "FitParameters.h" #include "GeneralUtils.h" +#include "GeneratorUtils.h" #include "InputUtils.h" namespace InputUtils { //******************************************************************** InputType ParseInputType(std::string const &inp) { //******************************************************************** // The hard-coded list of supported input generators const static std::string filetypes[] = {"NEUT", "NUWRO", "GENIE", "GiBUU", "NUANCE", "EVSPLN", "EMPTY", "FEVENT", "JOINT"}; size_t nInputTypes = GeneralUtils::GetArraySize(filetypes); for (size_t i = 0; i < nInputTypes; i++) { if (inp == filetypes[i]) { return InputType(i); } } return kInvalid_Input; } //******************************************************************** bool IsJointInput(std::string const &inputs) { //******************************************************************** bool isJoint = (inputs[0] == '('); if (isJoint && (inputs[inputs.length() - 1] != ')')) { ERR(FTL) << "Inputs specifier: \"" << inputs << "\" looks like a composite input specifier -- " "(filea.root,fileb.root), however, it did not end in a \')\', " "it ended in a \'" << inputs[inputs.length() - 1] << "\'" << std::endl; throw; } return isJoint; } //******************************************************************** std::string ExpandInputDirectories(std::string const &inputs) { //******************************************************************** // Parse the "environement" flags in the fitter config // Can specify NEUT_DIR = "" and others in parameters/fitter.config.dat const static std::string filedir[] = {"NEUT_DIR", "NUWRO_DIR", "GENIE_DIR", "NUANCE_DIR", "EVSPLN_DIR", "GIBUU_DIR"}; size_t nfiledir = GeneralUtils::GetArraySize(filedir); std::string expandedInputs = inputs; for (size_t i = 0; i < nfiledir; i++) { std::string tempdir = "@" + filedir[i]; size_t torpl = expandedInputs.find(tempdir); if (torpl != std::string::npos) { std::string event_folder = FitPar::Config().GetParS(filedir[i]); expandedInputs.replace(torpl, tempdir.size(), event_folder); break; } } return expandedInputs; } + +InputType GuessInputTypeFromFile(TFile *inpF) { + if (!inpF) { + return kInvalid_Input; + } + TTree *NEUT_Input = + dynamic_cast<TTree *>(inpF->Get(GeneratorUtils::NEUT_TreeName.c_str())); + if (NEUT_Input) { + return kNEUT_Input; + } + TTree *NUWRO_Input = + dynamic_cast<TTree *>(inpF->Get(GeneratorUtils::NuWro_TreeName.c_str())); + if (NUWRO_Input) { + return kNUWRO_Input; + } + TTree *GENIE_Input = + dynamic_cast<TTree *>(inpF->Get(GeneratorUtils::GENIE_TreeName.c_str())); + if (GENIE_Input) { + return kGENIE_Input; + } + TTree *GiBUU_Input = + dynamic_cast<TTree *>(inpF->Get(GeneratorUtils::GiBUU_TreeName.c_str())); + if (GiBUU_Input) { + return kGiBUU_Input; + } + + return kInvalid_Input; +} + +std::string PrependGuessedInputTypeToName(std::string const &inpFName) { + TFile *inpF = TFile::Open(inpFName.c_str(), "READ"); + if (!inpF || !inpF->IsOpen()) { + ERR(FTL) << "Couldn't open \"" << inpFName << "\" for reading." + << std::endl; + throw; + } + InputType iType = GuessInputTypeFromFile(inpF); + if (iType == kInvalid_Input) { + ERR(FTL) << "Couldn't determine input type from file: " << inpFName + << "." << std::endl; + throw; + } + inpF->Close(); + delete inpF; + + switch (iType) { + case kNEUT_Input: { + return "NEUT:" + inpFName; + } + case kNUWRO_Input: { + return "NUWRO:" + inpFName; + } + case kGENIE_Input: { + return "GENIE:" + inpFName; + } + case kGiBUU_Input: { + return "GiBUU:" + inpFName; + } + default: { + ERR(FTL) << "Input type from file: " << inpFName << " was invalid." + << std::endl; + throw; + } + } +} } diff --git a/src/FitBase/InputUtils.h b/src/FitBase/InputUtils.h index c0dd433..4f0a481 100644 --- a/src/FitBase/InputUtils.h +++ b/src/FitBase/InputUtils.h @@ -1,83 +1,89 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #ifndef INPUT_UTILS_H #define INPUT_UTILS_H #include <string> +#include "TFile.h" namespace InputUtils { enum InputType { kNEUT_Input = 0, kNUWRO_Input, kGENIE_Input, kGiBUU_Input, kNUANCE_Input, kEVSPLN_Input, kEMPTY_Input, kFEVENT_Input, kJOINT_Input, // Kept for backwards compatibility kInvalid_Input, kHIST_Input, // Not sure if this are currently used. kBNSPLN_Input // Not sure if this are currently used. }; InputType ParseInputType(std::string const &inp); bool IsJointInput(std::string const &inputs); std::string ExpandInputDirectories(std::string const &inputs); + +InputType GuessInputTypeFromFile(TFile *inpF); +std::string PrependGuessedInputTypeToName(std::string const &inpFName); } inline std::ostream &operator<<(std::ostream &os, InputUtils::InputType it) { switch (it) { case InputUtils::kNEUT_Input: { return os << "kNEUT_Input"; } case InputUtils::kNUWRO_Input: { return os << "kNUWRO_Input"; } case InputUtils::kGENIE_Input: { return os << "kGENIE_Input"; } case InputUtils::kGiBUU_Input: { return os << "kGiBUU_Input"; } case InputUtils::kNUANCE_Input: { return os << "kNUANCE_Input"; } case InputUtils::kEVSPLN_Input: { return os << "kEVSPLN_Input"; } case InputUtils::kEMPTY_Input: { return os << "kEMPTY_Input"; } case InputUtils::kFEVENT_Input: { return os << "kFEVENT_Input"; } case InputUtils::kJOINT_Input: { return os << "kJOINT_Input"; } case InputUtils::kInvalid_Input: case InputUtils::kHIST_Input: case InputUtils::kBNSPLN_Input: default: { return os << "kInvalid_Input"; } } } + + #endif diff --git a/src/FitBase/JointMeas1D.cxx b/src/FitBase/JointMeas1D.cxx index 3fc09ae..2f9e7ba 100644 --- a/src/FitBase/JointMeas1D.cxx +++ b/src/FitBase/JointMeas1D.cxx @@ -1,518 +1,518 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "JointMeas1D.h" /* Constructor/Deconstuctor */ //******************************************************************** JointMeas1D::JointMeas1D() { //******************************************************************** // Reset list for (std::vector<MeasurementBase*>::const_iterator iter = fSubChain.begin(); iter != fSubChain.end(); iter++) { MeasurementBase* exp = *iter; if (exp) delete exp; } // Reset Variables this->Init(); } //******************************************************************** JointMeas1D::~JointMeas1D() { //******************************************************************** // Delete sub experiments for (std::vector<MeasurementBase*>::const_iterator iter = fSubChain.begin(); iter != fSubChain.end(); iter++) { MeasurementBase* exp = *iter; if (exp) delete exp; } } //******************************************************************** void JointMeas1D::Init() { //******************************************************************** // Flags for Joint Measurements fIsRatio = false; fIsSummed = false; fSaveSubMeas = false; // Clear Input Files fSubInFiles.clear(); return; } /* Setup Functions */ //******************************************************************** void JointMeas1D::SetupMeasurement(std::string input, std::string type, FitWeight* rw, std::string fkdt) { //******************************************************************** // For joint samples, input files are given as a semi-colon seperated list. // Parse this list and save it for later, and set up the types etc. if (FitPar::Config().GetParB("EventManager")){ ERR(FTL) << "Event Manager does not yet work with JointMeas1D Samples" << std::endl; ERR(FTL) << "If you want good predictions for " << fName << " then run with it turned off! (-q EventManager=0)" << std::endl; sleep(2); } fSubInFiles.clear(); std::vector<std::string> entries = GeneralUtils::ParseToStr(input, ";"); if (entries.size() < 2) { ERR(FTL) << "Joint measurement expected to recieve at least two semi-colon " "separated input files, but recieved: \"" << input << "\"" << std::endl; throw; } std::vector<std::string> first_file_descriptor = GeneralUtils::ParseToStr(entries.front(), ":"); if (first_file_descriptor.size() != 2) { ERR(FTL) << "Found Joint measurement where the input file had no type: \"" << input << "\", expected \"INPUTTYPE:File.root;File2.root\"." << std::endl; throw; } std::string inpType = first_file_descriptor[0]; for (std::vector<string>::iterator iter = entries.begin(); iter != entries.end(); iter++) { if (GeneralUtils::ParseToStr(*iter, ":").size() != 2) { std::stringstream ss(""); ss << inpType << ":" << (*iter); fSubInFiles.push_back(ss.str()); } else { fSubInFiles.push_back(*iter); } } // Set Engine and Fake Data fRW = rw; fakeDataFile = fkdt; // Set Fit Options SetFitOptions(type); return; } /* XSec Functions */ //******************************************************************** double JointMeas1D::TotalIntegratedFlux(std::string intOpt, double low, double high) { //******************************************************************** double totalflux = 0.0; // Destroy the job for sub samples for (std::vector<MeasurementBase*>::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase* exp = *expIter; double expflux = exp->TotalIntegratedFlux(intOpt, low, high); // Fill flux options if (fIsRatio) { totalflux = expflux; break; } if (fIsSummed) { totalflux += expflux; } } return totalflux; } /* Reconfigure Functions */ //******************************************************************** void JointMeas1D::Reconfigure() { //******************************************************************** // This will just call reconfigure explicitly and apply all the standard // scalings too each sub sample. // If you just want to fill event rates into plots make a Reconfigure in the // top level sample, you will // need to loop over each sample explicitly and cast it to an InputHandler // before calling ReconfigureAllEvents. for (std::vector<MeasurementBase*>::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase* exp = *expIter; exp->Reconfigure(); } // Joint function called by top level class MakePlots(); // Do Final Normalisation ApplyNormScale(fRW->GetSampleNorm(this->fName)); return; } //******************************************************************** void JointMeas1D::ReconfigureFast() { //******************************************************************** // This will just call reconfigure explicitly and apply all the standard // scalings too each sub sample. // If you just want to fill event rates into plots make a Reconfigure in the // top level sample, you will // need to loop over each sample explicitly and cast it to an InputHandler // before calling ReconfigureAllEvents. for (std::vector<MeasurementBase*>::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase* exp = *expIter; exp->ReconfigureFast(); } // Joint function called by top level class MakePlots(); // Do Final Normalisation ApplyNormScale(fRW->GetSampleNorm(this->fName)); return; } //******************************************************************** void JointMeas1D::MakePlots() { //******************************************************************** // Reset the 1D histograms but not the subClasses Measurement1D::ResetAll(); // If Summed if (fIsSummed) { for (std::vector<MeasurementBase*>::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase* exp = static_cast<MeasurementBase*>(*expIter); this->fMCHist->Add(exp->GetMCList().at(0)); this->fMCFine->Add(exp->GetFineList().at(0)); } return; } // If Ratio if (fIsRatio) { int sample = 0; for (std::vector<MeasurementBase*>::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase* exp = *expIter; if (sample == 0) { this->fMCHist->Add(exp->GetMCList().at(0)); this->fMCFine->Add(exp->GetFineList().at(0)); } else if (sample == 1) { this->fMCHist->Divide(exp->GetMCList().at(0)); this->fMCFine->Divide(exp->GetFineList().at(0)); } else break; sample++; } return; } return; } /* Access Functions */ //******************************************************************** std::vector<TH1*> JointMeas1D::GetMCList() { //******************************************************************** // Make Default Vector std::vector<TH1*> tempVect; tempVect.push_back(this->fMCHist); // Return vector from all sub samples for (std::vector<MeasurementBase*>::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase* exp = *expIter; std::vector<TH1*> subTempVect = exp->GetMCList(); for (UInt_t i = 0; i < subTempVect.size(); i++) { tempVect.push_back(subTempVect.at(i)); } } return tempVect; } //******************************************************************** std::vector<TH1*> JointMeas1D::GetDataList() { //******************************************************************** // Make Default Vector std::vector<TH1*> tempVect; tempVect.push_back(this->fDataHist); // Return vector from all sub samples for (std::vector<MeasurementBase*>::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase* exp = *expIter; std::vector<TH1*> subTempVect = exp->GetDataList(); for (UInt_t i = 0; i < subTempVect.size(); i++) { tempVect.push_back(subTempVect.at(i)); } } return tempVect; } //******************************************************************** std::vector<TH1*> JointMeas1D::GetFineList() { //******************************************************************** // Make Default Vector std::vector<TH1*> tempVect; tempVect.push_back(this->fMCFine); // Return vector from all sub samples for (std::vector<MeasurementBase*>::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase* exp = *expIter; std::vector<TH1*> subTempVect = exp->GetFineList(); for (UInt_t i = 0; i < subTempVect.size(); i++) { tempVect.push_back(subTempVect.at(i)); } } return tempVect; } //******************************************************************** std::vector<TH1*> JointMeas1D::GetMaskList() { //******************************************************************** // Make Default Vector std::vector<TH1*> tempVect; tempVect.push_back(this->fMaskHist); // Return vector from all sub samples for (std::vector<MeasurementBase*>::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase* exp = *expIter; std::vector<TH1*> subTempVect = exp->GetMaskList(); for (UInt_t i = 0; i < subTempVect.size(); i++) { tempVect.push_back(subTempVect.at(i)); } } return tempVect; } //******************************************************************** std::vector<TH1*> JointMeas1D::GetFluxList() { //******************************************************************** // Make Default Vector std::vector<TH1*> tempVect; - tempVect.push_back(this->fFluxHist); + tempVect.push_back(MeasurementBase::GetFluxHistogram()); // Return vector from all sub samples for (std::vector<MeasurementBase*>::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase* exp = *expIter; std::vector<TH1*> subTempVect = exp->GetFluxList(); for (UInt_t i = 0; i < subTempVect.size(); i++) { tempVect.push_back(subTempVect.at(i)); } } return tempVect; } //******************************************************************** std::vector<TH1*> JointMeas1D::GetEventRateList() { //******************************************************************** // Make Default Vector std::vector<TH1*> tempVect; - tempVect.push_back(this->fEventHist); + tempVect.push_back(MeasurementBase::GetEventHistogram()); // Return vector from all sub samples for (std::vector<MeasurementBase*>::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase* exp = *expIter; std::vector<TH1*> subTempVect = exp->GetEventRateList(); for (UInt_t i = 0; i < subTempVect.size(); i++) { tempVect.push_back(subTempVect.at(i)); } } return tempVect; } //******************************************************************** std::vector<TH1*> JointMeas1D::GetXSecList() { //******************************************************************** // Make Default Vector std::vector<TH1*> tempVect; - tempVect.push_back(this->fXSecHist); + tempVect.push_back(MeasurementBase::GetXSecHistogram()); // Return vector from all sub samples for (std::vector<MeasurementBase*>::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase* exp = *expIter; std::vector<TH1*> subTempVect = exp->GetXSecList(); for (UInt_t i = 0; i < subTempVect.size(); i++) { tempVect.push_back(subTempVect.at(i)); } } return tempVect; } //******************************************************************** TH1D* JointMeas1D::GetCombinedFlux() { //******************************************************************** TH1D* newflux; int sample = 0; for (std::vector<MeasurementBase*>::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase* exp = *expIter; // Get flux from experiment std::vector<TH1*> fluxVect = exp->GetFluxList(); // Setup newflux if (sample == 0) { newflux = (TH1D*)fluxVect.at(0); newflux->Reset(); } // Add all fluxes for (UInt_t i = 0; i < fluxVect.size(); i++) { newflux->Add((TH1D*)fluxVect.at(i)); sample++; } } return newflux; } //******************************************************************** TH1D* JointMeas1D::GetCombinedEventRate() { //******************************************************************** TH1D* newflux; int sample = 0; for (std::vector<MeasurementBase*>::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase* exp = *expIter; // Get flux from experiment std::vector<TH1*> fluxVect = exp->GetFluxList(); // Setup newflux if (sample == 0) { newflux = (TH1D*)fluxVect.at(0); newflux->Reset(); } // Add all fluxes for (UInt_t i = 0; i < fluxVect.size(); i++) { newflux->Add(fluxVect.at(i)); sample++; } } return newflux; } /* Write Functions */ //******************************************************************** void JointMeas1D::Write(std::string drawOpt) { //******************************************************************** // Write the top level class Measurement1D::Write(drawOpt); if (fSaveSubMeas) { for (std::vector<MeasurementBase*>::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase* exp = *expIter; exp->Write(drawOpt); } } return; }; diff --git a/src/FitBase/JointMeas1D.h b/src/FitBase/JointMeas1D.h index 960ddbf..f6c2c35 100644 --- a/src/FitBase/JointMeas1D.h +++ b/src/FitBase/JointMeas1D.h @@ -1,155 +1,170 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #ifndef JOINTMEASUREMENT_1D_H_SEEN #define JOINTMEASUREMENT_1D_H_SEEN /*! * \addtogroup FitBase * @{ */ - -#include <stdlib.h> -#include <numeric> #include <math.h> -#include <string> -#include <iostream> -#include <sstream> -#include <iomanip> +#include <stdlib.h> #include <deque> +#include <iomanip> +#include <iostream> #include <list> +#include <numeric> +#include <sstream> +#include <string> // ROOT includes -#include <TROOT.h> -#include <TH1D.h> -#include <TH2D.h> #include <TArrayF.h> -#include <TGraph.h> +#include <TCanvas.h> #include <TCut.h> +#include <TDecompChol.h> +#include <TDecompSVD.h> +#include <TGraph.h> #include <TGraphErrors.h> +#include <TH1D.h> +#include <TH2D.h> #include <TMatrixDSym.h> -#include <TDecompSVD.h> -#include <TDecompChol.h> +#include <TROOT.h> #include <TSystem.h> -#include <TCanvas.h> #include "Measurement1D.h" // External data fit includes -#include "MeasurementBase.h" #include "FitEvent.h" +#include "FitParameters.h" #include "FitUtils.h" -#include "StatUtils.h" +#include "MeasurementBase.h" #include "PlotUtils.h" -#include "FitParameters.h" +#include "StatUtils.h" #include "InputHandler.h" /// Joint Measurement 1D Class /// -/// Base class used to setup measurements that require multiple distributions to then be merged. -/// The "fSubChain" object is used to keep track of each of the individual experiments which are then +/// Base class used to setup measurements that require multiple distributions to +/// then be merged. +/// The "fSubChain" object is used to keep track of each of the individual +/// experiments which are then /// automatically reconfigured, written, etc. //******************************************************************** //! Base class to setup measurements that require several sub measurements class JointMeas1D : public Measurement1D { -//******************************************************************** + //******************************************************************** public: - /* Constructor/Deconstuctor */ //! Default Constructor JointMeas1D(); //! Default Virtual Destructor virtual ~JointMeas1D(); //! Initialise the samples void Init(); /* Worker Node Functions - - Input handler does the long reconfigures so gives option for cluster submission + - Input handler does the long reconfigures so gives option for cluster + submission - on a sample by sample basis */ - /* Setup Functions */ - /// Setup the measurement and weight engines, parse the input files and setup sub measurements. - virtual void SetupMeasurement(std::string input, std::string type, FitWeight *rw, std::string fkdt); + /// Setup the measurement and weight engines, parse the input files and setup + /// sub measurements. + virtual void SetupMeasurement(std::string input, std::string type, + FitWeight* rw, std::string fkdt); /* XSec Functions */ - /// Return total integrated flux. Will integrate flux of all sub samples if required. - virtual double TotalIntegratedFlux(std::string intOpt="width",double low=-9999.9, double high=-9999.9); + /// Return total integrated flux. Will integrate flux of all sub samples if + /// required. + virtual double TotalIntegratedFlux(std::string intOpt = "width", + double low = -9999.9, + double high = -9999.9); /* Reconfigure Functions */ /// Call reconfigure on every sub sample virtual void Reconfigure(); virtual void ReconfigureFast(); - /// Stitch the sub sample plots together to make a final fMCHist after reconfigure has been called + /// Stitch the sub sample plots together to make a final fMCHist after + /// reconfigure has been called virtual void MakePlots(); /* Access Functions */ virtual std::vector<TH1*> GetMCList(); virtual std::vector<TH1*> GetDataList(); virtual std::vector<TH1*> GetFineList(); virtual std::vector<TH1*> GetMaskList(); virtual std::vector<TH1*> GetFluxList(); virtual std::vector<TH1*> GetEventRateList(); virtual std::vector<TH1*> GetXSecList(); //! Return a flux integrated across all sub samples virtual TH1D* GetCombinedFlux(); //! Return an event rate integrated across all sub samples virtual TH1D* GetCombinedEventRate(); + virtual TH1D* GetEventHistogram() { return GetCombinedEventRate(); }; + virtual TH1D* GetXSecHistogram() { + ERR(WRN) + << "XSec histogram not properly implemented for joint measurements."; + return MeasurementBase::GetXSecHistogram(); + }; + virtual TH1D* GetFluxHistogram() { return GetCombinedFlux(); }; + /* Write Functions */ //! Write the current status of the plots to the current directory virtual void Write(std::string drawOpt); - std::vector<MeasurementBase*> fSubChain; //!< Vector of experimental classes that are the sub measurements - std::vector<std::string> fSubInFiles; //!< vector of input files for each of the sub measurements. - -protected: - - bool fIsRatio; //!< Flag: is this sample a hist1/hist2 ratio sample - bool fIsSummed; //!< Flag: is this sample a combination hist1 + hist2 - bool fSaveSubMeas; //!< Flag: Save each of the histograms from the sub samples as well as this joint samples plots + std::vector<MeasurementBase*> fSubChain; //!< Vector of experimental classes + //! that are the sub measurements + std::vector<std::string> + fSubInFiles; //!< vector of input files for each of the sub measurements. + protected: + bool fIsRatio; //!< Flag: is this sample a hist1/hist2 ratio sample + bool fIsSummed; //!< Flag: is this sample a combination hist1 + hist2 + bool fSaveSubMeas; //!< Flag: Save each of the histograms from the sub + //! samples as well as this joint samples plots }; /*! @} */ #endif diff --git a/src/FitBase/Measurement1D.cxx b/src/FitBase/Measurement1D.cxx index 4cf17d7..b24574b 100644 --- a/src/FitBase/Measurement1D.cxx +++ b/src/FitBase/Measurement1D.cxx @@ -1,1362 +1,1403 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "Measurement1D.h" /* Constructor/destructor Functions */ //******************************************************************** Measurement1D::Measurement1D() { //******************************************************************** + fScaleFactor = -1.0; fCurrentNorm = 1.0; fMCHist = NULL; fDataHist = NULL; fMCFine = NULL; fMCWeighted = NULL; fMaskHist = NULL; this->covar = NULL; fFullCovar = NULL; fDecomp = NULL; this->fakeDataFile = ""; - fFluxHist = NULL; - fEventHist = NULL; - fXSecHist = NULL; fDefaultTypes = "FIX/FULL/CHI2"; fAllowedTypes = "FIX,FREE,SHAPE/FULL,DIAG/CHI2/NORM/ENUCORR/Q2CORR/ENU1D/MASK"; fIsFix = false; fIsShape = false; fIsFree = false; fIsDiag = false; fIsFull = false; fAddNormPen = false; fIsMask = false; fIsChi2SVD = false; fIsRawEvents = false; fIsDifXSec = false; fIsEnu1D = false; + + NSignal = 0; } //******************************************************************** Measurement1D::~Measurement1D() { //******************************************************************** } //******************************************************************** void Measurement1D::Init() { //******************************************************************** } /* Setup Functions -- All these are used only at the start of the Measurement */ //******************************************************************** void Measurement1D::SetupMeasurement(std::string inputfile, std::string type, FitWeight* rw, std::string fkdt) { //******************************************************************** // Reset everything to NULL Init(); // Check if name contains Evt, indicating that it is a raw number of events // measurements and should thus be treated as once fIsRawEvents = false; if ((fName.find("Evt") != std::string::npos) && fIsRawEvents == false) { fIsRawEvents = true; LOG(SAM) << "Found event rate measurement but fIsRawEvents == false!" << std::endl; LOG(SAM) << "Overriding this and setting fIsRawEvents == true!" << std::endl; } fIsEnu1D = false; if (fName.find("XSec_1DEnu") != std::string::npos) { fIsEnu1D = true; LOG(SAM) << "::" << fName << "::" << std::endl; LOG(SAM) << "Found XSec Enu measurement, applying flux integrated scaling, " "not flux averaged!" << std::endl; - if (FitPar::Config().GetParB("EventManager")){ - ERR(FTL) << "Enu Measurements do not yet work with the Event Manager!" << std::endl; - ERR(FTL) << "If you want decent flux unfolded results please run in series mode (-q EventManager=0)" << std::endl; + if (FitPar::Config().GetParB("EventManager")) { + ERR(FTL) << "Enu Measurements do not yet work with the Event Manager!" + << std::endl; + ERR(FTL) << "If you want decent flux unfolded results please run in " + "series mode (-q EventManager=0)" + << std::endl; sleep(2); } } if (fIsEnu1D && fIsRawEvents) { LOG(SAM) << "Found 1D Enu XSec distribution AND fIsRawEvents, is this " "really correct?!" << std::endl; LOG(SAM) << "Check experiment constructor for " << fName << " and correct this!" << std::endl; LOG(SAM) << "I live in " << __FILE__ << ":" << __LINE__ << std::endl; exit(-1); } fRW = rw; - this->SetupInputs(inputfile); + SetupInputs(inputfile); // Set Default Options SetFitOptions(fDefaultTypes); // Set Passed Options SetFitOptions(type); // Still adding support for flat flux inputs // // Set Enu Flux Scaling // if (isFlatFluxFolding) this->Input()->ApplyFluxFolding( // this->defaultFluxHist ); } //******************************************************************** void Measurement1D::SetupDefaultHist() { //******************************************************************** // Setup fMCHist fMCHist = (TH1D*)fDataHist->Clone(); fMCHist->SetNameTitle((fName + "_MC").c_str(), (fName + "_MC" + fPlotTitles).c_str()); // Setup fMCFine Int_t nBins = fMCHist->GetNbinsX(); fMCFine = new TH1D( (fName + "_MC_FINE").c_str(), (fName + "_MC_FINE" + fPlotTitles).c_str(), nBins * 6, fMCHist->GetBinLowEdge(1), fMCHist->GetBinLowEdge(nBins + 1)); fMCStat = (TH1D*)fMCHist->Clone(); fMCStat->Reset(); fMCHist->Reset(); fMCFine->Reset(); // Setup the NEUT Mode Array PlotUtils::CreateNeutModeArray((TH1D*)fMCHist, (TH1**)fMCHist_PDG); PlotUtils::ResetNeutModeArray((TH1**)fMCHist_PDG); // Setup bin masks using sample name if (fIsMask) { std::string maskloc = FitPar::Config().GetParDIR(fName + ".mask"); if (maskloc.empty()) { maskloc = FitPar::GetDataBase() + "/masks/" + fName + ".mask"; } SetBinMask(maskloc); } return; } //******************************************************************** void Measurement1D::SetFitOptions(std::string opt) { //******************************************************************** // Do nothing if default given if (opt == "DEFAULT") return; // CHECK Conflicting Fit Options std::vector<std::string> fit_option_allow = GeneralUtils::ParseToStr(fAllowedTypes, "/"); for (UInt_t i = 0; i < fit_option_allow.size(); i++) { std::vector<std::string> fit_option_section = GeneralUtils::ParseToStr(fit_option_allow.at(i), ","); bool found_option = false; for (UInt_t j = 0; j < fit_option_section.size(); j++) { std::string av_opt = fit_option_section.at(j); if (!found_option and opt.find(av_opt) != std::string::npos) { found_option = true; } else if (found_option and opt.find(av_opt) != std::string::npos) { ERR(FTL) << "ERROR: Conflicting fit options provided: " << opt << std::endl; ERR(FTL) << "Conflicting group = " << fit_option_section.at(i) << std::endl; ERR(FTL) << "You should only supply one of these options in card file." << std::endl; exit(-1); } } } // Check all options are allowed - std::vector<std::string> fit_options_input = GeneralUtils::ParseToStr(opt, "/"); + std::vector<std::string> fit_options_input = + GeneralUtils::ParseToStr(opt, "/"); for (UInt_t i = 0; i < fit_options_input.size(); i++) { if (fAllowedTypes.find(fit_options_input.at(i)) == std::string::npos) { ERR(FTL) << "ERROR: Fit Option '" << fit_options_input.at(i) << "' Provided is not allowed for this measurement." << std::endl; ERR(FTL) << "Fit Options should be provided as a '/' seperated list " "(e.g. FREE/DIAG/NORM)" << std::endl; ERR(FTL) << "Available options for " << fName << " are '" << fAllowedTypes << "'" << std::endl; exit(-1); } } // Set TYPE fFitType = opt; // FIX,SHAPE,FREE if (opt.find("FIX") != std::string::npos) { fIsFree = fIsShape = false; fIsFix = true; } else if (opt.find("SHAPE") != std::string::npos) { fIsFree = fIsFix = false; fIsShape = true; } else if (opt.find("FREE") != std::string::npos) { fIsFix = fIsShape = false; fIsFree = true; } // DIAG,FULL (or default to full) if (opt.find("DIAG") != std::string::npos) { fIsDiag = true; fIsFull = false; } else if (opt.find("FULL") != std::string::npos) { fIsDiag = false; fIsFull = true; } // CHI2/LL (OTHERS?) if (opt.find("LOG") != std::string::npos) fIsChi2 = false; else fIsChi2 = true; // EXTRAS if (opt.find("RAW") != std::string::npos) fIsRawEvents = true; if (opt.find("DIF") != std::string::npos) fIsDifXSec = true; if (opt.find("ENU1D") != std::string::npos) fIsEnu1D = true; if (opt.find("NORM") != std::string::npos) fAddNormPen = true; if (opt.find("MASK") != std::string::npos) fIsMask = true; return; }; //******************************************************************** void Measurement1D::SetDataValues(std::string dataFile) { //******************************************************************** // Override this function if the input file isn't in a suitable format LOG(SAM) << "Reading data from: " << dataFile.c_str() << std::endl; fDataHist = PlotUtils::GetTH1DFromFile(dataFile, (fName + "_data"), fPlotTitles); fDataTrue = (TH1D*)fDataHist->Clone(); // Number of data points is number of bins fNDataPointsX = fDataHist->GetXaxis()->GetNbins(); return; }; //******************************************************************** void Measurement1D::SetDataFromDatabase(std::string inhistfile, std::string histname) { //******************************************************************** LOG(SAM) << "Filling histogram from " << inhistfile << "->" << histname << std::endl; fDataHist = PlotUtils::GetTH1DFromRootFile( (GeneralUtils::GetTopLevelDir() + "/data/" + inhistfile), histname); fDataHist->SetNameTitle((fName + "_data").c_str(), (fName + "_data").c_str()); return; }; //******************************************************************** void Measurement1D::SetDataFromFile(std::string inhistfile, std::string histname) { //******************************************************************** LOG(SAM) << "Filling histogram from " << inhistfile << "->" << histname << std::endl; fDataHist = PlotUtils::GetTH1DFromRootFile((inhistfile), histname); fDataHist->SetNameTitle((fName + "_data").c_str(), (fName + "_data").c_str()); return; }; //******************************************************************** void Measurement1D::SetCovarMatrix(std::string covarFile) { //******************************************************************** // Covariance function, only really used when reading in the MB Covariances. TFile* tempFile = new TFile(covarFile.c_str(), "READ"); TH2D* covarPlot = new TH2D(); // TH2D* decmpPlot = new TH2D(); TH2D* covarInvPlot = new TH2D(); TH2D* fFullCovarPlot = new TH2D(); std::string covName = ""; std::string covOption = FitPar::Config().GetParS("thrown_covariance"); if (fIsShape || fIsFree) covName = "shp_"; if (fIsDiag) covName += "diag"; else covName += "full"; covarPlot = (TH2D*)tempFile->Get((covName + "cov").c_str()); covarInvPlot = (TH2D*)tempFile->Get((covName + "covinv").c_str()); if (!covOption.compare("SUB")) fFullCovarPlot = (TH2D*)tempFile->Get((covName + "cov").c_str()); else if (!covOption.compare("FULL")) fFullCovarPlot = (TH2D*)tempFile->Get("fullcov"); else ERR(WRN) << "Incorrect thrown_covariance option in parameters." << std::endl; int dim = int(fDataHist->GetNbinsX()); //-this->masked->Integral()); int covdim = int(fDataHist->GetNbinsX()); this->covar = new TMatrixDSym(dim); fFullCovar = new TMatrixDSym(dim); fDecomp = new TMatrixDSym(dim); int row, column = 0; row = 0; column = 0; for (Int_t i = 0; i < covdim; i++) { // if (this->masked->GetBinContent(i+1) > 0) continue; for (Int_t j = 0; j < covdim; j++) { // if (this->masked->GetBinContent(j+1) > 0) continue; (*this->covar)(row, column) = covarPlot->GetBinContent(i + 1, j + 1); (*fFullCovar)(row, column) = fFullCovarPlot->GetBinContent(i + 1, j + 1); column++; } column = 0; row++; } // Set bin errors on data if (!fIsDiag) { StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar); } // Get Deteriminant and inverse matrix fCovDet = this->covar->Determinant(); TDecompSVD LU = TDecompSVD(*this->covar); this->covar = new TMatrixDSym(dim, LU.Invert().GetMatrixArray(), ""); return; }; //******************************************************************** // Sets the covariance matrix from a provided file in a text format -// scale is a multiplicative pre-factor to apply in the case where the covariance is given in some unit (e.g. 1E-38) -void Measurement1D::SetCovarMatrixFromText(std::string covarFile, int dim, double scale) { -//******************************************************************** +// scale is a multiplicative pre-factor to apply in the case where the +// covariance is given in some unit (e.g. 1E-38) +void Measurement1D::SetCovarMatrixFromText(std::string covarFile, int dim, + double scale) { + //******************************************************************** // Make a counter to track the line number int row = 0; std::string line; std::ifstream covarread(covarFile.c_str(), ifstream::in); this->covar = new TMatrixDSym(dim); fFullCovar = new TMatrixDSym(dim); if (covarread.is_open()) LOG(SAM) << "Reading covariance matrix from file: " << covarFile << std::endl; else ERR(FTL) << "Covariance matrix provided is incorrect: " << covarFile << std::endl; // Loop over the lines in the file while (std::getline(covarread >> std::ws, line, '\n')) { int column = 0; // Loop over entries and insert them into matrix std::vector<double> entries = GeneralUtils::ParseToDbl(line, " "); - if (entries.size() <= 1){ - ERR(WRN) << "SetCovarMatrixFromText -> Covariance matrix only has <= 1 entries on this line: " << row << std::endl; + if (entries.size() <= 1) { + ERR(WRN) << "SetCovarMatrixFromText -> Covariance matrix only has <= 1 " + "entries on this line: " + << row << std::endl; } - - for (std::vector<double>::iterator iter = entries.begin(); - iter != entries.end(); iter++){ + for (std::vector<double>::iterator iter = entries.begin(); + iter != entries.end(); iter++) { (*covar)(row, column) = *iter; (*fFullCovar)(row, column) = *iter; column++; } row++; } covarread.close(); // Scale the actualy covariance matrix by some multiplicative factor (*fFullCovar) *= scale; // Robust matrix inversion method TDecompSVD LU = TDecompSVD(*this->covar); // THIS IS ACTUALLY THE INVERSE COVARIANCE MATRIXA AAAAARGH delete this->covar; this->covar = new TMatrixDSym(dim, LU.Invert().GetMatrixArray(), ""); // Now need to multiply by the scaling factor // If the covariance - (*this->covar) *= 1./(scale); + (*this->covar) *= 1. / (scale); return; }; //******************************************************************** -void Measurement1D::SetCovarMatrixFromCorrText(std::string corrFile, int dim){ -//******************************************************************** +void Measurement1D::SetCovarMatrixFromCorrText(std::string corrFile, int dim) { + //******************************************************************** // Make a counter to track the line number int row = 0; std::string line; - std::ifstream corr(corrFile.c_str(),ifstream::in); + std::ifstream corr(corrFile.c_str(), ifstream::in); this->covar = new TMatrixDSym(dim); this->fFullCovar = new TMatrixDSym(dim); - if(corr.is_open()) LOG(SAM) << "Reading and converting correlation matrix from file: " << corrFile << std::endl; + if (corr.is_open()) + LOG(SAM) << "Reading and converting correlation matrix from file: " + << corrFile << std::endl; else { - ERR(FTL) <<"Correlation matrix provided is incorrect: "<<corrFile<<std::endl; + ERR(FTL) << "Correlation matrix provided is incorrect: " << corrFile + << std::endl; exit(-1); } while (std::getline(corr >> std::ws, line, '\n')) { int column = 0; // Loop over entries and insert them into matrix - // Multiply by the errors to get the covariance, rather than the correlation matrix + // Multiply by the errors to get the covariance, rather than the correlation + // matrix std::vector<double> entries = GeneralUtils::ParseToDbl(line, " "); for (std::vector<double>::iterator iter = entries.begin(); - iter != entries.end(); iter++){ - - double val = (*iter) * this->fDataHist->GetBinError(row+1)*1E38*this->fDataHist->GetBinError(column+1)*1E38; + iter != entries.end(); iter++) { + double val = (*iter) * this->fDataHist->GetBinError(row + 1) * 1E38 * + this->fDataHist->GetBinError(column + 1) * 1E38; if (val == 0) { - ERR(FTL) << "Found a zero value in the covariance matrix, assuming this is an error!" << std::endl; + ERR(FTL) << "Found a zero value in the covariance matrix, assuming " + "this is an error!" + << std::endl; exit(-1); } (*this->covar)(row, column) = val; (*this->fFullCovar)(row, column) = val; column++; } row++; } // Robust matrix inversion method TDecompSVD LU = TDecompSVD(*this->covar); delete this->covar; - this->covar = new TMatrixDSym(dim, LU .Invert().GetMatrixArray(), ""); - + this->covar = new TMatrixDSym(dim, LU.Invert().GetMatrixArray(), ""); + return; }; //******************************************************************** -void Measurement1D::SetSmearingMatrix(std::string smearfile, int truedim, int recodim){ +void Measurement1D::SetSmearingMatrix(std::string smearfile, int truedim, + int recodim) { //******************************************************************** // The smearing matrix describes the migration from true bins (rows) to reco // bins (columns) // Counter over the true bins! int row = 0; std::string line; std::ifstream smear(smearfile.c_str(), ifstream::in); // Note that the smearing matrix may be rectangular. fSmearMatrix = new TMatrixD(truedim, recodim); if (smear.is_open()) LOG(SAM) << "Reading smearing matrix from file: " << smearfile << std::endl; else ERR(FTL) << "Smearing matrix provided is incorrect: " << smearfile - << std::endl; + << std::endl; while (std::getline(smear >> std::ws, line, '\n')) { int column = 0; std::vector<double> entries = GeneralUtils::ParseToDbl(line, " "); for (std::vector<double>::iterator iter = entries.begin(); - iter != entries.end(); iter++){ - (*fSmearMatrix)(row, column) = (*iter) / 100.; // Convert to fraction from + iter != entries.end(); iter++) { + (*fSmearMatrix)(row, column) = + (*iter) / 100.; // Convert to fraction from // percentage (this may not be // general enough) column++; } row++; } return; } //******************************************************************** +// FullUnits refers to if we have "real" unscaled units in the covariance matrix, e.g. 1E-76. +// If this is the case we need to scale it so that the chi2 contribution is correct +// NUISANCE internally assumes the covariance matrix has units of 1E76 void Measurement1D::SetCovarFromDataFile(std::string covarFile, - std::string covName) { + std::string covName, bool FullUnits) { //******************************************************************** LOG(SAM) << "Getting covariance from " << covarFile << "->" << covName - << std::endl; + << std::endl; TFile* tempFile = new TFile(covarFile.c_str(), "READ"); TH2D* covPlot = (TH2D*)tempFile->Get(covName.c_str()); covPlot->SetDirectory(0); + // Scale the covariance matrix if it comes in normal units + if (FullUnits) { + covPlot->Scale(1.E76); + } int dim = covPlot->GetNbinsX(); fFullCovar = new TMatrixDSym(dim); for (int i = 0; i < dim; i++) { for (int j = 0; j < dim; j++) { (*fFullCovar)(i, j) = covPlot->GetBinContent(i + 1, j + 1); } } this->covar = (TMatrixDSym*)fFullCovar->Clone(); fDecomp = (TMatrixDSym*)fFullCovar->Clone(); TDecompSVD LU = TDecompSVD(*this->covar); this->covar = new TMatrixDSym(dim, LU.Invert().GetMatrixArray(), ""); TDecompChol LUChol = TDecompChol(*fDecomp); LUChol.Decompose(); fDecomp = new TMatrixDSym(dim, LU.GetU().GetMatrixArray(), ""); return; }; //******************************************************************** void Measurement1D::SetBinMask(std::string maskFile) { //******************************************************************** // Create a mask histogram. int nbins = fDataHist->GetNbinsX(); fMaskHist = - new TH1I((fName + "_fMaskHist").c_str(), - (fName + "_fMaskHist; Bin; Mask?").c_str(), nbins, 0, nbins); + new TH1I((fName + "_fMaskHist").c_str(), + (fName + "_fMaskHist; Bin; Mask?").c_str(), nbins, 0, nbins); std::string line; std::ifstream mask(maskFile.c_str(), ifstream::in); if (mask.is_open()) LOG(SAM) << "Reading bin mask from file: " << maskFile << std::endl; else LOG(FTL) << " Cannot find mask file." << std::endl; while (std::getline(mask >> std::ws, line, '\n')) { - std::vector<int> entries = GeneralUtils::ParseToInt(line, " "); // Skip lines with poorly formatted lines if (entries.size() < 2) { - LOG(WRN) << "Measurement1D::SetBinMask(), couldn't parse line: " << line << std::endl; + LOG(WRN) << "Measurement1D::SetBinMask(), couldn't parse line: " << line + << std::endl; continue; } - // The first index should be the bin number, the second should be the mask value. + // The first index should be the bin number, the second should be the mask + // value. fMaskHist->SetBinContent(entries[0], entries[1]); } // Set masked data bins to zero PlotUtils::MaskBins(fDataHist, fMaskHist); return; } /* XSec Functions */ -//******************************************************************** -void Measurement1D::SetFluxHistogram(std::string fluxFile, int minE, int maxE, - double fluxNorm) { - //******************************************************************** +// //******************************************************************** +// void Measurement1D::SetFluxHistogram(std::string fluxFile, int minE, int +// maxE, +// double fluxNorm) { +// //******************************************************************** - // Note this expects the flux bins to be given in terms of MeV - LOG(SAM) << "Reading flux from file: " << fluxFile << std::endl; +// // Note this expects the flux bins to be given in terms of MeV +// LOG(SAM) << "Reading flux from file: " << fluxFile << std::endl; - TGraph f(fluxFile.c_str(), "%lg %lg"); +// TGraph f(fluxFile.c_str(), "%lg %lg"); - fFluxHist = - new TH1D((fName + "_flux").c_str(), (fName + "; E_{#nu} (GeV)").c_str(), - f.GetN() - 1, minE, maxE); +// fFluxHist = +// new TH1D((fName + "_flux").c_str(), (fName + "; E_{#nu} (GeV)").c_str(), +// f.GetN() - 1, minE, maxE); - Double_t* yVal = f.GetY(); +// Double_t* yVal = f.GetY(); - for (int i = 0; i < fFluxHist->GetNbinsX(); ++i) - fFluxHist->SetBinContent(i + 1, yVal[i] * fluxNorm); -}; +// for (int i = 0; i < fFluxHist->GetNbinsX(); ++i) +// fFluxHist->SetBinContent(i + 1, yVal[i] * fluxNorm); +// }; -//******************************************************************** -double Measurement1D::TotalIntegratedFlux(std::string intOpt, double low, - double high) { - //******************************************************************** - - if (GetInput()->GetType() == kGiBUU) { - return 1.0; - } +// //******************************************************************** +// double Measurement1D::TotalIntegratedFlux(std::string intOpt, double low, +// double high) { +// //******************************************************************** - // The default case of low = -9999.9 and high = -9999.9 - if (low == -9999.9) low = this->EnuMin; - if (high == -9999.9) high = this->EnuMax; +// if (fInput->GetType() == kGiBUU) { +// return 1.0; +// } +// // The default case of low = -9999.9 and high = -9999.9 +// if (low == -9999.9) low = this->EnuMin; +// if (high == -9999.9) high = this->EnuMax; - int minBin = fFluxHist->GetXaxis()->FindBin(low); - int maxBin = fFluxHist->GetXaxis()->FindBin(high); +// int minBin = fFluxHist->GetXaxis()->FindBin(low); +// int maxBin = fFluxHist->GetXaxis()->FindBin(high); - // Get integral over custom range - double integral = fFluxHist->Integral(minBin, maxBin + 1, intOpt.c_str()); +// // Get integral over custom range +// double integral = fFluxHist->Integral(minBin, maxBin + 1, intOpt.c_str()); - return integral; -}; +// return integral; +// }; /* Reconfigure LOOP */ //******************************************************************** void Measurement1D::ResetAll() { //******************************************************************** // Simple function to reset the mc Histograms incase that is all that is // needed. // Clear histograms fMCHist->Reset(); fMCFine->Reset(); fMCStat->Reset(); + NSignal = 0; PlotUtils::ResetNeutModeArray((TH1**)fMCHist_PDG); return; }; //******************************************************************** void Measurement1D::FillHistograms() { //******************************************************************** if (Signal) { fMCHist->Fill(fXVar, Weight); fMCFine->Fill(fXVar, Weight); fMCStat->Fill(fXVar, 1.0); + NSignal++; PlotUtils::FillNeutModeArray(fMCHist_PDG, Mode, fXVar, Weight); } return; }; //******************************************************************** void Measurement1D::ScaleEvents() { //******************************************************************** - LOG(REC) << std::setw(10) << std::right << fMCHist->Integral() << "/" << fNEvents - << " events passed selection + binning after reweight" << std::endl; + // Check that the fScaleFactor variable has been set and makes sense + if (fScaleFactor < 0) { + ERR(FTL) << "I found a negative fScaleFactor in " << __FILE__ << ":" << __LINE__ << std::endl; + ERR(FTL) << "fScaleFactor = " << fScaleFactor << std::endl; + ERR(FTL) << "EXITING" << std::endl; + exit(-1); + } + + LOG(REC) << std::setw(10) << std::right << NSignal << "/" + << fNEvents << " events passed selection + binning after reweight" + << std::endl; // Simple function to scale to xsec result if this is all that is needed. // Scale bin errors correctly TH1D* tempFine = (TH1D*)fMCFine->Clone(); // Create Weighted Histogram if (fMCWeighted) delete fMCWeighted; fMCWeighted = (TH1D*)fMCHist->Clone(); fMCWeighted->SetNameTitle((fName + "_MC_WGHTS").c_str(), - (fName + "_MC_WGHTS" + fPlotTitles).c_str()); + (fName + "_MC_WGHTS" + fPlotTitles).c_str()); fMCWeighted->GetYaxis()->SetTitle("Weighted Events"); // Should apply different scaling for: // 1D Enu distributions -- need bin by bin flux unfolding (bin by bin flux // integration) // 1D count distributions -- need shape scaling to data // anything else -- flux averages LOG(DEB) << "Scaling Factor = " << fScaleFactor << endl; LOG(DEB) << "MC Hist = " << fMCHist->Integral() << endl; // Scaling for raw event rates if (fIsRawEvents) { PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_PDG, - (fDataHist->Integral() / fMCHist->Integral()), - "width"); + (fDataHist->Integral() / fMCHist->Integral()), + "width"); fMCHist->Scale(fDataHist->Integral() / fMCHist->Integral()); fMCFine->Scale(fDataHist->Integral() / fMCFine->Integral()); // Scaling for XSec as function of Enu } else if (fIsEnu1D) { - - PlotUtils::FluxUnfoldedScaling(fMCHist, fFluxHist, fEventHist, fScaleFactor, fNEvents); - PlotUtils::FluxUnfoldedScaling(fMCFine, fFluxHist, fEventHist, fScaleFactor, fNEvents); + PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram(), + GetEventHistogram(), fScaleFactor, + fNEvents); + PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram(), + GetEventHistogram(), fScaleFactor, + fNEvents); // Any other differential scaling } else { fMCHist->Scale(fScaleFactor, "width"); fMCFine->Scale(fScaleFactor, "width"); PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_PDG, fScaleFactor, "width"); } // Proper error scaling - ROOT Freaks out with xsec weights sometimes // Scale the MC histogram for (int i = 0; i < fMCStat->GetNbinsX(); i++) { if (fMCStat->GetBinContent(i + 1) != 0) { fMCHist->SetBinError(i + 1, fMCHist->GetBinContent(i + 1) * - fMCStat->GetBinError(i + 1) / - fMCStat->GetBinContent(i + 1)); + fMCStat->GetBinError(i + 1) / + fMCStat->GetBinContent(i + 1)); } else { fMCHist->SetBinError(i + 1, fMCHist->Integral()); } } // Scale the fine MC histogram for (int i = 0; i < tempFine->GetNbinsX(); i++) { if (tempFine->GetBinContent(i + 1) != 0) { fMCFine->SetBinError(i + 1, fMCFine->GetBinContent(i + 1) * - tempFine->GetBinError(i + 1) / - tempFine->GetBinContent(i + 1)); + tempFine->GetBinError(i + 1) / + tempFine->GetBinContent(i + 1)); } else { fMCFine->SetBinError(i + 1, fMCFine->Integral()); } } return; }; //******************************************************************** void Measurement1D::ApplyNormScale(double norm) { //******************************************************************** fCurrentNorm = norm; fMCHist->Scale(1.0 / norm); fMCFine->Scale(1.0 / norm); PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_PDG, 1.0 / norm); return; }; //******************************************************************** void Measurement1D::ApplySmearingMatrix() { //******************************************************************** if (!fSmearMatrix) { ERR(WRN) << fName - << ": attempted to apply smearing matrix, but none was set" - << std::endl; + << ": attempted to apply smearing matrix, but none was set" + << std::endl; return; } TH1D* unsmeared = (TH1D*)fMCHist->Clone(); TH1D* smeared = (TH1D*)fMCHist->Clone(); smeared->Reset(); // Loop over reconstructed bins // true = row; reco = column for (int rbin = 0; rbin < fSmearMatrix->GetNcols(); ++rbin) { // Sum up the constributions from all true bins double rBinVal = 0; // Loop over true bins for (int tbin = 0; tbin < fSmearMatrix->GetNrows(); ++tbin) { rBinVal += - (*fSmearMatrix)(tbin, rbin) * unsmeared->GetBinContent(tbin + 1); + (*fSmearMatrix)(tbin, rbin) * unsmeared->GetBinContent(tbin + 1); } smeared->SetBinContent(rbin + 1, rBinVal); } fMCHist = (TH1D*)smeared->Clone(); return; } /* Statistic Functions - Outsources to StatUtils */ //******************************************************************** int Measurement1D::GetNDOF() { //******************************************************************** return fDataHist->GetNbinsX(); // - fMaskHist->Integral(); } //******************************************************************** double Measurement1D::GetLikelihood() { //******************************************************************** double stat = 0.0; // If this is for a ratio, there is no data histogram to compare to! if (fNoData || !fDataHist) return 0.; // Fix weird masking bug if (!fIsMask) { if (fMaskHist) { fMaskHist = NULL; } } else { if (fMaskHist) { PlotUtils::MaskBins(fMCHist, fMaskHist); } } // Sort Initial Scaling double scaleF = 0.0; if (fMCHist->Integral(1, fMCHist->GetNbinsX(), "width")) { scaleF = fDataHist->Integral(1, fDataHist->GetNbinsX(), "width") / - fMCHist->Integral(1, fMCHist->GetNbinsX(), "width"); + fMCHist->Integral(1, fMCHist->GetNbinsX(), "width"); } if (fIsShape) { fMCHist->Scale(scaleF); fMCFine->Scale(scaleF); PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_PDG, scaleF); } // Get Chi2 if (fIsChi2) { + // If this isn't a diagonal matrix (i.e. it has a covariance supplied) if (!fIsDiag) { + // If we don't want to get the chi2 from SVD decomp if (!fIsChi2SVD) { stat = StatUtils::GetChi2FromCov(fDataHist, fMCHist, covar, fMaskHist); } else { stat = StatUtils::GetChi2FromSVD(fDataHist, fMCHist, fFullCovar, - fMaskHist); + fMaskHist); } } else { if (fIsRawEvents) { stat = StatUtils::GetChi2FromEventRate(fDataHist, fMCHist, fMaskHist); } else { stat = StatUtils::GetChi2FromDiag(fDataHist, fMCHist, fMaskHist); } } } else { if (!fIsDiag) { if (!fIsChi2SVD) stat = StatUtils::GetLikelihoodFromCov(fDataHist, fMCHist, covar, - fMaskHist); + fMaskHist); else stat = StatUtils::GetLikelihoodFromSVD(fDataHist, fMCHist, fFullCovar, - fMaskHist); + fMaskHist); } else { if (fIsRawEvents) stat = StatUtils::GetLikelihoodFromEventRate(fDataHist, fMCHist, - fMaskHist); + fMaskHist); else stat = StatUtils::GetLikelihoodFromDiag(fDataHist, fMCHist, fMaskHist); } } // Sort Penalty Terms if (fAddNormPen) { if (fNormError <= 0.0) { ERR(WRN) << "Norm error for class " << fName << " is 0.0!" << endl; ERR(WRN) << "Skipping norm penalty." << endl; } double penalty = - (1. - fCurrentNorm) * (1. - fCurrentNorm) / (fNormError * fNormError); + (1. - fCurrentNorm) * (1. - fCurrentNorm) / (fNormError * fNormError); stat += penalty; } // Return to normal scaling if (fIsShape and !FitPar::Config().GetParB("saveshapescaling")) { fMCHist->Scale(1. / scaleF); fMCFine->Scale(1. / scaleF); PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_PDG, 1.0 / scaleF); } return stat; } //******************************************************************** void Measurement1D::SetFakeDataValues(std::string fakeOption) { //******************************************************************** // Reset things if (fIsFakeData) { this->ResetFakeData(); } else { fIsFakeData = true; } // Make a copy of the original data histogram. if (!(fDataOrig)) fDataOrig = (TH1D*)fDataHist->Clone((fName + "_data_original").c_str()); TH1D* tempData = (TH1D*)fDataHist->Clone(); TFile* fake = new TFile(); if (fakeOption.compare("MC") == 0) { LOG(SAM) << "Setting fake data from MC " << std::endl; fDataHist = (TH1D*)fMCHist->Clone((fName + "_MC").c_str()); if (fMCHist->Integral() == 0.0) ERR(WRN) << fName << ": Invalid histogram" << std::endl; } else { fake = new TFile(fakeOption.c_str()); fDataHist = (TH1D*)fake->Get((fName + "_MC").c_str()); } fDataHist->SetNameTitle((fName + "_FAKE").c_str(), - (fName + fPlotTitles).c_str()); + (fName + fPlotTitles).c_str()); fDataTrue = (TH1D*)fDataHist->Clone(); fDataTrue->SetNameTitle((fName + "_FAKE_TRUE").c_str(), - (fName + fPlotTitles).c_str()); + (fName + fPlotTitles).c_str()); int nbins = fDataHist->GetNbinsX(); double alpha_i = 0.0; double alpha_j = 0.0; for (int i = 0; i < nbins; i++) { for (int j = 0; j < nbins; j++) { alpha_i = - fDataHist->GetBinContent(i + 1) / tempData->GetBinContent(i + 1); + fDataHist->GetBinContent(i + 1) / tempData->GetBinContent(i + 1); alpha_j = - fDataHist->GetBinContent(j + 1) / tempData->GetBinContent(j + 1); + fDataHist->GetBinContent(j + 1) / tempData->GetBinContent(j + 1); (*this->covar)(i, j) = (1.0 / (alpha_i * alpha_j)) * (*this->covar)(i, j); (*fFullCovar)(i, j) = alpha_i * alpha_j * (*fFullCovar)(i, j); } } (this->covar) = (TMatrixDSym*)fFullCovar->Clone(); TDecompSVD LU = TDecompSVD(*this->covar); this->covar = new TMatrixDSym(nbins, LU.Invert().GetMatrixArray(), ""); return; }; //******************************************************************** void Measurement1D::ResetFakeData() { //******************************************************************** if (fIsFakeData) if (fDataHist) delete fDataHist; fDataHist = (TH1D*)fDataTrue->Clone((fName + "_FKDAT").c_str()); return; } //******************************************************************** void Measurement1D::ResetData() { //******************************************************************** if (fIsFakeData) if (fDataHist) delete fDataHist; fDataHist = (TH1D*)fDataTrue->Clone((fName + "_Data").c_str()); fIsFakeData = false; } //******************************************************************** void Measurement1D::ThrowCovariance() { //******************************************************************** // Take a fDecomposition and use it to throw the current dataset. // Requires fDataTrue also be set incase used repeatedly. delete fDataHist; fDataHist = StatUtils::ThrowHistogram(fDataTrue, fFullCovar); return; }; /* Access Functions */ //******************************************************************** std::vector<TH1*> Measurement1D::GetMCList() { //******************************************************************** // If this isn't a NULL pointer, make the plot pretty! if (!fMCHist) return std::vector<TH1*>(1, fMCHist); std::ostringstream chi2; chi2 << std::setprecision(5) << this->GetLikelihood(); int plotcolor = kRed; if (FitPar::Config().GetParI("linecolour") > 0) { plotcolor = FitPar::Config().GetParI("linecolour"); } int plotstyle = 1; if (FitPar::Config().GetParI("linestyle") > 0) { plotstyle = FitPar::Config().GetParI("linestyle"); } int plotfillstyle = 0; if (FitPar::Config().GetParI("fillstyle") > 0) { plotfillstyle = FitPar::Config().GetParI("fillstyle"); } fMCHist->SetTitle(chi2.str().c_str()); fMCHist->SetLineWidth(3); fMCHist->SetLineColor(plotcolor); fMCHist->SetFillColor(plotcolor); fMCHist->SetLineStyle(plotstyle); fMCHist->SetFillStyle(plotfillstyle); return std::vector<TH1*>(1, fMCHist); }; //******************************************************************** std::vector<TH1*> Measurement1D::GetDataList() { //******************************************************************** // If this isn't a NULL pointer, make the plot pretty! if (!fDataHist) return std::vector<TH1*>(1, fDataHist); fDataHist->SetLineWidth(2); fDataHist->SetMarkerStyle(8); fDataHist->SetLineColor(kBlack); return std::vector<TH1*>(1, fDataHist); }; //******************************************************************** void Measurement1D::GetBinContents(std::vector<double>& cont, - std::vector<double>& err) { + std::vector<double>& err) { //******************************************************************** // Return a vector of the main bin contents for (int i = 0; i < fMCHist->GetNbinsX(); i++) { cont.push_back(fMCHist->GetBinContent(i + 1)); err.push_back(fMCHist->GetBinError(i + 1)); } return; }; //******************************************************************** std::vector<double> Measurement1D::GetXSec(std::string option) { //******************************************************************** std::vector<double> vals; vals.push_back(0.0); vals.push_back(0.0); bool getMC = !option.compare("MC"); bool getDT = !option.compare("DATA"); for (int i = 0; i < fMCHist->GetNbinsX(); i++) { if (fDataHist->GetBinContent(i + 1) == 0.0 and fDataHist->GetBinError(i + 1) == 0.0) continue; if (getMC) { vals[0] += fMCHist->GetBinContent(i + 1) * - fMCHist->GetXaxis()->GetBinWidth(i + 1); + fMCHist->GetXaxis()->GetBinWidth(i + 1); vals[1] += fMCHist->GetBinError(i + 1) * fMCHist->GetBinError(i + 1) * - fMCHist->GetXaxis()->GetBinWidth(i + 1) * - fMCHist->GetXaxis()->GetBinWidth(i + 1); + fMCHist->GetXaxis()->GetBinWidth(i + 1) * + fMCHist->GetXaxis()->GetBinWidth(i + 1); } else if (getDT) { vals[0] += fDataHist->GetBinContent(i + 1) * - fDataHist->GetXaxis()->GetBinWidth(i + 1); + fDataHist->GetXaxis()->GetBinWidth(i + 1); vals[1] += fDataHist->GetBinError(i + 1) * fDataHist->GetBinError(i + 1) * - fDataHist->GetXaxis()->GetBinWidth(i + 1) * - fDataHist->GetXaxis()->GetBinWidth(i + 1); + fDataHist->GetXaxis()->GetBinWidth(i + 1) * + fDataHist->GetXaxis()->GetBinWidth(i + 1); } } // If not diag Get the total error from the covariance if (!fIsDiag and !fIsRawEvents and getDT and fFullCovar) { vals[1] = 0.0; for (int i = 0; i < fDataHist->GetNbinsX(); i++) { for (int j = 0; j < fDataHist->GetNbinsX(); j++) { vals[1] += (*fFullCovar)(i, j); } } vals[1] = sqrt(vals[1]) * 1E-38; } return vals; } /* Write Functions */ // Save all the histograms at once //******************************************************************** void Measurement1D::Write(std::string drawOpt) { //******************************************************************** // If null pointer return if (!fMCHist and !fDataHist) { ERR(WRN) << fName << "Incomplete histogram set!" << std::endl; return; } // FitPar::Config().out->cd(); // Get Draw Options drawOpt = FitPar::Config().GetParS("drawopts"); bool drawData = (drawOpt.find("DATA") != std::string::npos); bool drawNormal = (drawOpt.find("MC") != std::string::npos); bool drawEvents = (drawOpt.find("EVT") != std::string::npos); bool drawFine = (drawOpt.find("FINE") != std::string::npos); bool drawRatio = (drawOpt.find("RATIO") != std::string::npos); bool drawModes = (drawOpt.find("MODES") != std::string::npos); bool drawShape = (drawOpt.find("SHAPE") != std::string::npos); // bool residual = (drawOpt.find("RESIDUAL") != std::string::npos); // bool drawMatrix = (drawOpt.find("MATRIX") != std::string::npos); bool drawXSec = (drawOpt.find("XSEC") != std::string::npos); bool drawFlux = (drawOpt.find("FLUX") != std::string::npos); bool drawMask = (drawOpt.find("MASK") != std::string::npos); bool drawCov = (drawOpt.find("COV") != std::string::npos); bool drawInvCov = (drawOpt.find("INVCOV") != std::string::npos); bool drawDecomp = (drawOpt.find("DECOMP") != std::string::npos); bool drawCanvPDG = (drawOpt.find("CANVPDG") != std::string::npos); bool drawCanvMC = (drawOpt.find("CANVMC") != std::string::npos); bool drawWeighted = (drawOpt.find("WGHT") != std::string::npos); - - if (FitPar::Config().GetParB("EventManager")){ + if (FitPar::Config().GetParB("EventManager")) { drawFlux = false; drawXSec = false; drawEvents = false; } // Save standard plots if (drawData) this->GetDataList().at(0)->Write(); if (drawNormal) this->GetMCList().at(0)->Write(); // Save only mc and data if splines if (fEventType == 4 or fEventType == 3) { return; } // Draw Extra plots if (drawFine) this->GetFineList().at(0)->Write(); if (fIsMask and drawMask) fMaskHist->Write((fName + "_MSK").c_str()); //< save mask - if (drawFlux and fFluxHist) fFluxHist->Write(); - if (drawXSec and fXSecHist) fXSecHist->Write(); - if (drawEvents and fEventHist) fEventHist->Write(); + if (drawFlux and GetFluxHistogram()) + GetFluxHistogram()->Write(); + if (drawXSec and GetXSecHistogram()) + GetXSecHistogram()->Write(); + if (drawEvents and GetEventHistogram()) + GetEventHistogram()->Write(); if (fIsMask and drawMask and fMaskHist) { fMaskHist->Write((fName + "_MSK").c_str()); //< save mask } // Save neut stack if (drawModes) { // LOG(SAM) << "Writing MC Hist PDG" << std::endl; THStack combo_fMCHist_PDG = PlotUtils::GetNeutModeStack( (fName + "_MC_PDG").c_str(), (TH1**)fMCHist_PDG, 0); combo_fMCHist_PDG.Write(); } if (fIsMask && drawMask && fMaskHist) { fMaskHist->Write((this->fName + "_MSK").c_str()); //< save mask } // Save Matrix plots if (!fIsRawEvents && !fIsDiag && fFullCovar) { if (drawCov && fFullCovar) { TH2D cov = TH2D((*this->fFullCovar)); cov.SetNameTitle((this->fName + "_cov").c_str(), - (this->fName + "_cov;Bins; Bins;").c_str()); + (this->fName + "_cov;Bins; Bins;").c_str()); cov.Write(); } - if (!drawInvCov && !covar){ + if (!drawInvCov && !covar) { std::cout << "Missing invert! " << std::endl; } if (drawInvCov && covar) { TH2D covinv = TH2D((*this->covar)); covinv.SetNameTitle((fName + "_covinv").c_str(), - (fName + "_covinv;Bins; Bins;").c_str()); + (fName + "_covinv;Bins; Bins;").c_str()); covinv.Write(); } if (drawDecomp and fDecomp) { TH2D covdec = TH2D((*fDecomp)); covdec.SetNameTitle((fName + "_covdec").c_str(), - (fName + "_covdec;Bins; Bins;").c_str()); + (fName + "_covdec;Bins; Bins;").c_str()); covdec.Write(); } } // Save ratio plots if required if (drawRatio) { // Needed for error bars for (int i = 0; i < fMCHist->GetNbinsX() * fMCHist->GetNbinsY(); i++) fMCHist->SetBinError(i + 1, 0.0); fDataHist->GetSumw2(); fMCHist->GetSumw2(); // Create Ratio Histograms TH1D* dataRatio = (TH1D*)fDataHist->Clone((fName + "_data_RATIO").c_str()); TH1D* mcRatio = (TH1D*)fMCHist->Clone((fName + "_MC_RATIO").c_str()); mcRatio->Divide(fMCHist); dataRatio->Divide(fMCHist); // Cancel bin errors on MC for (int i = 0; i < mcRatio->GetNbinsX(); i++) mcRatio->SetBinError( i + 1, fMCHist->GetBinError(i + 1) / fMCHist->GetBinContent(i + 1)); mcRatio->SetMinimum(0); mcRatio->SetMaximum(2); dataRatio->SetMinimum(0); dataRatio->SetMaximum(2); mcRatio->Write(); dataRatio->Write(); delete mcRatio; delete dataRatio; } // Save Shape Plots if required if (drawShape) { // Create Shape Histogram TH1D* mcShape = (TH1D*)fMCHist->Clone((fName + "_MC_SHAPE").c_str()); double shapeScale = 1.0; - if (fIsRawEvents){ + if (fIsRawEvents) { shapeScale = fDataHist->Integral() / fMCHist->Integral(); } else { shapeScale = fDataHist->Integral("width") / fMCHist->Integral("width"); } - + mcShape->Scale(shapeScale); std::stringstream ss; ss << shapeScale; mcShape->SetTitle(ss.str().c_str()); mcShape->SetLineWidth(3); mcShape->SetLineStyle(7); // dashes mcShape->Write(); // Save shape ratios if (drawRatio) { // Needed for error bars mcShape->GetSumw2(); // Create shape ratio histograms TH1D* mcShapeRatio = - (TH1D*)mcShape->Clone((fName + "_MC_SHAPE_RATIO").c_str()); + (TH1D*)mcShape->Clone((fName + "_MC_SHAPE_RATIO").c_str()); TH1D* dataShapeRatio = - (TH1D*)fDataHist->Clone((fName + "_data_SHAPE_RATIO").c_str()); + (TH1D*)fDataHist->Clone((fName + "_data_SHAPE_RATIO").c_str()); // Divide the histograms mcShapeRatio->Divide(mcShape); dataShapeRatio->Divide(mcShape); // Colour the shape ratio plots mcShapeRatio->SetLineWidth(3); mcShapeRatio->SetLineStyle(7); // dashes mcShapeRatio->Write(); dataShapeRatio->Write(); delete mcShapeRatio; delete dataShapeRatio; } delete mcShape; } // Make a pretty PDG Canvas if (drawCanvPDG) { TCanvas* c1 = new TCanvas((fName + "_PDG_CANV").c_str(), - (fName + "_PDG_CANV").c_str(), 800, 600); + (fName + "_PDG_CANV").c_str(), 800, 600); fDataHist->Draw("E1"); fMCHist->Draw("HIST SAME"); THStack combo_fMCHist_PDG = PlotUtils::GetNeutModeStack( (fName + "_MC_PDG").c_str(), (TH1**)fMCHist_PDG, 0); combo_fMCHist_PDG.Draw("HIST SAME"); TLegend leg = - PlotUtils::GenerateStackLegend(combo_fMCHist_PDG, 0.6, 0.6, 0.9, 0.9); + PlotUtils::GenerateStackLegend(combo_fMCHist_PDG, 0.6, 0.6, 0.9, 0.9); fDataHist->Draw("E1 SAME"); // leg.Draw("SAME"); c1->Write(); delete c1; } if (drawCanvMC) { TCanvas* c1 = new TCanvas((fName + "_MC_CANV").c_str(), - (fName + "_MC_CANV").c_str(), 800, 600); + (fName + "_MC_CANV").c_str(), 800, 600); c1->cd(); fDataHist->Draw("E1"); fMCHist->Draw("SAME HIST"); TH1D* mcShape = (TH1D*)fMCHist->Clone((fName + "_MC_SHAPE").c_str()); double shapeScale = - fDataHist->Integral("width") / fMCHist->Integral("width"); + fDataHist->Integral("width") / fMCHist->Integral("width"); mcShape->Scale(shapeScale); mcShape->SetLineStyle(7); mcShape->Draw("SAME HIST"); TLegend* leg = new TLegend(0.6, 0.6, 0.9, 0.9); leg->AddEntry(fDataHist, (fName + " Data").c_str(), "ep"); leg->AddEntry(fMCHist, (fName + " MC").c_str(), "l"); leg->AddEntry(mcShape, (fName + " Shape").c_str(), "l"); leg->Draw("SAME"); c1->Write(); delete c1; } if (drawWeighted) { fMCWeighted->Write(); } // Returning LOG(SAM) << "Written Histograms: " << fName << std::endl; return; }; // ******************************************** // Returns the NEUT mode stack THStack Measurement1D::GetModeStack() { // ******************************************** THStack combo_hist = PlotUtils::GetNeutModeStack((fName + "_MC_PDG").c_str(), - (TH1**)fMCHist_PDG, 0); + (TH1**)fMCHist_PDG, 0); return combo_hist; } diff --git a/src/FitBase/Measurement1D.h b/src/FitBase/Measurement1D.h index 28aa62c..9e7b8b5 100644 --- a/src/FitBase/Measurement1D.h +++ b/src/FitBase/Measurement1D.h @@ -1,260 +1,269 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #ifndef MEASUREMENT_1D_H_SEEN #define MEASUREMENT_1D_H_SEEN /*! * \addtogroup FitBase * @{ */ #include <math.h> #include <stdlib.h> #include <deque> #include <iomanip> #include <iostream> #include <numeric> #include <sstream> #include <string> // ROOT includes #include <TArrayF.h> #include <TCanvas.h> #include <TCut.h> #include <TDecompChol.h> #include <TDecompSVD.h> #include <TGraph.h> #include <TGraphErrors.h> #include <TH1D.h> #include <TH2D.h> #include <TMatrixDSym.h> #include <TROOT.h> #include <TSystem.h> // External data fit includes #include "FitEvent.h" #include "FitParameters.h" #include "FitUtils.h" #include "MeasurementBase.h" #include "PlotUtils.h" #include "StatUtils.h" #include "InputHandler.h" #include "SignalDef.h" //******************************************************************** //! 1D Measurement base class. Histogram handling is done in this base layer. class Measurement1D : public MeasurementBase { //******************************************************************** public: /* Constructor/Deconstuctor */ //! Default Constructor Measurement1D(void); //! Default destructor virtual ~Measurement1D(void); //! Initialise values to NULL void Init(void); //! Setup the measurement with input values. This automatically handles //! parsing the fit type and data. virtual void SetupMeasurement(std::string input, std::string type, FitWeight* rw, std::string fkdt); //! Setup the default MC histograms from the currently set fDataHist. virtual void SetupDefaultHist(void); //! Set fit options by parsing type virtual void SetFitOptions(std::string opt); //! Setup the data values from a text file virtual void SetDataValues(std::string dataFile); //! Setup the data values by reading in a histogram from a TFile virtual void SetDataFromFile(std::string inhistfile, std::string histname); //! Setup the data by reading in a histogram from the database. virtual void SetDataFromDatabase(std::string inhistfile, std::string histname); //! Read the covariance matrix from a root file (automatically grabs plot //! "covar") virtual void SetCovarMatrix(std::string covarFile); - //! Read the correlation matrix from a text file given the covar size and convert to covariance matrix - virtual void SetCovarMatrixFromText(std::string covarFile, int dim, double scale = 1.0); + //! Read the correlation matrix from a text file given the covar size and + //! convert to covariance matrix + virtual void SetCovarMatrixFromText(std::string covarFile, int dim, + double scale = 1.0); // //! Read the covariance matrix from a text file given the covar size virtual void SetCovarMatrixFromCorrText(std::string covarFile, int dim); //! Set the covariance from a custom root file - virtual void SetCovarFromDataFile(std::string covarFile, std::string covName); + //! FullUnits refers to if the covariance has "real" unscaled units, e.g. + //! 1E-76 + //! If that is the case we need to scale it to make sure the extracted chi2 is + //! correct + virtual void SetCovarFromDataFile(std::string covarFile, std::string covName, + bool FullUnits = false); //! Set the smearing matrix from a text file given the size of the matrix virtual void SetSmearingMatrix(std::string smearfile, int truedim, int recodim); //! Set the bin mask from a text file virtual void SetBinMask(std::string maskFile); - //! Set the flux histogram from a ROOT file - virtual void SetFluxHistogram(std::string fluxFile, int minE, int maxE, - double fluxNorm); + // //! Set the flux histogram from a ROOT file + // virtual void SetFluxHistogram(std::string fluxFile, int minE, int maxE, + // double fluxNorm); - //! Get the total integrated flux between this samples energy range - virtual double TotalIntegratedFlux(std::string intOpt = "width", - double low = -9999.9, - double high = -9999.9); + // //! Get the total integrated flux between this samples energy range + // virtual double TotalIntegratedFlux(std::string intOpt = "width", + // double low = -9999.9, + // double high = -9999.9); //! Reset histograms to zero virtual void ResetAll(void); //! Fill histograms using fXVar,Weight virtual void FillHistograms(void); //! Scale to XSec Prediction virtual void ScaleEvents(void); //! Apply normalisation scale after reconfigure virtual void ApplyNormScale(double norm); //! Apply smearing matrix to fMCHist virtual void ApplySmearingMatrix(void); //! Get the current Number of degrees of freedom accounting for bin masking. virtual int GetNDOF(void); //! Get Likelihood of iteration virtual double GetLikelihood(void); //! Set the fake data values from either a file, or MC using fakeOption="MC" virtual void SetFakeDataValues(std::string fakeOption); //! Reset the fake data back to original fake data (Reset to before //! ThrowCovariance was called) virtual void ResetFakeData(void); //! Reset the fake data back to the true original dataset for this sample virtual void ResetData(void); //! Generate fake data by throwing the current fDataHist using the covariance. //! Can be used on fake MC data or just the original dataset. virtual void ThrowCovariance(void); // Get MC Histogram Stack virtual THStack GetModeStack(void); /// Get Histogram Functions inline TH1D* GetMCHistogram(void) { return fMCHist; }; inline TH1D* GetDataHistogram(void) { return fDataHist; }; virtual std::vector<TH1*> GetMCList(void); virtual std::vector<TH1*> GetDataList(void); inline virtual std::vector<TH1*> GetMaskList(void) { return std::vector<TH1*>(1, fMaskHist); }; inline virtual std::vector<TH1*> GetFineList(void) { return std::vector<TH1*>(1, fMCFine); }; //! Get the bin contents and errors from fMCHist virtual void GetBinContents(std::vector<double>& cont, std::vector<double>& err); //! Get the covariance matrix as a pretty plot inline virtual TH2D GetCovarMatrix(void) { return TH2D(*covar); }; //! Return the integrated XSec for this sample, options define whether data or //! MC is returned. virtual std::vector<double> GetXSec(std::string opt); //! Save the current state to the current TFile directory virtual void Write(std::string drawOpt); //! array of histograms to handle fMCHist for each interaction channel. // TODO (P.Stowell) Figure out why I put mcHist as unprotected! :S TH1D* fMCHist_PDG[61]; protected: // data histograms TH1D* fDataHist; //!< default data histogram TH1D* fDataOrig; //!< histogram to store original data before throws. TH1D* fDataTrue; //!< histogram to store true dataset // Fake Data Flag bool fIsFakeData; //!< Flag: whether the current data is actually fake from MC std::string fakeDataFile; //!< Input fake data file // The histogram into which the measurement will be filled TH1D* fMCHist; //!< default MC Histogram used in the chi2 fits TH1D* fMCFine; //!< finely binned MC histogram TH1D* fMCStat; //!< histogram with unweighted events to properly calculate - //!statistical error on MC + //! statistical error on MC TH1D* fMCWeighted; //!< Weighted histogram before xsec scaling TH1I* fMaskHist; //!< Mask histogram for neglecting specific bins std::string fPlotTitles; //!< Plot title x and y for the histograms // The covariance matrix and its fDecomposition TMatrixDSym* covar; //!< Inverted Covariance TMatrixDSym* fFullCovar; //!< Full Covariance TMatrixDSym* fDecomp; //!< Decomposed Covariance TMatrixDSym* fCorrel; //!< Correlation Matrix TMatrixD* fSmearMatrix; //!< Smearing matrix (note, this is not symmetric, - //!and also in general not square) + //! and also in general not square) double fCovDet; //!< Determinant of the covariance double fNormError; //!< Sample norm error std::string fFitType; // Arrays for data entries Double_t* fXBins; //!< xBin edges Double_t* fDataValues; //!< data bin contents Double_t* fDataErrors; //!< data bin errors Int_t fNDataPointsX; //!< number of data points // Fit specific flags bool fIsShape; //!< Flag: Perform Shape-only fit bool fIsFree; //!< Flag: Perform normalisation free fit bool fIsDiag; //!< Flag: only include uncorrelated diagonal errors bool fIsMask; //!< Flag: Apply bin masking bool fIsRawEvents; //!< Flag: Are bin contents just event rates bool fIsEnu1D; //!< Flag: Perform Flux Unfolded Scaling bool fIsChi2SVD; //!< Flag: Use alternative Chi2 SVD Method (Do not use) bool fAddNormPen; //!< Flag: Add a normalisation penalty term to the chi2. bool fIsFix; //!< Flag for keeping norm fixed bool fIsFull; //!< Flag for using full covariaince bool fIsDifXSec; //!< Flag for creating a dif xsec bool fIsChi2; //!< Flag for using Chi2 over LL methods std::string fAllowedTypes; //!< Fit Types Possible std::string fDefaultTypes; //!< Starting Default Fit Types + + size_t NSignal; }; /*! @} */ #endif diff --git a/src/FitBase/Measurement2D.cxx b/src/FitBase/Measurement2D.cxx index 75c62ef..4d349b4 100644 --- a/src/FitBase/Measurement2D.cxx +++ b/src/FitBase/Measurement2D.cxx @@ -1,1290 +1,1332 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "Measurement2D.h" #include "TDecompChol.h" //******************************************************************** Measurement2D::Measurement2D() { -//******************************************************************** + //******************************************************************** covar = NULL; fDecomp = NULL; fFullCovar = NULL; fMCHist = NULL; fMCFine = NULL; fDataHist = NULL; fMCHist_X = NULL; fMCHist_Y = NULL; fDataHist_X = NULL; fDataHist_Y = NULL; fMaskHist = NULL; fMapHist = NULL; fDataOrig = NULL; fDataTrue = NULL; fMCWeighted = NULL; - + fDefaultTypes = "FIX/FULL/CHI2"; - fAllowedTypes = "FIX,FREE,SHAPE/FULL,DIAG/CHI2/NORM/ENUCORR/Q2CORR/ENU1D/FITPROJX/FITPROJY"; + fAllowedTypes = + "FIX,FREE,SHAPE/FULL,DIAG/CHI2/NORM/ENUCORR/Q2CORR/ENU1D/FITPROJX/" + "FITPROJY"; - fIsFix = false; + fIsFix = false; fIsShape = false; - fIsFree = false; + fIsFree = false; - fIsDiag = false; - fIsFull = false; + fIsDiag = false; + fIsFull = false; fAddNormPen = false; fIsMask = false; fIsChi2SVD = false; fIsRawEvents = false; fIsDifXSec = false; fIsEnu = false; - }; //******************************************************************** -Measurement2D:: ~Measurement2D() { -//******************************************************************** +Measurement2D::~Measurement2D(){ + //******************************************************************** }; /* Setup Functions */ //******************************************************************** -void Measurement2D::SetupMeasurement(std::string inputfile, std::string type, FitWeight *rw, std::string fkdt){ -//******************************************************************** +void Measurement2D::SetupMeasurement(std::string inputfile, std::string type, + FitWeight* rw, std::string fkdt) { + //******************************************************************** // Check if name contains Evt, indicating that it is a raw number of events // measurements and should thus be treated as once fIsRawEvents = false; if ((fName.find("Evt") != std::string::npos) && fIsRawEvents == false) { fIsRawEvents = true; LOG(SAM) << "Found event rate measurement but fIsRawEvents == false!" << std::endl; LOG(SAM) << "Overriding this and setting fIsRawEvents == true!" << std::endl; } fIsEnu = false; - if ((fName.find("XSec") != std::string::npos) && (fName.find("Enu") != std::string::npos)) { - + if ((fName.find("XSec") != std::string::npos) && + (fName.find("Enu") != std::string::npos)) { fIsEnu = true; LOG(SAM) << "::" << fName << "::" << std::endl; LOG(SAM) << "Found XSec Enu measurement, applying flux integrated scaling, " "not flux averaged!" << std::endl; - if (FitPar::Config().GetParB("EventManager")){ - ERR(FTL) << "Enu Measurements do not yet work with the Event Manager!" <<std::endl; - ERR(FTL) << "If you want decent flux unfolded results please run in series mode (-q EventManager=0)" << std::endl; + if (FitPar::Config().GetParB("EventManager")) { + ERR(FTL) << "Enu Measurements do not yet work with the Event Manager!" + << std::endl; + ERR(FTL) << "If you want decent flux unfolded results please run in " + "series mode (-q EventManager=0)" + << std::endl; sleep(2); } } if (fIsEnu && fIsRawEvents) { LOG(SAM) << "Found 1D Enu XSec distribution AND fIsRawEvents, is this " "really correct?!" << std::endl; LOG(SAM) << "Check experiment constructor for " << fName << " and correct this!" << std::endl; LOG(SAM) << "I live in " << __FILE__ << ":" << __LINE__ << std::endl; exit(-1); } // Reset everything to NULL fRW = rw; // Setting up 2D Inputs this->SetupInputs(inputfile); - + // Set Default Options - SetFitOptions( fDefaultTypes ); + SetFitOptions(fDefaultTypes); // Set Passed Options SetFitOptions(type); - } //******************************************************************** -void Measurement2D::SetupDefaultHist(){ -//******************************************************************** +void Measurement2D::SetupDefaultHist() { + //******************************************************************** // Setup fMCHist - fMCHist = (TH2D*) fDataHist->Clone(); - fMCHist->SetNameTitle( (fName + "_MC").c_str(), (fName + "_MC" + fPlotTitles).c_str() ); + fMCHist = (TH2D*)fDataHist->Clone(); + fMCHist->SetNameTitle((fName + "_MC").c_str(), + (fName + "_MC" + fPlotTitles).c_str()); // Setup fMCFine Int_t nBinsX = fMCHist->GetNbinsX(); Int_t nBinsY = fMCHist->GetNbinsY(); - fMCFine = new TH2D( (fName + "_MC_FINE").c_str(), (fName + "_MC_FINE" + fPlotTitles).c_str(), - nBinsX*3, fMCHist->GetXaxis()->GetBinLowEdge(1), fMCHist->GetXaxis()->GetBinLowEdge(nBinsX+1), - nBinsY*3, fMCHist->GetYaxis()->GetBinLowEdge(1), fMCHist->GetYaxis()->GetBinLowEdge(nBinsY+1)); + fMCFine = new TH2D((fName + "_MC_FINE").c_str(), + (fName + "_MC_FINE" + fPlotTitles).c_str(), nBinsX * 3, + fMCHist->GetXaxis()->GetBinLowEdge(1), + fMCHist->GetXaxis()->GetBinLowEdge(nBinsX + 1), nBinsY * 3, + fMCHist->GetYaxis()->GetBinLowEdge(1), + fMCHist->GetYaxis()->GetBinLowEdge(nBinsY + 1)); // Setup the NEUT Mode Array - PlotUtils::CreateNeutModeArray(fMCHist,(TH1**)fMCHist_PDG); + PlotUtils::CreateNeutModeArray(fMCHist, (TH1**)fMCHist_PDG); // Setup bin masks using sample name - if (fIsMask){ - std::string maskloc = FitPar::Config().GetParDIR( fName + ".mask"); - if (maskloc.empty()){ + if (fIsMask) { + std::string maskloc = FitPar::Config().GetParDIR(fName + ".mask"); + if (maskloc.empty()) { maskloc = FitPar::GetDataBase() + "/masks/" + fName + ".mask"; } SetBinMask(maskloc); } - + return; } - -//******************************************************************** -void Measurement2D::SetFitOptions(std::string opt){ //******************************************************************** +void Measurement2D::SetFitOptions(std::string opt) { + //******************************************************************** // Do nothing if set DEFAULT if (opt == "DEFAULT") return; - + // CHECK Conflicting Fit Options - std::vector<std::string> fit_option_allow = GeneralUtils::ParseToStr(fAllowedTypes, "/"); - for (UInt_t i = 0; i < fit_option_allow.size(); i++){ - std::vector<std::string> fit_option_section = GeneralUtils::ParseToStr(fit_option_allow.at(i), ","); + std::vector<std::string> fit_option_allow = + GeneralUtils::ParseToStr(fAllowedTypes, "/"); + for (UInt_t i = 0; i < fit_option_allow.size(); i++) { + std::vector<std::string> fit_option_section = + GeneralUtils::ParseToStr(fit_option_allow.at(i), ","); bool found_option = false; - for (UInt_t j = 0; j < fit_option_section.size(); j++){ + for (UInt_t j = 0; j < fit_option_section.size(); j++) { std::string av_opt = fit_option_section.at(j); if (!found_option and opt.find(av_opt) != std::string::npos) { - found_option = true; - - } else if (found_option and opt.find(av_opt) != std::string::npos){ - - ERR(FTL) << "ERROR: Conflicting fit options provided: "<<opt<<std::endl; - ERR(FTL) << "Conflicting group = "<<fit_option_section.at(i)<<std::endl; - ERR(FTL) << "You should only supply one of these options in card file."<<std::endl; - exit(-1); - + found_option = true; + + } else if (found_option and opt.find(av_opt) != std::string::npos) { + ERR(FTL) << "ERROR: Conflicting fit options provided: " << opt + << std::endl; + ERR(FTL) << "Conflicting group = " << fit_option_section.at(i) + << std::endl; + ERR(FTL) << "You should only supply one of these options in card file." + << std::endl; + exit(-1); } } } // Check all options are allowed - std::vector<std::string> fit_options_input = GeneralUtils::ParseToStr(opt,"/"); - for (UInt_t i = 0; i < fit_options_input.size(); i++){ - if (fAllowedTypes.find(fit_options_input.at(i)) == std::string::npos){ - - ERR(FTL) <<"ERROR: Fit Option '"<<fit_options_input.at(i)<<"' Provided is not allowed for this measurement."<<std::endl; - ERR(FTL) <<"Fit Options should be provided as a '/' seperated list (e.g. FREE/DIAG/NORM)" << std::endl; - ERR(FTL) <<"Available options for "<<fName<<" are '"<< fAllowedTypes <<"'"<<std::endl; + std::vector<std::string> fit_options_input = + GeneralUtils::ParseToStr(opt, "/"); + for (UInt_t i = 0; i < fit_options_input.size(); i++) { + if (fAllowedTypes.find(fit_options_input.at(i)) == std::string::npos) { + ERR(FTL) << "ERROR: Fit Option '" << fit_options_input.at(i) + << "' Provided is not allowed for this measurement." + << std::endl; + ERR(FTL) << "Fit Options should be provided as a '/' seperated list " + "(e.g. FREE/DIAG/NORM)" + << std::endl; + ERR(FTL) << "Available options for " << fName << " are '" << fAllowedTypes + << "'" << std::endl; exit(-1); } } - // Set TYPE fFitType = opt; // FIX,SHAPE,FREE - if (opt.find("FIX") != std::string::npos){ + if (opt.find("FIX") != std::string::npos) { fIsFree = fIsShape = false; - fIsFix = true; - } else if (opt.find("SHAPE") != std::string::npos){ + fIsFix = true; + } else if (opt.find("SHAPE") != std::string::npos) { fIsFree = fIsFix = false; fIsShape = true; - } else if (opt.find("FREE") != std::string::npos){ + } else if (opt.find("FREE") != std::string::npos) { fIsFix = fIsShape = false; fIsFree = true; } // DIAG,FULL (or default to full) - if (opt.find("DIAG") != std::string::npos){ + if (opt.find("DIAG") != std::string::npos) { fIsDiag = true; fIsFull = false; - } else if (opt.find("FULL") != std::string::npos){ + } else if (opt.find("FULL") != std::string::npos) { fIsDiag = false; fIsFull = true; } // CHI2/LL (OTHERS?) - if (opt.find("LOG") != std::string::npos) fIsChi2 = false; - else fIsChi2 = true; + if (opt.find("LOG") != std::string::npos) + fIsChi2 = false; + else + fIsChi2 = true; // EXTRAS - if (opt.find("RAW") != std::string::npos) fIsRawEvents = true; - if (opt.find("DIF") != std::string::npos) fIsDifXSec = true; - if (opt.find("ENU1D") != std::string::npos) fIsEnu = true; - if (opt.find("NORM") != std::string::npos) fAddNormPen = true; - if (opt.find("MASK") != std::string::npos) fIsMask = true; + if (opt.find("RAW") != std::string::npos) fIsRawEvents = true; + if (opt.find("DIF") != std::string::npos) fIsDifXSec = true; + if (opt.find("ENU1D") != std::string::npos) fIsEnu = true; + if (opt.find("NORM") != std::string::npos) fAddNormPen = true; + if (opt.find("MASK") != std::string::npos) fIsMask = true; - fIsProjFitX = (opt.find("FITPROJX") != std::string::npos); - fIsProjFitY = (opt.find("FITPROJY") != std::string::npos); + fIsProjFitX = (opt.find("FITPROJX") != std::string::npos); + fIsProjFitY = (opt.find("FITPROJY") != std::string::npos); return; }; - //******************************************************************** void Measurement2D::SetDataValues(std::string dataFile, std::string TH2Dname) { -//******************************************************************** + //******************************************************************** if (dataFile.find(".root") == std::string::npos) { - ERR(FTL) << "Error! " << dataFile << " is not a .root file" << std::endl; - ERR(FTL) << "Currently only .root file reading is supported (MiniBooNE CC1pi+ 2D), but implementing .txt should be dirt easy" << std::endl; + ERR(FTL) << "Currently only .root file reading is supported (MiniBooNE " + "CC1pi+ 2D), but implementing .txt should be dirt easy" + << std::endl; ERR(FTL) << "See me at " << __FILE__ << ":" << __LINE__ << std::endl; exit(-1); } else { - - TFile *inFile = new TFile(dataFile.c_str(), "READ"); + TFile* inFile = new TFile(dataFile.c_str(), "READ"); fDataHist = (TH2D*)(inFile->Get(TH2Dname.c_str())->Clone()); fDataHist->SetDirectory(0); - fDataHist->SetNameTitle((fName+"_data").c_str(), (fName+"_MC"+fPlotTitles).c_str()); + fDataHist->SetNameTitle((fName + "_data").c_str(), + (fName + "_MC" + fPlotTitles).c_str()); delete inFile; - } return; } - -//******************************************************************** -void Measurement2D::SetDataValues(std::string dataFile, double dataNorm, std::string errorFile, double errorNorm) { //******************************************************************** +void Measurement2D::SetDataValues(std::string dataFile, double dataNorm, + std::string errorFile, double errorNorm) { + //******************************************************************** // Make a counter to track the line number int yBin = 0; std::string line; - std::ifstream data(dataFile.c_str(),ifstream::in); + std::ifstream data(dataFile.c_str(), ifstream::in); - fDataHist = new TH2D((fName+"_data").c_str(), (fName+fPlotTitles).c_str(), fNDataPointsX-1, fXBins, fNDataPointsY-1, fYBins); + fDataHist = new TH2D((fName + "_data").c_str(), (fName + fPlotTitles).c_str(), + fNDataPointsX - 1, fXBins, fNDataPointsY - 1, fYBins); - if(data.is_open()) LOG(SAM) << "Reading data from: " << dataFile.c_str() << std::endl; + if (data.is_open()) + LOG(SAM) << "Reading data from: " << dataFile.c_str() << std::endl; - while(std::getline(data >> std::ws, line, '\n')){ + while (std::getline(data >> std::ws, line, '\n')) { int xBin = 0; // Loop over entries and insert them into the histogram std::vector<double> entries = GeneralUtils::ParseToDbl(line, " "); for (std::vector<double>::iterator iter = entries.begin(); - iter != entries.end(); iter++){ - - fDataHist->SetBinContent(xBin+1, yBin+1, (*iter)*dataNorm); + iter != entries.end(); iter++) { + fDataHist->SetBinContent(xBin + 1, yBin + 1, (*iter) * dataNorm); xBin++; } yBin++; } yBin = 0; - std::ifstream error(errorFile.c_str(),ifstream::in); + std::ifstream error(errorFile.c_str(), ifstream::in); - if(error.is_open()) LOG(SAM) << "Reading errors from: " << errorFile.c_str() << std::endl; + if (error.is_open()) + LOG(SAM) << "Reading errors from: " << errorFile.c_str() << std::endl; - while(std::getline(error >> std::ws, line, '\n')){ + while (std::getline(error >> std::ws, line, '\n')) { int xBin = 0; // Loop over entries and insert them into the histogram std::vector<double> entries = GeneralUtils::ParseToDbl(line, " "); for (std::vector<double>::iterator iter = entries.begin(); - iter != entries.end(); iter++){ - fDataHist->SetBinError(xBin+1, yBin+1, (*iter)*errorNorm); + iter != entries.end(); iter++) { + fDataHist->SetBinError(xBin + 1, yBin + 1, (*iter) * errorNorm); xBin++; } yBin++; } return; - }; - -//******************************************************************** -void Measurement2D::SetDataValuesFromText(std::string dataFile, double dataNorm) { //******************************************************************** +void Measurement2D::SetDataValuesFromText(std::string dataFile, + double dataNorm) { + //******************************************************************** - fDataHist = new TH2D((fName+"_data").c_str(), (fName+fPlotTitles).c_str(), - fNDataPointsX-1, fXBins, fNDataPointsY-1, fYBins); + fDataHist = new TH2D((fName + "_data").c_str(), (fName + fPlotTitles).c_str(), + fNDataPointsX - 1, fXBins, fNDataPointsY - 1, fYBins); - LOG(SAM) <<"Reading data from: "<<dataFile<<std::endl; + LOG(SAM) << "Reading data from: " << dataFile << std::endl; PlotUtils::Set2DHistFromText(dataFile, fDataHist, dataNorm, true); return; }; - -//******************************************************************** -void Measurement2D::SetCovarMatrix(std::string covarFile){ //******************************************************************** +void Measurement2D::SetCovarMatrix(std::string covarFile) { + //******************************************************************** // Used to read a covariance matrix from a root file - TFile* tempFile = new TFile(covarFile.c_str(),"READ"); + TFile* tempFile = new TFile(covarFile.c_str(), "READ"); // Make plots that we want TH2D* covarPlot = new TH2D(); // TH2D* decmpPlot = new TH2D(); TH2D* covarInvPlot = new TH2D(); TH2D* fFullCovarPlot = new TH2D(); // Get covariance options for fake data studies std::string covName = ""; std::string covOption = FitPar::Config().GetParS("throw_covariance"); // Which matrix to get? if (fIsShape || fIsFree) covName = "shp_"; - if (fIsDiag) covName += "diag"; - else covName += "full"; + if (fIsDiag) + covName += "diag"; + else + covName += "full"; - covarPlot = (TH2D*) tempFile->Get((covName + "cov").c_str()); - covarInvPlot = (TH2D*) tempFile->Get((covName + "covinv").c_str()); + covarPlot = (TH2D*)tempFile->Get((covName + "cov").c_str()); + covarInvPlot = (TH2D*)tempFile->Get((covName + "covinv").c_str()); // Throw either the sub matrix or the full matrix - if (!covOption.compare("SUB")) fFullCovarPlot = (TH2D*) tempFile->Get((covName + "cov").c_str()); - else if (!covOption.compare("FULL")) fFullCovarPlot = (TH2D*) tempFile->Get("fullcov"); - else ERR(WRN)<<" Incorrect thrown_covariance option in parameters."<<std::endl; + if (!covOption.compare("SUB")) + fFullCovarPlot = (TH2D*)tempFile->Get((covName + "cov").c_str()); + else if (!covOption.compare("FULL")) + fFullCovarPlot = (TH2D*)tempFile->Get("fullcov"); + else + ERR(WRN) << " Incorrect thrown_covariance option in parameters." + << std::endl; // Bin masking? - int dim = int(fDataHist->GetNbinsX());//-this->masked->Integral()); + int dim = int(fDataHist->GetNbinsX()); //-this->masked->Integral()); int covdim = int(fDataHist->GetNbinsX()); // Make new covars this->covar = new TMatrixDSym(dim); fFullCovar = new TMatrixDSym(dim); fDecomp = new TMatrixDSym(dim); // Full covariance values - int row,column = 0; + int row, column = 0; row = 0; column = 0; - for (Int_t i = 0; i < covdim; i++){ - + for (Int_t i = 0; i < covdim; i++) { // masking can be dodgy // if (this->masked->GetBinContent(i+1) > 0) continue; - for (Int_t j = 0; j < covdim; j++){ - + for (Int_t j = 0; j < covdim; j++) { // if (this->masked->GetBinContent(j+1) > 0) continue; - (*this->covar)(row, column) = covarPlot->GetBinContent(i+1,j+1); - (*fFullCovar)(row, column) = fFullCovarPlot->GetBinContent(i+1,j+1); + (*this->covar)(row, column) = covarPlot->GetBinContent(i + 1, j + 1); + (*fFullCovar)(row, column) = fFullCovarPlot->GetBinContent(i + 1, j + 1); column++; } column = 0; row++; } // Set bin errors on data - if (!fIsDiag){ - for (Int_t i = 0; i < fDataHist->GetNbinsX(); i++){ - fDataHist->SetBinError(i+1, sqrt((covarPlot->GetBinContent(i+1,i+1)))*1E-38); + if (!fIsDiag) { + for (Int_t i = 0; i < fDataHist->GetNbinsX(); i++) { + fDataHist->SetBinError( + i + 1, sqrt((covarPlot->GetBinContent(i + 1, i + 1))) * 1E-38); } } TDecompSVD LU = TDecompSVD(*this->covar); - this->covar = new TMatrixDSym(dim, LU .Invert().GetMatrixArray(), ""); + this->covar = new TMatrixDSym(dim, LU.Invert().GetMatrixArray(), ""); tempFile->Close(); delete tempFile; return; }; - //******************************************************************** -void Measurement2D::SetCovarMatrixFromText(std::string covarFile, int dim){ +void Measurement2D::SetCovarMatrixFromText(std::string covarFile, int dim) { //******************************************************************** // Make a counter to track the line number int row = 0; std::string line; - std::ifstream covar(covarFile.c_str(),ifstream::in); + std::ifstream covar(covarFile.c_str(), ifstream::in); this->covar = new TMatrixDSym(dim); fFullCovar = new TMatrixDSym(dim); - if(covar.is_open()) LOG(SAM) << "Reading covariance matrix from file: " << covarFile << std::endl; + if (covar.is_open()) + LOG(SAM) << "Reading covariance matrix from file: " << covarFile + << std::endl; - while(std::getline(covar >> std::ws, line, '\n')){ + while (std::getline(covar >> std::ws, line, '\n')) { int column = 0; // Loop over entries and insert them into matrix - // Multiply by the errors to get the covariance, rather than the correlation matrix + // Multiply by the errors to get the covariance, rather than the correlation + // matrix std::vector<double> entries = GeneralUtils::ParseToDbl(line, " "); for (std::vector<double>::iterator iter = entries.begin(); - iter != entries.end(); iter++){ - - double val = (*iter)*fDataHist->GetBinError(row+1)*1E38*fDataHist->GetBinError(column+1)*1E38; + iter != entries.end(); iter++) { + double val = (*iter) * fDataHist->GetBinError(row + 1) * 1E38 * + fDataHist->GetBinError(column + 1) * 1E38; (*this->covar)(row, column) = val; (*fFullCovar)(row, column) = val; column++; } row++; } // Robust matrix inversion method TDecompSVD LU = TDecompSVD(*this->covar); - this->covar = new TMatrixDSym(dim, LU .Invert().GetMatrixArray(), ""); + this->covar = new TMatrixDSym(dim, LU.Invert().GetMatrixArray(), ""); return; }; - //******************************************************************** -void Measurement2D::SetCovarMatrixFromChol(std::string covarFile, int dim){ +void Measurement2D::SetCovarMatrixFromChol(std::string covarFile, int dim) { //******************************************************************** // Make a counter to track the line number int row = 0; std::string line; - std::ifstream covarread(covarFile.c_str(),ifstream::in); + std::ifstream covarread(covarFile.c_str(), ifstream::in); - TMatrixD* newcov = new TMatrixD(dim,dim); + TMatrixD* newcov = new TMatrixD(dim, dim); - if(covarread.is_open()) LOG(SAM) << "Reading covariance matrix from file: " << covarFile << std::endl; - while(std::getline(covarread >> std::ws, line, '\n')){ + if (covarread.is_open()) + LOG(SAM) << "Reading covariance matrix from file: " << covarFile + << std::endl; + while (std::getline(covarread >> std::ws, line, '\n')) { int column = 0; // Loop over entries and insert them into matrix - // Multiply by the errors to get the covariance, rather than the correlation matrix + // Multiply by the errors to get the covariance, rather than the correlation + // matrix std::vector<double> entries = GeneralUtils::ParseToDbl(line, " "); for (std::vector<double>::iterator iter = entries.begin(); - iter != entries.end(); iter++){ - + iter != entries.end(); iter++) { (*newcov)(row, column) = *iter; column++; } row++; } covarread.close(); // Form full covariance - TMatrixD* trans = (TMatrixD*) (newcov)->Clone(); + TMatrixD* trans = (TMatrixD*)(newcov)->Clone(); trans->T(); (*trans) *= (*newcov); fFullCovar = new TMatrixDSym(dim, trans->GetMatrixArray(), ""); delete newcov; delete trans; // Robust matrix inversion method TDecompChol LU = TDecompChol(*this->fFullCovar); - this->covar = new TMatrixDSym(dim, LU .Invert().GetMatrixArray(), ""); - + this->covar = new TMatrixDSym(dim, LU.Invert().GetMatrixArray(), ""); + return; }; // virtual void SetMaskValuesFromText(std::string dataFile); //******************************************************************** -void Measurement2D::SetMapValuesFromText(std::string dataFile){ -//******************************************************************** +void Measurement2D::SetMapValuesFromText(std::string dataFile) { + //******************************************************************** - fMapHist = new TH2I((fName+"_map").c_str(), (fName+fPlotTitles).c_str(), - fNDataPointsX-1, fXBins, fNDataPointsY-1, fYBins); + fMapHist = new TH2I((fName + "_map").c_str(), (fName + fPlotTitles).c_str(), + fNDataPointsX - 1, fXBins, fNDataPointsY - 1, fYBins); - LOG(SAM) <<"Reading map from: "<<dataFile<<std::endl; + LOG(SAM) << "Reading map from: " << dataFile << std::endl; PlotUtils::Set2DHistFromText(dataFile, fMapHist, 1.0); return; }; - -//******************************************************************** -void Measurement2D::SetBinMask(std::string maskFile){ //******************************************************************** +void Measurement2D::SetBinMask(std::string maskFile) { + //******************************************************************** -// Create a mask histogram. + // Create a mask histogram. int nbinsX = fDataHist->GetNbinsX(); int nbinsY = fDataHist->GetNbinsY(); - fMaskHist = new TH2I((fName+"_fMaskHist").c_str(),(fName+"_fMaskHist; Bin; Mask?") \ - .c_str(),nbinsX,0,nbinsX,nbinsY,0,nbinsY); + fMaskHist = new TH2I((fName + "_fMaskHist").c_str(), + (fName + "_fMaskHist; Bin; Mask?").c_str(), nbinsX, 0, + nbinsX, nbinsY, 0, nbinsY); // int row ,column= 0; std::string line; - std::ifstream mask(maskFile.c_str(),ifstream::in); + std::ifstream mask(maskFile.c_str(), ifstream::in); - if (mask.is_open()) LOG(SAM) <<"Reading bin mask from file: "<<maskFile <<std::endl; - else ERR(WRN) <<" Cannot find mask file."<<std::endl; + if (mask.is_open()) + LOG(SAM) << "Reading bin mask from file: " << maskFile << std::endl; + else + ERR(WRN) << " Cannot find mask file." << std::endl; - while(std::getline(mask >> std::ws, line, '\n')){ - + while (std::getline(mask >> std::ws, line, '\n')) { std::vector<int> entries = GeneralUtils::ParseToInt(line, " "); // Skip lines with poorly formatted lines if (entries.size() < 3) { - LOG(WRN) << "Measurement2D::SetBinMask(), couldn't parse line: " << line << std::endl; + LOG(WRN) << "Measurement2D::SetBinMask(), couldn't parse line: " << line + << std::endl; continue; } // The indices should be x, y, value fMaskHist->SetBinContent(entries[0], entries[1], entries[2]); } // Set masked data bins to zero PlotUtils::MaskBins(fDataHist, fMaskHist); return; } - - - - - /* XSec Functions */ -//******************************************************************** -void Measurement2D::SetFluxHistogram(std::string fluxFile, int minE, int maxE, double fluxNorm){ -//******************************************************************** - - // Note this expects the flux bins to be given in terms of MeV - // Used to read in the flux from a text file - LOG(SAM) << "Reading flux from file: " << fluxFile << std::endl; - - TGraph *f = new TGraph(fluxFile.c_str(),"%lg %lg"); +// //******************************************************************** +// void Measurement2D::SetFluxHistogram(std::string fluxFile, int minE, int +// maxE, double fluxNorm){ +// //******************************************************************** - fFluxHist = new TH1D((fName+"_flux").c_str(), (fName+";E_{#nu} (GeV)").c_str(), f->GetN()-1, minE, maxE); +// // Note this expects the flux bins to be given in terms of MeV +// // Used to read in the flux from a text file +// LOG(SAM) << "Reading flux from file: " << fluxFile << std::endl; - // Get graph points - Double_t *yVal = f->GetY(); +// TGraph *f = new TGraph(fluxFile.c_str(),"%lg %lg"); - // Fill flux histogram from graph - for (int i = 0; i<fFluxHist->GetNbinsX(); ++i) - fFluxHist->SetBinContent(i+1, yVal[i]*fluxNorm); +// fFluxHist = new TH1D((fName+"_flux").c_str(), (fName+";E_{#nu} +// (GeV)").c_str(), f->GetN()-1, minE, maxE); - delete f; +// // Get graph points +// Double_t *yVal = f->GetY(); -}; +// // Fill flux histogram from graph +// for (int i = 0; i<fFluxHist->GetNbinsX(); ++i) +// fFluxHist->SetBinContent(i+1, yVal[i]*fluxNorm); -//******************************************************************** -double Measurement2D::TotalIntegratedFlux(std::string intOpt, double low, double high){ -//******************************************************************** +// delete f; - if(GetInput()->GetType() == kGiBUU){ - return 1.0; - } +// }; - // Return the integrated flux between two energy values - // If non passed return it between the experimental flux - if (low == -9999.9) low = this->EnuMin; - if (high == -9999.9) high = this->EnuMax; +// //******************************************************************** +// double Measurement2D::TotalIntegratedFlux(std::string intOpt, double low, +// double high){ +// //******************************************************************** - // Get bin integers - int minBin = fFluxHist->GetXaxis()->FindBin(low); - int maxBin = fFluxHist->GetXaxis()->FindBin(high); +// if(GetInput()->GetType() == kGiBUU){ +// return 1.0; +// } - // Find integral - double integral = fFluxHist->Integral(minBin, maxBin+1, intOpt.c_str()); +// // Return the integrated flux between two energy values +// // If non passed return it between the experimental flux +// if (low == -9999.9) low = this->EnuMin; +// if (high == -9999.9) high = this->EnuMax; - return integral; +// // Get bin integers +// int minBin = fFluxHist->GetXaxis()->FindBin(low); +// int maxBin = fFluxHist->GetXaxis()->FindBin(high); -}; +// // Find integral +// double integral = fFluxHist->Integral(minBin, maxBin+1, intOpt.c_str()); +// return integral; +// }; /* Reconfigure LOOP */ //******************************************************************** -void Measurement2D::ResetAll(){ -//******************************************************************** +void Measurement2D::ResetAll() { + //******************************************************************** - // Simple function to reset the mc Histograms incase that is all that is needed. + // Simple function to reset the mc Histograms incase that is all that is + // needed. // Clear histograms fMCHist->Reset(); fMCFine->Reset(); return; }; - -//******************************************************************** -void Measurement2D::FillHistograms(){ //******************************************************************** +void Measurement2D::FillHistograms() { + //******************************************************************** - if (Signal){ - fMCHist->Fill(fXVar,fYVar,Weight); - fMCFine->Fill(fXVar,fYVar,Weight); + if (Signal) { + fMCHist->Fill(fXVar, fYVar, Weight); + fMCFine->Fill(fXVar, fYVar, Weight); - PlotUtils::FillNeutModeArray((TH2D**)fMCHist_PDG, Mode, fXVar, fYVar, Weight); + PlotUtils::FillNeutModeArray((TH2D**)fMCHist_PDG, Mode, fXVar, fYVar, + Weight); } return; } //******************************************************************** -void Measurement2D::ScaleEvents(){ -//******************************************************************** +void Measurement2D::ScaleEvents() { + //******************************************************************** if (fMCWeighted) delete fMCWeighted; - fMCWeighted = (TH2D*) fMCHist->Clone(); - fMCWeighted->SetNameTitle( (fName + "_MC_WGHTS").c_str(), - (fName + "_MC_WGHTS" + fPlotTitles).c_str() ); + fMCWeighted = (TH2D*)fMCHist->Clone(); + fMCWeighted->SetNameTitle((fName + "_MC_WGHTS").c_str(), + (fName + "_MC_WGHTS" + fPlotTitles).c_str()); fMCWeighted->GetYaxis()->SetTitle("Weighted Events"); - - if (fIsEnu) { // If we have Enu we need to do flux integration bin by bin + + if (fIsEnu) { // If we have Enu we need to do flux integration bin by bin // This assumes we have the Enu on the x-axis - // fairly trivial to make the change but only MiniBooNE 2D CC1pi+ has Enu in a 2D - PlotUtils::FluxUnfoldedScaling(fMCHist, fFluxHist, fEventHist, fScaleFactor); - PlotUtils::FluxUnfoldedScaling(fMCFine, fFluxHist, fEventHist, fScaleFactor); + // fairly trivial to make the change but only MiniBooNE 2D CC1pi+ has Enu in + // a 2D + PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram(), + GetEventHistogram(), fScaleFactor); + PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram(), + GetEventHistogram(), fScaleFactor); - } else { // Else we just do normal scaling + } else { // Else we just do normal scaling // Scale bin errors correctly fMCHist->GetSumw2(); fMCFine->GetSumw2(); // Final Scaling factors fMCHist->Scale(fScaleFactor, "width"); fMCFine->Scale(fScaleFactor, "width"); - PlotUtils::ScaleNeutModeArray((TH1**)this->fMCHist_PDG, fScaleFactor, "width"); + PlotUtils::ScaleNeutModeArray((TH1**)this->fMCHist_PDG, fScaleFactor, + "width"); } return; }; //******************************************************************** -void Measurement2D::ApplyNormScale(double norm){ +void Measurement2D::ApplyNormScale(double norm) { //******************************************************************** fCurrentNorm = norm; double scale = 0.0; - if (norm > 0.0) scale = 1.0/norm; + if (norm > 0.0) scale = 1.0 / norm; fMCHist->Scale(scale); fMCFine->Scale(scale); PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_PDG, scale); return; - }; - /* Statistic Functions - Outsources to StatUtils */ //******************************************************************** -int Measurement2D::GetNDOF(){ -//******************************************************************** +int Measurement2D::GetNDOF() { + //******************************************************************** // Just incase it has gone... if (!fDataHist) return 0; int nDOF = 0; - // If datahist has no errors make sure we don't include those bins as they are not data points - for (int xBin = 0; xBin < fDataHist->GetNbinsX()+1; ++xBin){ - for (int yBin = 0; yBin < fDataHist->GetNbinsY()+1; ++yBin){ - if (fDataHist->GetBinContent(xBin, yBin) != 0 && fDataHist->GetBinError(xBin, yBin) != 0) - ++nDOF; + // If datahist has no errors make sure we don't include those bins as they are + // not data points + for (int xBin = 0; xBin < fDataHist->GetNbinsX() + 1; ++xBin) { + for (int yBin = 0; yBin < fDataHist->GetNbinsY() + 1; ++yBin) { + if (fDataHist->GetBinContent(xBin, yBin) != 0 && + fDataHist->GetBinError(xBin, yBin) != 0) + ++nDOF; } } // Account for possible bin masking int nMasked = 0; if (fMaskHist and fIsMask) - if (fMaskHist->Integral()>0) - for (int xBin = 0; xBin < fMaskHist->GetNbinsX()+1; ++xBin) - for (int yBin = 0; yBin < fMaskHist->GetNbinsY()+1; ++yBin) - if (fMaskHist->GetBinContent(xBin, yBin) > 0.5) ++nMasked; + if (fMaskHist->Integral() > 0) + for (int xBin = 0; xBin < fMaskHist->GetNbinsX() + 1; ++xBin) + for (int yBin = 0; yBin < fMaskHist->GetNbinsY() + 1; ++yBin) + if (fMaskHist->GetBinContent(xBin, yBin) > 0.5) ++nMasked; // Take away those masked DOF nDOF -= nMasked; return nDOF; } - -//******************************************************************** -double Measurement2D::GetLikelihood(){ //******************************************************************** +double Measurement2D::GetLikelihood() { + //******************************************************************** // Fix weird masking bug - if (!fIsMask){ - if (fMaskHist){ + if (!fIsMask) { + if (fMaskHist) { fMaskHist = NULL; } } else { - if (fMaskHist){ + if (fMaskHist) { PlotUtils::MaskBins(fMCHist, fMaskHist); } } - + // if (fIsProjFitX or fIsProjFitY) return GetProjectedChi2(); - // Scale up the results to match each other (Not using width might be inconsistent with Meas1D) - double scaleF = fDataHist->Integral()/fMCHist->Integral(); - if (fIsShape){ + // Scale up the results to match each other (Not using width might be + // inconsistent with Meas1D) + double scaleF = fDataHist->Integral() / fMCHist->Integral(); + if (fIsShape) { fMCHist->Scale(scaleF); fMCFine->Scale(scaleF); PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_PDG, scaleF); } - if (!fMapHist){ + if (!fMapHist) { fMapHist = StatUtils::GenerateMap(fDataHist); } - // Get the chi2 from either covar or diagonals double chi2; - if (fIsChi2){ + if (fIsChi2) { if (fIsDiag) { - chi2 = StatUtils::GetChi2FromDiag(fDataHist, fMCHist, fMapHist, fMaskHist); + chi2 = + StatUtils::GetChi2FromDiag(fDataHist, fMCHist, fMapHist, fMaskHist); } else { - chi2 = StatUtils::GetChi2FromCov(fDataHist, fMCHist, covar, fMapHist, fMaskHist); + chi2 = StatUtils::GetChi2FromCov(fDataHist, fMCHist, covar, fMapHist, + fMaskHist); } } else { - if (fIsDiag){ - chi2 = StatUtils::GetLikelihoodFromDiag(fDataHist, fMCHist, fMapHist, fMaskHist); + if (fIsDiag) { + chi2 = StatUtils::GetLikelihoodFromDiag(fDataHist, fMCHist, fMapHist, + fMaskHist); } else { - chi2 = StatUtils::GetLikelihoodFromCov(fDataHist, fMCHist, covar, fMapHist, fMaskHist); + chi2 = StatUtils::GetLikelihoodFromCov(fDataHist, fMCHist, covar, + fMapHist, fMaskHist); } } // Add a normal penalty term - if (fAddNormPen){ - chi2 += (1- (fCurrentNorm))*(1-(fCurrentNorm))/(fNormError*fNormError); - LOG(REC)<<"Norm penalty = "<<(1- (fCurrentNorm ))*(1-(fCurrentNorm))/(fNormError*fNormError)<<std::endl; + if (fAddNormPen) { + chi2 += + (1 - (fCurrentNorm)) * (1 - (fCurrentNorm)) / (fNormError * fNormError); + LOG(REC) << "Norm penalty = " + << (1 - (fCurrentNorm)) * (1 - (fCurrentNorm)) / + (fNormError * fNormError) + << std::endl; } - - // Adjust the shape back to where it was. - if (fIsShape and !FitPar::Config().GetParB("saveshapescaling")){ - fMCHist->Scale(1./scaleF); - fMCFine->Scale(1./scaleF); - PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_PDG, 1.0/scaleF); + // Adjust the shape back to where it was. + if (fIsShape and !FitPar::Config().GetParB("saveshapescaling")) { + fMCHist->Scale(1. / scaleF); + fMCFine->Scale(1. / scaleF); + PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_PDG, 1.0 / scaleF); } - LOG(REC)<<fName+" Chi2 = "<<chi2<<" \n"; + LOG(REC) << fName + " Chi2 = " << chi2 << " \n"; return chi2; }; // //******************************************************************** // double Measurement2D::GetProjectedChi2(){ // //******************************************************************** // PlotUtils::MatchEmptfYBins(fDataHist,fMCHist); // fMCHist_X = PlotUtils::GetProjectionX(fMCHist, fMaskHist); // fMCHist_Y = PlotUtils::GetProjectionY(fMCHist, fMaskHist); // fDataHist_X = PlotUtils::GetProjectionX(fDataHist, fMaskHist); // fDataHist_Y = PlotUtils::GetProjectionY(fDataHist, fMaskHist); // // Depending on the option either the rate of only X or only Y is used. // // If using Y rate, scale X to match data and vice versa // // Note: Projection will have already accounted for masking. -// if (fIsProjFitY) fMCHist_X->Scale(PlotUtils::GetDataMCRatio(fDataHist_X, fMCHist_X)); -// if (fIsProjFitX) fMCHist_Y->Scale(PlotUtils::GetDataMCRatio(fDataHist_Y, fMCHist_Y)); +// if (fIsProjFitY) fMCHist_X->Scale(PlotUtils::GetDataMCRatio(fDataHist_X, +// fMCHist_X)); +// if (fIsProjFitX) fMCHist_Y->Scale(PlotUtils::GetDataMCRatio(fDataHist_Y, +// fMCHist_Y)); // // Now get individual chi2 from each // double chi2X = StatUtils::GetChi2FromDiag(fDataHist_X, fMCHist_X); // double chi2Y = StatUtils::GetChi2FromDiag(fDataHist_Y, fMCHist_Y); // double chi2 = chi2X + chi2Y; // fMCHist_X->SetTitle(Form("%d", chi2X)); // fMCHist_Y->SetTitle(Form("%d", chi2Y)); // return chi2; // } /* Fake Data */ //******************************************************************** void Measurement2D::SetFakeDataValues(std::string fakeOption) { -//******************************************************************** + //******************************************************************** // This is the original data - if (!(fDataOrig)) fDataOrig = (TH2D*)fDataHist->Clone((fName+"_data_original").c_str()); - TH2D *tempData = (TH2D*)fDataHist->Clone(); + if (!(fDataOrig)) + fDataOrig = (TH2D*)fDataHist->Clone((fName + "_data_original").c_str()); + TH2D* tempData = (TH2D*)fDataHist->Clone(); - TFile *fake = new TFile(); + TFile* fake = new TFile(); - if (fakeOption.compare("MC")==0){ - LOG(SAM) << fName <<"Setting fake data from MC "<<std::endl; - fDataHist = (TH2D*)fMCHist->Clone((fName+"_MC").c_str()); - if (fMCHist->Integral() == 0.0) LOG(SAM) << fName <<"Invalid histogram"<<std::endl; - } - else { + if (fakeOption.compare("MC") == 0) { + LOG(SAM) << fName << "Setting fake data from MC " << std::endl; + fDataHist = (TH2D*)fMCHist->Clone((fName + "_MC").c_str()); + if (fMCHist->Integral() == 0.0) + LOG(SAM) << fName << "Invalid histogram" << std::endl; + } else { fake = new TFile(fakeOption.c_str()); - fDataHist = (TH2D*)fake->Get((fName+"_MC").c_str()); + fDataHist = (TH2D*)fake->Get((fName + "_MC").c_str()); } - fDataHist ->SetNameTitle((fName+"_FAKE").c_str(), (fName+fPlotTitles).c_str()); + fDataHist->SetNameTitle((fName + "_FAKE").c_str(), + (fName + fPlotTitles).c_str()); int nbins_x = fDataHist->GetNbinsX(); int nbins_y = fDataHist->GetNbinsY(); double alpha_i = 0.0; - for (int i = 0; i < nbins_x; i++){ - for (int j = 0; j < nbins_y; j++){ - - if (tempData->GetBinContent(i+1,j+1) == 0.0) continue; - - alpha_i = fDataHist->GetBinContent(i+1,j+1)/fDataOrig->GetBinContent(i+1,j+1); - fDataHist->SetBinError(i+1,j+1,alpha_i*fDataOrig->GetBinError(i+1,j+1)); + for (int i = 0; i < nbins_x; i++) { + for (int j = 0; j < nbins_y; j++) { + if (tempData->GetBinContent(i + 1, j + 1) == 0.0) continue; + alpha_i = fDataHist->GetBinContent(i + 1, j + 1) / + fDataOrig->GetBinContent(i + 1, j + 1); + fDataHist->SetBinError(i + 1, j + 1, + alpha_i * fDataOrig->GetBinError(i + 1, j + 1)); } } - fDataTrue = (TH2D*) fDataHist->Clone(); + fDataTrue = (TH2D*)fDataHist->Clone(); fake->Close(); delete fake; return; }; // virtual void ResetFakeData(); // virtual void ResetData(); //******************************************************************** -void Measurement2D::ThrowCovariance(){ -//******************************************************************** +void Measurement2D::ThrowCovariance() { + //******************************************************************** return; }; - /* Access Functions */ //******************************************************************** -std::vector<TH1*> Measurement2D::GetMCList(){ -//******************************************************************** +std::vector<TH1*> Measurement2D::GetMCList() { + //******************************************************************** // If this isn't a NULL pointer, make the plot pretty! - if (!fMCHist) return std::vector<TH1*> (1, fMCHist); + if (!fMCHist) return std::vector<TH1*>(1, fMCHist); std::ostringstream chi2; chi2 << std::setprecision(5) << this->GetLikelihood(); int plotcolor = kRed; - if (FitPar::Config().GetParI("linecolour") > 0){ + if (FitPar::Config().GetParI("linecolour") > 0) { plotcolor = FitPar::Config().GetParI("linecolour"); } int plotstyle = 1; - if (FitPar::Config().GetParI("linestyle") > 0){ + if (FitPar::Config().GetParI("linestyle") > 0) { plotstyle = FitPar::Config().GetParI("linestyle"); } - int plotfillstyle=0; - if (FitPar::Config().GetParI("fillstyle") > 0){ + int plotfillstyle = 0; + if (FitPar::Config().GetParI("fillstyle") > 0) { plotfillstyle = FitPar::Config().GetParI("fillstyle"); } LOG(SAM) << fName << " chi2 = " << GetLikelihood() << std::endl; fMCHist->SetTitle(chi2.str().c_str()); fMCHist->SetLineWidth(2); fMCHist->SetLineColor(plotcolor); fMCHist->SetFillColor(plotcolor); fMCHist->SetLineStyle(plotstyle); fMCHist->SetFillStyle(plotfillstyle); - return std::vector<TH1*> (1, fMCHist); + return std::vector<TH1*>(1, fMCHist); }; //******************************************************************** -std::vector<TH1*> Measurement2D::GetDataList(){ -//******************************************************************** +std::vector<TH1*> Measurement2D::GetDataList() { + //******************************************************************** // If this isn't a NULL pointer, make the plot pretty! - if (!fDataHist) return std::vector<TH1*> (1, fDataHist); + if (!fDataHist) return std::vector<TH1*>(1, fDataHist); fDataHist->SetLineWidth(2); fDataHist->SetLineColor(kBlue); - return std::vector<TH1*> (1, fDataHist); + return std::vector<TH1*>(1, fDataHist); }; - //******************************************************************** -void Measurement2D:: GetBinContents(std::vector<double>& cont, std::vector<double>& err){ +void Measurement2D::GetBinContents(std::vector<double>& cont, + std::vector<double>& err) { //******************************************************************** int count = 0; - for (int i = 0; i < (fMCHist->GetNbinsX()+2) * (fMCHist->GetNbinsY()+2); i++){ + for (int i = 0; i < (fMCHist->GetNbinsX() + 2) * (fMCHist->GetNbinsY() + 2); + i++) { cont.push_back(fMCHist->GetBinContent(i)); err.push_back(fMCHist->GetBinError(i)); count++; } return; }; - -//******************************************************************** -std::vector<double> Measurement2D::GetXSec(std::string option){ //******************************************************************** +std::vector<double> Measurement2D::GetXSec(std::string option) { + //******************************************************************** std::vector<double> vals; vals.push_back(0.0); vals.push_back(0.0); bool getMC = !option.compare("MC"); bool getDT = !option.compare("DATA"); - for (int i = 0; i < fMCHist->GetNbinsX(); i++){ - if (fDataHist->GetBinContent(i+1) == 0.0 and fDataHist->GetBinError(i+1) == 0.0) continue; - - if (getMC){ - - vals[0] += fMCHist->GetBinContent(i+1) * fMCHist->GetXaxis()->GetBinWidth(i+1); - vals[1] += fMCHist->GetBinError(i+1) * fMCHist->GetBinError(i+1) * fMCHist->GetXaxis()->GetBinWidth(i+1) * fMCHist->GetXaxis()->GetBinWidth(i+1); - - } else if (getDT){ - - vals[0] += fDataHist->GetBinContent(i+1) * fDataHist->GetXaxis()->GetBinWidth(i+1); - vals[1] += fDataHist->GetBinError(i+1) * fDataHist->GetBinError(i+1) * fDataHist->GetXaxis()->GetBinWidth(i+1) * fDataHist->GetXaxis()->GetBinWidth(i+1); + for (int i = 0; i < fMCHist->GetNbinsX(); i++) { + if (fDataHist->GetBinContent(i + 1) == 0.0 and + fDataHist->GetBinError(i + 1) == 0.0) + continue; + if (getMC) { + vals[0] += fMCHist->GetBinContent(i + 1) * + fMCHist->GetXaxis()->GetBinWidth(i + 1); + vals[1] += fMCHist->GetBinError(i + 1) * fMCHist->GetBinError(i + 1) * + fMCHist->GetXaxis()->GetBinWidth(i + 1) * + fMCHist->GetXaxis()->GetBinWidth(i + 1); + + } else if (getDT) { + vals[0] += fDataHist->GetBinContent(i + 1) * + fDataHist->GetXaxis()->GetBinWidth(i + 1); + vals[1] += fDataHist->GetBinError(i + 1) * fDataHist->GetBinError(i + 1) * + fDataHist->GetXaxis()->GetBinWidth(i + 1) * + fDataHist->GetXaxis()->GetBinWidth(i + 1); } } // If not diag Get the total error from the covariance - if (!fIsDiag and getDT){ + if (!fIsDiag and getDT) { vals[1] = 0.0; - for (int i = 0; i < fDataHist->GetNbinsX(); i++){ - for(int j = 0; j < fDataHist->GetNbinsX(); j++){ - - vals[1] += (*fFullCovar)(i,j); - + for (int i = 0; i < fDataHist->GetNbinsX(); i++) { + for (int j = 0; j < fDataHist->GetNbinsX(); j++) { + vals[1] += (*fFullCovar)(i, j); } } vals[1] = sqrt(vals[1]) * 1E-38; } return vals; } - - - /* Write Functions */ //******************************************************************** -void Measurement2D::Write(std::string drawOpt){ -//******************************************************************** +void Measurement2D::Write(std::string drawOpt) { + //******************************************************************** // If null pointer return - if (!fMCHist and !fDataHist){ - LOG(SAM) << fName <<"Incomplete histogram set!"<<std::endl; + if (!fMCHist and !fDataHist) { + LOG(SAM) << fName << "Incomplete histogram set!" << std::endl; return; } // FitPar::Config().out->cd(); // Get Draw Options drawOpt = FitPar::Config().GetParS("drawopts"); - bool drawData = (drawOpt.find("DATA") != std::string::npos); + bool drawData = (drawOpt.find("DATA") != std::string::npos); bool drawNormal = (drawOpt.find("MC") != std::string::npos); bool drawEvents = (drawOpt.find("EVT") != std::string::npos); - bool drawXSec = (drawOpt.find("XSEC") != std::string::npos); - bool drawFine = (drawOpt.find("FINE") != std::string::npos); - bool drawRatio = (drawOpt.find("RATIO") != std::string::npos); - bool drawModes = (drawOpt.find("MODES") != std::string::npos); - bool drawShape = (drawOpt.find("SHAPE") != std::string::npos); - bool residual = (drawOpt.find("RESIDUAL") != std::string::npos); + bool drawXSec = (drawOpt.find("XSEC") != std::string::npos); + bool drawFine = (drawOpt.find("FINE") != std::string::npos); + bool drawRatio = (drawOpt.find("RATIO") != std::string::npos); + bool drawModes = (drawOpt.find("MODES") != std::string::npos); + bool drawShape = (drawOpt.find("SHAPE") != std::string::npos); + bool residual = (drawOpt.find("RESIDUAL") != std::string::npos); bool drawMatrix = (drawOpt.find("MATRIX") != std::string::npos); - bool drawFlux = (drawOpt.find("FLUX") != std::string::npos); - bool drawMask = (drawOpt.find("MASK") != std::string::npos); - bool drawMap = (drawOpt.find("MAP") != std::string::npos); - bool drawProj = (drawOpt.find("PROJ") != std::string::npos); - //bool drawCanvPDG = (drawOpt.find("CANVPDG") != std::string::npos); - bool drawCov = (drawOpt.find("COV") != std::string::npos); + bool drawFlux = (drawOpt.find("FLUX") != std::string::npos); + bool drawMask = (drawOpt.find("MASK") != std::string::npos); + bool drawMap = (drawOpt.find("MAP") != std::string::npos); + bool drawProj = (drawOpt.find("PROJ") != std::string::npos); + // bool drawCanvPDG = (drawOpt.find("CANVPDG") != std::string::npos); + bool drawCov = (drawOpt.find("COV") != std::string::npos); bool drawSliceCanvYMC = (drawOpt.find("CANVYMC") != std::string::npos); bool drawWeighted = (drawOpt.find("WGHT") != std::string::npos); - - if (FitPar::Config().GetParB("EventManager")){ + + if (FitPar::Config().GetParB("EventManager")) { drawFlux = false; drawXSec = false; drawEvents = false; } // Save standard plots - if (drawData) this->GetDataList().at(0)->Write(); - if (drawNormal) this->GetMCList() .at(0)->Write(); + if (drawData) this->GetDataList().at(0)->Write(); + if (drawNormal) this->GetMCList().at(0)->Write(); - if (drawCov){ - TH2D(*fFullCovar).Write( (fName + "_COV").c_str() ); + if (drawCov) { + TH2D(*fFullCovar).Write((fName + "_COV").c_str()); } - - if (drawOpt.find("INVCOV") != std::string::npos){ - TH2D(*covar).Write( (fName + "_INVCOV").c_str() ); + + if (drawOpt.find("INVCOV") != std::string::npos) { + TH2D(*covar).Write((fName + "_INVCOV").c_str()); } - + // Generate a simple map - if (!fMapHist) - fMapHist = StatUtils::GenerateMap(fDataHist); + if (!fMapHist) fMapHist = StatUtils::GenerateMap(fDataHist); // Convert to 1D Lists TH1D* data_1D = StatUtils::MapToTH1D(fDataHist, fMapHist); - TH1D* mc_1D = StatUtils::MapToTH1D(fMCHist, fMapHist); + TH1D* mc_1D = StatUtils::MapToTH1D(fMCHist, fMapHist); TH1I* mask_1D = StatUtils::MapToMask(fMaskHist, fMapHist); data_1D->Write(); mc_1D->Write(); - if (mask_1D){ + if (mask_1D) { mask_1D->Write(); - TMatrixDSym* calc_cov = StatUtils::ApplyInvertedMatrixMasking(covar, mask_1D); + TMatrixDSym* calc_cov = + StatUtils::ApplyInvertedMatrixMasking(covar, mask_1D); TH1D* calc_data = StatUtils::ApplyHistogramMasking(data_1D, mask_1D); - TH1D* calc_mc = StatUtils::ApplyHistogramMasking(mc_1D, mask_1D); + TH1D* calc_mc = StatUtils::ApplyHistogramMasking(mc_1D, mask_1D); TH2D* bin_cov = new TH2D(*calc_cov); bin_cov->Write(); calc_data->Write(); calc_mc->Write(); delete mask_1D; delete calc_cov; delete calc_data; delete calc_mc; delete bin_cov; - } delete data_1D; delete mc_1D; - - // Save only mc and data if splines - if(fEventType == 4 or fEventType==3){ return; } + // Save only mc and data if splines + if (fEventType == 4 or fEventType == 3) { + return; + } // Draw Extra plots - if (drawFine) this->GetFineList().at(0)->Write(); - if (drawFlux) fFluxHist->Write(); - if (drawEvents) fEventHist->Write(); - if (fIsMask and drawMask) fMaskHist->Write( (fName + "_MSK").c_str() ); //< save mask - if (drawMap) fMapHist->Write( (fName + "_MAP").c_str() ); //< save map + if (drawFine) this->GetFineList().at(0)->Write(); + if (drawFlux and GetFluxHistogram()) { + GetFluxHistogram()->Write(); + } + if (drawEvents and GetEventHistogram()) { + GetEventHistogram()->Write(); + } + if (fIsMask and drawMask) { + fMaskHist->Write((fName + "_MSK").c_str()); //< save mask + } + if (drawMap) fMapHist->Write((fName + "_MAP").c_str()); //< save map // Save neut stack - if (drawModes){ - THStack combo_fMCHist_PDG = PlotUtils::GetNeutModeStack((fName + "_MC_PDG").c_str(), (TH1**)fMCHist_PDG, 0); + if (drawModes) { + THStack combo_fMCHist_PDG = PlotUtils::GetNeutModeStack( + (fName + "_MC_PDG").c_str(), (TH1**)fMCHist_PDG, 0); combo_fMCHist_PDG.Write(); } // Save Matrix plots - if (drawMatrix and fFullCovar and covar and fDecomp){ - + if (drawMatrix and fFullCovar and covar and fDecomp) { TH2D cov = TH2D((*fFullCovar)); - cov.SetNameTitle((fName+"_cov").c_str(),(fName+"_cov;Bins; Bins;").c_str()); + cov.SetNameTitle((fName + "_cov").c_str(), + (fName + "_cov;Bins; Bins;").c_str()); cov.Write(); TH2D covinv = TH2D((*this->covar)); - covinv.SetNameTitle((fName+"_covinv").c_str(),(fName+"_cov;Bins; Bins;").c_str()); + covinv.SetNameTitle((fName + "_covinv").c_str(), + (fName + "_cov;Bins; Bins;").c_str()); covinv.Write(); TH2D covdec = TH2D((*fDecomp)); - covdec.SetNameTitle((fName+"_covdec").c_str(),(fName+"_cov;Bins; Bins;").c_str()); + covdec.SetNameTitle((fName + "_covdec").c_str(), + (fName + "_cov;Bins; Bins;").c_str()); covdec.Write(); - } - // Save ratio plots if required - if (drawRatio){ - + if (drawRatio) { // Needed for error bars - for(int i = 0; i < fMCHist->GetNbinsX()*fMCHist->GetNbinsY(); i++) - fMCHist->SetBinError(i+1,0.0); + for (int i = 0; i < fMCHist->GetNbinsX() * fMCHist->GetNbinsY(); i++) + fMCHist->SetBinError(i + 1, 0.0); fDataHist->GetSumw2(); fMCHist->GetSumw2(); // Create Ratio Histograms - TH2D* dataRatio = (TH2D*) fDataHist->Clone((fName + "_data_RATIO").c_str()); - TH2D* mcRatio = (TH2D*) fMCHist->Clone((fName + "_MC_RATIO").c_str()); + TH2D* dataRatio = (TH2D*)fDataHist->Clone((fName + "_data_RATIO").c_str()); + TH2D* mcRatio = (TH2D*)fMCHist->Clone((fName + "_MC_RATIO").c_str()); mcRatio->Divide(fMCHist); dataRatio->Divide(fMCHist); // Cancel bin errors on MC - for(int i = 0; i < mcRatio->GetNbinsX()*mcRatio->GetNbinsY(); i++) { - mcRatio->SetBinError(i+1,fMCHist->GetBinError(i+1) / fMCHist->GetBinContent(i+1)); + for (int i = 0; i < mcRatio->GetNbinsX() * mcRatio->GetNbinsY(); i++) { + mcRatio->SetBinError( + i + 1, fMCHist->GetBinError(i + 1) / fMCHist->GetBinContent(i + 1)); } mcRatio->SetMinimum(0); mcRatio->SetMaximum(2); dataRatio->SetMinimum(0); dataRatio->SetMaximum(2); mcRatio->Write(); dataRatio->Write(); delete mcRatio; delete dataRatio; } // Save Shape Plots if required - if (drawShape){ - + if (drawShape) { // Create Shape Histogram - TH2D* mcShape = (TH2D*) fMCHist->Clone((fName + "_MC_SHAPE").c_str()); + TH2D* mcShape = (TH2D*)fMCHist->Clone((fName + "_MC_SHAPE").c_str()); double shapeScale = 1.0; - if (fIsRawEvents){ + if (fIsRawEvents) { shapeScale = fDataHist->Integral() / fMCHist->Integral(); } else { - shapeScale = fDataHist->Integral("width") / fMCHist->Integral("width"); + shapeScale = fDataHist->Integral("width") / fMCHist->Integral("width"); } - - mcShape->Scale( shapeScale ); + + mcShape->Scale(shapeScale); mcShape->SetLineWidth(3); - mcShape->SetLineStyle(7); //dashes + mcShape->SetLineStyle(7); // dashes mcShape->Write(); // Save shape ratios - if (drawRatio){ - + if (drawRatio) { // Needed for error bars mcShape->GetSumw2(); // Create shape ratio histograms - TH2D* mcShapeRatio = (TH2D*)mcShape->Clone((fName + "_MC_SHAPE_RATIO").c_str()); - TH2D* dataShapeRatio = (TH2D*)fDataHist->Clone((fName + "_data_SHAPE_RATIO").c_str()); + TH2D* mcShapeRatio = + (TH2D*)mcShape->Clone((fName + "_MC_SHAPE_RATIO").c_str()); + TH2D* dataShapeRatio = + (TH2D*)fDataHist->Clone((fName + "_data_SHAPE_RATIO").c_str()); // Divide the histograms - mcShapeRatio ->Divide(mcShape); - dataShapeRatio ->Divide(mcShape); + mcShapeRatio->Divide(mcShape); + dataShapeRatio->Divide(mcShape); // Colour the shape ratio plots - mcShapeRatio ->SetLineWidth(3); - mcShapeRatio ->SetLineStyle(7); // dashes + mcShapeRatio->SetLineWidth(3); + mcShapeRatio->SetLineStyle(7); // dashes - mcShapeRatio ->Write(); + mcShapeRatio->Write(); dataShapeRatio->Write(); delete mcShapeRatio; delete dataShapeRatio; } delete mcShape; } // Save residual calculations of what contributed to the chi2 values. - if (residual){ + if (residual) { } - if (fIsProjFitX or fIsProjFitY or drawProj){ - + if (fIsProjFitX or fIsProjFitY or drawProj) { // If not already made, make the projections - if (!fMCHist_X){ - PlotUtils::MatchEmptyBins(fDataHist,fMCHist); + if (!fMCHist_X) { + PlotUtils::MatchEmptyBins(fDataHist, fMCHist); fMCHist_X = PlotUtils::GetProjectionX(fMCHist, fMaskHist); fMCHist_Y = PlotUtils::GetProjectionY(fMCHist, fMaskHist); fDataHist_X = PlotUtils::GetProjectionX(fDataHist, fMaskHist); fDataHist_Y = PlotUtils::GetProjectionY(fDataHist, fMaskHist); double chi2X = StatUtils::GetChi2FromDiag(fDataHist_X, fMCHist_X); double chi2Y = StatUtils::GetChi2FromDiag(fDataHist_Y, fMCHist_Y); fMCHist_X->SetTitle(Form("%f", chi2X)); fMCHist_Y->SetTitle(Form("%f", chi2Y)); } // Save the histograms fDataHist_X->Write(); fMCHist_X->Write(); fDataHist_Y->Write(); fMCHist_Y->Write(); } - if (drawSliceCanvYMC or true){ + if (drawSliceCanvYMC or true) { TCanvas* c1 = new TCanvas((fName + "_MC_CANV_Y").c_str(), - (fName + "_MC_CANV_Y").c_str(), - 800,600); + (fName + "_MC_CANV_Y").c_str(), 800, 600); - c1->Divide( int(sqrt(fDataHist->GetNbinsY()+1)), int(sqrt(fDataHist->GetNbinsY()+1)) ); - TH2D* mcShape = (TH2D*) fMCHist->Clone((fName + "_MC_SHAPE").c_str()); - double shapeScale = fDataHist->Integral("width")/fMCHist->Integral("width"); + c1->Divide(int(sqrt(fDataHist->GetNbinsY() + 1)), + int(sqrt(fDataHist->GetNbinsY() + 1))); + TH2D* mcShape = (TH2D*)fMCHist->Clone((fName + "_MC_SHAPE").c_str()); + double shapeScale = + fDataHist->Integral("width") / fMCHist->Integral("width"); mcShape->Scale(shapeScale); mcShape->SetLineStyle(7); c1->cd(1); - TLegend* leg = new TLegend(0.6,0.6,0.9,0.9); + TLegend* leg = new TLegend(0.6, 0.6, 0.9, 0.9); leg->AddEntry(fDataHist, (fName + " Data").c_str(), "ep"); - leg->AddEntry(fMCHist, (fName + " MC").c_str(), "l"); - leg->AddEntry(mcShape, (fName + " Shape").c_str(), "l"); + leg->AddEntry(fMCHist, (fName + " MC").c_str(), "l"); + leg->AddEntry(mcShape, (fName + " Shape").c_str(), "l"); leg->Draw("SAME"); /* // Make Y slices for (int i = 0; i < fDataHist->GetNbinY(); i++){ - + c1->cd(i+2); TH1D* fDataHist_SliceY = PlotUtils::GetSliceY(fDataHist, i); fDataHist_SliceY->Draw("E1"); TH1D* fMCHist_SliceY = PlotUtils::GetSliceY(fMCHist, i); fMCHist_SliceY->Draw("SAME HIST C"); TH1D* mcShape_SliceY = PlotUtils::GetSliceY(mcShape, i); mcShape_SliceY->Draw("SAME HIST C"); } */ c1->Write(); } - - if (drawWeighted){ + + if (drawWeighted) { fMCWeighted->Write(); } - + // Returning - LOG(SAM) << "Written Histograms: "<<fName<<std::endl; + LOG(SAM) << "Written Histograms: " << fName << std::endl; return; }; - -THStack Measurement2D::GetModeStack(){ - THStack combo_hist = PlotUtils::GetNeutModeStack((fName + "_MC_PDG").c_str(), (TH1**)fMCHist_PDG, 0); +THStack Measurement2D::GetModeStack() { + THStack combo_hist = PlotUtils::GetNeutModeStack((fName + "_MC_PDG").c_str(), + (TH1**)fMCHist_PDG, 0); return combo_hist; } diff --git a/src/FitBase/Measurement2D.h b/src/FitBase/Measurement2D.h index 5019c05..b683437 100644 --- a/src/FitBase/Measurement2D.h +++ b/src/FitBase/Measurement2D.h @@ -1,254 +1,263 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #ifndef MEASUREMENT_2D_HXX_SEEN #define MEASUREMENT_2D_HXX_SEEN /*! * \addtogroup FitBase * @{ */ -#include <stdlib.h> -#include <numeric> #include <math.h> -#include <string> -#include <iostream> -#include <sstream> +#include <stdlib.h> +#include <deque> #include <fstream> #include <iomanip> -#include <deque> +#include <iostream> +#include <numeric> +#include <sstream> +#include <string> // ROOT includes -#include <TROOT.h> -#include <TH1D.h> -#include <TH2D.h> #include <TArrayF.h> +#include <TDecompSVD.h> #include <TGraph.h> #include <TGraphErrors.h> +#include <TH1D.h> +#include <TH2D.h> #include <TMatrixDSym.h> -#include <TDecompSVD.h> +#include <TROOT.h> #include <TSystem.h> // External data fit includes -#include "MeasurementBase.h" #include "FitEvent.h" +#include "FitParameters.h" #include "FitUtils.h" -#include "StatUtils.h" +#include "MeasurementBase.h" #include "PlotUtils.h" -#include "FitParameters.h" #include "SignalDef.h" +#include "StatUtils.h" //******************************************************************** //! 2D Measurement base class. Histogram handling is done in this base layer. class Measurement2D : public MeasurementBase { -//******************************************************************** + //******************************************************************** public: - /* Constructor/Deconstuctor */ //! Default Constructor Measurement2D(); //! Default Destructor virtual ~Measurement2D(); /* Setup Functions */ - //! Intial setup of common measurement variables. Parse input files, types, etc. - virtual void SetupMeasurement(std::string input, std::string type, FitWeight *rw, std::string fkdt); + //! Intial setup of common measurement variables. Parse input files, types, + //! etc. + virtual void SetupMeasurement(std::string input, std::string type, + FitWeight* rw, std::string fkdt); //! Setup the default mc Hist given a data histogram virtual void SetupDefaultHist(); //! Parse the fit type to get fit options virtual void SetFitOptions(std::string opt); //! Set the data values and errors from two files - virtual void SetDataValues(std::string dataFile, double dataNorm, std::string errorFile, double errorNorm); + virtual void SetDataValues(std::string dataFile, double dataNorm, + std::string errorFile, double errorNorm); virtual void SetDataValues(std::string dataFile, std::string TH2Dname); //! Set the data values only from a text file - virtual void SetDataValuesFromText(std::string dataFile, double norm); + virtual void SetDataValuesFromText(std::string dataFile, double norm); //! Read a covariance matrix from a file (Default name "covar" in file) virtual void SetCovarMatrix(std::string covarFile); //! Set the covariance matrix from a text file virtual void SetCovarMatrixFromText(std::string covarFile, int dim); - //! Set the covariance matrix from a text file containing the cholesky fDecomposition + //! Set the covariance matrix from a text file containing the cholesky + //! fDecomposition virtual void SetCovarMatrixFromChol(std::string covarFile, int dim); // virtual void SetMaskValuesFromText(std::string dataFile); //! Read in a histogram 2Dto1D map from a text file virtual void SetMapValuesFromText(std::string dataFile); //! Set the bin mask for a 2D histogram (list: bini, binj, MaskFlag) virtual void SetBinMask(std::string maskFile); - // virtual void ReadHistogramFile(); /* XSec Functions */ - //! Set the flux from a text file - virtual void SetFluxHistogram(std::string fluxFile, int minE, int maxE, double fluxNorm); + // // ! Set the flux from a text file + // virtual void SetFluxHistogram(std::string fluxFile, int minE, int maxE, + // double fluxNorm); - //! Get the integrated flux between this measurements energy ranges - virtual double TotalIntegratedFlux(std::string intOpt="width",double low=-9999.9, double high=-9999.9); + // //! Get the integrated flux between this measurements energy ranges + // virtual double TotalIntegratedFlux(std::string intOpt="width",double + // low=-9999.9, double high=-9999.9); /* Reconfigure LOOP */ //! Reset the MC Histograms to zero virtual void ResetAll(); //! Fill the histograms given fXVar, fYVar, and Weight for this event virtual void FillHistograms(); //! Apply event scaling to XSec values after reconfigure has been called virtual void ScaleEvents(); - //! Apply a normalisation scale in free normalisation fits after reconfigure has been called + //! Apply a normalisation scale in free normalisation fits after reconfigure + //! has been called virtual void ApplyNormScale(double norm); /* Statistic Functions - Outsources to StatUtils */ //! Get the Number of degrees of freedom accounting for bin masking virtual int GetNDOF(); //! Get the likelihood at current state virtual double GetLikelihood(); - /* Fake Data Functions */ - //! Set fake data values from MC. Use external file, or current MC prediction using option "MC" + //! Set fake data values from MC. Use external file, or current MC prediction + //! using option "MC" virtual void SetFakeDataValues(std::string fakeOption); // virtual void ResetFakeData(); // virtual void ResetData(); //! Use the covariance to throw fake data from the current fDataHist virtual void ThrowCovariance(); virtual THStack GetModeStack(); /* Access Functions */ - TH2D* GetMCHistogram(){ return fMCHist; }; - TH2D* GetDataHistogram(){ return fDataHist; }; + TH2D* GetMCHistogram() { return fMCHist; }; + TH2D* GetDataHistogram() { return fDataHist; }; virtual std::vector<TH1*> GetMCList(); virtual std::vector<TH1*> GetDataList(); - virtual std::vector<TH1*> GetMaskList(){return std::vector<TH1*> (1, fMaskHist);}; - virtual std::vector<TH1*> GetFineList(){return std::vector<TH1*> (1, fMCFine);}; + virtual std::vector<TH1*> GetMaskList() { + return std::vector<TH1*>(1, fMaskHist); + }; + virtual std::vector<TH1*> GetFineList() { + return std::vector<TH1*>(1, fMCFine); + }; //! Get bin contents and errors from fMCHist and fill a vector with them - virtual void GetBinContents(std::vector<double>& cont,std::vector<double>& err); + virtual void GetBinContents(std::vector<double>& cont, + std::vector<double>& err); //! Get covariance matrix as a pretty plot - virtual TH2D GetCovarMatrix(){ return TH2D(*covar);}; + virtual TH2D GetCovarMatrix() { return TH2D(*covar); }; //! Get Integrated XSec (option flags whether to get data or MC) virtual std::vector<double> GetXSec(std::string option); /* Write Functions */ //! Save Histograms to the current directory virtual void Write(std::string drawOpt); -protected: - + protected: // The data histograms - TH2D* fDataHist; //!< default data histogram (use in chi2 calculations) - TH2D* fDataOrig; //!< histogram to store original data before throws. - TH2D* fDataTrue; //!< histogram to store true dataset - TH1D* fDataHist_X; //!< Projections onto X of the fDataHist - TH1D* fDataHist_Y; //!< Projections onto Y of the fDataHist + TH2D* fDataHist; //!< default data histogram (use in chi2 calculations) + TH2D* fDataOrig; //!< histogram to store original data before throws. + TH2D* fDataTrue; //!< histogram to store true dataset + TH1D* fDataHist_X; //!< Projections onto X of the fDataHist + TH1D* fDataHist_Y; //!< Projections onto Y of the fDataHist // The MC histograms - TH2D* fMCHist; //!< MC Histogram (used in chi2 calculations) - TH2D* fMCFine; //!< Finely binned MC Histogram - TH2D* fMCHist_PDG[61]; //!< MC Histograms for each interaction mode - TH1D* fMCHist_X; //!< Projections onto X of the fMCHist - TH1D* fMCHist_Y; //!< Projections onto Y of the fMCHist - TH2D* fMCWeighted; //!< Raw Event Weights - - TH2I* fMaskHist; //!< mask histogram for the data - TH2I* fMapHist; //!< map histogram used to convert 2D to 1D distributions - - bool fIsFakeData; //!< is current data actually fake - std::string fakeDataFile; //!< MC fake data input file - - std::string fPlotTitles; //!< X and Y plot titles. + TH2D* fMCHist; //!< MC Histogram (used in chi2 calculations) + TH2D* fMCFine; //!< Finely binned MC Histogram + TH2D* fMCHist_PDG[61]; //!< MC Histograms for each interaction mode + TH1D* fMCHist_X; //!< Projections onto X of the fMCHist + TH1D* fMCHist_Y; //!< Projections onto Y of the fMCHist + TH2D* fMCWeighted; //!< Raw Event Weights + + TH2I* fMaskHist; //!< mask histogram for the data + TH2I* fMapHist; //!< map histogram used to convert 2D to 1D distributions + + bool fIsFakeData; //!< is current data actually fake + std::string fakeDataFile; //!< MC fake data input file + + std::string fPlotTitles; //!< X and Y plot titles. std::string fFitType; - std::string fDefaultTypes; //!< Default Fit Options - std::string fAllowedTypes; //!< Any allowed Fit Options - - - TMatrixDSym *covar; //!< inverted covariance matrix - TMatrixDSym *fFullCovar; //!< covariance matrix - TMatrixDSym *fDecomp; //!< fDecomposed covariance matrix - TMatrixDSym *fCorrel; //!< correlation matrix - double fCovDet; //!< covariance deteriminant - double fNormError; //!< Normalisation on the error on the data - - Double_t* fXBins; //!< X Bin Edges - Double_t* fYBins; //!< Y Bin Edges + std::string fDefaultTypes; //!< Default Fit Options + std::string fAllowedTypes; //!< Any allowed Fit Options + + TMatrixDSym* covar; //!< inverted covariance matrix + TMatrixDSym* fFullCovar; //!< covariance matrix + TMatrixDSym* fDecomp; //!< fDecomposed covariance matrix + TMatrixDSym* fCorrel; //!< correlation matrix + double fCovDet; //!< covariance deteriminant + double fNormError; //!< Normalisation on the error on the data + + Double_t* fXBins; //!< X Bin Edges + Double_t* fYBins; //!< Y Bin Edges Int_t fNDataPointsX; //!< Number of X data points Int_t fNDataPointsY; //!< NUmber of Y data points // Fit specific flags - bool fIsShape; //!< Flag: Perform shape-only fit - bool fIsFree; //!< Flag: Perform normalisation free fit - bool fIsDiag; //!< Flag: Only use diagonal bin errors in stats - bool fIsMask; //!< Flag: Apply bin masking - bool fIsRawEvents; //!< Flag: Only event rates in histograms - bool fIsEnu; //!< Needs Enu Unfolding - bool fIsChi2SVD; //!< Flag: Chi2 SVD Method (DO NOT USE) - bool fAddNormPen; //!< Flag: Add normalisation penalty to fi - bool fIsProjFitX; //!< Flag: Use 1D projections onto X and Y to calculate the Chi2 Method. If flagged X will be used to set the rate. - bool fIsProjFitY; //!< Flag: Use 1D projections onto X and Y to calculate the Chi2 Method. If flagged Y will be used to set the rate. - bool fIsFix; //!< Flag: Fixed Histogram Norm - bool fIsFull; //!< Flag; Use Full Covar - bool fIsDifXSec; //!< Flag: Differential XSec - bool fIsEnu1D; //!< Flag: Flux Unfolded XSec - bool fIsChi2; //!< Flag; Use Chi2 over LL - + bool fIsShape; //!< Flag: Perform shape-only fit + bool fIsFree; //!< Flag: Perform normalisation free fit + bool fIsDiag; //!< Flag: Only use diagonal bin errors in stats + bool fIsMask; //!< Flag: Apply bin masking + bool fIsRawEvents; //!< Flag: Only event rates in histograms + bool fIsEnu; //!< Needs Enu Unfolding + bool fIsChi2SVD; //!< Flag: Chi2 SVD Method (DO NOT USE) + bool fAddNormPen; //!< Flag: Add normalisation penalty to fi + bool fIsProjFitX; //!< Flag: Use 1D projections onto X and Y to calculate the + //!Chi2 Method. If flagged X will be used to set the rate. + bool fIsProjFitY; //!< Flag: Use 1D projections onto X and Y to calculate the + //!Chi2 Method. If flagged Y will be used to set the rate. + bool fIsFix; //!< Flag: Fixed Histogram Norm + bool fIsFull; //!< Flag; Use Full Covar + bool fIsDifXSec; //!< Flag: Differential XSec + bool fIsEnu1D; //!< Flag: Flux Unfolded XSec + bool fIsChi2; //!< Flag; Use Chi2 over LL }; /*! @} */ #endif diff --git a/src/FitBase/MeasurementBase.cxx b/src/FitBase/MeasurementBase.cxx index 35daec1..c48419b 100644 --- a/src/FitBase/MeasurementBase.cxx +++ b/src/FitBase/MeasurementBase.cxx @@ -1,457 +1,450 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MeasurementBase.h" /* Constructor/Destructors */ //******************************************************************** // 2nd Level Constructor (Inherits From MeasurementBase.h) MeasurementBase::MeasurementBase() { //******************************************************************** fScaleFactor = 1.0; fMCFilled = false; fNoData = false; fInput = NULL; // Set the default values // After-wards this gets set in SetupMeasurement EnuMin = 0.; EnuMax = 1.E5; fMeasurementSpeciesType = kSingleSpeciesMeasurement; }; //******************************************************************** // 2nd Level Destructor (Inherits From MeasurementBase.h) MeasurementBase::~MeasurementBase(){ //******************************************************************** }; //******************************************************************** double MeasurementBase::TotalIntegratedFlux(std::string intOpt, double low, double high) { //******************************************************************** // Set Energy Limits if (low == -9999.9) low = this->EnuMin; if (high == -9999.9) high = this->EnuMax; return GetInput()->TotalIntegratedFlux(low, high, intOpt); }; //******************************************************************** double MeasurementBase::PredictedEventRate(std::string intOpt, double low, double high) { //******************************************************************** // Set Energy Limits if (low == -9999.9) low = this->EnuMin; if (high == -9999.9) high = this->EnuMax; return GetInput()->PredictedEventRate(low, high, intOpt) * 1E-38; }; //******************************************************************** void MeasurementBase::SetupInputs(std::string inputfile) { //******************************************************************** // Add this infile to the global manager if (FitPar::Config().GetParB("EventManager")) { fInput = FitBase::AddInput(fName, inputfile); } else { std::vector<std::string> file_descriptor = GeneralUtils::ParseToStr(inputfile, ":"); if (file_descriptor.size() != 2) { ERR(FTL) << "File descriptor had no filetype declaration: \"" << inputfile << "\". expected \"FILETYPE:file.root\"" << std::endl; throw; } InputUtils::InputType inpType = InputUtils::ParseInputType(file_descriptor[0]); fInput = new InputHandler(fName, inpType, file_descriptor[1]); } - fFluxHist = (TH1D*) fInput->GetFluxHistogram()->Clone(); - fEventHist = (TH1D*) fInput->GetEventHistogram()->Clone(); - fXSecHist = (TH1D*) fInput->GetXSecHistogram()->Clone(); + // fFluxHist = (TH1D*) fInput->GetFluxHistogram()->Clone(); + // fEventHist = (TH1D*) fInput->GetEventHistogram()->Clone(); + // fXSecHist = (TH1D*) fInput->GetXSecHistogram()->Clone(); fNEvents = fInput->GetNEvents(); // Expect INPUTTYPE:FileLocation(s) std::vector<std::string> file_descriptor = GeneralUtils::ParseToStr(inputfile, ":"); if (file_descriptor.size() != 2) { ERR(FTL) << "File descriptor had no filetype declaration: \"" << inputfile << "\". expected \"FILETYPE:file.root\"" << std::endl; throw; } fInputType = InputUtils::ParseInputType(file_descriptor[0]); - fFluxHist = (TH1D*) fInput->GetFluxHistogram()->Clone(); - fEventHist = (TH1D*) fInput->GetEventHistogram()->Clone(); - fXSecHist = (TH1D*) fInput->GetXSecHistogram()->Clone(); - fNEvents = fInput->GetNEvents(); - fInputFileName = file_descriptor[1]; if (EnuMin == 0 && EnuMax == 1.E5) { - EnuMin = fFluxHist->GetBinLowEdge(1); - EnuMax = fFluxHist->GetBinLowEdge(fFluxHist->GetNbinsX()+1); + EnuMin = fInput->GetFluxHistogram()->GetBinLowEdge(1); + EnuMax = fInput->GetFluxHistogram()->GetBinLowEdge( + fInput->GetFluxHistogram()->GetNbinsX() + 1); } } //*********************************************** int MeasurementBase::GetInputID() { //*********************************************** return FitBase::GetInputID(fInputFileName); } //*********************************************** void MeasurementBase::Reconfigure() { //*********************************************** LOG(REC) << " Reconfiguring sample " << fName << std::endl; bool using_evtmanager = FitPar::Config().GetParB("EventManager"); int input_id = -1; if (using_evtmanager) { input_id = FitBase::GetInputID(fInputFileName); } cust_event = fInput->GetEventPointer(); if (FitPar::Config().GetParI("cachesize") > 0) { fInput->SetupCache(); } // Reset Histograms this->ResetAll(); // READ in spline head for this input if (fInput->GetType() == kEVTSPLINE) { FitBase::GetRW()->ReadSplineHead(fInput->GetSplineHead()); } FitEvent* cust_event = fInput->GetEventPointer(); int fNEvents = fInput->GetNEvents(); int countwidth = (fNEvents / 5); // Reset Signal Vectors fXVar_VECT.clear(); fYVar_VECT.clear(); fZVar_VECT.clear(); this->fMode_VECT.clear(); this->fIndex_VECT.clear(); - - #ifdef __GiBUU_ENABLED__ +#ifdef __GiBUU_ENABLED__ bool UsingGiBUU = (fInput->GetType() == kGiBUU); - #endif - +#endif + size_t NSignal = 0; // MAIN EVENT LOOP for (int i = 0; i < fNEvents; i++) { // Read in the TChain and Calc Kinematics if (using_evtmanager) { cust_event = FitBase::EvtManager().GetEvent(input_id, i); } else { fInput->ReadEvent(i); cust_event->RWWeight = FitBase::GetRW()->CalcWeight(cust_event); cust_event->Weight = cust_event->RWWeight * cust_event->InputWeight; } Weight = cust_event->Weight; +#ifdef __GiBUU_ENABLED__ - #ifdef __GiBUU_ENABLED__ - /// For multi species measurements the flux scalings must be correctly /// applied here if (UsingGiBUU) { switch (fMeasurementSpeciesType) { case kSingleSpeciesMeasurement: default: { break; } case kNumuWithWrongSignMeasurement: { Weight *= cust_event->GiRead->SpeciesWght_numu; break; } case kNueWithWrongSignMeasurement: { Weight *= cust_event->GiRead->SpeciesWght_nue; break; } case kFourSpeciesMeasurement: { Weight *= cust_event->GiRead->SpeciesWght; break; } } } - #endif - +#endif + // Initialize fXVar = -999.9; fYVar = -999.9; fZVar = -999.9; Signal = false; Mode = cust_event->Mode; // Extract Measurement Variables this->FillEventVariables(cust_event); Signal = this->isSignal(cust_event); // Push Back Signal if (Signal) { fXVar_VECT.push_back(fXVar); fYVar_VECT.push_back(fYVar); fZVar_VECT.push_back(fZVar); this->fMode_VECT.push_back(Mode); this->fIndex_VECT.push_back((UInt_t)i); NSignal++; } // Fill Histogram Values this->FillHistograms(); // this->FillExtraHistograms(); // Print Out if (LOG_LEVEL(REC) && countwidth > 0 && !(i % countwidth)) { std::stringstream ss(""); ss.unsetf(ios_base::fixed); ss << std::setw(7) << std::right << i << "/" << fNEvents << " events (" << std::setw(2) << double(i) / double(fNEvents) * 100. << std::left << std::setw(5) << "%) " << "[S,X,Y,Z,M,W] = [" << std::fixed << std::setprecision(2) << std::right << Signal << ", " << std::setw(5) << fXVar << ", " << std::setw(5) << fYVar << ", " << std::setw(5) << fYVar << ", " << std::setw(3) << (int)Mode << ", " << std::setw(5) << Weight << "] " << std::endl; LOG(SAM) << ss.str(); } } int npassed = fXVar_VECT.size(); LOG(SAM) << npassed << "/" << fNEvents << " passed selection " << std::endl; if (npassed == 0) { LOG(SAM) << "WARNING: NO EVENTS PASSED SELECTION!" << std::endl; } // Finalise Histograms fMCFilled = true; this->ConvertEventRates(); } //*********************************************** void MeasurementBase::ReconfigureFast() { //*********************************************** LOG(REC) << " Reconfiguring signal " << this->fName << std::endl; bool using_evtmanager = FitPar::Config().GetParB("EventManager"); int input_id = -1; if (using_evtmanager) { input_id = FitBase::GetInputID(fInputFileName); } else { cust_event = fInput->GetEventPointer(); } // Check if we Can't Signal Reconfigure if (!fMCFilled) { this->Reconfigure(); return; } // Reset Histograms this->ResetAll(); // READ in spline head for this input if (fInput->GetType() == kEVTSPLINE) { FitBase::GetRW()->ReadSplineHead(fInput->GetSplineHead()); } // Get Pointer To Base Event (Just Generator Formats) int countwidth = (fIndex_VECT.size() / 5); // Setup Iterators std::vector<double>::iterator X = fXVar_VECT.begin(); std::vector<double>::iterator Y = fYVar_VECT.begin(); std::vector<double>::iterator Z = fZVar_VECT.begin(); std::vector<int>::iterator M = fMode_VECT.begin(); std::vector<UInt_t>::iterator I = fIndex_VECT.begin(); - - #ifdef __GiBUU_ENABLED__ +#ifdef __GiBUU_ENABLED__ bool UsingGiBUU = (fInput->GetType() == kGiBUU); - #endif - +#endif + // SIGNAL LOOP for (int i = 0; I != fIndex_VECT.end(); I++, i++) { // Just Update Weight if (using_evtmanager) { Weight = FitBase::EvtManager().GetEventWeight(input_id, (*I)); } else { fInput->GetTreeEntry((*I)); Weight = FitBase::GetRW()->CalcWeight(cust_event) * cust_event->InputWeight; } - - #ifdef __GiBUU_ENABLED__ +#ifdef __GiBUU_ENABLED__ /// For multi species measurements the flux scalings must be correctly /// applied here if (UsingGiBUU) { switch (fMeasurementSpeciesType) { case kSingleSpeciesMeasurement: default: { break; } case kNumuWithWrongSignMeasurement: { Weight *= cust_event->GiRead->SpeciesWght_numu; break; } case kNueWithWrongSignMeasurement: { Weight *= cust_event->GiRead->SpeciesWght_nue; break; } case kFourSpeciesMeasurement: { Weight *= cust_event->GiRead->SpeciesWght; break; } } } - #endif +#endif fXVar = (*X); fYVar = (*Y); fZVar = (*Z); Mode = (*M); // Set signal to true because here every event looped is true signal Signal = true; // Sort Histograms this->FillHistograms(); // Get Next Iteration X++; Y++; Z++; M++; // Print Out if (LOG_LEVEL(REC) && (i) % countwidth == 0) LOG(REC) << "Reconfigured " << std::setw(7) << std::right << i << " signal events. [X,Y,Z,M,W] = [" << std::setprecision(2) << std::setw(5) << std::right << fXVar << ", " << std::setw(5) << std::right << fYVar << ", " << std::setw(5) << std::right << fYVar << ", " << std::setw(3) << std::right << (int)Mode << ", " << std::setw(5) << std::right << Weight << "] " << std::endl; } // Finalise histograms fMCFilled = true; this->ConvertEventRates(); } //*********************************************** void MeasurementBase::ConvertEventRates() { //*********************************************** this->ScaleEvents(); this->ApplyNormScale(FitBase::GetRW()->GetSampleNorm(this->fName)); } //*********************************************** InputHandler* MeasurementBase::GetInput() { //*********************************************** if (!fInput) { ERR(FTL) << "MeasurementBase::fInput not set. Please submit your command " "line options and input cardfile with a bug report to: " "nuisance@projects.hepforge.org" << std::endl; + throw; } return fInput; }; //*********************************************** void MeasurementBase::Renormalise() { //*********************************************** // Called when the fitter has changed a measurements normalisation but not any // reweight dials // Means we don't have to call the time consuming reconfigure when this // happens. double norm = FitBase::GetRW()->GetDialValue(this->fName + "_norm"); if ((this->fCurrentNorm == 0.0 and norm != 0.0) or not fMCFilled) { this->ReconfigureFast(); return; } if (this->fCurrentNorm == norm) return; this->ApplyNormScale(1.0 / this->fCurrentNorm); this->ApplyNormScale(norm); return; }; //*********************************************** void MeasurementBase::SetSignal(bool sig) { //*********************************************** Signal = sig; } //*********************************************** void MeasurementBase::SetSignal(FitEvent* evt) { //*********************************************** Signal = this->isSignal(evt); } //*********************************************** void MeasurementBase::SetWeight(double wght) { //*********************************************** Weight = wght; } //*********************************************** void MeasurementBase::SetMode(int md) { //*********************************************** Mode = md; } //*********************************************** std::vector<TH1*> MeasurementBase::GetFluxList() { //*********************************************** return GetInput()->GetFluxList(); } //*********************************************** std::vector<TH1*> MeasurementBase::GetEventRateList() { //*********************************************** return GetInput()->GetEventList(); } //*********************************************** std::vector<TH1*> MeasurementBase::GetXSecList() { //*********************************************** return GetInput()->GetXSecList(); } diff --git a/src/FitBase/MeasurementBase.h b/src/FitBase/MeasurementBase.h index 7ad0470..55fa00b 100644 --- a/src/FitBase/MeasurementBase.h +++ b/src/FitBase/MeasurementBase.h @@ -1,265 +1,277 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #ifndef INPUTHANDLER_H_SEEN #define INPUTHANDLER_H_SEEN /*! * \addtogroup FitBase * @{ */ // C Includes -#include <stdlib.h> -#include <numeric> #include <math.h> -#include <string> -#include <iostream> -#include <sstream> -#include <iomanip> -#include <deque> +#include <stdlib.h> #include <time.h> +#include <deque> +#include <iomanip> +#include <iostream> #include <list> +#include <numeric> +#include <sstream> +#include <string> // ROOT includes -#include <TROOT.h> -#include <TH1D.h> -#include <TH2D.h> #include <TArrayF.h> +#include <TDecompChol.h> +#include <TDecompSVD.h> #include <TGraph.h> #include <TGraphErrors.h> +#include <TH1D.h> +#include <TH2D.h> #include <TMatrixDSym.h> -#include <TDecompSVD.h> -#include <TDecompChol.h> +#include <TROOT.h> #include <TSystem.h> // External data fit includes #include "FitEvent.h" +#include "FitParameters.h" #include "FitUtils.h" +#include "GeneralUtils.h" #include "PlotUtils.h" #include "StatUtils.h" -#include "FitParameters.h" -#include "GeneralUtils.h" #include "FitWeight.h" #include "TMultiDimFit.h" #ifdef __GENIE_ENABLED__ #include "Conventions/Units.h" #endif -#include "TObject.h" -#include "InputHandler.h" #include "EventManager.h" +#include "InputHandler.h" +#include "TObject.h" /// Enumerations to help with extra plot functions enum extraplotflags { - kExtraPlotError = 0, - kExtraPlotReset = 1, - kExtraPlotFill = 2, + kExtraPlotError = 0, + kExtraPlotReset = 1, + kExtraPlotFill = 2, kExtraPlotConvert = 3, - kExtraPlotWrite = 4 + kExtraPlotWrite = 4 }; enum MeasurementSpeciesClass { kSingleSpeciesMeasurement = 0, kNumuWithWrongSignMeasurement, kNueWithWrongSignMeasurement, kFourSpeciesMeasurement, }; - /// InputHandler Class /// -/// Inherits from Measurement base to handle whatever input is throwna t the fitter automatically. -/// All functions here handle how files are read in, converted to custom formats and reconfigures are called. +/// Inherits from Measurement base to handle whatever input is throwna t the +/// fitter automatically. +/// All functions here handle how files are read in, converted to custom formats +/// and reconfigures are called. /// Used generally for the MC inputs. -//! 2nd level experiment class that handles converting MC into a common format and calling reconfigure +//! 2nd level experiment class that handles converting MC into a common format +//! and calling reconfigure class MeasurementBase { public: - /* Constructor/Destructors */ //! Default Constructor. Set everything to NULL MeasurementBase(void); //! Default virtual destructor virtual ~MeasurementBase(void); /* Reconfigure Functions */ - //! Function called if MC tuning dials haven't been changed and all we want to do is update the normalisation. + //! Function called if MC tuning dials haven't been changed and all we want to + //! do is update the normalisation. virtual void Renormalise(void); //! Call reconfigure only looping over signal events to save time. virtual void ReconfigureFast(void); //! Call reconfigure looping over all MC events including background virtual void Reconfigure(void); virtual TH2D GetCovarMatrix(void) = 0; - virtual double GetLikelihood(void){return 0.0;}; - virtual int GetNDOF(void){return 0;}; + virtual double GetLikelihood(void) { return 0.0; }; + virtual int GetNDOF(void) { return 0; }; virtual void ThrowCovariance(void) = 0; virtual void SetFakeDataValues(std::string fkdt) = 0; - //! Get the total integrated flux between this samples energy range - virtual double TotalIntegratedFlux(std::string intOpt="width",double low=-9999.9, double high=-9999.9); + virtual double TotalIntegratedFlux(std::string intOpt = "width", + double low = -9999.9, + double high = -9999.9); //! Get the predicted event rate for this sample - virtual double PredictedEventRate(std::string intOpt="width",double low=-9999.9, double high=-9999.9); - + virtual double PredictedEventRate(std::string intOpt = "width", + double low = -9999.9, + double high = -9999.9); int GetPassed() { int signalSize = fXVar_VECT.size(); return signalSize; } - int GetTotal() { - return fNEvents; - } + int GetTotal() { return fNEvents; } /* Reconfigure LOOP */ // All these should be virtual ///! Reset Histograms (Handled at Measurement Stage) virtual void ResetAll(void) = 0; - ///! Fill the event variables for this sample (Handled in each inherited sample) - virtual void FillEventVariables(FitEvent* event){(void)event;}; + ///! Fill the event variables for this sample (Handled in each inherited + /// sample) + virtual void FillEventVariables(FitEvent* event) { (void)event; }; ///! Check whether this event is signle (Handled in each inherited sample) - virtual bool isSignal(FitEvent* event){ (void)event; return false;}; + virtual bool isSignal(FitEvent* event) { + (void)event; + return false; + }; - ///! Fill the histogram for this event using fXVar and fYVar (Handled in each inherited sample) + ///! Fill the histogram for this event using fXVar and fYVar (Handled in each + /// inherited sample) virtual void FillHistograms(void){}; ///! Convert event rates to whatever distributions you need. virtual void ConvertEventRates(void); - ///! Call scale events after the plots have been filled at the end of reconfigure. + ///! Call scale events after the plots have been filled at the end of + /// reconfigure. virtual void ScaleEvents(void){}; ///! Apply the scale factor at the end of reconfigure. - virtual void ApplyNormScale(double norm){(void) norm;}; + virtual void ApplyNormScale(double norm) { (void)norm; }; ///! Save Histograms virtual void Write(std::string drawOpt = "") = 0; /* Histogram Access Functions */ ///! Virtual function to get data histogram virtual std::vector<TH1*> GetDataList(void) = 0; ///! Virtual function to get MC histogram - virtual std::vector<TH1*> GetMCList (void) = 0; - virtual std::vector<TH1*> GetFineList (void) = 0; - virtual std::vector<TH1*> GetMaskList (void) = 0; + virtual std::vector<TH1*> GetMCList(void) = 0; + virtual std::vector<TH1*> GetFineList(void) = 0; + virtual std::vector<TH1*> GetMaskList(void) = 0; ///! Return flux histograms in a vector - virtual std::vector<TH1*> GetFluxList (void); - virtual std::vector<TH1*> GetEventRateList (void); - virtual std::vector<TH1*> GetXSecList (void); + virtual std::vector<TH1*> GetFluxList(void); + virtual std::vector<TH1*> GetEventRateList(void); + virtual std::vector<TH1*> GetXSecList(void); + + virtual TH1D* GetEventHistogram() { return fInput->GetEventHistogram(); }; + virtual TH1D* GetXSecHistogram() { return fInput->GetXSecHistogram(); }; + virtual TH1D* GetFluxHistogram() { return fInput->GetFluxHistogram(); }; ///! Return input for this sample - InputHandler* GetInput (void); + InputHandler* GetInput(void); - std::string GetName (void){ return fName; }; - double GetScaleFactor(void){ return fScaleFactor; }; + std::string GetName(void) { return fName; }; + double GetScaleFactor(void) { return fScaleFactor; }; - double GetXVar(void){ return fXVar; }; - double GetYVar(void){ return fYVar; }; - double GetZVar(void){ return fZVar; }; - double GetMode(void){ return this->Mode; }; - double GetEnu(void){ return this->Enu; }; + double GetXVar(void) { return fXVar; }; + double GetYVar(void) { return fYVar; }; + double GetZVar(void) { return fZVar; }; + double GetMode(void) { return this->Mode; }; + double GetEnu(void) { return this->Enu; }; void SetupInputs(std::string inputfile); int GetInputID(void); - std::string GetInputFileName(){ return fInputFileName; }; + std::string GetInputFileName() { return fInputFileName; }; void SetSignal(bool sig); void SetSignal(FitEvent* evt); void SetWeight(double wght); void SetMode(int md); - void SetNoData(bool isTrue=true){ fNoData = isTrue; }; + void SetNoData(bool isTrue = true) { fNoData = isTrue; }; - inline void SetXVar(double xvar){ fXVar = xvar; }; - inline void SetYVar(double yvar){ fYVar = yvar; }; - inline void SetZVar(double zvar){ fZVar = zvar; }; - - -protected: + inline void SetXVar(double xvar) { fXVar = xvar; }; + inline void SetYVar(double yvar) { fYVar = yvar; }; + inline void SetZVar(double zvar) { fZVar = zvar; }; + protected: // Minimum and maximum energies - double Enu; //!< Neutrino Energy - double EnuMin; //!< Minimum incoming particle energy of events to include - double EnuMax; //!< Maximum incoming particle energy of events to include + double Enu; //!< Neutrino Energy + double EnuMin; //!< Minimum incoming particle energy of events to include + double EnuMax; //!< Maximum incoming particle energy of events to include BaseFitEvt* signal_event; FitEvent* cust_event; - FitWeight* fRW; //!< Pointer to the rw engine - InputHandler* fInput; //!< Instance of the input handler - std::string fName; - int fEventType; - TH1D* fEventHist; - TH1D* fXSecHist; - TH1D* fFluxHist; + FitWeight* fRW; //!< Pointer to the rw engine + InputHandler* fInput; //!< Instance of the input handler + + std::string fName; //!< Name of the sample + int fEventType; - double fBeamDistance; //!< Incoming Particle flight distance (for oscillation analysis) - double fScaleFactor; //!< fScaleFactor applied to events to convert from eventrate to final distribution - double fCurrentNorm; //!< current normalisation factor applied if fit is "FREE" - bool fMCFilled; //!< flag whether MC plots have been filled (For ApplyNormalisation) - bool fNoData; //!< flag whether data plots do not exist (for ratios) + double fBeamDistance; //!< Incoming Particle flight distance (for oscillation + //! analysis) + double fScaleFactor; //!< fScaleFactor applied to events to convert from + //! eventrate to final distribution + double + fCurrentNorm; //!< current normalisation factor applied if fit is "FREE" + bool fMCFilled; //!< flag whether MC plots have been filled (For + //! ApplyNormalisation) + bool fNoData; //!< flag whether data plots do not exist (for ratios) // TEMP OBJECTS TO HANDLE MERGE - double fXVar,fYVar,fZVar,Mode,Weight; + double fXVar, fYVar, fZVar, Mode, Weight; bool Signal; int ievt; int fNEvents; double Enu_rec, ThetaMu, CosThetaMu; std::vector<double> fXVar_VECT; std::vector<double> fYVar_VECT; std::vector<double> fZVar_VECT; - std::vector<int> fMode_VECT; + std::vector<int> fMode_VECT; std::vector<UInt_t> fIndex_VECT; InputUtils::InputType fInputType; std::string fInputFileName; MeasurementSpeciesClass fMeasurementSpeciesType; }; // Class TypeDefs typedef std::list<MeasurementBase*>::const_iterator MeasListConstIter; typedef std::list<MeasurementBase*>::iterator MeasListIter; typedef std::vector<MeasurementBase*>::const_iterator MeasVectConstIter; typedef std::vector<MeasurementBase*>::iterator MeasVectIter; /*! @} */ #endif diff --git a/src/FitBase/TemplateMeas1D.cxx b/src/FitBase/TemplateMeas1D.cxx index ffd5490..59dc348 100644 --- a/src/FitBase/TemplateMeas1D.cxx +++ b/src/FitBase/TemplateMeas1D.cxx @@ -1,222 +1,221 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "TemplateMeas1D.h" -//******************************************************************** +//******************************************************************** TemplateMeas1D::TemplateMeas1D(std::string name, std::string inputfile, - FitWeight *rw, std::string type){ -//******************************************************************** + FitWeight *rw, std::string type) { + //******************************************************************** - // Setup Main Measurement Details + // Setup Main Measurement Details fName = name; fPlotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"; - + // Setup Enu Limits. NUISANCE selects only events between this limit // when a flux integrals are calculated. EnuMin = 0.; EnuMax = 3.; // Set normalisation error for data. This will be used to add a penalty // if NORM is supplied in the type. - fNormError = 0.20; // 20% - + fNormError = 0.20; // 20% + // Setup allowed/default types - // These give the starting possible options that can be specified when making the class. - // Different discrete fields should be seperated by '/' and conflicting options - // should be seperated by ','. e.g. FIX, FREE, and SHAPE are conflicting types because - // they all handle the normalisation. NORM is an extra option to add a penalty term - // so should be kept seperate as below. We also want to force DIAG as there is no - // covariance so we put that as the starting default option so it will be set even if + // These give the starting possible options that can be specified when making + // the class. + // Different discrete fields should be seperated by '/' and conflicting + // options + // should be seperated by ','. e.g. FIX, FREE, and SHAPE are conflicting types + // because + // they all handle the normalisation. NORM is an extra option to add a penalty + // term + // so should be kept seperate as below. We also want to force DIAG as there is + // no + // covariance so we put that as the starting default option so it will be set + // even if // the user doesn't explicitly set it. fDefaultTypes = "FIX/DIAG"; fAllowedTypes = "FIX,FREE,SHAPE/DIAG/NORM"; - + // Multiple similar classes can be read by a single class. // e.g. MB numu CCQE or CC0pi. // The standard is to switch from the default by using fName. - fAnalysis = kTemplateMeas1D_CC0pi_Tmu; // Default Analysis - - if (fName == "TemplateMeas1D_CCQE_Q2"){ + fAnalysis = kTemplateMeas1D_CC0pi_Tmu; // Default Analysis + + if (fName == "TemplateMeas1D_CCQE_Q2") { fAnalysis = kTemplateMeas1D_CCQE_Q2; // Alternate Analysis } // Once all the options are set we setup the lower level event variables // !! This must go after all the settings above !! Measurement1D::SetupMeasurement(inputfile, type, rw, ""); - + // Setup a scaling factor once the measurement has been setup // !! This must go after SetupMeasurement !! // The scalefactor goes from rawevents -> xsec prediction. // First we scale the histograms to match the fEventHist prediction. // Here the data is saved as cm^2 / neutron, but we generate on a // CH2 target. We must then convert it by multiplying by (14.0/6.0). // Finally we divide by the integrated flux to get the cross-section. - fScaleFactor = ((fEventHist->Integral("width")*1E-38/(fNEvents+0.)) - * (14.0/6.0) - / TotalIntegratedFlux()); - - + fScaleFactor = + ((GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) * + (14.0 / 6.0) / TotalIntegratedFlux()); // After initial setup the constructor should setup the plots // according to what analysis has been stated. - if (fAnalysis == kTemplateMeas1D_CC0pi_Tmu){ - SetDataFromDatabase( "/Template/TemplateMeas1D_Data.root", - "Tmu_CC0pi_Data.root" ); + if (fAnalysis == kTemplateMeas1D_CC0pi_Tmu) { + SetDataFromDatabase("/Template/TemplateMeas1D_Data.root", + "Tmu_CC0pi_Data.root"); } else { - SetDataFromDatabase( "/Template/TemplateMeas1D_Data.root", - "Q2_CCQE_Data.root" ); + SetDataFromDatabase("/Template/TemplateMeas1D_Data.root", + "Q2_CCQE_Data.root"); } // NUISANCE uses the data histogram to setup all the default MC histograms // fMCHist,fMCFine,fMCStat,fMaskHist,fMCHist_PDG are all set here. // !! It must go after the data hist has been set !! SetupDefaultHist(); // Setup Covariance // Since its diagonal it is useful to setup a diagonal covariance matrix // for use in fake data study covariance throws. - // If a covariance IS provided it should be setup here. + // If a covariance IS provided it should be setup here. fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); - covar = StatUtils::GetInvert(fFullCovar); - - + covar = StatUtils::GetInvert(fFullCovar); // There will be cases where we want to save optional histograms // to help with validation/studies. They should be setup in the constructor. - // Here we also save a true Q2 plot split by interaction channels in CC0pi for one analysis - if (fAnalysis == kTemplateMeas1D_CC0pi_Tmu){ - + // Here we also save a true Q2 plot split by interaction channels in CC0pi for + // one analysis + if (fAnalysis == kTemplateMeas1D_CC0pi_Tmu) { // Create basic plot - fMCHist_ExtraQ2Plot = new TH1D( (fName + "_MC_Q2").c_str(), - (fName + "_MC_Q2;" - "Q^{2}_{QE} (GeV^2);d#sigma/dQ^{2}_{QE} (cm^{2}/GeV^{2})").c_str(), - 20, 0.0, 3.0 ); + fMCHist_ExtraQ2Plot = new TH1D( + (fName + "_MC_Q2").c_str(), + (fName + "_MC_Q2;" + "Q^{2}_{QE} (GeV^2);d#sigma/dQ^{2}_{QE} (cm^{2}/GeV^{2})") + .c_str(), + 20, 0.0, 3.0); // Create Channel Plot // fMCHist_ExtraQ2Plot_PDG = NULL; } - - }; -//******************************************************************** +//******************************************************************** /// @details Extract q2qe(fXVar) from the event -void TemplateMeas1D::FillEventVariables(FitEvent *event){ -//******************************************************************** - +void TemplateMeas1D::FillEventVariables(FitEvent *event) { + //******************************************************************** + // Init double q2qe = -999.9; // Loop over the particle stack - for (UInt_t j = 2; j < event->Npart(); ++j){ - + for (UInt_t j = 2; j < event->Npart(); ++j) { int PID = abs((event->PartInfo(j))->fPID); if (!event->PartInfo(j)->fIsAlive) continue; - - if (PID != 13 and !ccqelike) continue; + + if (PID != 13 and !ccqelike) continue; if (abs(PID) != 13 and ccqelike) continue; - - // Now find the Q2QE value and fill the histogram - q2qe = FitUtils::Q2QErec((event->PartInfo(j))->fP, - cos(((event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect()))), - 34., true); - - break; + + // Now find the Q2QE value and fill the histogram + q2qe = FitUtils::Q2QErec((event->PartInfo(j))->fP, + cos(((event->PartInfo(0)) + ->fP.Vect() + .Angle((event->PartInfo(j))->fP.Vect()))), + 34., true); + + break; } // Set X Variables fXVar = q2qe; - + return; }; -//******************************************************************** -bool TemplateMeas1D::isSignal(FitEvent *event){ -//******************************************************************** +//******************************************************************** +bool TemplateMeas1D::isSignal(FitEvent *event) { + //******************************************************************** // 2 Different Signal Definitions - //if (ccqelike) return SignalDef::isCCQELike(event, 14, EnuMin, EnuMax); + // if (ccqelike) return SignalDef::isCCQELike(event, 14, EnuMin, EnuMax); // else return SignalDef::isCCQE(event, 14, EnuMin, EnuMax); return true; }; -//******************************************************************** +//******************************************************************** /// @details Fills a ccqe-like background plot if required -void TemplateMeas1D::FillHistograms(){ -//******************************************************************** +void TemplateMeas1D::FillHistograms() { + //******************************************************************** Measurement1D::FillHistograms(); // if (Mode != 1 and Mode != 2 and ccqelike and Signal){ // PlotUtils::FillNeutModeArray(fMCHist_CCQELIKE, Mode, fXVar, Weight); // } } - -//******************************************************************** +//******************************************************************** /// @details Extra write command to save the CCQELike PDG if required -void TemplateMeas1D::Write(std::string drawOpt){ -//******************************************************************** +void TemplateMeas1D::Write(std::string drawOpt) { + //******************************************************************** Measurement1D::Write(drawOpt); /* if (ccqelike){ fDataHist_CCQELIKE->Write(); - - THStack combo_fMCHist_CCQELIKE = PlotUtils::GetNeutModeStack((this->fName + "_MC_CCQELIKE").c_str(), (TH1**)this->fMCHist_CCQELIKE, 0); + + THStack combo_fMCHist_CCQELIKE = PlotUtils::GetNeutModeStack((this->fName + + "_MC_CCQELIKE").c_str(), (TH1**)this->fMCHist_CCQELIKE, 0); combo_fMCHist_CCQELIKE.Write(); } */ - } - -//******************************************************************** -void TemplateMeas1D::ResetAll(){ -//******************************************************************** +//******************************************************************** +void TemplateMeas1D::ResetAll() { + //******************************************************************** Measurement1D::ResetAll(); - -// if (ccqelike) - // PlotUtils::ResetNeutModeArray((TH1**)fMCHist_CCQELIKE); - + + // if (ccqelike) + // PlotUtils::ResetNeutModeArray((TH1**)fMCHist_CCQELIKE); } -//******************************************************************** -void TemplateMeas1D::ScaleEvents(){ -//******************************************************************** +//******************************************************************** +void TemplateMeas1D::ScaleEvents() { + //******************************************************************** Measurement1D::ScaleEvents(); // if (ccqelike) - // PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_CCQELIKE, fScaleFactor,"width"); - + // PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_CCQELIKE, + // fScaleFactor,"width"); } - -//******************************************************************** -void TemplateMeas1D::ApplyNormScale(double norm){ -//******************************************************************** +//******************************************************************** +void TemplateMeas1D::ApplyNormScale(double norm) { + //******************************************************************** Measurement1D::ApplyNormScale(norm); // if (ccqelike) - // PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_CCQELIKE, 1.0/norm, ""); + // PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_CCQELIKE, 1.0/norm, ""); } diff --git a/src/GGM/GGM_CC1ppip_Evt_1DQ2_nu.cxx b/src/GGM/GGM_CC1ppip_Evt_1DQ2_nu.cxx index aaf7cbc..7fffd5f 100644 --- a/src/GGM/GGM_CC1ppip_Evt_1DQ2_nu.cxx +++ b/src/GGM/GGM_CC1ppip_Evt_1DQ2_nu.cxx @@ -1,74 +1,74 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "GGM_CC1ppip_Evt_1DQ2_nu.h" // The constructor GGM_CC1ppip_Evt_1DQ2_nu::GGM_CC1ppip_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "GGM_CC1ppip_Evt_1DQ2_nu"; // could replace with fName = std::string(__FILE__).substr(0, std::string(__FILE__).find_last_of(".")) fPlotTitles = "; Q^{2}_{CC1#pi} (GeV^{2}); Number of events"; EnuMin = 1; EnuMax = 10; fIsDiag = true; fIsRawEvents = true; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/GGM/CC1pip_on_p/GGM_CC1ppip_Q2_events_bin_edit.txt"); this->SetupDefaultHist(); // set Poisson errors on fDataHist (scanned does not have this) // Simple counting experiment here for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i+1, sqrt(fDataHist->GetBinContent(i+1))); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents+0.)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents+0.)*(16./8.); }; void GGM_CC1ppip_Evt_1DQ2_nu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::MpPi(Pp, Ppip); double q2CCpip = -1.0; // GGM has a M(pi, p) < 1.4 GeV cut imposed only on this channel if (hadMass < 1400) q2CCpip = -1*(Pnu-Pmu).Mag2()/1.E6; fXVar = q2CCpip; return; } bool GGM_CC1ppip_Evt_1DQ2_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } diff --git a/src/GGM/GGM_CC1ppip_XSec_1DEnu_nu.cxx b/src/GGM/GGM_CC1ppip_XSec_1DEnu_nu.cxx index cc550c8..764b052 100644 --- a/src/GGM/GGM_CC1ppip_XSec_1DEnu_nu.cxx +++ b/src/GGM/GGM_CC1ppip_XSec_1DEnu_nu.cxx @@ -1,68 +1,68 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "GGM_CC1ppip_XSec_1DEnu_nu.h" // The constructor GGM_CC1ppip_XSec_1DEnu_nu::GGM_CC1ppip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "GGM_CC1ppip_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/proton)"; EnuMin = 1.; EnuMax = 10.0; fIsDiag = true; fNormError = 0.20; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/GGM/CC1pip_on_p/Gargamelle78-numu-p-to-mu-p-piplus-lowW_EDGES.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(16./8.); }; void GGM_CC1ppip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; // should probably put in a weight here! double hadMass = FitUtils::MpPi(Pp, Ppip); double Enu = -1.0; if (hadMass < 1400) Enu = Pnu.E()/1.E3; fXVar = Enu; return; } bool GGM_CC1ppip_XSec_1DEnu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212,EnuMin,EnuMax); } diff --git a/src/MCStudies/ExpMultDist_CCQE_XSec_1DVar_FakeStudy.cxx b/src/MCStudies/ExpMultDist_CCQE_XSec_1DVar_FakeStudy.cxx index b5c463a..4b635f5 100644 --- a/src/MCStudies/ExpMultDist_CCQE_XSec_1DVar_FakeStudy.cxx +++ b/src/MCStudies/ExpMultDist_CCQE_XSec_1DVar_FakeStudy.cxx @@ -1,153 +1,153 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "ExpMultDist_CCQE_XSec_1DVar_FakeStudy.h" -//******************************************************************** +//******************************************************************** /// @brief Class to perform CCQE Fake Data Studies on a custom measurement ExpMultDist_CCQE_XSec_1DVar_FakeStudy::ExpMultDist_CCQE_XSec_1DVar_FakeStudy(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ -//******************************************************************** - +//******************************************************************** + // Measurement Details fName = name; // Define our energy range for flux calcs EnuMin = 0.; EnuMax = 6.; // Set default fitter flags fIsDiag = true; fIsShape = false; fIsRawEvents = false; // This function will sort out the input files automatically and parse all the inputs,flags,etc. // There may be complex cases where you have to do this by hand, but usually this will do. - Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); + Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); + - // Use the name to define what variable to measure int nbins; double binlow, binhigh; if (name.find("1DQ2") != std::string::npos){ plottype = 1; fPlotTitles = ""; nbins = 30; binlow = 0.0; binhigh = 2.0; } else if (name.find("1DTmu") != std::string::npos){ plottype = 2; fPlotTitles = ""; nbins = 20; binlow = 0.0; binhigh = 3.0; } else if (name.find("1DCos") != std::string::npos){ plottype = 3; fPlotTitles = ""; - nbins = 10; binlow = -1.0; binhigh = 1.0; + nbins = 10; binlow = -1.0; binhigh = 1.0; } - + // Setup the datahist as empty, we will use fake data to fill it. this->fDataHist = new TH1D((fName + "_data").c_str(), (fName + "_data" + fPlotTitles).c_str(), nbins, binlow, binhigh); - + // Once fDataHist is setup this function will automatically generate matching MC histograms this->SetupDefaultHist(); - + // Setup Covariance assuming a diagonal covar. // If you want a full covariance to be used examples are given in the MINERvA 1D classes fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); - + // 3. The generator is organised in SetupMeasurement so it gives the cross-section in "per nucleon" units. // So some extra scaling for a specific measurement may be required. For Example to get a "per neutron" measurement on carbon // which we do here, we have to multiple by the number of nucleons 12 and divide by the number of neutrons 6. - this->fScaleFactor = (this->fEventHist->Integral()*1E-38/(fNEvents+0.)) * (12.0 / 6.0) /this->TotalIntegratedFlux(); + this->fScaleFactor = (GetEventHistogram()->Integral()*1E-38/(fNEvents+0.)) * (12.0 / 6.0) /this->TotalIntegratedFlux(); }; -//******************************************************************** +//******************************************************************** /// @details Extract Enu and totcrs from event assuming quasi-elastic scattering void ExpMultDist_CCQE_XSec_1DVar_FakeStudy::FillEventVariables(FitEvent *event){ -//******************************************************************** +//******************************************************************** // MUST be defined for each new sample. // This function reads in the FitEvent format and lets you grab any information you need // from the event. This function is only called during the first and last iteration of each fit so that // a vector of fXVar variables can be filled for the signal events. // Define empty variables fXVar = -1.0; double q2qe = 0.0; double CosThetaMu = -2.0; double TMu = 0.0; - + // Loop over the particle stack for (UInt_t j = 2; j < event->Npart(); ++j){ - + // Look for the outgoing muon if ((event->PartInfo(j))->fPID != 13) continue; // Define any variables we may need ThetaMu = (event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect()); Enu_rec = FitUtils::EnuQErec((event->PartInfo(j))->fP, cos(ThetaMu), 0.,true); q2qe = FitUtils::Q2QErec( (event->PartInfo(j))->fP, cos(ThetaMu), 0.,true); CosThetaMu = cos(ThetaMu); TMu = FitUtils::T((event->PartInfo(j))->fP); - + // Once lepton is found, don't continue the loop - break; + break; } if (this->plottype == 1) fXVar = q2qe; else if (this->plottype == 2) fXVar = TMu; else if (this->plottype == 3) fXVar = CosThetaMu; - + return; }; -//******************************************************************** +//******************************************************************** /// @details Signal is true CCQE scattering /// /// @details Cut 1: numu event /// @details Cut 2: Mode == 1 /// @details Cut 3: EnuMin < Enu < EnuMax bool ExpMultDist_CCQE_XSec_1DVar_FakeStudy::isSignal(FitEvent *event){ -//******************************************************************** +//******************************************************************** // Place cuts on each of the events here. // MUST be defined for all new samples, there is no default signal definition. // Check FitUtils and CutUtils for example cuts that can be used quickly. // During a fit isSignal is only used in the first fit function call to define // which of the events actually need to be considered, so don't worry too much if // this function is inefficient. // Mode and Enu are automatically avaialble in this function, they don't need to be set earlier. - + // Only look at numu events if ((event->PartInfo(0))->fPID != 14) return false; // Only look at CCQE Events and MEC Events if (Mode != 1 and Mode != 2) return false; - + // Restrict energy range if (Enu < this->EnuMin || Enu > this->EnuMax) return false; return true; }; diff --git a/src/MCStudies/ExpMultDist_CCQE_XSec_2DVar_FakeStudy.cxx b/src/MCStudies/ExpMultDist_CCQE_XSec_2DVar_FakeStudy.cxx index a5e0429..0fbb341 100644 --- a/src/MCStudies/ExpMultDist_CCQE_XSec_2DVar_FakeStudy.cxx +++ b/src/MCStudies/ExpMultDist_CCQE_XSec_2DVar_FakeStudy.cxx @@ -1,169 +1,169 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "ExpMultDist_CCQE_XSec_2DVar_FakeStudy.h" -//******************************************************************** +//******************************************************************** /// @brief Class to perform CCQE Fake Data Studies on a custom measurement ExpMultDist_CCQE_XSec_2DVar_FakeStudy::ExpMultDist_CCQE_XSec_2DVar_FakeStudy(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ -//******************************************************************** - +//******************************************************************** + // Measurement Details fName = name; // Define our energy range for flux calcs EnuMin = 0.; EnuMax = 6.; // Set default fitter flags fIsDiag = true; fIsShape = false; fIsRawEvents = false; // This function will sort out the input files automatically and parse all the inputs,flags,etc. // There may be complex cases where you have to do this by hand, but usually this will do. - Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile); + Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // Use the name to define what variable to measure int nbinsx, nbinsy; double binlowx, binhighx; double binlowy, binhighy; if (name.find("Q2vsTmu") != std::string::npos){ plottype = 1; fPlotTitles = ""; nbinsx = 30; binlowx = 0.0; binhighx = 2.0; nbinsy = 20; binlowy = 0.0; binhighy = 3.0; } else if (name.find("Q2vsCos") != std::string::npos){ plottype = 2; fPlotTitles = ""; nbinsx = 30; binlowx = 0.0;binhighx = 2.0; nbinsy = 10; binlowy = -1.0; binhighy = 1.0; } else if (name.find("TmuvsCos") != std::string::npos){ plottype = 3; fPlotTitles = ""; nbinsx = 20; binlowx = 0.0; binhighx = 3.0; nbinsy = 10; binlowy = -1.0; binhighy = 1.0; } - + // Setup the datahist as empty, we will use fake data to fill it. this->fDataHist = new TH2D((fName + "_data").c_str(), (fName + "_data" + fPlotTitles).c_str(), nbinsx, binlowx, binhighx, nbinsy, binlowy, binhighy); - + // Once fDataHist is setup this function will automatically generate matching MC histograms this->SetupDefaultHist(); double threshold = 10.0; for (int i = 0; i < this->fDataHist->GetNbinsX(); i++){ for (int j = 0; j < this->fDataHist->GetNbinsY(); j++){ if (fDataHist->GetBinContent(i+1,j+1) <= threshold){ fDataHist->SetBinError(i+1,j+1, 0.0); fDataHist->SetBinContent(i+1,j+1, 0.0); } } } - + // Setup Covariance assuming a diagonal covar. // If you want a full covariance to be used examples are given in the MINERvA 2D classes //fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); // covar = StatUtils::GetInvert(fFullCovar); - + // 3. The generator is organised in SetupMeasurement so it gives the cross-section in "per nucleon" units. // So some extra scaling for a specific measurement may be required. For Example to get a "per neutron" measurement on carbon // which we do here, we have to multiple by the number of nucleons 12 and divide by the number of neutrons 6. - this->fScaleFactor = (this->fEventHist->Integral()*1E-38/(fNEvents+0.)) * (12.0 / 6.0) /this->TotalIntegratedFlux(); + this->fScaleFactor = (GetEventHistogram()->Integral()*1E-38/(fNEvents+0.)) * (12.0 / 6.0) /this->TotalIntegratedFlux(); }; -//******************************************************************** +//******************************************************************** /// @details Extract Enu and totcrs from event assuming quasi-elastic scattering void ExpMultDist_CCQE_XSec_2DVar_FakeStudy::FillEventVariables(FitEvent *event){ -//******************************************************************** +//******************************************************************** // MUST be defined for each new sample. // This function reads in the FitEvent format and lets you grab any information you need // from the event. This function is only called during the first and last iteration of each fit so that // a vector of fXVar variables can be filled for the signal events. // Define empty variables fXVar = -1.0; fYVar = -1.0; - + double q2qe = 0.0; double CosThetaMu = -2.0; double TMu = 0.0; - + // Loop over the particle stack for (UInt_t j = 2; j < event->Npart(); ++j){ - + // Look for the outgoing muon if ((event->PartInfo(j))->fPID != 13) continue; // Define any variables we may need ThetaMu = (event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect()); Enu_rec = FitUtils::EnuQErec((event->PartInfo(j))->fP, cos(ThetaMu), 0.,true); q2qe = FitUtils::Q2QErec( (event->PartInfo(j))->fP, cos(ThetaMu), 0.,true); CosThetaMu = cos(ThetaMu); TMu = FitUtils::T((event->PartInfo(j))->fP); - + // Once lepton is found, don't continue the loop - break; + break; } if (this->plottype == 1) {fXVar = q2qe; fYVar = TMu;} else if (this->plottype == 2) {fXVar = q2qe; fXVar = CosThetaMu;} else if (this->plottype == 3) {fXVar = TMu; fYVar = CosThetaMu;} - + return; }; -//******************************************************************** +//******************************************************************** /// @details Signal is true CCQE scattering /// /// @details Cut 1: numu event /// @details Cut 2: Mode == 1 /// @details Cut 3: EnuMin < Enu < EnuMax bool ExpMultDist_CCQE_XSec_2DVar_FakeStudy::isSignal(FitEvent *event){ -//******************************************************************** +//******************************************************************** // Place cuts on each of the events here. // MUST be defined for all new samples, there is no default signal definition. // Check FitUtils and CutUtils for example cuts that can be used quickly. // During a fit isSignal is only used in the first fit function call to define // which of the events actually need to be considered, so don't worry too much if // this function is inefficient. // Mode and Enu are automatically avaialble in this function, they don't need to be set earlier. - + // Only look at numu events if ((event->PartInfo(0))->fPID != 14) return false; // Only look at CCQE Events and MEC Events if (Mode != 1 and Mode != 2) return false; - + // Restrict energy range if (Enu < this->EnuMin || Enu > this->EnuMax) return false; return true; }; diff --git a/src/MCStudies/GenericFlux_Tester.cxx b/src/MCStudies/GenericFlux_Tester.cxx index 5462b82..17bf2f1 100644 --- a/src/MCStudies/GenericFlux_Tester.cxx +++ b/src/MCStudies/GenericFlux_Tester.cxx @@ -1,555 +1,555 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "GenericFlux_Tester.h" //******************************************************************** /// @brief Class to perform MC Studies on a custom measurement GenericFlux_Tester::GenericFlux_Tester(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { //******************************************************************** // Measurement Details fName = name; eventVariables = NULL; // Define our energy range for flux calcs EnuMin = 0.; EnuMax = 100.; // Arbritrarily high energy limit // Set default fitter flags fIsDiag = true; fIsShape = false; fIsRawEvents = false; nu_4mom = new TLorentzVector(0, 0, 0, 0); - pmu = new TLorentzVector(0, 0, 0, 0); - ppip = new TLorentzVector(0, 0, 0, 0); - ppim = new TLorentzVector(0, 0, 0, 0); - ppi0 = new TLorentzVector(0, 0, 0, 0); - pprot = new TLorentzVector(0, 0, 0, 0); - pneut = new TLorentzVector(0, 0, 0, 0); + pmu = new TLorentzVector(0, 0, 0, 0); + ppip = new TLorentzVector(0, 0, 0, 0); + ppim = new TLorentzVector(0, 0, 0, 0); + ppi0 = new TLorentzVector(0, 0, 0, 0); + pprot = new TLorentzVector(0, 0, 0, 0); + pneut = new TLorentzVector(0, 0, 0, 0); // This function will sort out the input files automatically and parse all the // inputs,flags,etc. // There may be complex cases where you have to do this by hand, but usually // this will do. Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); eventVariables = NULL; liteMode = FitPar::Config().GetParB("isLiteMode"); // Setup fDataHist as a placeholder this->fDataHist = new TH1D(("empty_data"), ("empty-data"), 1, 0, 1); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // 1. The generator is organised in SetupMeasurement so it gives the // cross-section in "per nucleon" units. // So some extra scaling for a specific measurement may be required. For // Example to get a "per neutron" measurement on carbon // which we do here, we have to multiple by the number of nucleons 12 and // divide by the number of neutrons 6. - this->fScaleFactor = (this->fEventHist->Integral("width") * 1E-38 / (fNEvents + 0.)) / - this->TotalIntegratedFlux(); + this->fScaleFactor = + (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / + this->TotalIntegratedFlux(); - LOG(SAM) << " Generic Flux Scaling Factor = "<< fScaleFactor << endl; + LOG(SAM) << " Generic Flux Scaling Factor = " << fScaleFactor << endl; - if (fScaleFactor <= 0.0){ + if (fScaleFactor <= 0.0) { ERR(WRN) << "SCALE FACTOR TOO LOW " << std::endl; sleep(20); } // Setup our TTrees this->AddEventVariablesToTree(); this->AddSignalFlagsToTree(); } void GenericFlux_Tester::AddEventVariablesToTree() { // Setup the TTree to save everything if (!eventVariables) { FitPar::Config().out->cd(); eventVariables = new TTree((this->fName + "_VARS").c_str(), (this->fName + "_VARS").c_str()); } LOG(SAM) << "Adding Event Variables" << endl; eventVariables->Branch("Mode", &Mode, "Mode/I"); eventVariables->Branch("PDGnu", &PDGnu, "PDGnu/I"); eventVariables->Branch("Enu_true", &Enu_true, "Enu_true/F"); eventVariables->Branch("Nleptons", &Nleptons, "Nleptons/I"); eventVariables->Branch("MLep", &MLep, "MLep/F"); eventVariables->Branch("ELep", &ELep, "ELep/F"); eventVariables->Branch("TLep", &TLep, "TLep/F"); eventVariables->Branch("CosLep", &CosLep, "CosLep/F"); eventVariables->Branch("CosPmuPpip", &CosPmuPpip, "CosPmuPpip/F"); eventVariables->Branch("CosPmuPpim", &CosPmuPpim, "CosPmuPpim/F"); eventVariables->Branch("CosPmuPpi0", &CosPmuPpi0, "CosPmuPpi0/F"); eventVariables->Branch("CosPmuPprot", &CosPmuPprot, "CosPmuPprot/F"); eventVariables->Branch("CosPmuPneut", &CosPmuPneut, "CosPmuPneut/F"); eventVariables->Branch("Nprotons", &Nprotons, "Nprotons/I"); eventVariables->Branch("MPr", &MPr, "MPr/F"); eventVariables->Branch("EPr", &EPr, "EPr/F"); eventVariables->Branch("TPr", &TPr, "TPr/F"); eventVariables->Branch("CosPr", &CosPr, "CosPr/F"); eventVariables->Branch("CosPprotPneut", &CosPprotPneut, "CosPprotPneut/F"); eventVariables->Branch("Nneutrons", &Nneutrons, "Nneutrons/I"); eventVariables->Branch("MNe", &MNe, "MNe/F"); eventVariables->Branch("ENe", &ENe, "ENe/F"); eventVariables->Branch("TNe", &TNe, "TNe/F"); eventVariables->Branch("CosNe", &CosNe, "CosNe/F"); eventVariables->Branch("Npiplus", &Npiplus, "Npiplus/I"); eventVariables->Branch("MPiP", &MPiP, "MPiP/F"); eventVariables->Branch("EPiP", &EPiP, "EPiP/F"); eventVariables->Branch("TPiP", &TPiP, "TPiP/F"); eventVariables->Branch("CosPiP", &CosPiP, "CosPiP/F"); eventVariables->Branch("CosPpipPprot", &CosPpipPprot, "CosPpipProt/F"); eventVariables->Branch("CosPpipPneut", &CosPpipPneut, "CosPpipPneut/F"); eventVariables->Branch("CosPpipPpim", &CosPpipPpim, "CosPpipPpim/F"); eventVariables->Branch("CosPpipPpi0", &CosPpipPpi0, "CosPpipPpi0/F"); eventVariables->Branch("Npineg", &Npineg, "Npineg/I"); eventVariables->Branch("MPiN", &MPiN, "MPiN/F"); eventVariables->Branch("EPiN", &EPiN, "EPiN/F"); eventVariables->Branch("TPiN", &TPiN, "TPiN/F"); eventVariables->Branch("CosPiN", &CosPiN, "CosPiN/F"); eventVariables->Branch("CosPpimPprot", &CosPpimPprot, "CosPpimPprot/F"); eventVariables->Branch("CosPpimPneut", &CosPpimPneut, "CosPpimPneut/F"); eventVariables->Branch("CosPpimPpi0", &CosPpimPpi0, "CosPpimPpi0/F"); eventVariables->Branch("Npi0", &Npi0, "Npi0/I"); eventVariables->Branch("MPi0", &MPi0, "MPi0/F"); eventVariables->Branch("EPi0", &EPi0, "EPi0/F"); eventVariables->Branch("TPi0", &TPi0, "TPi0/F"); eventVariables->Branch("CosPi0", &CosPi0, "CosPi0/F"); eventVariables->Branch("CosPi0Pprot", &CosPi0Pprot, "CosPi0Pprot/F"); eventVariables->Branch("CosPi0Pneut", &CosPi0Pneut, "CosPi0Pneut/F"); eventVariables->Branch("Q2_true", &Q2_true, "Q2_true/F"); eventVariables->Branch("q0_true", &q0_true, "q0_true/F"); eventVariables->Branch("q3_true", &q3_true, "q3_true/F"); eventVariables->Branch("Enu_QE", &Enu_QE, "Enu_QE/F"); eventVariables->Branch("Q2_QE", &Q2_QE, "Q2_QE/F"); eventVariables->Branch("W_nuc_rest", &W_nuc_rest, "W_nuc_rest/F"); eventVariables->Branch("bjorken_x", &bjorken_x, "bjorken_x/F"); eventVariables->Branch("bjorken_y", &bjorken_y, "bjorken_y/F"); eventVariables->Branch("Erecoil_true", &Erecoil_true, "Erecoil_true/F"); eventVariables->Branch("Erecoil_charged", &Erecoil_charged, "Erecoil_charged/F"); eventVariables->Branch("Erecoil_minerva", &Erecoil_minerva, "Erecoil_minerva/F"); - if (!liteMode){ + if (!liteMode) { eventVariables->Branch("nu_4mom", &nu_4mom); eventVariables->Branch("pmu_4mom", &pmu); eventVariables->Branch("hm_ppip_4mom", &ppip); eventVariables->Branch("hm_ppim_4mom", &ppim); eventVariables->Branch("hm_ppi0_4mom", &ppi0); eventVariables->Branch("hm_pprot_4mom", &pprot); eventVariables->Branch("hm_pneut_4mom", &pneut); } // Event Scaling Information eventVariables->Branch("Weight", &Weight, "Weight/F"); eventVariables->Branch("InputWeight", &InputWeight, "InputWeight/F"); eventVariables->Branch("RWWeight", &RWWeight, "RWWeight/F"); eventVariables->Branch("FluxWeight", &FluxWeight, "FluxWeight/F"); eventVariables->Branch("fScaleFactor", &fScaleFactor, "fScaleFactor/D"); return; } void GenericFlux_Tester::AddSignalFlagsToTree() { if (!eventVariables) { FitPar::Config().out->cd(); eventVariables = new TTree((this->fName + "_VARS").c_str(), (this->fName + "_VARS").c_str()); } LOG(SAM) << "Adding Samples" << endl; // Signal Definitions from SignalDef.cxx - eventVariables->Branch("flagCCINC", &flagCCINC, "flagCCINC/O"); - eventVariables->Branch("flagNCINC", &flagNCINC, "flagNCINC/O"); - eventVariables->Branch("flagCCQE", &flagCCQE, "flagCCQE/O"); - eventVariables->Branch("flagCC0pi", &flagCC0pi,"flagCC0pi/O"); - eventVariables->Branch("flagCCQELike", &flagCCQELike,"flagCCQELike/O"); - eventVariables->Branch("flagNCEL", &flagNCEL, "flagNCEL/O"); - eventVariables->Branch("flagNC0pi", &flagNC0pi,"flagNC0pi/O"); - eventVariables->Branch("flagCCcoh", &flagCCcoh, "flagCCcoh/O"); - eventVariables->Branch("flagNCcoh", &flagNCcoh, "flagNCcoh/O"); - eventVariables->Branch("flagCC1pip", &flagCC1pip,"flagCC1pip/O"); - eventVariables->Branch("flagNC1pip", &flagNC1pip,"flagNC1pip/O"); - eventVariables->Branch("flagCC1pim", &flagCC1pim,"flagCC1pim/O"); - eventVariables->Branch("flagNC1pim", &flagNC1pim,"flagNC1pim/O"); - eventVariables->Branch("flagCC1pi0", &flagCC1pi0,"flagCC1pi0/O"); - eventVariables->Branch("flagNC1pi0", &flagNC1pi0,"flagNC1pi0/O"); - - + eventVariables->Branch("flagCCINC", &flagCCINC, "flagCCINC/O"); + eventVariables->Branch("flagNCINC", &flagNCINC, "flagNCINC/O"); + eventVariables->Branch("flagCCQE", &flagCCQE, "flagCCQE/O"); + eventVariables->Branch("flagCC0pi", &flagCC0pi, "flagCC0pi/O"); + eventVariables->Branch("flagCCQELike", &flagCCQELike, "flagCCQELike/O"); + eventVariables->Branch("flagNCEL", &flagNCEL, "flagNCEL/O"); + eventVariables->Branch("flagNC0pi", &flagNC0pi, "flagNC0pi/O"); + eventVariables->Branch("flagCCcoh", &flagCCcoh, "flagCCcoh/O"); + eventVariables->Branch("flagNCcoh", &flagNCcoh, "flagNCcoh/O"); + eventVariables->Branch("flagCC1pip", &flagCC1pip, "flagCC1pip/O"); + eventVariables->Branch("flagNC1pip", &flagNC1pip, "flagNC1pip/O"); + eventVariables->Branch("flagCC1pim", &flagCC1pim, "flagCC1pim/O"); + eventVariables->Branch("flagNC1pim", &flagNC1pim, "flagNC1pim/O"); + eventVariables->Branch("flagCC1pi0", &flagCC1pi0, "flagCC1pi0/O"); + eventVariables->Branch("flagNC1pi0", &flagNC1pi0, "flagNC1pi0/O"); }; //******************************************************************** void GenericFlux_Tester::FillEventVariables(FitEvent *event) { //******************************************************************** // Fill Signal Variables FillSignalFlags(event); - LOG(DEB)<<"Filling signal"<<std::endl; + LOG(DEB) << "Filling signal" << std::endl; // Function used to extract any variables of interest to the event Mode = event->Mode; Nleptons = 0; Nparticles = 0; PDGnu = 0; PDGLep = 0; Enu_true = Enu_QE = Q2_true = Q2_QE = TLep = TPr = TNe = TPiP = TPiN = TPi0 = -999.9; Nprotons = 0; PPr = EPr = MPr = CosPr = -999.9; Nneutrons = 0; PNe = ENe = MNe = CosNe = -999.9; Npiplus = 0; PPiP = EPiP = MPiP = CosPiP = -999.9; Npineg = 0; PPiN = EPiN = MPiN = CosPiN = -999.9; Npi0 = 0; PPi0 = EPi0 = MPi0 = CosPi0 = -999.9; // All of the angles Clarence added CosPmuPpip = CosPmuPpim = CosPmuPpi0 = CosPmuPprot = CosPmuPneut = CosPpipPprot = CosPpipPneut = CosPpipPpim = CosPpipPpi0 = CosPpimPprot = CosPpimPneut = CosPpimPpi0 = CosPi0Pprot = CosPi0Pneut = CosPprotPneut = -999.9; float proton_highmom = -999.9; float neutron_highmom = -999.9; float piplus_highmom = -999.9; float pineg_highmom = -999.9; float pi0_highmom = -999.9; (*nu_4mom) = event->PartInfo(0)->fP; - - if (!liteMode){ - (*pmu) = TLorentzVector(0, 0, 0, 0); - (*ppip) = TLorentzVector(0, 0, 0, 0); - (*ppim) = TLorentzVector(0, 0, 0, 0); - (*ppi0) = TLorentzVector(0, 0, 0, 0); + + if (!liteMode) { + (*pmu) = TLorentzVector(0, 0, 0, 0); + (*ppip) = TLorentzVector(0, 0, 0, 0); + (*ppim) = TLorentzVector(0, 0, 0, 0); + (*ppi0) = TLorentzVector(0, 0, 0, 0); (*pprot) = TLorentzVector(0, 0, 0, 0); (*pneut) = TLorentzVector(0, 0, 0, 0); } Enu_true = nu_4mom->E(); PDGnu = event->PartInfo(0)->fPID; bool cc = (abs(event->Mode) < 30); (void)cc; // Add all pion distributions for the event. // Add classifier for CC0pi or CC1pi or CCOther // Save Modes Properly // Save low recoil measurements // Start Particle Loop UInt_t npart = event->Npart(); for (UInt_t i = 0; i < npart; i++) { // Skip particles that weren't in the final state bool part_alive = event->PartInfo(i)->fIsAlive; if (!part_alive) continue; // PDG Particle int PDGpart = event->PartInfo(i)->fPID; TLorentzVector part_4mom = event->PartInfo(i)->fP; Nparticles++; // Get Charged Lepton if (abs(PDGpart) == abs(PDGnu) - 1) { Nleptons++; PDGLep = PDGpart; TLep = FitUtils::T(part_4mom) * 1000.0; PLep = (part_4mom.Vect().Mag()); ELep = (part_4mom.E()); MLep = (part_4mom.Mag()); CosLep = cos(part_4mom.Vect().Angle(nu_4mom->Vect())); pmu = &part_4mom; Q2_true = -1 * (part_4mom - (*nu_4mom)).Mag2(); float ThetaLep = (event->PartInfo(0)) ->fP.Vect() .Angle((event->PartInfo(i))->fP.Vect()); q0_true = (part_4mom - (*nu_4mom)).E(); q3_true = (part_4mom - (*nu_4mom)).Vect().Mag(); // Get W_true with assumption of initial state nucleon at rest - float m_n = (float)PhysConst::mass_proton*1000.; + float m_n = (float)PhysConst::mass_proton * 1000.; W_nuc_rest = sqrt(-Q2_true + 2 * m_n * (Enu_true - ELep) + m_n * m_n); // Get the Bjorken x and y variables // Assume that E_had = Enu - Emu as in MINERvA bjorken_x = Q2_true / (2 * m_n * (Enu_true - ELep)); bjorken_y = 1 - ELep / Enu_true; // Quasi-elastic ---------------------- // ------------------------------------ // Q2 QE Assuming Carbon Input. Should change this to be dynamic soon. Q2_QE = FitUtils::Q2QErec(part_4mom, cos(ThetaLep), 34., true) * 1000000.0; Enu_QE = FitUtils::EnuQErec(part_4mom, cos(ThetaLep), 34., true) * 1000.0; // Pion Production ---------------------- // -------------------------------------- } else if (PDGpart == 2212) { Nprotons++; if (part_4mom.Vect().Mag() > proton_highmom) { proton_highmom = part_4mom.Vect().Mag(); PPr = (part_4mom.Vect().Mag()); EPr = (part_4mom.E()); TPr = FitUtils::T(part_4mom) * 1000.; MPr = (part_4mom.Mag()); CosPr = cos(part_4mom.Vect().Angle(nu_4mom->Vect())); (*pprot) = part_4mom; } } else if (PDGpart == 2112) { Nneutrons++; if (part_4mom.Vect().Mag() > neutron_highmom) { neutron_highmom = part_4mom.Vect().Mag(); PNe = (part_4mom.Vect().Mag()); ENe = (part_4mom.E()); TNe = FitUtils::T(part_4mom) * 1000.; MNe = (part_4mom.Mag()); CosNe = cos(part_4mom.Vect().Angle(nu_4mom->Vect())); (*pneut) = part_4mom; } } else if (PDGpart == 211) { Npiplus++; if (part_4mom.Vect().Mag() > piplus_highmom) { piplus_highmom = part_4mom.Vect().Mag(); PPiP = (part_4mom.Vect().Mag()); EPiP = (part_4mom.E()); TPiP = FitUtils::T(part_4mom) * 1000.; MPiP = (part_4mom.Mag()); CosPiP = cos(part_4mom.Vect().Angle(nu_4mom->Vect())); (*ppip) = part_4mom; } } else if (PDGpart == -211) { Npineg++; if (part_4mom.Vect().Mag() > pineg_highmom) { pineg_highmom = part_4mom.Vect().Mag(); PPiN = (part_4mom.Vect().Mag()); EPiN = (part_4mom.E()); TPiN = FitUtils::T(part_4mom) * 1000.; MPiN = (part_4mom.Mag()); CosPiN = cos(part_4mom.Vect().Angle(nu_4mom->Vect())); (*ppim) = part_4mom; } } else if (PDGpart == 111) { Npi0++; if (part_4mom.Vect().Mag() > pi0_highmom) { pi0_highmom = part_4mom.Vect().Mag(); PPi0 = (part_4mom.Vect().Mag()); EPi0 = (part_4mom.E()); TPi0 = FitUtils::T(part_4mom) * 1000.; MPi0 = (part_4mom.Mag()); CosPi0 = cos(part_4mom.Vect().Angle(nu_4mom->Vect())); - (*ppi0) = part_4mom; + (*ppi0) = part_4mom; } } } // Get Recoil Definitions ------ // ----------------------------- Erecoil_true = FitUtils::GetErecoil_TRUE(event); Erecoil_charged = FitUtils::GetErecoil_CHARGED(event); Erecoil_minerva = FitUtils::GetErecoil_MINERvA_LowRecoil(event); // Do the angles between final state particles if (Nleptons > 0 && Npiplus > 0) CosPmuPpip = cos(pmu->Vect().Angle(ppip->Vect())); if (Nleptons > 0 && Npineg > 0) CosPmuPpim = cos(pmu->Vect().Angle(ppim->Vect())); - if (Nleptons > 0 && Npi0 > 0) CosPmuPpi0 = cos(pmu->Vect().Angle(ppi0->Vect())); + if (Nleptons > 0 && Npi0 > 0) + CosPmuPpi0 = cos(pmu->Vect().Angle(ppi0->Vect())); if (Nleptons > 0 && Nprotons > 0) CosPmuPprot = cos(pmu->Vect().Angle(pprot->Vect())); if (Nleptons > 0 && Nneutrons > 0) CosPmuPneut = cos(pmu->Vect().Angle(pneut->Vect())); if (Npiplus > 0 && Nprotons > 0) CosPpipPprot = cos(ppip->Vect().Angle(pprot->Vect())); if (Npiplus > 0 && Nneutrons > 0) CosPpipPneut = cos(ppip->Vect().Angle(pneut->Vect())); if (Npiplus > 0 && Npineg > 0) CosPpipPpim = cos(ppip->Vect().Angle(ppim->Vect())); if (Npiplus > 0 && Npi0 > 0) CosPpipPpi0 = cos(ppip->Vect().Angle(ppi0->Vect())); if (Npineg > 0 && Nprotons > 0) CosPpimPprot = cos(ppim->Vect().Angle(pprot->Vect())); if (Npineg > 0 && Nneutrons > 0) CosPpimPneut = cos(ppim->Vect().Angle(pneut->Vect())); - if (Npineg > 0 && Npi0 > 0) CosPpimPpi0 = cos(ppim->Vect().Angle(ppi0->Vect())); + if (Npineg > 0 && Npi0 > 0) + CosPpimPpi0 = cos(ppim->Vect().Angle(ppi0->Vect())); if (Npi0 > 0 && Nprotons > 0) CosPi0Pprot = cos(ppi0->Vect().Angle(pprot->Vect())); if (Npi0 > 0 && Nneutrons > 0) CosPi0Pneut = cos(ppi0->Vect().Angle(pneut->Vect())); if (Nprotons > 0 && Nneutrons > 0) CosPprotPneut = cos(pprot->Vect().Angle(pneut->Vect())); // Event Weights ---- // ------------------ Weight = event->RWWeight * event->InputWeight; RWWeight = event->RWWeight; InputWeight = event->InputWeight; FluxWeight = - fFluxHist->GetBinContent(fFluxHist->FindBin(Enu)) / fFluxHist->Integral(); + GetFluxHistogram()->GetBinContent(GetFluxHistogram()->FindBin(Enu)) / GetFluxHistogram()->Integral(); xsecScaling = fScaleFactor; - if (fScaleFactor <= 0.0){ + if (fScaleFactor <= 0.0) { ERR(WRN) << "SCALE FACTOR TOO LOW " << std::endl; sleep(20); } // Fill the eventVariables Tree eventVariables->Fill(); return; }; //******************************************************************** void GenericFlux_Tester::Write(std::string drawOpt) { //******************************************************************** // First save the TTree eventVariables->Write(); // Save Flux and Event Histograms too GetInput()->GetFluxHistogram()->Write(); GetInput()->GetEventHistogram()->Write(); return; } //******************************************************************** void GenericFlux_Tester::FillSignalFlags(FitEvent *event) { //******************************************************************** // Some example flags are given from SignalDef. // See src/Utils/SignalDef.cxx for more. - int nuPDG = event->PartInfo(0)->fPID; + int nuPDG = event->PartInfo(0)->fPID; // Generic signal flags - flagCCINC = SignalDef::isCCINC(event, nuPDG); - flagNCINC = SignalDef::isNCINC(event, nuPDG); - flagCCQE = SignalDef::isCCQE(event, nuPDG); + flagCCINC = SignalDef::isCCINC(event, nuPDG); + flagNCINC = SignalDef::isNCINC(event, nuPDG); + flagCCQE = SignalDef::isCCQE(event, nuPDG); flagCCQELike = SignalDef::isCCQELike(event, nuPDG); - flagCC0pi = SignalDef::isCC0pi(event, nuPDG); - flagNCEL = SignalDef::isNCEL(event, nuPDG); - flagNC0pi = SignalDef::isNC0pi(event, nuPDG); - flagCCcoh = SignalDef::isCCCOH(event, nuPDG, 211); - flagNCcoh = SignalDef::isNCCOH(event, nuPDG, 111); - flagCC1pip = SignalDef::isCC1pi(event, nuPDG, 211); - flagNC1pip = SignalDef::isNC1pi(event, nuPDG, 211); - flagCC1pim = SignalDef::isCC1pi(event, nuPDG, -211); - flagNC1pim = SignalDef::isNC1pi(event, nuPDG, -211); - flagCC1pi0 = SignalDef::isCC1pi(event, nuPDG, 111); - flagNC1pi0 = SignalDef::isNC1pi(event, nuPDG, 111); - + flagCC0pi = SignalDef::isCC0pi(event, nuPDG); + flagNCEL = SignalDef::isNCEL(event, nuPDG); + flagNC0pi = SignalDef::isNC0pi(event, nuPDG); + flagCCcoh = SignalDef::isCCCOH(event, nuPDG, 211); + flagNCcoh = SignalDef::isNCCOH(event, nuPDG, 111); + flagCC1pip = SignalDef::isCC1pi(event, nuPDG, 211); + flagNC1pip = SignalDef::isNC1pi(event, nuPDG, 211); + flagCC1pim = SignalDef::isCC1pi(event, nuPDG, -211); + flagNC1pim = SignalDef::isNC1pi(event, nuPDG, -211); + flagCC1pi0 = SignalDef::isCC1pi(event, nuPDG, 111); + flagNC1pi0 = SignalDef::isNC1pi(event, nuPDG, 111); } // ------------------------------------------------------------------- // Purely MC Plot // Following functions are just overrides to handle this // ------------------------------------------------------------------- //******************************************************************** /// Everything is classed as signal... bool GenericFlux_Tester::isSignal(FitEvent *event) { //******************************************************************** (void)event; return true; }; //******************************************************************** void GenericFlux_Tester::ScaleEvents() { //******************************************************************** // Saving everything to a TTree so no scaling required return; } //******************************************************************** void GenericFlux_Tester::ApplyNormScale(float norm) { //******************************************************************** // Saving everything to a TTree so no scaling required this->fCurrentNorm = norm; return; } //******************************************************************** void GenericFlux_Tester::FillHistograms() { //******************************************************************** // No Histograms need filling........ return; } //******************************************************************** void GenericFlux_Tester::ResetAll() { //******************************************************************** eventVariables->Reset(); return; } //******************************************************************** float GenericFlux_Tester::GetChi2() { //******************************************************************** // No Likelihood to test, purely MC return 0.0; } diff --git a/src/MCStudies/MCStudy_KaonPreSelection.cxx b/src/MCStudies/MCStudy_KaonPreSelection.cxx index e355ba6..033bf83 100644 --- a/src/MCStudies/MCStudy_KaonPreSelection.cxx +++ b/src/MCStudies/MCStudy_KaonPreSelection.cxx @@ -1,238 +1,238 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MCStudy_KaonPreSelection.h" #include "T2K_SignalDef.h" #include "MINERvA_SignalDef.h" //******************************************************************** /// @brief Class to perform MC Studies on a custom measurement MCStudy_KaonPreSelection::MCStudy_KaonPreSelection(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { //******************************************************************** // Measurement Details fName = name; fEventTree = NULL; // Define our energy range for flux calcs EnuMin = 0.; EnuMax = 100.; // Arbritrarily high energy limit // Set default fitter flags fIsDiag = true; fIsShape = false; fIsRawEvents = false; // This function will sort out the input files automatically and parse all the // inputs,flags,etc. // There may be complex cases where you have to do this by hand, but usually // this will do. Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); fEventTree = NULL; // Setup fDataHist as a placeholder this->fDataHist = new TH1D(("approximate_data"), ("kaon_data"), 5, 1.0, 6.0); - + // Approximate data points for now fDataHist->SetBinContent(1,0.225E-39); fDataHist->SetBinContent(2,0.215E-39); fDataHist->SetBinContent(3,0.175E-39); fDataHist->SetBinContent(4,0.230E-39); fDataHist->SetBinContent(5,0.210E-39); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // 1. The generator is organised in SetupMeasurement so it gives the // cross-section in "per nucleon" units. // So some extra scaling for a specific measurement may be required. For // Example to get a "per neutron" measurement on carbon // which we do here, we have to multiple by the number of nucleons 12 and // divide by the number of neutrons 6. - this->fScaleFactor = (this->fEventHist->Integral("width") * 1E-38 / (fNEvents + 0.)) / + this->fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / this->TotalIntegratedFlux(); // Create a new TTree and add Nuisance Events Branches FitPar::Config().out->cd(); fEventTree = new TTree("nuisance_events","nuisance_events"); GetInput()->GetEventPointer()->AddBranchesToTree(fEventTree); - + fEventTree->Branch("nlep",&nlep, "nlep/I"); fEventTree->Branch("nkplus",&nkplus, "nkplus/I"); fEventTree->Branch("nkaon",&nkaon, "nkaon/I"); fEventTree->Branch("kplus_mom", &kplusmom, "kplus_mom/D"); fEventTree->Branch("kaon_mom", &kaonmom, "kaon_mom/D"); // Add Event Scaling Information - // This scale factor is used to get the predicted event rate for this sample given - // the input flux. Use this when merging different output event ttrees + // This scale factor is used to get the predicted event rate for this sample given + // the input flux. Use this when merging different output event ttrees fEventTree->Branch("EventScaleFactor", &fEventScaleFactor, "EventScaleFactor/D"); - fEventScaleFactor = fEventHist->Integral("width") * 1E-38 / (fNEvents + 0.); + fEventScaleFactor = GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.); // NOTES: // To get normalised predictions weight event event by 'EventScaleFactor' to get the // predicted event rate for that sample given the flux used. Then to get cross-sections - // divide by the integrated flux from all samples. + // divide by the integrated flux from all samples. // e.g. To get the numu+numubar prediction, add the event rate predictions from both - // samples together, then divide by the integral of the 'nuisance_flux' histograms in each + // samples together, then divide by the integral of the 'nuisance_flux' histograms in each // sample. // Every particle in the nuisance event is saved into the TTree. The list of particle // status codes are given in src/FitBase/FitParticle.h. The neutrino is usually the first // particle in the list. // If selecting final state kaons, select only kaons with state=2. /* enum particle_state{ kUndefinedState = 5, kInitialState = 0, kFSIState = 1, kFinalState = 2, kNuclearInitial = 3, kNuclearRemnant = 4 }; */ // The structure of the particle lists are a dimensional array for each particle mom, then a 1D array // for the PDG and state. Mode gives the true NEUT interaction channel code. /* tn->Branch("Mode", &fMode, "Mode/I"); tn->Branch("EventNo", &fEventNo, "EventNo/i"); tn->Branch("TotCrs", &fTotCrs, "TotCrs/D"); tn->Branch("TargetA", &fTargetA, "TargetA/I"); tn->Branch("TargetH", &fTargetH, "TargetH/I"); tn->Branch("Bound", &fBound, "Bound/O"); - + tn->Branch("InputWeight", &InputWeight, "InputWeight/D"); - + tn->Branch("NParticles", &fNParticles, "NParticles/I"); tn->Branch("ParticleState", fParticleState, "ParticleState[NParticles]/i"); tn->Branch("ParticlePDG", fParticlePDG, "ParticlePDG[NParticles]/I"); tn->Branch("ParticleMom", fParticleMom, "ParticleMom[NParticles][4]/D"); */ - + return; } //******************************************************************** void MCStudy_KaonPreSelection::FillEventVariables(FitEvent *event) { //******************************************************************** kplusmom = -999.9; kaonmom = -999.9; // Save Some Extra Information nkplus = event->NumParticle(PhysConst::pdg_kplus); nkaon = event->NumParticle(PhysConst::pdg_strangemesons) + event->NumParticle(PhysConst::pdg_antistrangemesons); // Nmuons nlep = event->NumFSParticle(13) + event->NumFSParticle(-13); - + // Leading K+ Mom if (event->GetHMParticle(PhysConst::pdg_kplus)){ - + kplusmom = FitUtils::T(event->GetHMParticle(PhysConst::pdg_kplus)->fP)*1000.0; } double strangemom = 0.0; if (event->GetHMParticle(PhysConst::pdg_strangemesons)){ if (event->GetHMParticle(PhysConst::pdg_strangemesons)){ strangemom = FitUtils::T(event->GetHMParticle(PhysConst::pdg_strangemesons)->fP)*1000.0; } } double antistrangemom = 0.0; if (event->GetHMParticle(PhysConst::pdg_antistrangemesons)){ if (event->GetHMParticle(PhysConst::pdg_antistrangemesons)){ antistrangemom = FitUtils::T(event->GetHMParticle(PhysConst::pdg_antistrangemesons)->fP)*1000.0; } } kaonmom = TMath::Max(strangemom, antistrangemom); fXVar = kplusmom / 1.E3; if (isSignal(event)){ fEventTree->Fill(); } return; }; //******************************************************************** void MCStudy_KaonPreSelection::Write(std::string drawOpt) { //******************************************************************** // Measurement1D::Write(drawOpt); // Save the event ttree fEventTree->Write(); // Save Flux and Event Histograms too GetInput()->GetFluxHistogram()->Write("nuisance_fluxhist"); GetInput()->GetEventHistogram()->Write("nuisance_eventhist"); return; } //******************************************************************** /// Select only events with final state Kaons bool MCStudy_KaonPreSelection::isSignal(FitEvent *event) { //******************************************************************** // Apply a Kaon Pre-selection // Search for Strange Mesons (included full list from MC PDG) /* PhystConst::pdg_strangemesons = {130,310,311,321, 9000311,9000321, 10311,10321,100311,100321, 9010311,9010321,9020311,9020321, 313,323, 10313,10323, 20313,20323, 100313,100323, 9000313,9000323, 30313,30323, 315,325, 9000315,9000325, 10315,10325, 20315,20325, 9010315,9010325,9020315,9020325, 317,327, 9010317,9010327}; - PhysConst::pdg_antistrangemesons = {above * -1.0}; + PhysConst::pdg_antistrangemesons = {above * -1.0}; */ int nstrangemesons = event->NumParticle(PhysConst::pdg_strangemesons); nstrangemesons += event->NumParticle(PhysConst::pdg_antistrangemesons); if (nstrangemesons < 1) return false; // Do we want any other signal? return true; }; diff --git a/src/MCStudies/MCStudy_MuonValidation.cxx b/src/MCStudies/MCStudy_MuonValidation.cxx index dbb07e7..2b85815 100644 --- a/src/MCStudies/MCStudy_MuonValidation.cxx +++ b/src/MCStudies/MCStudy_MuonValidation.cxx @@ -1,167 +1,167 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MCStudy_MuonValidation.h" #include "T2K_SignalDef.h" #include "MINERvA_SignalDef.h" //******************************************************************** /// @brief Class to perform MC Studies on a custom measurement MCStudy_MuonValidation::MCStudy_MuonValidation(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { //******************************************************************** // Measurement Details fName = name; fEventTree = NULL; // Define our energy range for flux calcs EnuMin = 0.; EnuMax = 100.; // Arbritrarily high energy limit // Set default fitter flags fIsDiag = true; fIsShape = false; fIsRawEvents = false; // This function will sort out the input files automatically and parse all the // inputs,flags,etc. // There may be complex cases where you have to do this by hand, but usually // this will do. Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); fEventTree = NULL; // Setup fDataHist as a placeholder this->fDataHist = new TH1D(("approximate_data"), ("kaon_data"), 5, 1.0, 6.0); - + this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // 1. The generator is organised in SetupMeasurement so it gives the // cross-section in "per nucleon" units. // So some extra scaling for a specific measurement may be required. For // Example to get a "per neutron" measurement on carbon // which we do here, we have to multiple by the number of nucleons 12 and // divide by the number of neutrons 6. - this->fScaleFactor = (this->fEventHist->Integral("width") * 1E-38 / (fNEvents + 0.)) / + this->fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / this->TotalIntegratedFlux(); // Create a new TTree and add Nuisance Events Branches FitPar::Config().out->cd(); fEventTree = new TTree((fName + "_EVENTS").c_str(),(fName + "_EVENTS").c_str()); fEventTree->Branch("ScaleFactor", &fScaleFactor, "ScaleFactor/D"); fEventTree->Branch("InputWeight", &LocalInputWeight, "InputWeight/D"); fEventTree->Branch("RWWeight", &LocalRWWeight, "RWWeight/D"); fEventTree->Branch("Mode", &Mode, "Mode/I"); fEventTree->Branch("Enu",&Enu,"Enu/F"); fEventTree->Branch("TLep",&TLep,"TLep/F"); fEventTree->Branch("CosLep",&CosLep,"CosLep/F"); fEventTree->Branch("Q2",&Q2,"Q2/F"); fEventTree->Branch("Q2QE",&Q2QE,"Q2QE/F"); fEventTree->Branch("EQE",&EQE,"EQE/F"); fEventTree->Branch("q0",&q0,"q0/F"); fEventTree->Branch("q3",&q3,"q3/F"); - // the input flux. Use this when merging different output event ttrees + // the input flux. Use this when merging different output event ttrees fEventTree->Branch("EventScaleFactor", &fEventScaleFactor, "EventScaleFactor/D"); - fEventScaleFactor = fEventHist->Integral("width") * 1E-38 / (fNEvents + 0.); - + fEventScaleFactor = GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.); + return; } //******************************************************************** void MCStudy_MuonValidation::FillEventVariables(FitEvent *event) { //******************************************************************** FitParticle* muon = NULL; FitParticle* nu = event->GetNeutrinoIn(); bool IsNuMu = event->PDGnu() > 0; - + if (IsNuMu) muon = event->GetHMFSParticle(13); else muon = event->GetHMFSParticle(-13); // Reset Variables Enu = -999.9; TLep = -999.9; CosLep = -999.9; Q2 = -999.9; Q2QE = -999.9; EQE = -999.9; q0 = -999.9; q3 = -999.9; // Fill Variables if (muon){ Enu = event->Enu() / 1.E3; TLep = (muon->fP.E() - muon->fP.Mag()) / 1.E3; - CosLep = cos(muon->fP.Vect().Angle( nu->fP.Vect() )); + CosLep = cos(muon->fP.Vect().Angle( nu->fP.Vect() )); Q2 = fabs((muon->fP - nu->fP).Mag2() / 1.E6); Q2QE = FitUtils::Q2QErec(muon->fP, CosLep, 34., IsNuMu); EQE = FitUtils::EnuQErec(muon->fP, CosLep, 34., IsNuMu); - + q0 = fabs((muon->fP - nu->fP).E()) / 1.E3; q3 = fabs((muon->fP - nu->fP).Vect().Mag()) / 1.E3; LocalRWWeight = event->RWWeight; LocalInputWeight = event->InputWeight; - + } // Fill Tree if (isSignal(event)){ fEventTree->Fill(); } return; }; //******************************************************************** void MCStudy_MuonValidation::Write(std::string drawOpt) { //******************************************************************** // Save the event ttree fEventTree->Write(); // Save Flux and Event Histograms too GetInput()->GetFluxHistogram()->Write((fName + "_FLUX").c_str()); GetInput()->GetEventHistogram()->Write((fName + "_EVT").c_str()); return; } //******************************************************************** /// Select only events with final state Muons bool MCStudy_MuonValidation::isSignal(FitEvent *event) { //******************************************************************** if (!event->HasFSMuon()) return false; - + // Do we want any other signal? return true; }; diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DEe_nue.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_1DEe_nue.cxx index 44b46d5..4230889 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1DEe_nue.cxx +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DEe_nue.cxx @@ -1,94 +1,94 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC0pi_XSec_1DEe_nue.h" //******************************************************************** MINERvA_CC0pi_XSec_1DEe_nue::MINERvA_CC0pi_XSec_1DEe_nue(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ //******************************************************************** // Define Measurement fName = "MINERvA_CC0pi_XSec_1DEe_nue"; fPlotTitles = "; E_{e} (GeV); d#sigma/dE_{e} (cm^{2}/GeV)"; EnuMin = 0.0; EnuMax = 20.0; fNormError = 0.101; fDefaultTypes = "FIX/FULL"; fAllowedTypes = "FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // Setup Data File std::string datafile = FitPar::GetDataBase()+"/MINERvA/CC0pi/MINERvA_CC0pi_nue_Data_ARX1509_05729.root"; std::string dist_name = ""; dist_name = "1DEe"; fPlotTitles = "; Q_{QE}^{2} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"; SetDataFromFile(datafile, "Data_" + dist_name); SetCovarFromDataFile(datafile, "Covar_" + dist_name); // Setup Default MC Hists SetupDefaultHist(); // Convert covar from 1E-40 to 1E-38 *fDecomp *= (1.0 / 10.0); *fFullCovar *= (1.0 / 100.0); *covar *= (100.0); // Different generators require slightly different rescaling factors. - fScaleFactor = (fEventHist->Integral("width")*1E-38/(fNEvents+0.))/TotalIntegratedFlux(); + fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38/(fNEvents+0.))/TotalIntegratedFlux(); }; //******************************************************************** void MINERvA_CC0pi_XSec_1DEe_nue::FillEventVariables(FitEvent *event){ //******************************************************************** if (event->NumFSParticle(11) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pe = event->GetHMFSParticle(11)->fP; Thetae = Pnu.Vect().Angle(Pe.Vect()); Enu_rec = FitUtils::EnuQErec(Pe, cos(Thetae), 34.,true); Q2QEe = FitUtils::Q2QErec(Pe, cos(Thetae), 34.,true); Ee = Pe.E()/1000.0; fXVar = Ee; return; } //******************************************************************** bool MINERvA_CC0pi_XSec_1DEe_nue::isSignal(FitEvent *event){ //******************************************************************* // Check that this is a nue CC0pi event if (!SignalDef::isCC0pi(event, 12, EnuMin, EnuMax)) return false; // Electron Enrgy if (Ee < 0.5) return false; return true; }; diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nu_proton.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nu_proton.cxx index 535bc9c..ac3abf6 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nu_proton.cxx +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nu_proton.cxx @@ -1,125 +1,125 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include <string> #include <sstream> #include "MINERvA_SignalDef.h" #include "MINERvA_CC0pi_XSec_1DQ2_nu_proton.h" MINERvA_CC0pi_XSec_1DQ2_nu_proton::MINERvA_CC0pi_XSec_1DQ2_nu_proton(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ // Setup Measurement fName = "MINERvA_CC0pi_XSec_1DQ2_nu_proton"; fPlotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/GeV^{2})"; fDefaultTypes = "FIX/FULL"; fAllowedTypes = "FIX/FULL,DIAG"; fNormError = 0.100; EnuMin = 0.; EnuMax = 100.0; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // Setup Data SetDataValues( FitPar::GetDataBase()+"/MINERvA/CCQE/proton_Q2QE_nu_data.txt" ); SetCovarMatrixFromText(FitPar::GetDataBase()+"/MINERvA/CCQE/proton_Q2QE_nu_covar.txt", 7); SetupDefaultHist(); - // Quick Fix for Correl/Covar Issues + // Quick Fix for Correl/Covar Issues fCorrel = (TMatrixDSym*)fFullCovar->Clone(); delete fFullCovar; delete covar; delete fDecomp; fFullCovar = StatUtils::GetCovarFromCorrel(fCorrel,fDataHist); (*fFullCovar) *= 1E76; covar = StatUtils::GetInvert(fFullCovar); fDecomp = StatUtils::GetDecomp(fFullCovar); // Setup Coplanar Hist fCoplanarMCHist = NULL; fCoplanarDataHist = NULL; // Setup a scaling factor for evt->xsec - fScaleFactor = (fEventHist->Integral("width")*1E-38/(fNEvents+0.))/TotalIntegratedFlux(); + fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38/(fNEvents+0.))/TotalIntegratedFlux(); }; void MINERvA_CC0pi_XSec_1DQ2_nu_proton::FillEventVariables(FitEvent *event){ // Has NuMuCC1p if (event->HasISNuMuon() && event->HasFSMuon() && event->HasFSProton()){ TLorentzVector pnu = event->GetHMISNuMuon()->fP; TLorentzVector pprot = event->GetHMFSProton()->fP; TLorentzVector pmu = event->GetHMFSMuon()->fP; // Q2QE rec from leading proton assuming 34 MeV Eb double protmax = pprot.E(); double q2qe = FitUtils::ProtonQ2QErec(protmax, 34.); // Coplanar is angle between muon and proton plane TVector3 plnprotnu = pprot.Vect().Cross(pnu.Vect()); TVector3 plnmunu = pmu.Vect().Cross(pnu.Vect()); double copl = plnprotnu.Angle(plnmunu); // Fill X Variables fXVar = q2qe; // Save Coplanar into spare y variable fYVar = copl; } return; }; bool MINERvA_CC0pi_XSec_1DQ2_nu_proton::isSignal(FitEvent *event){ return SignalDef::isCC0pi1p_MINERvA(event, EnuMin*1.E3, EnuMax*1.E3); }; bool MINERvA_CC0pi_XSec_1DQ2_nu_proton::SortExtraPlots(int state){ switch(state){ // Reset Histograms at start of event loop case kExtraPlotReset: fCoplanarMCHist->Reset(); break; // Fill calls for extra histograms on each event case kExtraPlotFill: fCoplanarMCHist->Fill(fYVar, Weight); break; // Extra handling for histograms after event loop case kExtraPlotConvert: fCoplanarMCHist->Scale( fCoplanarDataHist->Integral() / fCoplanarMCHist->Integral() ); break; // Save the extra histograms case kExtraPlotWrite: fCoplanarMCHist->Write(); break; } return true; } diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nue.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nue.cxx index aeef280..d9c3af9 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nue.cxx +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nue.cxx @@ -1,95 +1,95 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC0pi_XSec_1DQ2_nue.h" //******************************************************************** MINERvA_CC0pi_XSec_1DQ2_nue::MINERvA_CC0pi_XSec_1DQ2_nue(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ //******************************************************************** // Define Measurement fName = "MINERvA_CC0pi_XSec_1DQ2_nue"; fPlotTitles = "; E_{e} (GeV); d#sigma/dE_{e} (cm^{2}/GeV)"; EnuMin = 0.0; EnuMax = 15.0; fNormError = 0.101; fDefaultTypes = "FIX/FULL"; fAllowedTypes = "FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // Setup Data File std::string datafile = FitPar::GetDataBase()+"/MINERvA/CC0pi/MINERvA_CC0pi_nue_Data_ARX1509_05729.root"; std::string dist_name = ""; dist_name = "1DQ2"; fPlotTitles = "; Q_{QE}^{2} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"; SetDataFromFile(datafile, "Data_" + dist_name); SetCovarFromDataFile(datafile, "Covar_" + dist_name); // Covariance is given in 1E-40, convert to 1E-38 *fDecomp *= (1.0 / 10.0); *fFullCovar *= (1.0 / 100.0); *covar *= (100.0); // Setup Default MC Hists SetupDefaultHist(); // Different generators require slightly different rescaling factors. - fScaleFactor = (this->fEventHist->Integral("width")*1E-38/(fNEvents+0.))/this->TotalIntegratedFlux(); + fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38/(fNEvents+0.))/this->TotalIntegratedFlux(); }; //******************************************************************** void MINERvA_CC0pi_XSec_1DQ2_nue::FillEventVariables(FitEvent *event){ //******************************************************************** if (event->NumFSParticle(11) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pe = event->GetHMFSParticle(11)->fP; Thetae = Pnu.Vect().Angle(Pe.Vect()); Enu_rec = FitUtils::EnuQErec(Pe, cos(Thetae), 34.,true); Q2QEe = FitUtils::Q2QErec(Pe, cos(Thetae), 34.,true); Ee = Pe.E()/1000.0; fXVar = Q2QEe; LOG(EVT) << "fXVar = "<<fXVar<<std::endl; return; } //******************************************************************** bool MINERvA_CC0pi_XSec_1DQ2_nue::isSignal(FitEvent *event){ //******************************************************************* // Check that this is a nue CC0pi event if (!SignalDef::isCC0pi(event, 12, EnuMin, EnuMax)) return false; // Restrct Ee if (Ee < 0.5) return false; return true; }; diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DThetae_nue.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_1DThetae_nue.cxx index 0d56e0f..2ea0a24 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1DThetae_nue.cxx +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DThetae_nue.cxx @@ -1,93 +1,93 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC0pi_XSec_1DThetae_nue.h" //******************************************************************** MINERvA_CC0pi_XSec_1DThetae_nue::MINERvA_CC0pi_XSec_1DThetae_nue(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ //******************************************************************** // Define Measurement fName = "MINERvA_CC0pi_XSec_1DThetae_nue"; fPlotTitles = "; E_{e} (GeV); d#sigma/dE_{e} (cm^{2}/GeV)"; EnuMin = 0.0; EnuMax = 10.0; fNormError = 0.101; fDefaultTypes = "FIX/FULL"; fAllowedTypes = "FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // Setup Data File std::string datafile = FitPar::GetDataBase()+"/MINERvA/CC0pi/MINERvA_CC0pi_nue_Data_ARX1509_05729.root"; std::string dist_name = ""; dist_name = "1DThetae"; fPlotTitles = "; Q_{QE}^{2} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"; SetDataFromFile(datafile, "Data_" + dist_name); SetCovarFromDataFile(datafile, "Covar_" + dist_name); // Convert covar from 1E-40 to 1E-38 *fDecomp *= (1.0 / 10.0); *fFullCovar *= (1.0 / 100.0); *covar *= (100.0); // Setup Default MC Hists SetupDefaultHist(); // Different generators require slightly different rescaling factors. - fScaleFactor = (this->fEventHist->Integral("width")*1E-38/(fNEvents+0.))/this->TotalIntegratedFlux(); + fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38/(fNEvents+0.))/this->TotalIntegratedFlux(); }; //******************************************************************** void MINERvA_CC0pi_XSec_1DThetae_nue::FillEventVariables(FitEvent *event){ //******************************************************************** if (event->NumFSParticle(11) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pe = event->GetHMFSParticle(11)->fP; Thetae = Pnu.Vect().Angle(Pe.Vect()) * 180. / TMath::Pi(); Ee = Pe.E()/1000.0; fXVar = Thetae; LOG(EVT) << "fXVar = "<<fXVar<<std::endl; return; } //******************************************************************** bool MINERvA_CC0pi_XSec_1DThetae_nue::isSignal(FitEvent *event){ //******************************************************************* // Check this is a nue CC0pi event if (!SignalDef::isCC0pi(event, 12, EnuMin, EnuMax)) return false; // Restrict EE if (Ee < 0.5) return false; return true; }; diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1DEnu_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1DEnu_antinu.cxx index 3b5c185..9c5146f 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1DEnu_antinu.cxx +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1DEnu_antinu.cxx @@ -1,93 +1,93 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pi0_XSec_1DEnu_antinu.h" // The constructor MINERvA_CC1pi0_XSec_1DEnu_antinu::MINERvA_CC1pi0_XSec_1DEnu_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { fName = "MINERvA_CC1pi0_XSec_1DEnu_nubar_2016"; fPlotTitles = "; E_{#nu} (GeV); d#sigma(E_{#nu}) (cm^{2}/nucleon)"; EnuMin = 1.5; EnuMax = 10; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2016/anu-cc1pi0-xsec-enu.csv"); // Error is given as percentage of cross-section // Need to scale the bin error properly before we do correlation -> covariance conversion for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { fDataHist->SetBinError(i+1, fDataHist->GetBinContent(i+1)*fDataHist->GetBinError(i+1)/100.); } // This is a correlation matrix, changed to covariance in SetCovarMatrixFromText this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2016/anu-cc1pi0-correlation-enu.csv", fDataHist->GetNbinsX()); this->SetupDefaultHist(); - fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents); + fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents); }; void MINERvA_CC1pi0_XSec_1DEnu_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(111) == 0 || event->NumFSParticle(-13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(-13)->fP; - + double hadMass = FitUtils::Wrec(Pnu, Pmu); double Enu = -999; if (hadMass > 100 && hadMass < 1800) Enu = Pnu.E()/1000.; fXVar = Enu; return; }; // ************************************** // MINERvA CC1pi0 in anti-neutrino mode // Unfortunately there's no information on the neutrino component which is // subtracted off // // 2014 analysis: // Exactly one positive muon // Exactly one observed pi0 // No pi+/pi allowed // No information on what is done with mesons, oops? // No information on what is done with nucleons, oops? // // 2016 analysis: // Exactly one positive muon // Exactly one observed pi0 // No other mesons // No restriction on number of nucleons // //******************************************************************** bool MINERvA_CC1pi0_XSec_1DEnu_antinu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pi(event, -14, 111, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1DQ2_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1DQ2_antinu.cxx index db64238..3f0af51 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1DQ2_antinu.cxx +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1DQ2_antinu.cxx @@ -1,76 +1,76 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pi0_XSec_1DQ2_antinu.h" // The constructor MINERvA_CC1pi0_XSec_1DQ2_antinu::MINERvA_CC1pi0_XSec_1DQ2_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "MINERvA_CC1pi0_XSec_1DQ2_antinu_2016"; fPlotTitles = "; Q^{2} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/(GeV^{2})/nucleon)"; EnuMin = 1.5; EnuMax = 10; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2016/anu-cc1pi0-xsec-q2.csv"); // Error is given as percentage of cross-section // Need to scale the bin error properly before we do correlation -> covariance conversion for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { fDataHist->SetBinError(i+1, fDataHist->GetBinContent(i+1)*fDataHist->GetBinError(i+1)/100.); } this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2016/anu-cc1pi0-correlation-q2.csv", fDataHist->GetNbinsX()); this->SetupDefaultHist(); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; void MINERvA_CC1pi0_XSec_1DQ2_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(111) == 0 || event->NumFSParticle(-13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(-13)->fP; double hadMass = FitUtils::Wrec(Pnu, Pmu); double Q2 = -999; if (hadMass > 100 && hadMass < 1800) Q2 = FitUtils::Q2CC1pi0rec(Pnu, Pmu, Ppi0); fXVar = Q2; return; }; //******************************************************************** bool MINERvA_CC1pi0_XSec_1DQ2_antinu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pi(event, -14, 111, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1DTpi0_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1DTpi0_antinu.cxx index 7007a35..f18a823 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1DTpi0_antinu.cxx +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1DTpi0_antinu.cxx @@ -1,76 +1,76 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pi0_XSec_1DTpi0_antinu.h" // The constructor MINERvA_CC1pi0_XSec_1DTpi0_antinu::MINERvA_CC1pi0_XSec_1DTpi0_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "MINERvA_CC1pi0_XSec_1DTpi0_antinu_2016"; fPlotTitles = "; T_{#pi} (GeV); d#sigma/dT_{#pi} (cm^{2}/GeV/nucleon)"; hadMassCut = 1800; fIsDiag = false; EnuMin = 1.5; EnuMax = 10; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2016/anu-cc1pi0-xsec-pion-kinetic-energy.csv"); // Error is given as percentage of cross-section // Need to scale the bin error properly before we do correlation -> covariance conversion for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { fDataHist->SetBinError(i+1, fDataHist->GetBinContent(i+1)*fDataHist->GetBinError(i+1)/100.); } this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2016/anu-cc1pi0-correlation-pion-kinetic-energy.csv", fDataHist->GetNbinsX()); this->SetupDefaultHist(); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; void MINERvA_CC1pi0_XSec_1DTpi0_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(111) == 0 || event->NumFSParticle(-13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(-13)->fP; double hadMass = FitUtils::Wrec(Pnu, Pmu); double Tpi0 = -999; if (hadMass > 100 && hadMass < hadMassCut) { Tpi0 = FitUtils::T(Ppi0); } fXVar = Tpi0; return; }; //******************************************************************** bool MINERvA_CC1pi0_XSec_1DTpi0_antinu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pi(event, -14, 111, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dpmu_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dpmu_antinu.cxx index 3a50922..e666321 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dpmu_antinu.cxx +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dpmu_antinu.cxx @@ -1,74 +1,74 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pi0_XSec_1Dpmu_antinu.h" // The constructor MINERvA_CC1pi0_XSec_1Dpmu_antinu::MINERvA_CC1pi0_XSec_1Dpmu_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "MINERvA_CC1pi0_XSec_1Dpmu_nubar_2016"; fPlotTitles = "; p_{#mu} (GeV); d#sigma/dp_{#mu} (cm^{2}/GeV/nucleon)"; EnuMin = 1.5; EnuMax = 10; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2016/anu-cc1pi0-xsec-muon-momentum.csv"); // Error is given as percentage of cross-section // Need to scale the bin error properly before we do correlation -> covariance conversion for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { fDataHist->SetBinError(i+1, fDataHist->GetBinContent(i+1)*fDataHist->GetBinError(i+1)/100.); } this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2016/anu-cc1pi0-correlation-muon-momentum.csv", fDataHist->GetNbinsX()); this->SetupDefaultHist(); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; void MINERvA_CC1pi0_XSec_1Dpmu_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(111) == 0 || event->NumFSParticle(-13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(-13)->fP; double hadMass = FitUtils::Wrec(Pnu, Pmu); double pmu = -999; if (hadMass > 100 && hadMass < 1800) pmu = FitUtils::p(Pmu); fXVar = pmu; return; }; //******************************************************************** bool MINERvA_CC1pi0_XSec_1Dpmu_antinu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pi(event, -14, 111, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dppi0_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dppi0_antinu.cxx index bbcf738..c987bcd 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dppi0_antinu.cxx +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dppi0_antinu.cxx @@ -1,83 +1,83 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pi0_XSec_1Dppi0_antinu.h" // The constructor MINERvA_CC1pi0_XSec_1Dppi0_antinu::MINERvA_CC1pi0_XSec_1Dppi0_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "MINERvA_CC1pi0_XSec_1Dppi0_nubar"; fPlotTitles = "; p_{#pi^{0}} (GeV/c); d#sigma/dp_{#pi^{0}} (cm^{2}/(GeV/c)/nucleon)"; EnuMin = 1.5; EnuMax = 10; fIsDiag = true; fNormError = 0.15; // No hadronic mass cut on old publication hadMassCut = 99999; fAllowedTypes += "NEW"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2015/ccpi0_ppi0.csv"); // Adjust MINERvA data to flux correction; roughly a 11% normalisation increase in data // Please change when MINERvA releases new data! for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinContent(i+1, fDataHist->GetBinContent(i+1)*1.11); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); this->SetupDefaultHist(); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; void MINERvA_CC1pi0_XSec_1Dppi0_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(111) == 0 || event->NumFSParticle(-13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(-13)->fP; double hadMass = FitUtils::Wrec(Pnu, Pmu); double ppi0 = -999; if (hadMass > 100 && hadMass < hadMassCut) { // 2016 does pion kinetic energy in GeV // 2015 does pion momentum in GeV ppi0 = FitUtils::p(Ppi0); } fXVar = ppi0; return; }; //******************************************************************** bool MINERvA_CC1pi0_XSec_1Dppi0_antinu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pi(event, -14, 111, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dth_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dth_antinu.cxx index 839ebe1..afeade3 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dth_antinu.cxx +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dth_antinu.cxx @@ -1,103 +1,103 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pi0_XSec_1Dth_antinu.h" // The constructor MINERvA_CC1pi0_XSec_1Dth_antinu::MINERvA_CC1pi0_XSec_1Dth_antinu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { fName = name; fPlotTitles = "; #theta_{#pi} (degrees); d#sigma/d#theta_{#pi} (cm^{2}/degrees/nucleon)"; fUpdatedData = fName.find("2015") == std::string::npos; EnuMin = 1.5; EnuMax = 10; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); if (fUpdatedData){ hadMassCut = 1800; fIsDiag = false; this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2016/anu-cc1pi0-xsec-pion-angle.csv"); // Error is given as percentage of cross-section // Need to scale the bin error properly before we do correlation -> covariance conversion for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { fDataHist->SetBinError(i+1, fDataHist->GetBinContent(i+1)*fDataHist->GetBinError(i+1)/100.); } this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2016/anu-cc1pi0-correlation-pion-angle.csv", fDataHist->GetNbinsX()); } else { // Although the covariance is given for MINERvA CC1pi0 nubar from 2015, it doesn't Cholesky decompose, hinting at something bad // I've tried adding small numbers to the diagonal but it still didn't work and the chi2s are crazy fIsDiag = true; fNormError = 0.15; // No hadronic mass cut on old publication hadMassCut = 99999; this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2015/ccpi0_th.csv"); this->SetupDefaultHist(); // Adjust MINERvA data to flux correction; roughly a 11% normalisation increase in data // Please change when MINERvA releases new data! for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinContent(i+1, fDataHist->GetBinContent(i+1)*1.11); } fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); } // end special treatment depending on release year this->SetupDefaultHist(); - fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; void MINERvA_CC1pi0_XSec_1Dth_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(111) == 0 || event->NumFSParticle(-13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(-13)->fP; double hadMass = FitUtils::Wrec(Pnu, Pmu); double th = -999; if (hadMass > 100 && hadMass < hadMassCut) th = (180./M_PI)*FitUtils::th(Pnu, Ppi0); fXVar = th; return; }; //******************************************************************** bool MINERvA_CC1pi0_XSec_1Dth_antinu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pi(event, -14, 111, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dthmu_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dthmu_antinu.cxx index cec3447..8f0d7da 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dthmu_antinu.cxx +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dthmu_antinu.cxx @@ -1,74 +1,74 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pi0_XSec_1Dthmu_antinu.h" // The constructor MINERvA_CC1pi0_XSec_1Dthmu_antinu::MINERvA_CC1pi0_XSec_1Dthmu_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "MINERvA_CC1pi0_XSec_1Dthmu_nubar_2016"; fPlotTitles = "; #theta_{#mu}; d#sigma/d#theta_{#mu} (cm^{2}/degrees/nucleon)"; EnuMin = 1.5; EnuMax = 10; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2016/anu-cc1pi0-xsec-muon-angle.csv"); // Error is given as percentage of cross-section // Need to scale the bin error properly before we do correlation -> covariance conversion for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { fDataHist->SetBinError(i+1, fDataHist->GetBinContent(i+1)*fDataHist->GetBinError(i+1)/100.); } this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2016/anu-cc1pi0-correlation-muon-angle.csv", fDataHist->GetNbinsX()); this->SetupDefaultHist(); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; void MINERvA_CC1pi0_XSec_1Dthmu_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(111) == 0 || event->NumFSParticle(-13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(-13)->fP; double hadMass = FitUtils::Wrec(Pnu, Pmu); double thmu = -999; if (hadMass > 100 && hadMass < 1800) thmu = (180./M_PI)*FitUtils::th(Pnu, Pmu); fXVar = thmu; return; }; //******************************************************************** bool MINERvA_CC1pi0_XSec_1Dthmu_antinu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pi(event, -14, 111, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_20deg_nu.cxx b/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_20deg_nu.cxx index 195c5df..05cceaf 100644 --- a/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_20deg_nu.cxx +++ b/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_20deg_nu.cxx @@ -1,78 +1,78 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pip_XSec_1DTpi_20deg_nu.h" // The constructor MINERvA_CC1pip_XSec_1DTpi_20deg_nu::MINERvA_CC1pip_XSec_1DTpi_20deg_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "MINERvA_CC1pip_XSec_1DTpi_20deg_nu"; fPlotTitles = "; T_{#pi} (MeV); d#sigma/dT_{#pi} (cm^{2}/MeV/nucleon)"; EnuMin = 1.5; EnuMax = 10; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); if (this->fIsShape) { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_Tpi_20_shape.csv"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_Tpi_20_cov_shape.csv", fDataHist->GetNbinsX()); } else { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_Tpi_20.csv"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_Tpi_20_cov.csv", fDataHist->GetNbinsX()); } this->SetupDefaultHist(); for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinContent(i+1, fDataHist->GetBinContent(i+1)*1.11); } - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; void MINERvA_CC1pip_XSec_1DTpi_20deg_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(PhysConst::pdg_charged_pions) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(PhysConst::pdg_charged_pions)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::Wrec(Pnu, Pmu); double Tpi = -999; if (hadMass > 100 && hadMass < 1400) Tpi = FitUtils::T(Ppip)*1000.; fXVar = Tpi; return; }; //******************************************************************** bool MINERvA_CC1pip_XSec_1DTpi_20deg_nu::isSignal(FitEvent *event) { //******************************************************************** // Last true refers to that this is the restricted MINERvA phase space, in which only forward-going muons are accepted return SignalDef::isCC1pip_MINERvA(event, EnuMin, EnuMax, true); } diff --git a/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_nu.cxx b/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_nu.cxx index e299f58..676ae6c 100644 --- a/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_nu.cxx +++ b/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_nu.cxx @@ -1,89 +1,90 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pip_XSec_1DTpi_nu.h" // The constructor MINERvA_CC1pip_XSec_1DTpi_nu::MINERvA_CC1pip_XSec_1DTpi_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { fName = name; fPlotTitles = "; T_{#pi} (MeV); d#sigma/dT_{#pi} (cm^{2}/MeV/nucleon)"; fFullPhaseSpace = fName.find("_20deg") == std::string::npos; EnuMin = 1.5; EnuMax = 10; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); if (fFullPhaseSpace){ if (fIsShape) { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_Tpi_shape.csv"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_Tpi_cov_shape.csv", fDataHist->GetNbinsX()); } else { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_Tpi.csv"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_Tpi_cov.csv", fDataHist->GetNbinsX()); } } else { if (this->fIsShape) { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_Tpi_20_shape.csv"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_Tpi_20_cov_shape.csv", fDataHist->GetNbinsX()); } else { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_Tpi_20.csv"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_Tpi_20_cov.csv", fDataHist->GetNbinsX()); } } this->SetupDefaultHist(); // Scale the MINERvA data to account for the flux difference for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinContent(i+1, fDataHist->GetBinContent(i+1)*1.11); } - fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + std::cout << "SF: " << fScaleFactor << std::endl; }; void MINERvA_CC1pip_XSec_1DTpi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(PhysConst::pdg_charged_pions) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(PhysConst::pdg_charged_pions)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::Wrec(Pnu, Pmu); double Tpi = -999; if (hadMass > 100 && hadMass < 1400) Tpi = FitUtils::T(Ppip)*1000.; fXVar = Tpi; return; }; //******************************************************************** bool MINERvA_CC1pip_XSec_1DTpi_nu::isSignal(FitEvent *event) { //******************************************************************** // Last true refers to that this is the restricted MINERvA phase space, in which only forward-going muons are accepted return SignalDef::isCC1pip_MINERvA(event, EnuMin, EnuMax, !fFullPhaseSpace); } diff --git a/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_20deg_nu.cxx b/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_20deg_nu.cxx index 0e119c9..d6894f2 100644 --- a/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_20deg_nu.cxx +++ b/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_20deg_nu.cxx @@ -1,89 +1,89 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pip_XSec_1Dth_20deg_nu.h" // The constructor MINERvA_CC1pip_XSec_1Dth_20deg_nu::MINERvA_CC1pip_XSec_1Dth_20deg_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "MINERvA_CC1pip_XSec_1Dth_20deg_nu"; fPlotTitles = "; #theta_{#pi} (degrees); d#sigma/d#theta_{#pi} (cm^{2}/degrees/nucleon)"; EnuMin = 1.5; EnuMax = 10; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); if (fIsShape) { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_20_shape.csv"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_20_cov_shape.csv", fDataHist->GetNbinsX()); } else { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_20.csv"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_20_cov.csv", fDataHist->GetNbinsX()); } this->SetupDefaultHist(); // Scaling for MINERvA corrected flux; roughly a normalisation change of 11% // PLEASE CHANGE THIS WHEN NEW MINERvA MEASUREMENT IS RELEASED for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinContent(i+1, fDataHist->GetBinContent(i+1)*1.11); } hadMassHist = new TH1D((fName+"_hadMass").c_str(), (fName+"_hadMass").c_str(), 100, 1000, 2000); - fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; void MINERvA_CC1pip_XSec_1Dth_20deg_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(PhysConst::pdg_charged_pions) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(PhysConst::pdg_charged_pions)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; hadMass = FitUtils::Wrec(Pnu, Pmu); hadMassHist->Fill(hadMass); double th = -999; // MINERvA CC1pi+ imposes a 0.1 < W < 1.4 GeV hadronic mass constraint if (hadMass > 100 && hadMass < 1400) th = (180./M_PI)*FitUtils::th(Pnu, Ppip); fXVar = th; return; }; //******************************************************************** bool MINERvA_CC1pip_XSec_1Dth_20deg_nu::isSignal(FitEvent *event) { //******************************************************************** // Last true refers to that this is the restricted MINERvA phase space, in which only forward-going muons are accepted return SignalDef::isCC1pip_MINERvA(event, EnuMin, EnuMax, true); } void MINERvA_CC1pip_XSec_1Dth_20deg_nu::Write(std::string drawOpt) { Measurement1D::Write(drawOpt); hadMassHist->Write(); return; } diff --git a/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_nu.cxx b/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_nu.cxx index 109b5b9..3a7b7c1 100644 --- a/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_nu.cxx +++ b/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_nu.cxx @@ -1,92 +1,92 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pip_XSec_1Dth_nu.h" // The constructor MINERvA_CC1pip_XSec_1Dth_nu::MINERvA_CC1pip_XSec_1Dth_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ - fName = name; + fName = name; fPlotTitles = "; #theta_{#pi} (degrees); d#sigma/d#theta_{#pi} (cm^{2}/degrees/nucleon)"; fFullPhaseSpace = name.find("_20deg") == std::string::npos; EnuMin = 1.5; EnuMax = 10; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // Full Phase Space if (fFullPhaseSpace){ if (fIsShape) { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_shape.csv"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_cov_shape.csv", fDataHist->GetNbinsX()); } else { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta.csv"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_cov.csv", fDataHist->GetNbinsX()); } // Restricted Phase Space } else { if (fIsShape) { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_20_shape.csv"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_20_cov_shape.csv", fDataHist->GetNbinsX()); } else { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_20.csv"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_20_cov.csv", fDataHist->GetNbinsX()); } } this->SetupDefaultHist(); // Adjust MINERvA data to flux correction; roughly a 11% normalisation increase in data // Please change when MINERvA releases new data! for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinContent(i+1, fDataHist->GetBinContent(i+1)*1.11); } - fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; void MINERvA_CC1pip_XSec_1Dth_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(PhysConst::pdg_charged_pions) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(PhysConst::pdg_charged_pions)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = FitUtils::Wrec(Pnu, Pmu); double th = -999; if (hadMass > 100 && hadMass < 1400) th = (180./M_PI)*FitUtils::th(Pnu, Ppip); fXVar = th; return; }; //******************************************************************** bool MINERvA_CC1pip_XSec_1Dth_nu::isSignal(FitEvent *event) { //******************************************************************** // Last false refers to that this is NOT the restricted MINERvA phase space, in which only forward-going muons are accepted return SignalDef::isCC1pip_MINERvA(event, EnuMin, EnuMax, !fFullPhaseSpace); } diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1DEnu_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1DEnu_nu.cxx index 2084894..29f891b 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1DEnu_nu.cxx +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1DEnu_nu.cxx @@ -1,71 +1,71 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCNpip_XSec_1DEnu_nu.h" //******************************************************************** // The constructor MINERvA_CCNpip_XSec_1DEnu_nu::MINERvA_CCNpip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { //******************************************************************** fName = "MINERvA_CCNpip_XSec_1DEnu_nu_2016"; fPlotTitles = "; E_{#nu} (GeV); d#sigma(E_{#nu}) (cm^{2}/nucleon)"; EnuMin = 1.5; EnuMax = 10; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2016/nu-ccNpi+-xsec-enu.csv"); // MINERvA has the error quoted as a percentage of the cross-section // Need to make this into an absolute error before we go from correlation matrix -> covariance matrix since it depends on the error in the ith bin for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { fDataHist->SetBinError(i+1, fDataHist->GetBinContent(i+1)*(fDataHist->GetBinError(i+1)/100.)); } // We're given a correlation matrix, so need to convert it to a covariance matrix this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2016/nu-ccNpi+-correlation-enu.csv", fDataHist->GetNbinsX()); this->SetupDefaultHist(); - fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents); + fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents); }; //******************************************************************** void MINERvA_CCNpip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { //******************************************************************** TLorentzVector Pnu = event->GetNeutrinoIn()->fP; double Enu = Pnu.E()/1000.; fXVar = Enu; return; }; //******************************************************************** // The false refers to that this cross-section uses the full phase space bool MINERvA_CCNpip_XSec_1DEnu_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCCNpip_MINERvA(event, EnuMin, EnuMax, false); } diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1DQ2_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1DQ2_nu.cxx index cc966e4..589ffa9 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1DQ2_nu.cxx +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1DQ2_nu.cxx @@ -1,74 +1,74 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCNpip_XSec_1DQ2_nu.h" //******************************************************************** // The constructor MINERvA_CCNpip_XSec_1DQ2_nu::MINERvA_CCNpip_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ //******************************************************************** fName = "MINERvA_CCNpip_XSec_1DQ2_nu_2016"; fPlotTitles = "; Q^{2} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/GeV^{2}/nucleon)"; EnuMin = 1.5; EnuMax = 10; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2016/nu-ccNpi+-xsec-q2.csv"); // MINERvA has the error quoted as a percentage of the cross-section // Need to make this into an absolute error before we go from correlation matrix -> covariance matrix since it depends on the error in the ith bin for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { fDataHist->SetBinError(i+1, fDataHist->GetBinContent(i+1)*(fDataHist->GetBinError(i+1)/100.)); } // This is a correlation matrix this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2016/nu-ccNpi+-correlation-q2.csv", fDataHist->GetNbinsX()); this->SetupDefaultHist(); - fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; //******************************************************************** void MINERvA_CCNpip_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) { //******************************************************************** if (event->NumFSParticle(13) == 0 || event->NumFSParticle(211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; // This Q2 defaults to calculating true Q2 (using true Enu instead of recon. Enu) // This agrees with what MINERvA used double q2 = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip); fXVar = q2; return; }; //******************************************************************** bool MINERvA_CCNpip_XSec_1DQ2_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCCNpip_MINERvA(event, EnuMin, EnuMax, false); } diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_nu.cxx index 0ab964c..93df36b 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_nu.cxx +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_nu.cxx @@ -1,239 +1,280 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCNpip_XSec_1DTpi_nu.h" //******************************************************************** // The constructor -MINERvA_CCNpip_XSec_1DTpi_nu::MINERvA_CCNpip_XSec_1DTpi_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ -//******************************************************************** +MINERvA_CCNpip_XSec_1DTpi_nu::MINERvA_CCNpip_XSec_1DTpi_nu( + std::string name, std::string inputfile, FitWeight *rw, std::string type, + std::string fakeDataFile) { + //******************************************************************** fName = name; - fPlotTitles = "; T_{#pi} (MeV); (1/T#Phi) dN_{#pi}/dT_{#pi} (cm^{2}/MeV/nucleon)"; + fPlotTitles = + "; T_{#pi} (MeV); (1/T#Phi) dN_{#pi}/dT_{#pi} (cm^{2}/MeV/nucleon)"; fFullPhaseSpace = fName.find("_20deg") == std::string::npos; fUpdatedData = fName.find("2015") == std::string::npos; EnuMin = 1.5; EnuMax = 10; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); if (fUpdatedData && fName.find("2016") == std::string::npos) fName += "_2016"; - if (!fUpdatedData && fName.find("2015") == std::string::npos) fName += "_2015"; + if (!fUpdatedData && fName.find("2015") == std::string::npos) + fName += "_2015"; // Reserve length 3 for the number of pions TpiVect.reserve(3); // Lots of good data from MINERvA, thanks! // Full Phase Space - if (fFullPhaseSpace){ + if (fFullPhaseSpace) { // 2016 release - if (fUpdatedData){ - - this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2016/nu-ccNpi+-xsec-pion-kinetic-energy.csv"); + if (fUpdatedData) { + this->SetDataValues( + GeneralUtils::GetTopLevelDir() + + "/data/MINERvA/CCNpip/2016/nu-ccNpi+-xsec-pion-kinetic-energy.csv"); // MINERvA has the error quoted as a percentage of the cross-section - // Need to make this into an absolute error before we go from correlation matrix -> covariance matrix since it depends on the error in the ith bin - for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { - fDataHist->SetBinError(i+1, fDataHist->GetBinContent(i+1)*(fDataHist->GetBinError(i+1)/100.)); + // Need to make this into an absolute error before we go from correlation + // matrix -> covariance matrix since it depends on the error in the ith + // bin + for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { + fDataHist->SetBinError(i + 1, + fDataHist->GetBinContent(i + 1) * + (fDataHist->GetBinError(i + 1) / 100.)); } - // This is a correlation matrix, not covariance matrix, so needs to be converted - this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2016/nu-ccNpi+-correlation-pion-kinetic-energy.csv", fDataHist->GetNbinsX()); + // This is a correlation matrix, not covariance matrix, so needs to be + // converted + this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir() + + "/data/MINERvA/CCNpip/2016/" + "nu-ccNpi+-correlation-pion-kinetic-" + "energy.csv", + fDataHist->GetNbinsX()); - // 2015 release + // 2015 release } else { - // If we're doing shape only if (fIsShape) { fName += "_shape"; - this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_shape.txt"); - this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_shape_cov.txt", fDataHist->GetNbinsX()); - // If we're doing full cross-section + this->SetDataValues( + GeneralUtils::GetTopLevelDir() + + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_shape.txt"); + this->SetCovarMatrixFromCorrText( + GeneralUtils::GetTopLevelDir() + + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_shape_cov.txt", + fDataHist->GetNbinsX()); + // If we're doing full cross-section } else { - this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi.txt"); - this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_cov.txt", fDataHist->GetNbinsX()); + this->SetDataValues(GeneralUtils::GetTopLevelDir() + + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi.txt"); + this->SetCovarMatrixFromCorrText( + GeneralUtils::GetTopLevelDir() + + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_cov.txt", + fDataHist->GetNbinsX()); } - // Adjust MINERvA data to flux correction; roughly a 11% normalisation increase in data + // Adjust MINERvA data to flux correction; roughly a 11% normalisation + // increase in data for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { - fDataHist->SetBinContent(i+1, fDataHist->GetBinContent(i+1)*1.11); + fDataHist->SetBinContent(i + 1, fDataHist->GetBinContent(i + 1) * 1.11); } } - // Restricted Phase Space + // Restricted Phase Space } else { - - // Only 2015 data released restricted muon phase space cross-section unfortunately - if (fUpdatedData){ - LOG(SAM) << fName << " has no updated 2016 data for restricted phase space! Using 2015 data." << std::endl; + // Only 2015 data released restricted muon phase space cross-section + // unfortunately + if (fUpdatedData) { + LOG(SAM) << fName << " has no updated 2016 data for restricted phase " + "space! Using 2015 data." + << std::endl; fUpdatedData = false; - } + } // If we're using the shape only data if (fIsShape) { - this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_20deg_shape.txt"); - this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_20deg_shape_cov.txt", fDataHist->GetNbinsX()); - // Or total cross-section + this->SetDataValues( + GeneralUtils::GetTopLevelDir() + + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_20deg_shape.txt"); + this->SetCovarMatrixFromCorrText( + GeneralUtils::GetTopLevelDir() + + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_20deg_shape_cov.txt", + fDataHist->GetNbinsX()); + // Or total cross-section } else { - this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_20deg.txt"); - this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+ - "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_20deg_cov.txt", fDataHist->GetNbinsX()); + this->SetDataValues( + GeneralUtils::GetTopLevelDir() + + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_20deg.txt"); + this->SetCovarMatrixFromCorrText( + GeneralUtils::GetTopLevelDir() + + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_20deg_cov.txt", + fDataHist->GetNbinsX()); } - // Adjust 2015 MINERvA data to account for flux correction; roughly a 11% normalisation increase in data + // Adjust 2015 MINERvA data to account for flux correction; roughly a 11% + // normalisation increase in data for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { - fDataHist->SetBinContent(i+1, fDataHist->GetBinContent(i+1)*1.11); + fDataHist->SetBinContent(i + 1, fDataHist->GetBinContent(i + 1) * 1.11); } - } SetupDefaultHist(); - onePions = (TH1D*)(fDataHist->Clone()); - twoPions = (TH1D*)(fDataHist->Clone()); - threePions = (TH1D*)(fDataHist->Clone()); - morePions = (TH1D*)(fDataHist->Clone()); - - onePions->SetNameTitle((fName+"_1pions").c_str(), (fName+"_1pions"+fPlotTitles).c_str()); - twoPions->SetNameTitle((fName+"_2pions").c_str(), (fName+"_2pions;"+fPlotTitles).c_str()); - threePions->SetNameTitle((fName+"_3pions").c_str(), (fName+"_3pions"+fPlotTitles).c_str()); - morePions->SetNameTitle((fName+"_4pions").c_str(), (fName+"_4pions"+fPlotTitles).c_str()); - - fScaleFactor = fEventHist->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); - + onePions = (TH1D *)(fDataHist->Clone()); + twoPions = (TH1D *)(fDataHist->Clone()); + threePions = (TH1D *)(fDataHist->Clone()); + morePions = (TH1D *)(fDataHist->Clone()); + + onePions->SetNameTitle((fName + "_1pions").c_str(), + (fName + "_1pions" + fPlotTitles).c_str()); + twoPions->SetNameTitle((fName + "_2pions").c_str(), + (fName + "_2pions;" + fPlotTitles).c_str()); + threePions->SetNameTitle((fName + "_3pions").c_str(), + (fName + "_3pions" + fPlotTitles).c_str()); + morePions->SetNameTitle((fName + "_4pions").c_str(), + (fName + "_4pions" + fPlotTitles).c_str()); + + fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / + double(fNEvents) / TotalIntegratedFlux("width"); }; //******************************************************************** // Here we have to fill for every pion we find in the event void MINERvA_CCNpip_XSec_1DTpi_nu::FillEventVariables(FitEvent *event) { -//******************************************************************** + //******************************************************************** // Clear out the vectors TpiVect.clear(); if (event->NumFSParticle(211) == 0 && event->NumFSParticle(-211) == 0) return; // Loop over the particle stack for (unsigned int j = 2; j < event->Npart(); ++j) { - // Only include alive particles - if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fNEUTStatusCode != 0) continue; + if (!(event->PartInfo(j))->fIsAlive && + (event->PartInfo(j))->fNEUTStatusCode != 0) + continue; int PID = (event->PartInfo(j))->fPID; // Pick up the charged pions in the event if (abs(PID) == 211) { double ppi = FitUtils::T(event->PartInfo(j)->fP) * 1000.; TpiVect.push_back(ppi); } } fXVar = 0; return; }; //******************************************************************** // The last bool refers to if we're using restricted phase space or not bool MINERvA_CCNpip_XSec_1DTpi_nu::isSignal(FitEvent *event) { -//******************************************************************** - // Last false refers to that this is NOT the restricted MINERvA phase space, in which only forward-going muons are accepted + //******************************************************************** + // Last false refers to that this is NOT the restricted MINERvA phase space, + // in which only forward-going muons are accepted return SignalDef::isCCNpip_MINERvA(event, EnuMin, EnuMax, !fFullPhaseSpace); } //******************************************************************** -// Need to override FillHistograms() here because we fill the histogram N_pion times +// Need to override FillHistograms() here because we fill the histogram N_pion +// times void MINERvA_CCNpip_XSec_1DTpi_nu::FillHistograms() { -//******************************************************************** - - if (Signal){ + //******************************************************************** + if (Signal) { int nPions = TpiVect.size(); // Need to loop over all the pions in the sample for (size_t k = 0; k < TpiVect.size(); ++k) { double tpi = TpiVect[k]; this->fMCHist->Fill(tpi, Weight); this->fMCFine->Fill(tpi, Weight); this->fMCStat->Fill(tpi, 1.0); if (nPions == 1) { onePions->Fill(tpi, Weight); } else if (nPions == 2) { twoPions->Fill(tpi, Weight); } else if (nPions == 3) { threePions->Fill(tpi, Weight); } else if (nPions > 3) { morePions->Fill(tpi, Weight); } PlotUtils::FillNeutModeArray(fMCHist_PDG, Mode, TpiVect[k], Weight); } } } //******************************************************************** void MINERvA_CCNpip_XSec_1DTpi_nu::ScaleEvents() { -//******************************************************************** + //******************************************************************** Measurement1D::ScaleEvents(); onePions->Scale(this->fScaleFactor, "width"); twoPions->Scale(this->fScaleFactor, "width"); threePions->Scale(this->fScaleFactor, "width"); morePions->Scale(this->fScaleFactor, "width"); return; } //******************************************************************** void MINERvA_CCNpip_XSec_1DTpi_nu::Write(std::string drawOpts) { -//******************************************************************** + //******************************************************************** Measurement1D::Write(drawOpts); // Draw the npions stack onePions->SetTitle("1#pi"); onePions->SetLineColor(kBlack); - //onePions->SetFillStyle(0); + // onePions->SetFillStyle(0); onePions->SetFillColor(onePions->GetLineColor()); twoPions->SetTitle("2#pi"); twoPions->SetLineColor(kRed); - //twoPions->SetFillStyle(0); + // twoPions->SetFillStyle(0); twoPions->SetFillColor(twoPions->GetLineColor()); threePions->SetTitle("3#pi"); threePions->SetLineColor(kGreen); - //threePions->SetFillStyle(0); + // threePions->SetFillStyle(0); threePions->SetFillColor(threePions->GetLineColor()); morePions->SetTitle(">3#pi"); morePions->SetLineColor(kBlue); - //morePions->SetFillStyle(0); + // morePions->SetFillStyle(0); morePions->SetFillColor(morePions->GetLineColor()); - THStack pionStack = THStack((fName+"_pionStack").c_str(), (fName+"_pionStack").c_str()); + THStack pionStack = + THStack((fName + "_pionStack").c_str(), (fName + "_pionStack").c_str()); pionStack.Add(onePions); pionStack.Add(twoPions); pionStack.Add(threePions); pionStack.Add(morePions); pionStack.Write(); return; } diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1Dpmu_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1Dpmu_nu.cxx index 20c96dc..561a708 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1Dpmu_nu.cxx +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1Dpmu_nu.cxx @@ -1,75 +1,75 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCNpip_XSec_1Dpmu_nu.h" //******************************************************************** // The constructor MINERvA_CCNpip_XSec_1Dpmu_nu::MINERvA_CCNpip_XSec_1Dpmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { //******************************************************************** fName = "MINERvA_CCNpip_XSec_1Dpmu_nu_2016"; fPlotTitles = "; p_{#mu} (GeV); d#sigma/dp_{#mu} (cm^{2}/GeV/nucleon)"; EnuMin = 1.5; EnuMax = 10; fIsDiag = false; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); //this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2016_upd/ccnpip_pmu.txt"); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2016/nu-ccNpi+-xsec-muon-momentum.csv"); // MINERvA has the error quoted as a percentage of the cross-section // Need to make this into an absolute error before we go from correlation matrix -> covariance matrix since it depends on the error in the ith bin for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { fDataHist->SetBinError(i+1, fDataHist->GetBinContent(i+1)*(fDataHist->GetBinError(i+1)/100.)); } // Correlation matrix is given this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2016/nu-ccNpi+-correlation-muon-momentum.csv", fDataHist->GetNbinsX()); this->SetupDefaultHist(); - fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; //******************************************************************** // Very simple event variable fill void MINERvA_CCNpip_XSec_1Dpmu_nu::FillEventVariables(FitEvent *event) { //******************************************************************** if (event->NumFSParticle(13) == 0) return; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double pmu = FitUtils::p(Pmu); fXVar = pmu; return; }; //******************************************************************** // The false refers to that this cross-section uses the full phase space bool MINERvA_CCNpip_XSec_1Dpmu_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCCNpip_MINERvA(event, EnuMin, EnuMax, false); } diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_nu.cxx index 6b3cdf2..801095b 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_nu.cxx +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_nu.cxx @@ -1,247 +1,247 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCNpip_XSec_1Dth_nu.h" //******************************************************************** // The constructor MINERvA_CCNpip_XSec_1Dth_nu::MINERvA_CCNpip_XSec_1Dth_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ //******************************************************************** fName = name; fPlotTitles = "; #theta_{#pi} (degrees); (1/T#Phi) dN_{#pi}/d#theta_{#pi} (cm^{2}/degrees/nucleon)"; // If we have full phase space we won't find 20deg in name fFullPhaseSpace = (fName.find("_20deg") == std::string::npos); // If we have updated data we won't have 2015 in name fUpdatedData = fName.find("2015") == std::string::npos; EnuMin = 1.5; EnuMax = 10; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // Reserve length 3 for the number of pions // We fill once per pion found in the event, so can fill multiple times for one event thVect.reserve(3); // So here is all the data we want to read in, pfoaw! // Same W cut for all releases // Full Phase Space if (fFullPhaseSpace) { // 2016 release data if (fUpdatedData) { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2016/nu-ccNpi+-xsec-pion-angle.csv"); // MINERvA has the error quoted as a percentage of the cross-section // Need to make this into an absolute error before we go from correlation matrix -> covariance matrix since it depends on the error in the ith bin for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { fDataHist->SetBinError(i+1, fDataHist->GetBinContent(i+1)*(fDataHist->GetBinError(i+1)/100.)); } // This is a correlation matrix! but it's all fixed in SetCovarMatrixFromText this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2016/nu-ccNpi+-correlation-pion-angle.csv", fDataHist->GetNbinsX()); // 2015 release data } else { // 2015 release allows for shape comparisons if (fIsShape) { fName += "_shape"; this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_th_shape.txt"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_th_shape_cov.txt", fDataHist->GetNbinsX()); } else { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_th.txt"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_th_cov.txt", fDataHist->GetNbinsX()); } // Adjust MINERvA data to flux correction; roughly a 11% normalisation increase in data // Please change when MINERvA releases new data! for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinContent(i+1, fDataHist->GetBinContent(i+1)*1.11); } } // Restricted Phase Space Data } else { // 2016 release data unfortunately not released in 20degree forward-going, revert to 2015 data if (fUpdatedData){ - LOG(SAM) << fName << " has no updated 2016 data for restricted phase space! Using 2015 data." << std::endl; + LOG(SAM) << fName << " has no updated 2016 data for restricted phase space! Using 2015 data." << std::endl; fUpdatedData = false; - } + } // Only 2015 20deg data if (fIsShape) { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_th_20deg_shape.txt"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+ "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_th_20deg_shape_cov.txt", fDataHist->GetNbinsX()); } else { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_th_20deg.txt"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+ "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_th_20deg_cov.txt", fDataHist->GetNbinsX()); } } this->SetupDefaultHist(); // Make some auxillary helper plots onePions = (TH1D*)(fDataHist->Clone()); twoPions = (TH1D*)(fDataHist->Clone()); threePions = (TH1D*)(fDataHist->Clone()); morePions = (TH1D*)(fDataHist->Clone()); onePions->SetNameTitle((fName+"_1pions").c_str(), (fName+"_1pions"+fPlotTitles).c_str()); twoPions->SetNameTitle((fName+"_2pions").c_str(), (fName+"_2pions;"+fPlotTitles).c_str()); threePions->SetNameTitle((fName+"_3pions").c_str(), (fName+"_3pions"+fPlotTitles).c_str()); morePions->SetNameTitle((fName+"_4pions").c_str(), (fName+"_4pions"+fPlotTitles).c_str()); - fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; // ******************************************** // Fill the event variables // Here we want to fill the angle for every pion we can find in the event void MINERvA_CCNpip_XSec_1Dth_nu::FillEventVariables(FitEvent *event) { // ******************************************** thVect.clear(); if (event->NumFSParticle(211) == 0 && event->NumFSParticle(-211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip; // Loop over the particle stack for (unsigned int j = 2; j < event->Npart(); ++j) { // Only include alive particles if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fNEUTStatusCode != 0) continue; int PID = (event->PartInfo(j))->fPID; // Select highest momentum (energy) charged pion if (abs(PID) == 211) { Ppip = (event->PartInfo(j))->fP; double th = (180./M_PI)*FitUtils::th(Pnu, Ppip); thVect.push_back(th); } } fXVar = 0; return; }; //******************************************************************** // The signal definition for MINERvA CCNpi+ // Last bool refers to if we're selecting on the full phase space or not bool MINERvA_CCNpip_XSec_1Dth_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCCNpip_MINERvA(event, EnuMin, EnuMax, !fFullPhaseSpace); } //******************************************************************** // Need to override FillHistograms() here because we fill the histogram N_pion times void MINERvA_CCNpip_XSec_1Dth_nu::FillHistograms() { //******************************************************************** if (Signal){ int nPions = thVect.size(); // Need to loop over all the pions in the sample for (size_t k = 0; k < thVect.size(); ++k) { double th = thVect[k]; this->fMCHist->Fill(th, Weight); this->fMCFine->Fill(th, Weight); this->fMCStat->Fill(th, 1.0); if (nPions == 1) { onePions->Fill(th, Weight); } else if (nPions == 2) { twoPions->Fill(th, Weight); } else if (nPions == 3) { threePions->Fill(th, Weight); } else if (nPions > 3) { morePions->Fill(th, Weight); } PlotUtils::FillNeutModeArray(fMCHist_PDG, Mode, th, Weight); } } return; } //******************************************************************** void MINERvA_CCNpip_XSec_1Dth_nu::ScaleEvents() { //******************************************************************** Measurement1D::ScaleEvents(); onePions->Scale(this->fScaleFactor, "width"); twoPions->Scale(this->fScaleFactor, "width"); threePions->Scale(this->fScaleFactor, "width"); morePions->Scale(this->fScaleFactor, "width"); return; } //******************************************************************** void MINERvA_CCNpip_XSec_1Dth_nu::Write(std::string drawOpts) { //******************************************************************** Measurement1D::Write(drawOpts); // Draw the npions stack onePions->SetTitle("1#pi"); onePions->SetLineColor(kBlack); //onePions->SetFillStyle(0); onePions->SetFillColor(onePions->GetLineColor()); twoPions->SetTitle("2#pi"); twoPions->SetLineColor(kRed); //twoPions->SetFillStyle(0); twoPions->SetFillColor(twoPions->GetLineColor()); threePions->SetTitle("3#pi"); threePions->SetLineColor(kGreen); //threePions->SetFillStyle(0); threePions->SetFillColor(threePions->GetLineColor()); morePions->SetTitle(">3#pi"); morePions->SetLineColor(kBlue); //morePions->SetFillStyle(0); morePions->SetFillColor(morePions->GetLineColor()); THStack pionStack = THStack((fName+"_pionStack").c_str(), (fName+"_pionStack").c_str()); pionStack.Add(onePions); pionStack.Add(twoPions); pionStack.Add(threePions); pionStack.Add(morePions); pionStack.Write(); return; } diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1Dthmu_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1Dthmu_nu.cxx index bb75785..3f47375 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1Dthmu_nu.cxx +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1Dthmu_nu.cxx @@ -1,71 +1,71 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCNpip_XSec_1Dthmu_nu.h" //******************************************************************** // The constructor MINERvA_CCNpip_XSec_1Dthmu_nu::MINERvA_CCNpip_XSec_1Dthmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ //******************************************************************** fName = "MINERvA_CCNpip_XSec_1Dthmu_nu_2016"; fPlotTitles = "; #theta_{#mu} (degrees); d#sigma/d#theta_{#mu} (cm^{2}/degrees/nucleon)"; EnuMin = 1.5; EnuMax = 10; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2016/nu-ccNpi+-xsec-muon-theta.csv"); // MINERvA has the error quoted as a percentage of the cross-section // Need to make this into an absolute error before we go from correlation matrix -> covariance matrix since it depends on the error in the ith bin for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { fDataHist->SetBinError(i+1, fDataHist->GetBinContent(i+1)*(fDataHist->GetBinError(i+1)/100.)); } // This is a correlation matrix this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CCNpip/2016/nu-ccNpi+-correlation-muon-angle.csv", fDataHist->GetNbinsX()); this->SetupDefaultHist(); - fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; //******************************************************************** void MINERvA_CCNpip_XSec_1Dthmu_nu::FillEventVariables(FitEvent *event) { //******************************************************************** if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double thmu = (180./M_PI)*FitUtils::th(Pnu, Pmu); fXVar = thmu; return; }; //******************************************************************** // Last false refers to that this is NOT the restricted MINERvA phase space, in which only forward-going muons are accepted bool MINERvA_CCNpip_XSec_1Dthmu_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCCNpip_MINERvA(event, EnuMin, EnuMax, false); } diff --git a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_antinu.cxx b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_antinu.cxx index 1e15d2c..ee32c05 100644 --- a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_antinu.cxx +++ b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_antinu.cxx @@ -1,123 +1,123 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCQE_XSec_1DQ2_antinu.h" //******************************************************************** MINERvA_CCQE_XSec_1DQ2_antinu::MINERvA_CCQE_XSec_1DQ2_antinu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ //******************************************************************** // Setup Measurement Defaults fName = name; fPlotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"; isFluxFix = name.find("_oldflux") == std::string::npos; fullphasespace = name.find("_20deg") == std::string::npos; EnuMin = 1.5; EnuMax = 10.; fNormError = 0.110; fAllowedTypes = "FIX,FREE,SHAPE/DIAG,FULL/NORM"; fDefaultTypes = "FIX/FULL"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // Setup the Data Plots std::string basedir = FitPar::GetDataBase()+"/MINERvA/CCQE/"; std::string datafilename = ""; std::string covarfilename = ""; // Full Phase Space if (fullphasespace){ if (isFluxFix){ if (fIsShape){ ERR(WRN) << "SHAPE likelihood comparison not available for MINERvA " << "datasets with fixed flux information. NUISANCE will scale MC to match " << "data normalization but full covariance will be used. " << std::endl; } datafilename = "Q2QE_numubar_data_fluxfix.txt"; covarfilename = "Q2QE_numubar_covar_fluxfix.txt"; } else { if (fIsShape){ datafilename = "Q2QE_numubar_data_SHAPE-extracted.txt"; covarfilename = "Q2QE_numubar_covar_SHAPE-extracted.txt"; } else { datafilename = "Q2QE_numubar_data.txt"; covarfilename = "Q2QE_numubar_covar.txt"; } } // Restricted Phase Space } else { if (isFluxFix){ if (fIsShape){ ERR(WRN) << "SHAPE likelihood comparison not available for MINERvA " << "datasets with fixed flux information. NUISANCE will scale MC to match " << "data normalization but full covariance will be used. " << std::endl; } datafilename = "20deg_Q2QE_numubar_data_fluxfix.txt"; covarfilename = "20deg_Q2QE_numubar_covar_fluxfix.txt"; } else { if (fIsShape){ datafilename = "20deg_Q2QE_numubar_data_SHAPE-extracted.txt"; covarfilename = "20deg_Q2QE_numubar_covar_SHAPE-extracted.txt"; } else { datafilename = "20deg_Q2QE_numubar_data.txt"; covarfilename = "20deg_Q2QE_numubar_covar.txt"; } } } this->SetDataValues( basedir + datafilename ); this->SetCovarMatrixFromText( basedir + covarfilename, 8 ); // Setup Default MC Histograms this->SetupDefaultHist(); // Set Scale Factor (EventHist/nucleons) * NNucl / NNeutons - fScaleFactor = (this->fEventHist->Integral("width")*1E-38/(fNEvents+0.))*13./7./this->TotalIntegratedFlux(); + fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38/(fNEvents+0.))*13./7./this->TotalIntegratedFlux(); }; //******************************************************************** void MINERvA_CCQE_XSec_1DQ2_antinu::FillEventVariables(FitEvent *event){ //******************************************************************** if (event->NumFSParticle(-13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(-13)->fP; double ThetaMu = Pnu.Vect().Angle(Pmu.Vect()); double q2qe = FitUtils::Q2QErec(Pmu, cos(ThetaMu), 30.,true); fXVar = q2qe; return; } //******************************************************************** bool MINERvA_CCQE_XSec_1DQ2_antinu::isSignal(FitEvent *event){ //******************************************************************* return SignalDef::isCCQEnumubar_MINERvA(event, EnuMin, EnuMax, fullphasespace); } diff --git a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_joint.cxx b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_joint.cxx index 9f50c3d..5505e1c 100644 --- a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_joint.cxx +++ b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_joint.cxx @@ -1,167 +1,164 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCQE_XSec_1DQ2_joint.h" //******************************************************************** MINERvA_CCQE_XSec_1DQ2_joint::MINERvA_CCQE_XSec_1DQ2_joint(std::string name, std::string inputfiles, FitWeight *rw, std::string type, std::string fakeDataFile){ //******************************************************************** // Setup The Measurement fName = name; nBins = 16; fPlotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"; isFluxFix = name.find("_oldflux") == std::string::npos; fullphasespace = name.find("_20deg") == std::string::npos; fIsRatio = false; fIsSummed = false; fSaveSubMeas = true; SetupMeasurement(inputfiles, type, rw, fakeDataFile); // Get parsed input files if (fSubInFiles.size() != 2) ERR(FTL) << "MINERvA Joint requires input files in format: antinu;nu"<<std::endl; std::string inFileAntineutrino = fSubInFiles.at(0); std::string inFileNeutrino = fSubInFiles.at(1); // Push classes back into list for processing loop fSubChain.push_back(MIN_anu); fSubChain.push_back(MIN_nu); // Setup the Data input std::string basedir = FitPar::GetDataBase()+"/MINERvA/CCQE/"; std::string datafilename = ""; std::string covarfilename = ""; std::string neutrinoclass = ""; std::string antineutrinoclass = ""; // Full Phase Space if (fullphasespace){ if (isFluxFix){ if (fIsShape) { ERR(WRN) << "SHAPE likelihood comparison not available for MINERvA " << "datasets with fixed flux information. NUISANCE will scale MC to match " << "data normalization but full covariance will be used. " << std::endl; } datafilename = "Q2QE_joint_data_fluxfix.txt"; covarfilename = "Q2QE_joint_covar_fluxfix.txt"; neutrinoclass = "MINERvA_CCQE_XSec_1DQ2_nu_newflux"; antineutrinoclass = "MINERvA_CCQE_XSec_1DQ2_antinu_newflux"; } else { if (fIsShape){ datafilename = "Q2QE_joint_dataa_SHAPE-extracted.txt"; covarfilename = "Q2QE_joint_covara_SHAPE-extracted.txt"; } else { datafilename = "Q2QE_joint_data.txt"; covarfilename = "Q2QE_joint_covar.txt"; } neutrinoclass = "MINERvA_CCQE_XSec_1DQ2_nu"; antineutrinoclass = "MINERvA_CCQE_XSec_1DQ2_antinu"; } // Restricted Phase Space } else { if (isFluxFix){ if (fIsShape) { ERR(WRN) << "SHAPE likelihood comparison not available for MINERvA " << "datasets with fixed flux information. NUISANCE will scale MC to match " << "data normalization but full covariance will be used. " << std::endl; } - + datafilename = "20deg_Q2QE_joint_data_fluxfix.txt"; covarfilename = "20deg_Q2QE_joint_covar_fluxfix.txt"; neutrinoclass = "MINERvA_CCQE_XSec_1DQ2_nu_20deg_newflux"; antineutrinoclass = "MINERvA_CCQE_XSec_1DQ2_antinu_20deg_newflux"; } else { if (fIsShape){ datafilename = "20deg_Q2QE_joint_dataa_SHAPE-extracted.txt"; covarfilename = "20deg_Q2QE_joint_covara_SHAPE-extracted.txt"; } else { datafilename = "20deg_Q2QE_joint_data.txt"; covarfilename = "20deg_Q2QE_joint_covar.txt"; } neutrinoclass = "MINERvA_CCQE_XSec_1DQ2_nu_20deg"; antineutrinoclass = "MINERvA_CCQE_XSec_1DQ2_antinu_20deg"; } } // Setup Data this->SetDataValues( basedir + datafilename ); this->SetCovarMatrixFromText( basedir + covarfilename, nBins); // Setup Experiments MIN_anu = new MINERvA_CCQE_XSec_1DQ2_antinu(antineutrinoclass, inFileAntineutrino, rw, type, fakeDataFile); MIN_nu = new MINERvA_CCQE_XSec_1DQ2_nu (neutrinoclass, inFileNeutrino, rw, type, fakeDataFile); // Add to chain for processing this->fSubChain.clear(); this->fSubChain.push_back(MIN_anu); this->fSubChain.push_back(MIN_nu); - this->fFluxHist = GetCombinedFlux(); - this->fEventHist = GetCombinedEventRate(); - // Setup Default MC Hists SetupDefaultHist(); }; //******************************************************************** void MINERvA_CCQE_XSec_1DQ2_joint::MakePlots(){ //******************************************************************** UInt_t sample = 0; for (std::vector<MeasurementBase*>::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++){ MeasurementBase* exp = static_cast<MeasurementBase*>(*expIter); if (sample == 0){ MIN_anu = static_cast<MINERvA_CCQE_XSec_1DQ2_antinu*>(exp); TH1D* MIN_anu_mc = (TH1D*) MIN_anu->GetMCList().at(0); for (int i = 0; i < 8; i++){ std::cout << "Adding MIN_anu_MC " << i+1 << " : " << i+1 << " " << MIN_anu_mc->GetBinContent(i+1) << std::endl; fMCHist->SetBinContent(i+1, MIN_anu_mc->GetBinContent(i+1)); fMCHist->SetBinError(i+1, MIN_anu_mc->GetBinError(i+1)); } } else if (sample == 1){ MIN_nu = static_cast<MINERvA_CCQE_XSec_1DQ2_nu*>(exp); TH1D* MIN_nu_mc = (TH1D*) MIN_nu->GetMCList().at(0); for (int i = 0; i < 8; i++){ std::cout << "Adding MIN_nu_MC " << i+1+8 << " : " << i+1 << " " << MIN_nu_mc->GetBinContent(i+1) << std::endl; fMCHist->SetBinContent(i+1+8, MIN_nu_mc->GetBinContent(i+1)); fMCHist ->SetBinError(i+1+8, MIN_nu_mc->GetBinError(i+1)); } - } + } sample++; } return; } diff --git a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_nu.cxx b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_nu.cxx index 24626a3..250eb4f 100644 --- a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_nu.cxx +++ b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_nu.cxx @@ -1,138 +1,138 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCQE_XSec_1DQ2_nu.h" //******************************************************************** MINERvA_CCQE_XSec_1DQ2_nu::MINERvA_CCQE_XSec_1DQ2_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ //******************************************************************** // Measurement Defaults fName = name; fPlotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"; isFluxFix = name.find("_oldflux") == std::string::npos; fullphasespace = name.find("_20deg") == std::string::npos; EnuMin = 1.5; EnuMax = 10.; fNormError = 0.101; fAllowedTypes = "FIX,FREE,SHAPE/DIAG,FULL/NORM"; fDefaultTypes = "FIX/FULL"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // Setup the Data Plots std::string basedir = FitPar::GetDataBase()+"/MINERvA/CCQE/"; std::string datafilename = ""; std::string covarfilename = ""; // Full Phase Space if (fullphasespace){ if (isFluxFix){ if (fIsShape){ ERR(WRN) << "SHAPE likelihood comparison not available for MINERvA " << "datasets with fixed flux information. NUISANCE will scale MC to match " << "data normalization but full covariance will be used. " << std::endl; } datafilename = "Q2QE_numu_data_fluxfix.txt"; covarfilename = "Q2QE_numu_covar_fluxfix.txt"; } else { if (fIsShape){ datafilename = "Q2QE_numu_data_SHAPE-extracted.txt"; covarfilename = "Q2QE_numu_covar_SHAPE-extracted.txt"; } else { datafilename = "Q2QE_numu_data.txt"; covarfilename = "Q2QE_numu_covar.txt"; } } // Restricted Phase Space } else { if (isFluxFix){ if (fIsShape){ ERR(WRN) << "SHAPE likelihood comparison not available for MINERvA " << "datasets with fixed flux information. NUISANCE will scale MC to match " << "data normalization but full covariance will be used. " << std::endl; } datafilename = "20deg_Q2QE_numu_data_fluxfix.txt"; covarfilename = "20deg_Q2QE_numu_covar_fluxfix.txt"; } else { if (fIsShape){ datafilename = "20deg_Q2QE_numu_data_SHAPE-extracted.txt"; covarfilename = "20deg_Q2QE_numu_covar_SHAPE-extracted.txt"; } else { datafilename = "20deg_Q2QE_numu_data.txt"; covarfilename = "20deg_Q2QE_numu_covar.txt"; } } } this->SetDataValues( basedir + datafilename ); this->SetCovarMatrixFromText( basedir + covarfilename, 8 ); // Quick Fix for Correl/Covar Issues only for old data if (!isFluxFix){ fCorrel = (TMatrixDSym*)fFullCovar->Clone(); delete fFullCovar; delete covar; delete fDecomp; fFullCovar = StatUtils::GetCovarFromCorrel(fCorrel,fDataHist); (*fFullCovar) *= 1E76; } covar = StatUtils::GetInvert(fFullCovar); fDecomp = StatUtils::GetDecomp(fFullCovar); // Setup Default MC Histograms this->SetupDefaultHist(); // Set Scale Factor (EventHist/nucleons) * NNucl / NNeutons - fScaleFactor = (this->fEventHist->Integral("width")*1E-38*13.0/6.0/(fNEvents+0.))/this->TotalIntegratedFlux(); + fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38*13.0/6.0/(fNEvents+0.))/this->TotalIntegratedFlux(); }; //******************************************************************** void MINERvA_CCQE_XSec_1DQ2_nu::FillEventVariables(FitEvent *event){ //******************************************************************** if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double ThetaMu = Pnu.Vect().Angle(Pmu.Vect()); double q2qe = FitUtils::Q2QErec(Pmu, cos(ThetaMu), 34.,true); // Set binning variable fXVar = q2qe; return; } //******************************************************************** bool MINERvA_CCQE_XSec_1DQ2_nu::isSignal(FitEvent *event){ //******************************************************************* return SignalDef::isCCQEnumu_MINERvA(event, EnuMin, EnuMax, fullphasespace); } diff --git a/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_nu.cxx b/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_nu.cxx index 6d3eaf7..5864c16 100644 --- a/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_nu.cxx +++ b/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_nu.cxx @@ -1,116 +1,116 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCinc_XSec_1DEnu_nu.h" //******************************************************************** MINERvA_CCinc_XSec_1DEnu_nu::MINERvA_CCinc_XSec_1DEnu_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ //******************************************************************** // Measurement Details fName = name; fPlotTitles = "; Neutrino energy (GeV); d#sigma/dE_{#nu} (cm^{2}/GeV/nucleon)"; EnuMin = 2.; EnuMax = 20.; target = ""; fIsRawEvents = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); if (name.find("C12") != std::string::npos) target = "C12"; else if (name.find("Fe56") != std::string::npos) target = "Fe56"; else if (name.find("Pb208") != std::string::npos) target = "Pb208"; if (name.find("DEN") != std::string::npos) target = "CH"; if (target == "") ERR(WRN) << "target " << target << " was not found!" << std::endl; // Setup the Data Plots std::string basedir = FitPar::GetDataBase()+"/MINERvA/CCinc/"; std::string smearfilename = "CCinc_"+target+"_x_smear.csv"; int nbins = 8; double bins[9] = {2, 3, 4, 5, 6, 8, 10, 15, 20}; // Make a dummy fDataHist so it is used to construct other histograms... this->fDataHist = new TH1D(name.c_str(),(name+fPlotTitles).c_str(),nbins,bins); // Setup Default MC Histograms this->SetupDefaultHist(); // Set Scale Factor (EventHist/nucleons) so I don't need to know what the target is here - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38/(fNEvents+0.))/this->TotalIntegratedFlux(); // NEUT + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38/(fNEvents+0.))/this->TotalIntegratedFlux(); // NEUT }; //******************************************************************** void MINERvA_CCinc_XSec_1DEnu_nu::FillEventVariables(FitEvent *event){ //******************************************************************** if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; Enu = Pnu.E()/1000.; ThetaMu = Pnu.Vect().Angle(Pmu.Vect()); fXVar = Enu; return; } //******************************************************************** bool MINERvA_CCinc_XSec_1DEnu_nu::isSignal(FitEvent *event){ //******************************************************************* // Throw away NC events if (event->Mode > 30) return false; // Only look at numu events if ((event->PartInfo(0))->fPID != 14) return false; // Restrict the phase space to theta < 17 degrees if (ThetaMu > 0.296706) return false; // restrict energy range if (Enu < this->EnuMin || Enu > this->EnuMax) return false; return true; }; //******************************************************************** void MINERvA_CCinc_XSec_1DEnu_nu::ScaleEvents(){ //******************************************************************** // Get rid of this because it causes odd behaviour //Measurement1D::ScaleEvents(); this->fMCHist->Scale(this->fScaleFactor, "width"); // Proper error scaling - ROOT Freaks out with xsec weights sometimes for(int i=0; i<this->fMCStat->GetNbinsX();i++) { if (this->fMCStat->GetBinContent(i+1) != 0) this->fMCHist->SetBinError(i+1, this->fMCHist->GetBinContent(i+1) * this->fMCStat->GetBinError(i+1) / this->fMCStat->GetBinContent(i+1) ); else this->fMCHist->SetBinError(i+1, this->fMCHist->Integral()); } } diff --git a/src/MINERvA/MINERvA_CCinc_XSec_1Dx_nu.cxx b/src/MINERvA/MINERvA_CCinc_XSec_1Dx_nu.cxx index 47c7d3b..50e07c4 100644 --- a/src/MINERvA/MINERvA_CCinc_XSec_1Dx_nu.cxx +++ b/src/MINERvA/MINERvA_CCinc_XSec_1Dx_nu.cxx @@ -1,124 +1,124 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCinc_XSec_1Dx_nu.h" //******************************************************************** MINERvA_CCinc_XSec_1Dx_nu::MINERvA_CCinc_XSec_1Dx_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ //******************************************************************** // Measurement Details fName = name; fPlotTitles = "; Reconstructed Bjorken x; d#sigma/dx (cm^{2}/nucleon)"; EnuMin = 2.; EnuMax = 20.; target = ""; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); if (name.find("C12") != std::string::npos) target = "C12"; else if (name.find("Fe56") != std::string::npos) target = "Fe56"; else if (name.find("Pb208") != std::string::npos) target = "Pb208"; if (name.find("DEN") != std::string::npos) target = "CH"; if (target == "") ERR(WRN) << "target " << target << " was not found!" << std::endl; // Setup the Data Plots std::string basedir = FitPar::GetDataBase()+"/MINERvA/CCinc/"; std::string smearfilename = "CCinc_"+target+"_x_smear.csv"; int nbins = 6; double bins[7] = {0, 0.1, 0.3, 0.7, 0.9, 1.1, 1.5}; // Note that only the ratio is given, so I can't do this->SetDataValues or this->SetCovarMatrix this->fDataHist = new TH1D(name.c_str(),(name+fPlotTitles).c_str(),nbins,bins); // Setup Default MC Histograms this->SetupDefaultHist(); // The smearing matrix is rectangular this->SetSmearingMatrix(basedir + smearfilename, nbins, nbins+1); // Set Scale Factor (EventHist/nucleons) so I don't need to know what the target is here - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38/(fNEvents+0.))/this->TotalIntegratedFlux(); // NEUT + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38/(fNEvents+0.))/this->TotalIntegratedFlux(); // NEUT }; //******************************************************************** void MINERvA_CCinc_XSec_1Dx_nu::FillEventVariables(FitEvent *event){ //******************************************************************** if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; ThetaMu = Pnu.Vect().Angle(Pmu.Vect()); TLorentzVector q = Pnu - Pmu; double q0 = q.E()/1000.0; double Emu = (Pmu.E())/1000.0; Enu_rec = Emu + q0; double Q2 = 4*Enu_rec*Emu*sin(ThetaMu/2)*sin(ThetaMu/2); bjork_x = Q2/2./q0/((PhysConst::mass_proton+PhysConst::mass_neutron)/2.); // Average nucleon masses fXVar = bjork_x; return; } //******************************************************************** bool MINERvA_CCinc_XSec_1Dx_nu::isSignal(FitEvent *event){ //******************************************************************* // Only look at numu events if (!SignalDef::isCCINC(event, 14, EnuMin, EnuMax)) return false; // Restrict the phase space to theta < 17 degrees if (ThetaMu > 0.296706) return false; // restrict energy range if (Enu_rec < this->EnuMin || Enu_rec > this->EnuMax) return false; return true; }; //******************************************************************** void MINERvA_CCinc_XSec_1Dx_nu::ScaleEvents(){ //******************************************************************** this->fDataHist = (TH1D*)this->GetMCList().at(0)->Clone(); this->fDataHist->SetNameTitle((this->fName+"_unsmear").c_str(), (this->fName+"_unsmear"+this->fPlotTitles).c_str()); this->ApplySmearingMatrix(); // Get rid of this because it causes odd behaviour //Measurement1D::ScaleEvents(); this->fMCHist->Scale(this->fScaleFactor, "width"); // Proper error scaling - ROOT Freaks out with xsec weights sometimes for(int i=0; i<this->fMCStat->GetNbinsX();i++) { if (this->fMCStat->GetBinContent(i+1) != 0) this->fMCHist->SetBinError(i+1, this->fMCHist->GetBinContent(i+1) * this->fMCStat->GetBinError(i+1) / this->fMCStat->GetBinContent(i+1) ); else this->fMCHist->SetBinError(i+1, this->fMCHist->Integral()); } } diff --git a/src/MINERvA/MINERvA_CCinc_XSec_2DEavq3_nu.cxx b/src/MINERvA/MINERvA_CCinc_XSec_2DEavq3_nu.cxx index 67fc298..c2d201f 100755 --- a/src/MINERvA/MINERvA_CCinc_XSec_2DEavq3_nu.cxx +++ b/src/MINERvA/MINERvA_CCinc_XSec_2DEavq3_nu.cxx @@ -1,139 +1,139 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCinc_XSec_2DEavq3_nu.h" //******************************************************************** MINERvA_CCinc_XSec_2DEavq3_nu::MINERvA_CCinc_XSec_2DEavq3_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ //******************************************************************** // Measurement Details fName = "MINERvA_CCinc_XSec_2DEavq3_nu"; fPlotTitles = "; q_{3} (GeV); E_{avail} (GeV); d^{2}#sigma/dq_{3}dE_{avail} (cm^{2}/GeV^{2})"; EnuMin = 2.; EnuMax = 6.; hadroncut = FitPar::Config().GetParB("MINERvA_CCinc_XSec_2DEavq3_nu.hadron_cut"); useq3true = FitPar::Config().GetParB("MINERvA_CCinc_XSec_2DEavq3_nu.useq3true"); splitMEC_PN_NN = FitPar::Config().GetParB("Modes.split_PN_NN"); fNormError = 0.107; fDefaultTypes = "FIX/FULL"; fAllowedTypes = "FIX,FREE,SHAPE/FULL,DIAG/MASK"; Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // Binning for the 2D Histograms this->fNDataPointsX = 7; this->fNDataPointsY = 17; Double_t tempx[7] = {0.0, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8}; Double_t tempy[17] = {0.0, 0.02, 0.04, 0.06, 0.08, 0.10, 0.12, 0.14, 0.16, 0.20, 0.25, 0.30, 0.35, 0.40, 0.50, 0.60, 0.80}; this->fXBins = tempx; this->fYBins = tempy; // Fill data and 1Dto2D Maps for covariance SetDataValuesFromText( FitPar::GetDataBase()+"/MINERvA/CCEavq3/data_2D.txt", 1E-42); SetMapValuesFromText( FitPar::GetDataBase()+"/MINERvA/CCEavq3/map_2D.txt"); SetCovarMatrixFromChol( FitPar::GetDataBase()+"/MINERvA/CCEavq3/covar_2D.txt", 67); // Data is in 1E-42 and so is the covariance, need to scale accordingly. (*this->fFullCovar) *= 1E-16; (*this->covar) *= 1E16; // Set data errors from covariance matrix StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar, fMapHist, 1E-38); // Setup mc Histograms SetupDefaultHist(); // Set Scale Factor - fScaleFactor = (this->fEventHist->Integral("width")*1E-42/(fNEvents+0.))/this->TotalIntegratedFlux(); + fScaleFactor = (GetEventHistogram()->Integral("width")*1E-42/(fNEvents+0.))/this->TotalIntegratedFlux(); }; //******************************************************************** void MINERvA_CCinc_XSec_2DEavq3_nu::FillEventVariables(FitEvent *event){ //******************************************************************** // Seperate MEC if (splitMEC_PN_NN){ int npr = 0; int nne = 0; for (UInt_t j = 0; j < event->Npart(); j++){ if ((event->PartInfo(j))->fIsAlive) continue; if (event->PartInfo(j)->fPID == 2212) npr++; else if (event->PartInfo(j)->fPID == 2112) nne++; } if (event->Mode == 2 and npr == 1 and nne == 1){ event->Mode = 2; Mode = 2; } else if (event->Mode == 2 and npr == 0 and nne == 2){ event->Mode = 3; Mode = 3; } } // Set Defaults double Eav = -999.9; double q3 = -999.9; // If muon found get kinematics FitParticle* muon = event->GetHMFSParticle(13); FitParticle* neutrino = event->GetNeutrinoIn(); if (muon && neutrino){ // Set Q from Muon TLorentzVector q = neutrino->fP - muon->fP; double q0 = (q.E())/1.E3; //double q3_true = (q.Vect().Mag())/1.E3; double thmu = muon->fP.Vect().Angle(neutrino->fP.Vect()); double pmu = muon->fP.Vect().Mag()/1.E3; double emu = muon->fP.E()/1.E3; double mmu = muon->fP.Mag()/1.E3; // Get Enu Rec double enu_rec = emu + q0; // Set Q2 QE double q2qe = 2*enu_rec * (emu - pmu * cos(thmu)) - mmu*mmu; // Calc Q3 from Q2QE and EnuTree q3 = sqrt(q2qe + q0*q0); // Get Eav too Eav = FitUtils::GetErecoil_MINERvA_LowRecoil(event) / 1.E3; } // Set Hist Variables fXVar = q3; fYVar = Eav; return; } //******************************************************************** bool MINERvA_CCinc_XSec_2DEavq3_nu::isSignal(FitEvent *event){ //******************************************************************** return SignalDef::isCCincLowRecoil_MINERvA(event, EnuMin, EnuMax); } diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DEnu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DEnu_nu.cxx index 492aa7e..b76b42a 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DEnu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DEnu_nu.cxx @@ -1,74 +1,74 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CC1pi0_XSec_1DEnu_nu.h" // The constructor MiniBooNE_CC1pi0_XSec_1DEnu_nu::MiniBooNE_CC1pi0_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ - + fName = "MiniBooNE_CC1pi0_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/CH_{2})"; fIsDiag = false; fIsEnu1D = true; fNormError = 0.107; EnuMin = 0.5; EnuMax = 2.0; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pi0/totalxsec_edit.txt"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pi0/totalxsec_covar.txt", this->fNDataPointsX); //this->SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/cc1pi0/totalxsec_covar.txt", this->fNDataPointsX-1); this->SetupDefaultHist(); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(14.08); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08); }; void MiniBooNE_CC1pi0_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu =event->GetNeutrinoIn()->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; - + double Enu = FitUtils::EnuCC1pi0rec(Pnu, Pmu, Ppi0); fXVar = Enu; return; }; -// ************************************************** -// MiniBooNE CC1pi0 signal definition -// +// ************************************************** +// MiniBooNE CC1pi0 signal definition +// // The signal definition is: // Exactly one negative muon -// Exactly one pi0 -// No additional mesons +// Exactly one pi0 +// No additional mesons // Any number of nucleons -// +// // Does a few clever cuts on the likelihood to reduce CCQE contamination by // looking at "fuzziness" of the ring; CCQE events are sharp, CC1pi0 are fuzzy // (because of the pi0->2 gamma collinearity) bool MiniBooNE_CC1pi0_XSec_1DEnu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi(event, 14, 111, EnuMin, EnuMax); } diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DQ2_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DQ2_nu.cxx index 24fdb93..c7ab786 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DQ2_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DQ2_nu.cxx @@ -1,62 +1,62 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CC1pi0_XSec_1DQ2_nu.h" // The constructor MiniBooNE_CC1pi0_XSec_1DQ2_nu::MiniBooNE_CC1pi0_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ - + fName = "MiniBooNE_CC1pi0_XSec_1DQ2_nu"; fPlotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); d#sigma/dQ_{CC#pi}^{2} (cm^{2}/GeV^{2})"; fIsDiag = false; fNormError = 0.107; EnuMin = 0.5; EnuMax = 2.0; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pi0/dxsecdq2_edit.txt"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pi0/dxsecdq2_covar.txt", this->fNDataPointsX); //this->SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/cc1pi0/dxsecdq2_covar.txt", this->fNDataPointsX-1); this->SetupDefaultHist(); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); }; void MiniBooNE_CC1pi0_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; - + double q2CCpi0 = FitUtils::Q2CC1pi0rec(Pnu, Pmu, Ppi0); fXVar = q2CCpi0; return; }; -//******************************************************************** +//******************************************************************** bool MiniBooNE_CC1pi0_XSec_1DQ2_nu::isSignal(FitEvent *event) { -//******************************************************************** +//******************************************************************** return SignalDef::isCC1pi(event, 14, 111, EnuMin, EnuMax); } diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DTu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DTu_nu.cxx index ffb2d7a..6bb7fe2 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DTu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DTu_nu.cxx @@ -1,62 +1,62 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CC1pi0_XSec_1DTu_nu.h" // The constructor MiniBooNE_CC1pi0_XSec_1DTu_nu::MiniBooNE_CC1pi0_XSec_1DTu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "MiniBooNE_CC1pi0_XSec_1DTu_nu"; fPlotTitles = "; T_{#mu} (GeV); d#sigma/dE_{#mu} (cm^{2}/GeV^{2}/CH_{2})"; fIsDiag = false; fNormError = 0.107; EnuMin = 0.5; EnuMax = 2.0; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pi0/dxsecdemu_edit.txt"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pi0/dxsecdemu_covar.txt", this->fNDataPointsX); //this->SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/cc1pi0/dxsecdemu_covar.txt", this->fNDataPointsX-1); this->SetupDefaultHist(); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); }; void MiniBooNE_CC1pi0_XSec_1DTu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; - - double TuCCpi0 = FitUtils::T(Pmu); + + double TuCCpi0 = FitUtils::T(Pmu); fXVar = TuCCpi0; - + return; }; -//******************************************************************** +//******************************************************************** bool MiniBooNE_CC1pi0_XSec_1DTu_nu::isSignal(FitEvent *event) { -//******************************************************************** +//******************************************************************** return SignalDef::isCC1pi(event, 14, 111, EnuMin, EnuMax); } diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.cxx index 5f9eb62..68659eb 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.cxx @@ -1,63 +1,63 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.h" // The constructor MiniBooNE_CC1pi0_XSec_1Dcosmu_nu::MiniBooNE_CC1pi0_XSec_1Dcosmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ - + fName = "MiniBooNE_CC1pi0_XSec_1Dcosmu_nu"; fPlotTitles = "; cos#theta_{#mu}; d#sigma/dcos#theta_{#mu} (cm^{2}/CH_{2})"; fIsDiag = false; fNormError = 0.107; EnuMin = 0.5; EnuMax = 2.0; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pi0/dxsecdcosmu_edit.txt"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pi0/dxsecdcosmu_covar.txt", this->fNDataPointsX); this->SetupDefaultHist(); // Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0 - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); }; void MiniBooNE_CC1pi0_XSec_1Dcosmu_nu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; - // No W cut on MiniBooNE CC1pi+ + // No W cut on MiniBooNE CC1pi+ double CosMu = cos(FitUtils::th(Pnu, Pmu)); fXVar = CosMu; return; }; -//******************************************************************** +//******************************************************************** bool MiniBooNE_CC1pi0_XSec_1Dcosmu_nu::isSignal(FitEvent *event) { -//******************************************************************** +//******************************************************************** return SignalDef::isCC1pi(event, 14, 111, EnuMin, EnuMax); } diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.cxx index 6ef2555..0fefad6 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.cxx @@ -1,64 +1,64 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.h" // The constructor MiniBooNE_CC1pi0_XSec_1Dcospi0_nu::MiniBooNE_CC1pi0_XSec_1Dcospi0_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ - + fName = "MiniBooNE_CC1pi0_XSec_1Dcospi0_nu"; fPlotTitles = "; cos#theta_{#pi^{0}}; d#sigma/dcos#theta_{#pi^{0}} (cm^{2}/CH_{2})"; fIsDiag = false; fNormError = 0.107; EnuMin = 0.5; EnuMax = 2.0; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pi0/dxsecdcospi_edit.txt"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pi0/dxsecdcospi_covar.txt", this->fNDataPointsX); //this->SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/cc1pi0/dxsecdcospi_covar.txt", this->fNDataPointsX -1 ); this->SetupDefaultHist(); // Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0 - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); }; void MiniBooNE_CC1pi0_XSec_1Dcospi0_nu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu =event->GetNeutrinoIn()->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double CosPi0 = cos(FitUtils::th(Pnu, Ppi0)); fXVar = CosPi0; return; }; -//******************************************************************** +//******************************************************************** bool MiniBooNE_CC1pi0_XSec_1Dcospi0_nu::isSignal(FitEvent *event) { -//******************************************************************** +//******************************************************************** return SignalDef::isCC1pi(event, 14, 111, EnuMin, EnuMax); } diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dppi0_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dppi0_nu.cxx index b457f82..7df8da2 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dppi0_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dppi0_nu.cxx @@ -1,62 +1,62 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CC1pi0_XSec_1Dppi0_nu.h" // The constructor MiniBooNE_CC1pi0_XSec_1Dppi0_nu::MiniBooNE_CC1pi0_XSec_1Dppi0_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ - + fName = "MiniBooNE_CC1pi0_XSec_1Dppi0_nu"; fPlotTitles = "; p_{#pi^{0}} (GeV/c); d#sigma/dp_{#pi^{0}} (cm^{2}/GeV/CH_{2})"; fIsDiag = false; fNormError = 0.107; EnuMin = 0.5; EnuMax = 2.0; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pi0/dxsecdppi_edit.txt"); this->SetCovarMatrixFromCorrText(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pi0/dxsecdppi_covar.txt", this->fNDataPointsX); //this->SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/cc1pi0/dxsecdppi_covar.txt", this->fNDataPointsX-1); this->SetupDefaultHist(); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); }; void MiniBooNE_CC1pi0_XSec_1Dppi0_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu =event->GetNeutrinoIn()->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; - - double p_pi0 = FitUtils::p(Ppi0); + + double p_pi0 = FitUtils::p(Ppi0); fXVar = p_pi0; return; }; -//******************************************************************** +//******************************************************************** bool MiniBooNE_CC1pi0_XSec_1Dppi0_nu::isSignal(FitEvent *event) { -//******************************************************************** +//******************************************************************** return SignalDef::isCC1pi(event, 14, 111, EnuMin, EnuMax); } diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DEnu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DEnu_nu.cxx index bdd5aca..b8a9e9b 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DEnu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DEnu_nu.cxx @@ -1,90 +1,90 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_1DEnu_nu.h" // The constructor -//******************************************************************** +//******************************************************************** MiniBooNE_CC1pip_XSec_1DEnu_nu::MiniBooNE_CC1pip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { - + fName = "MiniBooNE_CC1pip_XSec_1DEnu_nu"; fPlotTitles = "; E_{#nu} (MeV); #sigma(E_{#nu}) (cm^{2}/CH_{2})"; fIsDiag = true; fIsEnu1D = true; fNormError = 0.107; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pip/ccpipXSec_enu.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); //StatUtils::ForceNormIntoCovar(this->covar, this->fDataHist, this->fNormError); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(14.08); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08); }; -//******************************************************************** +//******************************************************************** void MiniBooNE_CC1pip_XSec_1DEnu_nu::FillEventVariables(FitEvent* event) { -//******************************************************************** - +//******************************************************************** + if (event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; // No W cut on MiniBooNE data from publication // WARNING: DRAGONS LAY HERE! Mike Wilking's thesis might not have this. Beware that the publication says W < 1.35 GeV, but this is "efficiency corrected", i.e. FILLED WITH MONTE-CARLO!!!!!!!! AAAAAH //double hadMass = FitUtils::Wrec(Pnu, Pmu, Ppip); double Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip); // if (isRat) Enu = Enu/1000.; //CCpi+/CCQE ratio paper puts in GeV, CCpi+ paper in MeV fXVar = Enu; return; }; -// ********************************************* -// MiniBooNE CC1pi+ signal definition -// Warning: This one is a little scary because there's a W = 1.35 GeV cut for -// signal in the selection -// Although this is unfolded over and is filled up with NUANCE -// So there is actually no W cut applied, but everything above W = 1.35 -// GeV is NUANCE... -// -// The signal definition is: -// Exactly one negative muon -// Exactly one positive pion -// No other mesons -// No requirements on photons, nucleons and -// multi-nucleons -// Doesn't mention other leptons -// -// Additionally, it asks for 2 Michel e- from decay of muon and pion -// So there is good purity and we can be fairly sure that the positive pion is a -// positive pion -// +// ********************************************* +// MiniBooNE CC1pi+ signal definition +// Warning: This one is a little scary because there's a W = 1.35 GeV cut for +// signal in the selection +// Although this is unfolded over and is filled up with NUANCE +// So there is actually no W cut applied, but everything above W = 1.35 +// GeV is NUANCE... +// +// The signal definition is: +// Exactly one negative muon +// Exactly one positive pion +// No other mesons +// No requirements on photons, nucleons and +// multi-nucleons +// Doesn't mention other leptons +// +// Additionally, it asks for 2 Michel e- from decay of muon and pion +// So there is good purity and we can be fairly sure that the positive pion is a +// positive pion +// bool MiniBooNE_CC1pip_XSec_1DEnu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi(event, 14, 211, EnuMin, EnuMax); } diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DQ2_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DQ2_nu.cxx index 172bfdf..943e927 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DQ2_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DQ2_nu.cxx @@ -1,69 +1,69 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_1DQ2_nu.h" //******************************************************************** /// @brief MiniBooNE CC1pi+ numu 1DQ2 Measurement on CH2 (Ref: - ) /// // The constructor MiniBooNE_CC1pip_XSec_1DQ2_nu::MiniBooNE_CC1pip_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "MiniBooNE_CC1pip_XSec_1DQ2_nu"; fPlotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); d#sigma/dQ_{CC#pi^{+}}^{2} (cm^{2}/MeV^{2}/CH_{2})"; fIsDiag = true; fNormError = 0.107; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pip/ccpipXSec_Q2.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0 - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width")/1E6; + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width")/1E6; // Added /1E6. comes from Q2 being in MeV^2, not GeV^2 I think... Or maybe the units in the paper are simply wrong; 1E-45 is very small! :D }; //******************************************************************** void MiniBooNE_CC1pip_XSec_1DQ2_nu::FillEventVariables(FitEvent *event){ //******************************************************************** if (event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; // No W cut on MiniBooNE CC1pi+ double Q2CC1pip = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip); fXVar = Q2CC1pip; return; }; //******************************************************************** bool MiniBooNE_CC1pip_XSec_1DQ2_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pi(event, 14, 211, EnuMin, EnuMax); } diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTpi_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTpi_nu.cxx index a6eab49..fa83916 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTpi_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTpi_nu.cxx @@ -1,68 +1,68 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_1DTpi_nu.h" // The constructor MiniBooNE_CC1pip_XSec_1DTpi_nu::MiniBooNE_CC1pip_XSec_1DTpi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "MiniBooNE_CC1pip_XSec_1DTpi_nu"; fPlotTitles = "; T_{#pi} (MeV); d#sigma/dT_{#pi^{+}}} (cm^{2}/MeV/CH_{2})"; fIsDiag = true; fNormError = 0.107; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); - + this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pip/ccpipXSec_KEpi.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); //StatUtils::ForceNormIntoCovar(this->covar, this->fDataHist, this->fNormError); - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); }; -//******************************************************************** +//******************************************************************** void MiniBooNE_CC1pip_XSec_1DTpi_nu::FillEventVariables(FitEvent *event) { -//******************************************************************** +//******************************************************************** if (event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; // No W cut on MiniBooNE data from publication // WARNING: DRAGONS LAY HERE! Mike Wilking's thesis might not have this. Beware that the publication says W < 1.35 GeV, but this is "efficiency corrected", i.e. FILLED WITH MONTE-CARLO!!!!!!!! AAAAAH //double hadMass = FitUtils::Wrec(Pnu, Pmu, Ppip); double Tpi = FitUtils::T(Ppip)*1000.; fXVar = Tpi; return; }; bool MiniBooNE_CC1pip_XSec_1DTpi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi(event, 14, 211, EnuMin, EnuMax); } diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTu_nu.cxx index 4b9bd9e..b51eaaa 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTu_nu.cxx @@ -1,64 +1,64 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_1DTu_nu.h" MiniBooNE_CC1pip_XSec_1DTu_nu::MiniBooNE_CC1pip_XSec_1DTu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "MiniBooNE_CC1pip_XSec_1DTu_nu"; fPlotTitles = "; T_{#mu} (MeV); d#sigma/dT_{#mu} (cm^{2}/MeV/CH_{2})"; fIsDiag = true; fNormError = 0.107; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pip/ccpipXSec_KEmu.txt"); this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0 - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); }; //******************************************************************** void MiniBooNE_CC1pip_XSec_1DTu_nu::FillEventVariables(FitEvent *event) { //******************************************************************** if (event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; // No W cut on MiniBooNE CC1pi+ double Tmu = FitUtils::T(Pmu)*1000.; fXVar = Tmu; return; }; bool MiniBooNE_CC1pip_XSec_1DTu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi(event, 14, 211, EnuMin, EnuMax); } diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.cxx index b19b19e..625a2bd 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.cxx @@ -1,66 +1,66 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.h" -//******************************************************************** +//******************************************************************** MiniBooNE_CC1pip_XSec_2DQ2Enu_nu::MiniBooNE_CC1pip_XSec_2DQ2Enu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ -//******************************************************************** - +//******************************************************************** + fName = "MiniBooNE_CC1pip_XSec_2DQ2Enu_nu"; fPlotTitles = "; E_{#nu} (MeV); Q^{2} (MeV^{2}/c^{4}); d#sigma(E_{#nu})/dQ^{2} (cm^{2}/(MeV^{2}/c^{4})/CH_{2})"; fIsDiag = true; fNormError = 0.107; Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pip/ccpipXSecs.root", std::string("QSQVENUXSec"));//data comes in .root file, yes! this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0 - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(14.08); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08); }; void MiniBooNE_CC1pip_XSec_2DQ2Enu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip)*1000.; double Q2 = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip)*1E6; fXVar = Enu; fYVar = Q2; return; }; -//******************************************************************** +//******************************************************************** bool MiniBooNE_CC1pip_XSec_2DQ2Enu_nu::isSignal(FitEvent *event) { -//******************************************************************** +//******************************************************************** return SignalDef::isCC1pi(event, 14, 211, EnuMin, EnuMax); } diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.cxx index 794abad..8cb5d24 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.cxx @@ -1,81 +1,81 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.h" // The constructor MiniBooNE_CC1pip_XSec_2DTpiCospi_nu::MiniBooNE_CC1pip_XSec_2DTpiCospi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "MiniBooNE_CC1pip_XSec_2DTpiCospi_nu"; fPlotTitles = "; T_{#pi} (MeV); cos#theta_{#pi}; d^{2}#sigma/dT_{#pi}dcos#theta_{#pi} (cm^{2}/MeV)"; fIsDiag = true; fNormError = 0.107; Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pip/ccpipXSecs.root", std::string("PICTVKEXSec"));//data comes in .root file, yes! this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0 - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); }; /* void MiniBooNE_CC1pip_XSec_2DTpiCospi_nu::SetDataValues(std::string fileLocation) { LOG(DEB) << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! fDataHist = (TH2D*)(dataFile->Get("PICTVKEXSec")->Clone()); fDataHist->SetDirectory(0); //should disassociate fDataHist with dataFile dataFile->Close(); delete dataFile; }; */ void MiniBooNE_CC1pip_XSec_2DTpiCospi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double Tpi = FitUtils::T(Ppip)*1000.; double costh = cos(FitUtils::th(Pnu, Ppip)); fXVar = Tpi; fYVar = costh; return; }; -//******************************************************************** +//******************************************************************** bool MiniBooNE_CC1pip_XSec_2DTpiCospi_nu::isSignal(FitEvent *event) { -//******************************************************************** +//******************************************************************** return SignalDef::isCC1pi(event, 14, 211, EnuMin, EnuMax); } diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.cxx index 6db6115..1863569 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.cxx @@ -1,83 +1,83 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.h" -//******************************************************************** +//******************************************************************** MiniBooNE_CC1pip_XSec_2DTpiEnu_nu::MiniBooNE_CC1pip_XSec_2DTpiEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ -//******************************************************************** - +//******************************************************************** + fName = "MiniBooNE_CC1pip_XSec_2DTpiEnu_nu"; fPlotTitles = "; E_{#nu} (MeV); T_{#pi} (MeV); d#sigma(E_{#nu})/dT_{#pi} (cm^{2}/MeV)"; fIsDiag = true; fNormError = 0.107; Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pip/ccpipXSecs.root", std::string("PIKEVENUXSec"));//data comes in .root file, yes! this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0 - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(14.08); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08); }; /* void MiniBooNE_CC1pip_XSec_2DTpiEnu_nu::SetDataValues(std::string fileLocation) { LOG(DEB) << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! fDataHist = (TH2D*)(dataFile->Get("PIKEVENUXSec")->Clone()); fDataHist->SetDirectory(0); //should disassociate fDataHist with dataFile dataFile->Close(); delete dataFile; }; */ void MiniBooNE_CC1pip_XSec_2DTpiEnu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip)*1000.; double Tpi = FitUtils::T(Ppip)*1000.; fXVar = Enu; fYVar = Tpi; return; }; -//******************************************************************** +//******************************************************************** bool MiniBooNE_CC1pip_XSec_2DTpiEnu_nu::isSignal(FitEvent *event) { -//******************************************************************** +//******************************************************************** return SignalDef::isCC1pi(event, 14, 211, EnuMin, EnuMax); } diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.cxx index 8052335..1ebc9c5 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.cxx @@ -1,79 +1,79 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.h" // The constructor MiniBooNE_CC1pip_XSec_2DTuCosmu_nu::MiniBooNE_CC1pip_XSec_2DTuCosmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ - + fName = "MiniBooNE_CC1pip_XSec_2DTuCosmu_nu"; fPlotTitles = "; T_{#mu} (MeV); cos#theta_{#mu}; d^{2}#sigma/dT_{#mu}dcos#theta_{#mu} (cm^{2}/MeV)"; fIsDiag = true; fNormError = 0.107; Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pip/ccpipXSecs.root", std::string("MUCTVKEXSec"));//data comes in .root file, yes! this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0 - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); }; /* void MiniBooNE_CC1pip_XSec_2DTuCosmu_nu::SetDataValues(std::string fileLocation) { LOG(DEB) << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! fDataHist = (TH2D*)(dataFile->Get("MUCTVKEXSec")->Clone()); fDataHist->SetDirectory(0); //should disassociate fDataHist with dataFile dataFile->Close(); delete dataFile; }; */ void MiniBooNE_CC1pip_XSec_2DTuCosmu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double Tmu = FitUtils::T(Pmu)*1000.; double costh = cos(FitUtils::th(Pnu, Pmu)); fXVar = Tmu; fYVar = costh; return; }; -//******************************************************************** +//******************************************************************** bool MiniBooNE_CC1pip_XSec_2DTuCosmu_nu::isSignal(FitEvent *event) { -//******************************************************************** +//******************************************************************** return SignalDef::isCC1pi(event, 14, 211, EnuMin, EnuMax); } diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuEnu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuEnu_nu.cxx index 65f4480..aa8295c 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuEnu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuEnu_nu.cxx @@ -1,79 +1,79 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_2DTuEnu_nu.h" // The constructor MiniBooNE_CC1pip_XSec_2DTuEnu_nu::MiniBooNE_CC1pip_XSec_2DTuEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ - + fName = "MiniBooNE_CC1pip_XSec_2DTuEnu_nu"; fPlotTitles = "; E_{#nu} (MeV); T_{#mu} (MeV); d#sigma(E_{#nu})/dT_{#mu} (cm^{2}/MeV)"; fIsDiag = true; fNormError = 0.107; Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/MiniBooNE/CC1pip/ccpipXSecs.root", std::string("MUKEVENUXSec"));//data comes in .root file, yes! this->SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); // Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0 - this->fScaleFactor = this->fEventHist->Integral("width")*double(1E-38)/double(fNEvents)*(14.08); + this->fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08); }; /* void MiniBooNE_CC1pip_XSec_2DTuEnu_nu::SetDataValues(std::string fileLocation) { LOG(DEB) << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! fDataHist = (TH2D*)(dataFile->Get("MUKEVENUXSec")->Clone()); fDataHist->SetDirectory(0); //should disassociate fDataHist with dataFile dataFile->Close(); delete dataFile; }; */ void MiniBooNE_CC1pip_XSec_2DTuEnu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip)*1000.; double Tmu = FitUtils::T(Pmu)*1000.; fXVar = Enu; fYVar = Tmu; return; }; -//******************************************************************** +//******************************************************************** bool MiniBooNE_CC1pip_XSec_2DTuEnu_nu::isSignal(FitEvent *event) { -//******************************************************************** +//******************************************************************** return SignalDef::isCC1pi(event, 14, 211, EnuMin, EnuMax); } diff --git a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_antinu.cxx b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_antinu.cxx index 24a4a77..fa48df8 100644 --- a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_antinu.cxx +++ b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_antinu.cxx @@ -1,247 +1,247 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CCQE_XSec_1DQ2_antinu.h" #include <csignal> //******************************************************************** /// @brief MiniBooNE CCQE antinumu 1DQ2 Measurement on CH2 (Ref: - ) /// //******************************************************************** MiniBooNE_CCQE_XSec_1DQ2_antinu::MiniBooNE_CCQE_XSec_1DQ2_antinu( std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) { //******************************************************************** // Measurement Details fName = name; fPlotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"; EnuMin = 0.; EnuMax = 3.; fNormError = 0.130; fDefaultTypes = "FIX/DIAG"; fAllowedTypes = "FIX,FREE,SHAPE/DIAG/NORM"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // Setup Plots fPlotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"; fCCQElike = name.find("CCQELike") != std::string::npos; if(fCCQElike){ fMeasurementSpeciesType = kNumuWithWrongSignMeasurement; } fUseCorrectedCTarget = name.find("CTarg") != std::string::npos; if (fCCQElike && fUseCorrectedCTarget) { ERR(FTL) << "Sample: MiniBooNE_CCQE_XSec_1DQ2_antinu cannot run in both " "QELike and C-Target mode. You're welcome to add the data set." << std::endl; throw; } if(fUseCorrectedCTarget){ SetDataValues(FitPar::GetDataBase() + "/MiniBooNE/anti-ccqe/asqq_con_ctarget.txt"); } else { SetDataValues(FitPar::GetDataBase() + "/MiniBooNE/anti-ccqe/asqq_con.txt"); } SetupDefaultHist(); if (!fIsDiag){ ERR(FTL) << "Not allowed to run with non-diagonal covariance for MB CCQE antinu!" << std::endl; ERR(FTL) << "Please run with DIAG or DEFAULT option" << std::endl; throw; } else { LOG(SAM) << "Making diagonal covar" << endl; fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); } /// /// If CCQELike is used an additional the CCQELike BKG is used and a PDG /// Histogram is saved if (fCCQElike) { fDataHist_CCQELIKE = PlotUtils::GetTH1DFromFile( FitPar::GetDataBase() + "/MiniBooNE/anti-ccqe/asqq_bkg_ccqe.txt", (fName + "_data_CCQELIKE"), fPlotTitles); fDataHist_CCPIM = PlotUtils::GetTH1DFromFile( FitPar::GetDataBase() + "/MiniBooNE/anti-ccqe/asqq_bkg_ccpim.txt", (fName + "_data_CCPIM"), fPlotTitles); // Make NON CCPIM fDataHist_NONCCPIM = (TH1D *)fDataHist_CCQELIKE->Clone(); fDataHist_NONCCPIM->SetNameTitle((fName + "_data_NONCCPIM").c_str(), (fName + "_data_NONCCPIM").c_str()); // Perform fDataHist Sums for (int i = 0; i < fDataHist->GetNbinsX(); i++) { fDataHist_NONCCPIM->SetBinContent( i + 1, fDataHist_CCQELIKE->GetBinContent(i + 1) - fDataHist_CCPIM->GetBinContent(i + 1)); fDataHist->SetBinContent(i + 1, fDataHist->GetBinContent(i + 1) + fDataHist_CCQELIKE->GetBinContent(i + 1)); } PlotUtils::CreateNeutModeArray((TH1D *)fMCHist, (TH1 **)fMCHist_CCQELIKE); PlotUtils::ResetNeutModeArray((TH1 **)fMCHist_CCQELIKE); PlotUtils::CreateNeutModeArray((TH1D *)fMCHist, (TH1 **)fMCHist_NONCCPIM); PlotUtils::ResetNeutModeArray((TH1 **)fMCHist_NONCCPIM); PlotUtils::CreateNeutModeArray((TH1D *)fMCHist, (TH1 **)fMCHist_CCPIM); PlotUtils::ResetNeutModeArray((TH1 **)fMCHist_CCPIM); } // ScaleFactor double NNucPerNTarg = fUseCorrectedCTarget ? 12.0/6.0 : 14.08/8.0; - fScaleFactor = ((fEventHist->Integral("width") * 1E-38 / (fNEvents + 0.)) * + fScaleFactor = ((GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) * NNucPerNTarg / TotalIntegratedFlux()); }; //******************************************************************** /// @details Extract q2qe(fXVar) from the event void MiniBooNE_CCQE_XSec_1DQ2_antinu::FillEventVariables(FitEvent *event) { //******************************************************************** if (event->NumFSParticle(PhysConst::pdg_muons) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; // The highest momentum mu+/mu-. The isSignal definition should make sure we // only // accept events we want, so no need to do an additional check here. TLorentzVector Pmu = event->GetHMFSParticle(PhysConst::pdg_muons)->fP; // Set X Variables fXVar = FitUtils::Q2QErec(Pmu, cos(Pnu.Vect().Angle(Pmu.Vect())), 30., false); return; }; //******************************************************************** bool MiniBooNE_CCQE_XSec_1DQ2_antinu::isSignal(FitEvent *event) { //******************************************************************** // If CC0pi, include both charges if (fCCQElike) { if (SignalDef::isCC0pi(event, 14, EnuMin, EnuMax) || SignalDef::isCC0pi(event, -14, EnuMin, EnuMax)){ // P. Stowell Removed this bad check for only pdg=14 types // if(event->GetNeutrinoIn()->fPID == -14){ // return false; // } return true; } } else { if (SignalDef::isCCQELike(event, -14, EnuMin, EnuMax)) return true; } return false; }; //******************************************************************** /// @details Fills a ccqe-like and ccpim background plot if required void MiniBooNE_CCQE_XSec_1DQ2_antinu::FillHistograms() { //******************************************************************** Measurement1D::FillHistograms(); if (Mode != -1 && Mode != -2 and fCCQElike and Signal) { if (fabs(Mode) == 11 or fabs(Mode) == 13) PlotUtils::FillNeutModeArray(fMCHist_CCPIM, Mode, fXVar, Weight); else PlotUtils::FillNeutModeArray(fMCHist_NONCCPIM, Mode, fXVar, Weight); PlotUtils::FillNeutModeArray(fMCHist_CCQELIKE, Mode, fXVar, Weight); } } //******************************************************************** /// @details Extra write command to save the CCQELike/CCPIM PDG if required void MiniBooNE_CCQE_XSec_1DQ2_antinu::Write(std::string drawOpt) { //******************************************************************** Measurement1D::Write(drawOpt); if (fCCQElike) { fDataHist_CCQELIKE->Write(); THStack combo_fMCHist_CCQELIKE = PlotUtils::GetNeutModeStack( (fName + "_MC_CCQELIKE").c_str(), (TH1 **)fMCHist_CCQELIKE, 0); combo_fMCHist_CCQELIKE.Write(); fDataHist_CCPIM->Write(); THStack combo_fMCHist_CCPIM = PlotUtils::GetNeutModeStack( (fName + "_MC_CCPIM").c_str(), (TH1 **)fMCHist_CCPIM, 0); combo_fMCHist_CCPIM.Write(); fDataHist_NONCCPIM->Write(); THStack combo_fMCHist_NONCCPIM = PlotUtils::GetNeutModeStack( (fName + "_MC_NONCCPIM").c_str(), (TH1 **)fMCHist_NONCCPIM, 0); combo_fMCHist_NONCCPIM.Write(); } } //******************************************************************** /// @details Extra scale command for CCQELIKE/CCPIM PDG Hist void MiniBooNE_CCQE_XSec_1DQ2_antinu::ScaleEvents() { //******************************************************************** Measurement1D::ScaleEvents(); if (fCCQElike) { PlotUtils::ScaleNeutModeArray((TH1 **)fMCHist_CCQELIKE, fScaleFactor, "width"); PlotUtils::ScaleNeutModeArray((TH1 **)fMCHist_CCPIM, fScaleFactor, "width"); PlotUtils::ScaleNeutModeArray((TH1 **)fMCHist_NONCCPIM, fScaleFactor, "width"); } } //******************************************************************** /// @details Apply norm scaling to CCQELIKE/CCPIM PDG Hist void MiniBooNE_CCQE_XSec_1DQ2_antinu::ApplyNormScale(double norm) { //******************************************************************** Measurement1D::ApplyNormScale(norm); if (fCCQElike) { PlotUtils::ScaleNeutModeArray((TH1 **)fMCHist_CCQELIKE, 1.0 / norm, ""); PlotUtils::ScaleNeutModeArray((TH1 **)fMCHist_CCPIM, 1.0 / norm, ""); PlotUtils::ScaleNeutModeArray((TH1 **)fMCHist_NONCCPIM, 1.0 / norm, ""); } } //******************************************************************** ///// @details Extra scale command for CCQELIKE PDG Hist void MiniBooNE_CCQE_XSec_1DQ2_antinu::ResetAll() { //******************************************************************** Measurement1D::ResetAll(); if (fCCQElike) { PlotUtils::ResetNeutModeArray((TH1 **)fMCHist_CCQELIKE); PlotUtils::ResetNeutModeArray((TH1 **)fMCHist_CCPIM); PlotUtils::ResetNeutModeArray((TH1 **)fMCHist_NONCCPIM); } } diff --git a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_nu.cxx b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_nu.cxx index 5c74997..72c37c7 100644 --- a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_nu.cxx @@ -1,184 +1,184 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CCQE_XSec_1DQ2_nu.h" //******************************************************************** MiniBooNE_CCQE_XSec_1DQ2_nu::MiniBooNE_CCQE_XSec_1DQ2_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ //******************************************************************** // Measurement Details fName = name; fPlotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"; /// Using the sample name "MiniBooNE_CCQE_XSec_1DQ2_nu_CCQELike" will allow /// the CCQELike sample without background subtraction to be fitted. ccqelike = name.find("CCQELike") != std::string::npos; if(ccqelike){ fMeasurementSpeciesType = kNumuWithWrongSignMeasurement; } EnuMin = 0.; EnuMax = 3.; fNormError = 0.107; fDefaultTypes = "FIX/DIAG"; fAllowedTypes = "FIX,FREE,SHAPE/DIAG/NORM/MASK"; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // Setup Plots this->fPlotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"; this->SetDataValues(FitPar::GetDataBase()+"/MiniBooNE/ccqe/asqq_con.txt"); this->SetupDefaultHist(); // Setup Covariance if (!this->fIsDiag) { ERR(FTL) << "Non diagonal covariance not allowed for MB CCQE!" << std::endl; ERR(FTL) << "Run with DIAG or DEFAULT option" << std::endl; throw; } else { /// Assume a diagonal shape-only error is default fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); } /// If CCQELike is used an additional the CCQELike BKG is used and a PDG Histogram is saved if (ccqelike){ fDataHist_CCQELIKE = PlotUtils::GetTH1DFromFile(FitPar::GetDataBase()+"/MiniBooNE/ccqe/asqq_bkg.txt", (this->fName+"_data_CCQELIKE"), this->fPlotTitles); for (int i = 0; i < fDataHist->GetNbinsX(); i++){ this->fDataHist->SetBinContent(i+1, fDataHist->GetBinContent(i+1) + fDataHist_CCQELIKE->GetBinContent(i+1)); } PlotUtils::CreateNeutModeArray((TH1D*)this->fMCHist,(TH1**)this->fMCHist_CCQELIKE); PlotUtils::ResetNeutModeArray((TH1**)this->fMCHist_CCQELIKE); } // Get Scale Factor - fScaleFactor = ((fEventHist->Integral("width")*1E-38/(fNEvents+0.)) + fScaleFactor = ((GetEventHistogram()->Integral("width")*1E-38/(fNEvents+0.)) * (14.08/6.0) / TotalIntegratedFlux()); }; //******************************************************************** /// @details Extract q2qe(fXVar) from the event void MiniBooNE_CCQE_XSec_1DQ2_nu::FillEventVariables(FitEvent *event){ //******************************************************************** if (event->NumFSParticle(PhysConst::pdg_muons) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; // The highest momentum mu+/mu-. The isSignal definition should make sure we only // accept events we want, so no need to do an additional check here. TLorentzVector Pmu = event->GetHMFSParticle(PhysConst::pdg_muons)->fP; q2qe = FitUtils::Q2QErec(Pmu,cos(Pnu.Vect().Angle(Pmu.Vect())), 34., false); // Set X Variables fXVar = q2qe; return; }; //******************************************************************** bool MiniBooNE_CCQE_XSec_1DQ2_nu::isSignal(FitEvent *event){ //******************************************************************** // If CC0pi, include both charges if (ccqelike) { if (SignalDef::isCC0pi(event, 14, EnuMin, EnuMax) || SignalDef::isCC0pi(event, -14, EnuMin, EnuMax)) return true; } else { if (SignalDef::isCCQELike(event, 14, EnuMin, EnuMax)) return true; } return false; }; //******************************************************************** /// @details Fills a ccqe-like background plot if required void MiniBooNE_CCQE_XSec_1DQ2_nu::FillHistograms(){ //******************************************************************** Measurement1D::FillHistograms(); if (Mode != 1 and Mode != 2 and ccqelike and Signal){ PlotUtils::FillNeutModeArray(fMCHist_CCQELIKE, Mode, fXVar, Weight); } } //******************************************************************** /// @details Extra write command to save the CCQELike PDG if required void MiniBooNE_CCQE_XSec_1DQ2_nu::Write(std::string drawOpt){ //******************************************************************** Measurement1D::Write(drawOpt); if (ccqelike){ fDataHist_CCQELIKE->Write(); THStack combo_fMCHist_CCQELIKE = PlotUtils::GetNeutModeStack((this->fName + "_MC_CCQELIKE").c_str(), (TH1**)this->fMCHist_CCQELIKE, 0); combo_fMCHist_CCQELIKE.Write(); } } //******************************************************************** /// @details Extra scale command for CCQELIKE PDG Hist void MiniBooNE_CCQE_XSec_1DQ2_nu::ResetAll(){ //******************************************************************** if (ccqelike) PlotUtils::ResetNeutModeArray((TH1**)fMCHist_CCQELIKE); } //******************************************************************** /// @details Extra scale command for CCQELIKE PDG Hist void MiniBooNE_CCQE_XSec_1DQ2_nu::ScaleEvents(){ //******************************************************************** Measurement1D::ScaleEvents(); if (ccqelike) PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_CCQELIKE, fScaleFactor,"width"); } //******************************************************************** /// @details Apply norm scaling to CCQELIKE PDG Hist void MiniBooNE_CCQE_XSec_1DQ2_nu::ApplyNormScale(double norm){ //******************************************************************** Measurement1D::ApplyNormScale(norm); if (ccqelike) PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_CCQELIKE, 1.0/norm, ""); } diff --git a/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_antinu.cxx b/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_antinu.cxx index da242d2..43f4cf0 100644 --- a/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_antinu.cxx +++ b/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_antinu.cxx @@ -1,114 +1,114 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CCQE_XSec_2DTcos_antinu.h" //******************************************************************** MiniBooNE_CCQE_XSec_2DTcos_antinu::MiniBooNE_CCQE_XSec_2DTcos_antinu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ //******************************************************************** // Measurement Details fName = name; fPlotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"; EnuMin = 0.; EnuMax = 3.; fNormError = 0.130; fDefaultTypes="FIX/DIAG"; fAllowedTypes="FIX,FREE,SHAPE/DIAG/NORM"; Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // Setup Plots fPlotTitles = "; T_{#mu} (GeV); cos#theta_{#mu}; d^{2}#sigma/dT_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"; ccqelike = name.find("CCQELike") != std::string::npos; if(ccqelike){ fMeasurementSpeciesType = kNumuWithWrongSignMeasurement; } // Define Bin Edges fNDataPointsX = 19; fNDataPointsY = 21; Double_t tempx[19] = { 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0}; Double_t tempy[21] = {-1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0}; fXBins = tempx; fYBins = tempy; // Setup Data Plots if (!ccqelike){ SetDataValues(FitPar::GetDataBase()+"/MiniBooNE/anti-ccqe/aski_con.txt", 1E-41, FitPar::GetDataBase()+"/MiniBooNE/anti-ccqe/aski_err.txt", 1E-42); } else { SetDataValues(FitPar::GetDataBase()+"/MiniBooNE/anti-ccqe/aski_like.txt", 1E-41, FitPar::GetDataBase()+"/MiniBooNE/anti-ccqe/aski_err.txt", 1E-42); } this->SetupDefaultHist(); // Setup Covariances fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); fIsDiag = true; // Set Scaling for Differential Cross-section - fScaleFactor = ((fEventHist->Integral("width")*1E-38/(fNEvents+0.)) + fScaleFactor = ((GetEventHistogram()->Integral("width")*1E-38/(fNEvents+0.)) *(14.08/8.) /TotalIntegratedFlux()); }; //******************************************************************** void MiniBooNE_CCQE_XSec_2DTcos_antinu::FillEventVariables(FitEvent *event){ //******************************************************************** if (event->NumFSParticle(PhysConst::pdg_muons) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; // The highest momentum mu+/mu-. The isSignal definition should make sure we only // accept events we want, so no need to do an additional check here. TLorentzVector Pmu = event->GetHMFSParticle(PhysConst::pdg_muons)->fP; // Now find the kinematic values and fill the histogram Ekmu = Pmu.E()/1000.0 - PhysConst::mass_muon; costheta = cos(Pnu.Vect().Angle(Pmu.Vect())); // Set X Variables fXVar = Ekmu; fYVar = costheta; return; }; //******************************************************************** bool MiniBooNE_CCQE_XSec_2DTcos_antinu::isSignal(FitEvent *event){ //******************************************************************** // If CC0pi, include both charges if (ccqelike) { if (SignalDef::isCC0pi(event, 14, EnuMin, EnuMax) || SignalDef::isCC0pi(event, -14, EnuMin, EnuMax)) return true; } else { if (SignalDef::isCCQELike(event, -14, EnuMin, EnuMax)) return true; } return false; }; diff --git a/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_nu.cxx b/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_nu.cxx index 77c6954..68b2162 100644 --- a/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_nu.cxx @@ -1,115 +1,115 @@ /// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_CCQE_XSec_2DTcos_nu.h" //******************************************************************** MiniBooNE_CCQE_XSec_2DTcos_nu::MiniBooNE_CCQE_XSec_2DTcos_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ //******************************************************************** // Measurement Details fName = name; EnuMin = 0.; EnuMax = 3.; fIsDiag = true; fNormError = 0.107; fDefaultTypes = "FIX/DIAG"; fAllowedTypes = "FIX,FREE,SHAPE/DIAG/NORM"; Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile); // Setup Plots fPlotTitles = "; T_{#mu} (GeV); cos#theta_{#mu}; d^{2}#sigma/dT_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"; ccqelike = name.find("CCQELike") != std::string::npos; if(ccqelike){ fMeasurementSpeciesType = kNumuWithWrongSignMeasurement; } // Define Bin Edges fNDataPointsX = 19; fNDataPointsY = 21; Double_t tempx[19] = { 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0}; Double_t tempy[21] = {-1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0}; fXBins = tempx; fYBins = tempy; // Setup Data Plots if (!ccqelike){ SetDataValues(FitPar::GetDataBase()+"/MiniBooNE/ccqe/aski_con.txt", 1E-41, FitPar::GetDataBase()+"/MiniBooNE/ccqe/aski_err.txt", 1E-42); } else { SetDataValues(FitPar::GetDataBase()+"/MiniBooNE/ccqe/aski_like.txt", 1E-41, FitPar::GetDataBase()+"/MiniBooNE/ccqe/aski_err.txt", 1E-42); } SetupDefaultHist(); // Setup Covariances fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); fIsDiag = true; // Different generators require slightly different rescaling factors. - fScaleFactor = (fEventHist->Integral("width")*1E-38/(fNEvents+0.))*14.08/6./TotalIntegratedFlux(); + fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38/(fNEvents+0.))*14.08/6./TotalIntegratedFlux(); }; //******************************************************************** void MiniBooNE_CCQE_XSec_2DTcos_nu::FillEventVariables(FitEvent *event){ //******************************************************************** if (event->NumFSParticle(PhysConst::pdg_muons) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; // The highest momentum mu+/mu-. The isSignal definition should make sure we only // accept events we want, so no need to do an additional check here. TLorentzVector Pmu = event->GetHMFSParticle(PhysConst::pdg_muons)->fP; // Now find the kinematic values and fill the histogram Ekmu = Pmu.E()/1000.0 - PhysConst::mass_muon; costheta = cos(Pnu.Vect().Angle(Pmu.Vect())); // Set X and Y Variables fXVar = Ekmu; fYVar = costheta; return; }; //******************************************************************** bool MiniBooNE_CCQE_XSec_2DTcos_nu::isSignal(FitEvent *event){ //******************************************************************** // If CC0pi, include both charges if (ccqelike) { if (SignalDef::isCC0pi(event, 14, EnuMin, EnuMax) || SignalDef::isCC0pi(event, -14, EnuMin, EnuMax)) return true; } else { if (SignalDef::isCCQELike(event, 14, EnuMin, EnuMax)) return true; } return false; }; diff --git a/src/MiniBooNE/MiniBooNE_NCEL_XSec_Treco_nu.cxx b/src/MiniBooNE/MiniBooNE_NCEL_XSec_Treco_nu.cxx index c482b95..5a1eb89 100644 --- a/src/MiniBooNE/MiniBooNE_NCEL_XSec_Treco_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_NCEL_XSec_Treco_nu.cxx @@ -1,224 +1,224 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_NCEL_XSec_Treco_nu.h" #include "TLorentzVector.h" // The constructor MiniBooNE_NCEL_XSec_Treco_nu::MiniBooNE_NCEL_XSec_Treco_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "MiniBooNE_NCEL_XSec_Treco_nu"; fPlotTitles = "; T_{reco} (MeV); Events/(12 MeV)"; EnuMin = 0.; EnuMax = 10.0; - fTRecoEdges = {40.0, 52.0, 63.9, 75.9, 87.8, 99.8, 111.8, 123.7, 135.7, 147.6, 159.6, 171.6, 183.5, 195.5, - 207.5, 219.4, 231.4, 243.3, 255.3, 267.3, 279.2, 291.2, 303.1, 315.1, 327.1, 339.0, 351.0, 362.9, 374.9, 386.9, - 398.8, 410.8, 422.7, 434.7, 446.7, 458.6, 470.6, 482.5, 494.5, 506.5, 518.4, 530.4, 542.4, 554.3, 566.3, 578.2, + fTRecoEdges = {40.0, 52.0, 63.9, 75.9, 87.8, 99.8, 111.8, 123.7, 135.7, 147.6, 159.6, 171.6, 183.5, 195.5, + 207.5, 219.4, 231.4, 243.3, 255.3, 267.3, 279.2, 291.2, 303.1, 315.1, 327.1, 339.0, 351.0, 362.9, 374.9, 386.9, + 398.8, 410.8, 422.7, 434.7, 446.7, 458.6, 470.6, 482.5, 494.5, 506.5, 518.4, 530.4, 542.4, 554.3, 566.3, 578.2, 590.2, 602.2, 614.1, 626.1, 638.0, 650.0}; SetDataValues(FitPar::GetDataBase()+"/MiniBooNE/ncqe/input_data.txt"); SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/ncqe/ErrorMatrix.tab", 51); SetResponseMatrix(FitPar::GetDataBase()+"/MiniBooNE/ncqe/response_mat.txt", 51); // Setup MC Hists Measurement1D::SetupDefaultHist(); // Usually the MCFine histogram is a finer binned version of MC Hist. // In this case we need to use it to save the true distribution before smearing. if (fMCFine) delete fMCFine; fMCFine = new TH1D((this->fName+"_Ttrue").c_str(), (this->fName+this->fPlotTitles).c_str(), 50, 0, 900); // The scale factor is quite complicated because MB didn't divide by number of targets. // nMolMB is the number of CH_2 molecules in the MB FV (610.6 cm radius sphere) and 0.845 is the published density of the mineral oil. double nMolMB = 6.023E+23*0.845*4.0*M_PI*610.6*610.6*610.6/3.0; - fScaleFactor = (fEventHist->Integral("width")*1E-38*14.08/(fNEvents+0.))*nMolMB*0.646165; + fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38*14.08/(fNEvents+0.))*nMolMB*0.646165; }; void MiniBooNE_NCEL_XSec_Treco_nu::FillEventVariables(FitEvent *event){ double t_raw = 0.0; // Loop and add all Tnucleon for (UInt_t i = 0; i < event->Npart(); i++){ if (event->PartInfo(i)->Status() != kFinalState) continue; int pdg = event->PartInfo(i)->fPID; if (pdg == 2212 || pdg == 2112){ t_raw += FitUtils::T(event->PartInfo(i)->fP)*1.E3; } } fXVar = t_raw; } bool MiniBooNE_NCEL_XSec_Treco_nu::ScaleEvents(){ // Now convert Ttrue to Treco... for (int treco = 0; treco < 51; ++treco){ double total = 0.; for (int ttrue = 0; ttrue < 50; ++ttrue) total += fMCFine->GetBinContent(ttrue+1)*response_mat->GetBinContent(ttrue+1, treco+1); fMCHist->SetBinContent(treco+1, total); } // Scale this->fMCHist->Scale(this->fScaleFactor, "width"); this->fMCFine->Scale(this->fScaleFactor, "width"); PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_PDG, fScaleFactor, "width"); // Add in the backgrounds... for (int treco = 0; treco < 51; ++treco){ double total = this->fMCHist->GetBinContent(treco+1) + this->BKGD_other->GetBinContent(treco+1) + this->BKGD_irrid->GetBinContent(treco+1); this->fMCHist->SetBinContent(treco+1, total); } } bool MiniBooNE_NCEL_XSec_Treco_nu::isSignal(FitEvent *event){ // Should put in MB SignalDef eventually if (event->Mode != 51 && event->Mode != 52) return false; // Numu or nue if (event->PDGnu != 14 && event->PDGnu != 12) return false; // Enu if (event->Enu() < EnuMin*1000.0 || event->Enu() > EnuMax*1000.0) return false; return true; }; // Read in the covariance matrix from the file specified in the constructor void MiniBooNE_NCEL_XSec_Treco_nu::SetCovarMatrix(std::string covarFile, int dim){ - // Use Utils + // Use Utils // // Make a counter to track the line number // int row = 0; // std::string line; // std::ifstream covar(covarFile.c_str(),ifstream::in); // this->covar = new TMatrixDSym(dim); // if(covar.is_open()) LOG(DEB) << "Reading covariance matrix from file: " << covarFile << std::endl; // while(std::getline(covar >> std::ws, line, '\n')){ // std::istringstream stream(line); - // double entry; + // double entry; // int column = 0; // // Loop over entries and insert them into matrix // // Multiply by the errors to get the covariance, rather than the correlation matrix // while(stream >> entry){ // (*this->covar)(row, column) = entry; // if (row == column) this->fDataHist->SetBinError(row+1, sqrt(entry)); // column++; - // } + // } // row++; // } // // Robust matrix inversion method // TDecompSVD LU = TDecompSVD(*this->covar); // this->covar = new TMatrixDSym(dim, LU .Invert().GetMatrixArray(), ""); return; }; // Override the usual function in the base class because this is more complicated for the NCEL sample... void MiniBooNE_NCEL_XSec_Treco_nu::SetDataValues(std::string inputFile){ std::string line; std::ifstream input(inputFile.c_str(),ifstream::in); if(input.is_open()) LOG(DEB) << "Reading data from file: " << inputFile << std::endl; - - this->fDataHist = new TH1D((this->fName+"_data").c_str(), (this->fName+this->fPlotTitles).c_str(), + + this->fDataHist = new TH1D((this->fName+"_data").c_str(), (this->fName+this->fPlotTitles).c_str(), 51, this->arr_treco); - this->BKGD_other = new TH1D((this->fName+"_BKGD_other").c_str(), (this->fName+this->fPlotTitles).c_str(), + this->BKGD_other = new TH1D((this->fName+"_BKGD_other").c_str(), (this->fName+this->fPlotTitles).c_str(), 51, arr_treco); - this->BKGD_irrid = new TH1D((this->fName+"_BKGD_irrid").c_str(), (this->fName+this->fPlotTitles).c_str(), + this->BKGD_irrid = new TH1D((this->fName+"_BKGD_irrid").c_str(), (this->fName+this->fPlotTitles).c_str(), 51, arr_treco); To get the nDOF correct... this->fNDataPointsX= 52; double entry = 0; int xBin = 0; // First line is the MB data std::getline(input >> std::ws, line, '\n'); std::istringstream stream1(line); - + while(stream1 >> entry){ this->fDataHist->SetBinContent(xBin+1, entry); xBin++; } - + // Second line is "other" backgrounds std::getline(input >> std::ws, line, '\n'); std::istringstream stream2(line); entry = 0; - xBin = 0; + xBin = 0; while(stream2 >> entry){ this->BKGD_other->SetBinContent(xBin+1, entry); xBin++; - } + } // Third line is the irreducible background std::getline(input >> std::ws, line, '\n'); std::istringstream stream3(line); entry = 0; - xBin = 0; + xBin = 0; while(stream3 >> entry){ this->BKGD_irrid->SetBinContent(xBin+1, entry); xBin++; - } + } }; // Read in the response matrix -- thus far, a response matrix is unique to the NCEL sample void MiniBooNE_NCEL_XSec_Treco_nu::SetResponseMatrix(std::string responseFile, int dim){ // Make a counter to track the line number // int xBin = 0; // std::string line; // std::ifstream response(responseFile.c_str(),ifstream::in); // // Response matrix: x axis is Ttrue, y axis is Treco // this->response_mat = new TH2D((this->fName+"_RESPONSE_MATRIX").c_str(), (this->fName+this->fPlotTitles).c_str(), // 50, 0, 900, 51, this->arr_treco); // if(response.is_open()) LOG(DEB) << "Reading in the response matrix from file: " << responseFile << std::endl; // while(std::getline(response, line, '\n')){ // std::istringstream stream(line); - // double entry; + // double entry; // int yBin = 0; // // Loop over entries and insert them into matrix // // Multiply by the errors to get the covariance, rather than the correlation matrix // while(stream >> entry){ // this->response_mat->SetBinContent(xBin+1, yBin+1, entry); // yBin++; - // } + // } // xBin++; // } }; diff --git a/src/MiniBooNE/MiniBooNE_NCpi0_XSec_1Dppi0_nu.cxx b/src/MiniBooNE/MiniBooNE_NCpi0_XSec_1Dppi0_nu.cxx index 4617cdc..4c24717 100644 --- a/src/MiniBooNE/MiniBooNE_NCpi0_XSec_1Dppi0_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_NCpi0_XSec_1Dppi0_nu.cxx @@ -1,171 +1,171 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "MiniBooNE_NCpi0_XSec_1Dppi0_nu.h" // The constructor MiniBooNE_NCpi0_XSec_1Dppi0_nu::MiniBooNE_NCpi0_XSec_1Dppi0_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile, Double_t *anuBins) : isComb(false) { if (anuBins != NULL) isComb = true; isComb = false; // Needs Updating // // Set pointer to the reweighting engine // rw_engine = rw; // this->fBeamDistance = 0.541; // // Define the energy region // this->EnuMin = 0.; // this->EnuMax = 4.; // // In future read most of these from a card file // this->inFile = inputfile; // this->fName = "MB_NCpi0_XSec_numu_1Dppi0"; // this->fPlotTitles = "; p_{#pi^{0}} (GeV/c); d#sigma/dp_{#pi^{0}} (cm^{2}/(GeV/c)/nucleon)"; // this->SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/nc1pi0/nuppi0xsecerrormatrix.txt", 11); // this->SetDataValues(FitPar::GetDataBase()+"/MiniBooNE/nc1pi0/nuppi0xsec_edit.txt"); // this->fNormError=0.107; // if (isComb) { // fName += "_comb"; // this->fNDataPointsX = 11; // this->fXBins = anuBins; // } // this->fMCHist = new TH1D((this->fName+"_MC").c_str(), (this->fName+this->fPlotTitles).c_str(), this->fNDataPointsX-1, this->fXBins); // this->fMCFine = new TH1D((this->fName+"_MC_FINE").c_str(), (this->fName+this->fPlotTitles).c_str(), (this->fNDataPointsX - 1)*10, this->fXBins[0], this->fXBins[this->fNDataPointsX -1]); // this->ReadEventFile(); // // Different generators require slightly different rescaling factors. - // if (this->fEventType == 0) this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38/(fNEvents+0.))*14.08/14.0/this->TotalIntegratedFlux(); // NEUT - // else if (this->fEventType == 1) this->fScaleFactor = (this->fEventHist->Integral()*1E-38/(fNEvents+0.))*14.08*6.0/14./this->fFluxHist->Integral(); // NUWRO - // else if (this->fEventType == 5) this->fScaleFactor = (this->fEventHist->Integral()*1E-38/(fNEvents+0.))*14.08*6.0/14./this->fFluxHist->Integral(); // GENIE + // if (this->fEventType == 0) this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38/(fNEvents+0.))*14.08/14.0/this->TotalIntegratedFlux(); // NEUT + // else if (this->fEventType == 1) this->fScaleFactor = (GetEventHistogram()->Integral()*1E-38/(fNEvents+0.))*14.08*6.0/14./GetFluxHistogram()->Integral(); // NUWRO + // else if (this->fEventType == 5) this->fScaleFactor = (GetEventHistogram()->Integral()*1E-38/(fNEvents+0.))*14.08*6.0/14./GetFluxHistogram()->Integral(); // GENIE }; void MiniBooNE_NCpi0_XSec_1Dppi0_nu::FillEventVariables(FitEvent* event){ TLorentzVector Pnu = (event->PartInfo(0))->fP; TLorentzVector Pmu; TLorentzVector Ppi0; double EHad = 0; pi0Cnt = 0; bad_particle = false; for (UInt_t j = 2; j < event->Npart(); ++j){ if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fNEUTStatusCode != 0) continue; int PID = (event->PartInfo(j))->fPID; double KE = (event->PartInfo(j))->fP.E() - (event->PartInfo(j))->fMass; if (PID == 111) { Ppi0 = event->PartInfo(j)->fP; EHad += KE; } else if (PID == 2112 || PID == 2212) EHad += KE; else if (PID == -13) Pmu = event->PartInfo(j)->fP; if (abs(PID) >= 113 && abs(PID) <= 557) bad_particle = true; else if (abs(PID) == 11 || abs(PID) == 13 || abs(PID) == 15 || abs(PID) == 17) bad_particle = true; else if (PID == 111) pi0Cnt++; } double bind = 34.0; if (isComb) bind = 30.0; //double hadMass = FitUtils::Wrec(Pnu, Pmu, Ppi0); double ppi0 = Ppi0.Vect().Mag()/1000.0; fXVar = ppi0; return; }; bool MiniBooNE_NCpi0_XSec_1Dppi0_nu::isSignal(FitEvent* event){ return SignalDef::isNC1pi(event, 14, 111, EnuMin, EnuMax); }; void MiniBooNE_NCpi0_XSec_1Dppi0_nu::SetDataValues(std::string dataFile) { LOG(SAM) << this->fName << "Setting data for " << this->fName << std::endl; LOG(SAM) << this->fName << "From: " << dataFile << std::endl; LOG(SAM) << this->fName << "Reading error from covariance" << std::endl; TGraph *gr = new TGraph(dataFile.c_str()); this->fXBins = gr->GetX(); this->fDataValues = gr->GetY(); this->fNDataPointsX = gr->GetN(); // get the diagonal elements int rows = (this->tempCovar)->GetNrows(); Double_t errors[rows+1]; for (int i = 0; i < rows; i++) errors[i] = sqrt( (*this->tempCovar)(i,i)*1E-81); errors[rows] = 0.; this->fDataErrors = errors; this->fDataHist = new TH1D((this->fName+"_data").c_str(), (this->fName+this->fPlotTitles).c_str(), this->fNDataPointsX-1, this->fXBins); for (int i=0; i < this->fNDataPointsX; ++i) { this->fDataHist->SetBinContent(i+1, this->fDataValues[i]); this->fDataHist->SetBinError(i+1, this->fDataErrors[i]); } return; } void MiniBooNE_NCpi0_XSec_1Dppi0_nu::SetCovarMatrix(std::string covarFile, int dim) { LOG(SAM) << this->fName << "===============" << std::endl; LOG(SAM) << this->fName << "Reading covariance: " << this->fName << std::endl; LOG(SAM) << this->fName << "From: " << covarFile << std::endl; // tracks line number int row = 0; std::string line; std::ifstream covar(covarFile.c_str(), ifstream::in); this->tempCovar = new TMatrixDSym(dim); // while we're on a line in covar while(std::getline(covar >> std::ws, line, '\n')) { std::istringstream stream(line); // this is the netry we're reading! double entry; // this is the column counter! int column = 0; while(stream >> entry) { // get the covariance entry. // 1E-81 from the data release listing this unit double val = entry;// * 1E-81; // then fill the covariance matrix's row and column with this value, (*this->tempCovar)(row, column) = val; column++; } row++; } this->covar = (TMatrixDSym*) this->tempCovar->Clone(); TDecompChol LU = TDecompChol(*this->covar); this->covar = new TMatrixDSym(dim, LU.Invert().GetMatrixArray(), ""); (*this->covar) *= 1E81 * 1E-76; return; }; diff --git a/src/Routines/ComparisonRoutines.cxx b/src/Routines/ComparisonRoutines.cxx index 25fdea7..83182e9 100755 --- a/src/Routines/ComparisonRoutines.cxx +++ b/src/Routines/ComparisonRoutines.cxx @@ -1,711 +1,718 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "StatusMessage.h" #include "ComparisonRoutines.h" /* Constructor/Destructor */ //************************ void ComparisonRoutines::Init() { //************************ fInputFile = ""; fInputRootFile = NULL; fOutputFile = ""; fOutputRootFile = NULL; fStrategy = "Compare"; fRoutines.clear(); fCardFile = ""; fFakeDataInput = ""; fSampleFCN = NULL; fAllowedRoutines = ("Compare"); }; //************************************* ComparisonRoutines::~ComparisonRoutines(){ //************************************* }; /* Input Functions */ //************************************* ComparisonRoutines::ComparisonRoutines(int argc, char* argv[]) { //************************************* // Set everything to defaults Init(); std::vector<std::string> configs_cmd; std::string maxevents_flag = ""; int verbosity_flag = 0; int error_flag = 0; // If No Arguments print commands for (int i = 1; i < argc; ++i) { if (i + 1 != argc) { // Cardfile if (!std::strcmp(argv[i], "-c")) { fCardFile = argv[i + 1]; ++i; } else if (!std::strcmp(argv[i], "-o")) { fOutputFile = argv[i + 1]; ++i; } else if (!std::strcmp(argv[i], "-f")) { fStrategy = argv[i + 1]; ++i; } else if (!std::strcmp(argv[i], "-q")) { configs_cmd.push_back(argv[i + 1]); ++i; } else if (!std::strcmp(argv[i], "-n")) { maxevents_flag = argv[i + 1]; ++i; } else if (!std::strcmp(argv[i], "-v")) { verbosity_flag -= 1; } else if (!std::strcmp(argv[i], "+v")) { verbosity_flag += 1; } else if (!std::strcmp(argv[i], "-e")) { error_flag -= 1; } else if (!std::strcmp(argv[i], "+e")) { error_flag += 1; } else { ERR(FTL) << "ERROR: unknown command line option given! - '" << argv[i] << " " << argv[i + 1] << "'" << std::endl; throw; } } } if (fCardFile.empty()) { ERR(FTL) << "ERROR: card file not specified." << std::endl; ERR(FTL) << "Run with '-h' to see options." << std::endl; throw; } if (fOutputFile.empty()) { ERR(WRN) << "WARNING: output file not specified." << std::endl; ERR(WRN) << "Using " << fCardFile << ".root" << std::endl; fOutputFile = fCardFile + ".root"; } if (fCardFile == fOutputFile) { ERR(WRN) << "WARNING: output file and card file are the same file, " "writing: " << fCardFile << ".root" << std::endl; fOutputFile = fCardFile + ".root"; } // Fill fit routines and check they are good fRoutines = GeneralUtils::ParseToStr(fStrategy, ","); for (UInt_t i = 0; i < fRoutines.size(); i++) { if (fAllowedRoutines.find(fRoutines[i]) == std::string::npos) { ERR(FTL) << "Unknown fit routine given! " << "Must be provided as a comma seperated list." << std::endl; ERR(FTL) << "Allowed Routines: " << fAllowedRoutines << std::endl; throw; } } // CONFIG // --------------------------- std::string par_dir = GeneralUtils::GetTopLevelDir() + "/parameters/"; FitPar::Config().ReadParamFile(par_dir + "config.list.dat"); FitPar::Config().ReadParamFile(fCardFile); for (UInt_t iter = 0; iter < configs_cmd.size(); iter++) { FitPar::Config().ForceParam(configs_cmd[iter]); } if (!maxevents_flag.empty()) { FitPar::Config().SetParI("input.maxevents", atoi(maxevents_flag.c_str())); } if (verbosity_flag != 0) { int curverb = FitPar::Config().GetParI("VERBOSITY"); FitPar::Config().SetParI("VERBOSITY", curverb + verbosity_flag); } if (error_flag != 0) { int curwarn = FitPar::Config().GetParI("ERROR"); FitPar::Config().SetParI("ERROR", curwarn + error_flag); } LOG_VERB(FitPar::Config().GetParI("VERBOSITY")); ERR_VERB(FitPar::Config().GetParI("ERROR")); // CARD // --------------------------- // Parse Card Options ReadCard(fCardFile); // Outputs // --------------------------- // Save Configs to output file fOutputRootFile = new TFile(fOutputFile.c_str(), "RECREATE"); FitPar::Config().Write(); // Starting Setup // --------------------------- SetupRWEngine(); SetupFCN(); return; }; //************************************* void ComparisonRoutines::ReadCard(std::string cardfile) { //************************************* // Read cardlines into vector std::vector<std::string> cardlines = GeneralUtils::ParseFileToStr(cardfile, "\n"); FitPar::Config().cardLines = cardlines; // Read Samples first (norm params can be overridden) int linecount = 0; for (std::vector<std::string>::iterator iter = cardlines.begin(); iter != cardlines.end(); iter++) { std::string line = (*iter); linecount++; // Skip Comments if (line.empty()) continue; if (line.c_str()[0] == '#') continue; // Read Valid Samples int samstatus = ReadSamples(line); // Show line if bad to help user if (samstatus == kErrorStatus) { ERR(FTL) << "Bad Input in cardfile " << fCardFile << " at line " << linecount << "!" << endl; ERR(FTL) << line << endl; throw; } } // Read Parameters second linecount = 0; for (std::vector<std::string>::iterator iter = cardlines.begin(); iter != cardlines.end(); iter++) { std::string line = (*iter); linecount++; // Skip Comments if (line.empty()) continue; if (line.c_str()[0] == '#') continue; // Try Parameter Reads int parstatus = ReadParameters(line); int fakstatus = ReadFakeDataPars(line); // Show line if bad to help user if (parstatus == kErrorStatus || fakstatus == kErrorStatus) { ERR(FTL) << "Bad Parameter Input in cardfile " << fCardFile << " at line " << linecount << "!" << endl; ERR(FTL) << line << endl; throw; } } return; }; //***************************************** int ComparisonRoutines::ReadParameters(std::string parstring) { //****************************************** std::string inputspec = "RW Dial Inputs Syntax \n" "free input w/ limits: TYPE NAME START MIN MAX STEP [STATE] \n" "fix input: TYPE NAME VALUE [STATE] \n" "free input w/o limits: TYPE NAME START FREE,[STATE] \n" "Allowed Types: \n" "neut_parameter,niwg_parameter,t2k_parameter," "nuwro_parameter,gibuu_parameter"; // Check sample input if (parstring.find("parameter") == std::string::npos) return kGoodStatus; // Parse inputs std::vector<std::string> strvct = GeneralUtils::ParseToStr(parstring, " "); // Skip if comment or parameter somewhere later in line if (strvct[0].c_str()[0] == '#' || strvct[0].find("parameter") == std::string::npos) { return kGoodStatus; } // Check length if (strvct.size() < 3) { ERR(FTL) << "Input rw dials need to provide at least 3 inputs." << std::endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Setup default inputs std::string partype = strvct[0]; std::string parname = strvct[1]; double parval = GeneralUtils::StrToDbl(strvct[2]); std::string state = "FIX"; //[DEFAULT] // Check Type if (FitBase::ConvDialType(partype) == kUNKNOWN) { ERR(FTL) << "Unknown parameter type! " << partype << endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Check Parameter Name if (FitBase::GetDialEnum(partype, parname) == -1) { ERR(FTL) << "Bad RW parameter name! " << partype << " " << parname << endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Option Extra (No Limits) if (strvct.size() == 4) { state = strvct[3]; } // Run Parameter Conversion if needed if (state.find("ABS") != std::string::npos) { parval = FitBase::RWAbsToSigma(partype, parname, parval); } else if (state.find("FRAC") != std::string::npos) { parval = FitBase::RWFracToSigma(partype, parname, parval); } // Check no repeat params if (std::find(fParams.begin(), fParams.end(), parname) != fParams.end()) { ERR(FTL) << "Duplicate parameter names given for " << parname << endl; throw; } // Setup Containers fParams.push_back(parname); fTypeVals[parname] = FitBase::ConvDialType(partype); fCurVals[parname] = parval; fStateVals[parname] = state; // Print the parameter LOG(MIN) << "Read Parameter " << parname << " " << parval << " " << state << std::endl; // Tell reader its all good return kGoodStatus; } //******************************************* int ComparisonRoutines::ReadFakeDataPars(std::string parstring) { //****************************************** std::string inputspec = "Fake Data Dial Inputs Syntax \n" "fake value: fake_parameter NAME VALUE \n" "Name should match dialnames given in actual dial specification."; // Check sample input if (parstring.find("fake_parameter") == std::string::npos) return kGoodStatus; // Parse inputs std::vector<std::string> strvct = GeneralUtils::ParseToStr(parstring, " "); // Skip if comment or parameter somewhere later in line if (strvct[0].c_str()[0] == '#' || strvct[0] == "fake_parameter") { return kGoodStatus; } // Check length if (strvct.size() < 3) { ERR(FTL) << "Fake dials need to provide at least 3 inputs." << std::endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Read Inputs std::string parname = strvct[1]; double parval = GeneralUtils::StrToDbl(strvct[2]); // Setup Container fFakeVals[parname] = parval; // Print the fake parameter LOG(MIN) << "Read Fake Parameter " << parname << " " << parval << std::endl; // Tell reader its all good return kGoodStatus; } //****************************************** int ComparisonRoutines::ReadSamples(std::string samstring) { //****************************************** + const static std::string inputspec = "\tsample <sample_name> <input_type>:inputfile.root [OPTS] " "[norm]\nsample_name: Name " "of sample to include. e.g. MiniBooNE_CCQE_XSec_1DQ2_nu\ninput_type: The " "input event format. e.g. NEUT, GENIE, EVSPLN, ...\nOPTS: Additional, " "optional sample options.\nnorm: Additional, optional sample " "normalisation factor."; // Check sample input if (samstring.find("sample") == std::string::npos) return kGoodStatus; // Parse inputs std::vector<std::string> strvct = GeneralUtils::ParseToStr(samstring, " "); // Skip if comment or parameter somewhere later in line if (strvct[0].c_str()[0] == '#' || strvct[0] != "sample") { return kGoodStatus; } // Check length if (strvct.size() < 3) { ERR(FTL) << "Sample need to provide at least 3 inputs." << std::endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Setup default inputs std::string samname = strvct[1]; std::string samfile = strvct[2]; if (samfile == "FIX") { ERR(FTL) << "Input filename was \"FIX\", this line is probably malformed " "in the input card file. Line:\'" << samstring << "\'" << std::endl; ERR(FTL) << "Expect sample lines to look like:\n\t" << inputspec << std::endl; throw; } std::string samtype = "DEFAULT"; double samnorm = 1.0; // Optional Type if (strvct.size() > 3) { samtype = strvct[3]; + // Append the sample type to the normalsiation name + samname += "_"+samtype; + // Also get rid of the / and replace it with underscore because it might not be supported character + while (samname.find("/") != std::string::npos) { + samname.replace(samname.find("/"), 1, std::string("_")); + } } // Optional Norm if (strvct.size() > 4) samnorm = GeneralUtils::StrToDbl(strvct[4]); // Add Sample Names as Norm Dials std::string normname = samname + "_norm"; - // Check no repeat params + // Now match and check there are no repeated parameter names if (std::find(fParams.begin(), fParams.end(), normname) != fParams.end()) { ERR(FTL) << "Duplicate samples given for " << samname << endl; throw; } fParams.push_back(normname); fTypeVals[normname] = kNORM; fStateVals[normname] = samtype; fCurVals[normname] = samnorm; // Print read in LOG(MIN) << "Read sample " << samname << " " << samfile << " " << samtype << " " << samnorm << endl; // Tell reader its all good return kGoodStatus; } /* Setup Functions */ //************************************* void ComparisonRoutines::SetupRWEngine() { //************************************* for (UInt_t i = 0; i < fParams.size(); i++) { std::string name = fParams[i]; FitBase::GetRW()->IncludeDial(name, fTypeVals.at(name)); } return; } //************************************* void ComparisonRoutines::SetupFCN() { //************************************* LOG(FIT) << "Making the jointFCN" << std::endl; if (fSampleFCN) delete fSampleFCN; fSampleFCN = new JointFCN(fCardFile, fOutputRootFile); SetFakeData(); return; } //************************************* void ComparisonRoutines::SetFakeData() { //************************************* if (fFakeDataInput.empty()) return; if (fFakeDataInput.compare("MC") == 0) { LOG(FIT) << "Setting fake data from MC starting prediction." << std::endl; UpdateRWEngine(fFakeVals); FitBase::GetRW()->Reconfigure(); fSampleFCN->ReconfigureAllEvents(); fSampleFCN->SetFakeData("MC"); UpdateRWEngine(fCurVals); LOG(FIT) << "Set all data to fake MC predictions." << std::endl; } else { fSampleFCN->SetFakeData(fFakeDataInput); } return; } /* Fitting Functions */ //************************************* void ComparisonRoutines::UpdateRWEngine( std::map<std::string, double>& updateVals) { //************************************* for (UInt_t i = 0; i < fParams.size(); i++) { std::string name = fParams[i]; if (updateVals.find(name) == updateVals.end()) continue; FitBase::GetRW()->SetDialValue(name, updateVals.at(name)); } FitBase::GetRW()->Reconfigure(); return; } //************************************* void ComparisonRoutines::Run() { //************************************* for (UInt_t i = 0; i < fRoutines.size(); i++) { std::string routine = fRoutines.at(i); // int fitstate = kFitUnfinished; LOG(FIT) << "Running Routine: " << routine << std::endl; if (routine == "Compare") { UpdateRWEngine(fCurVals); GenerateComparison(); PrintState(); } } return; } //************************************* void ComparisonRoutines::GenerateComparison() { //************************************* // Main Event Loop from event Manager bool using_evtmanager = FitPar::Config().GetParB("EventManager"); if (using_evtmanager and false) { LOG(FIT) << "Using Comparison Routines Event Manager" << endl; std::list<MeasurementBase*> samchain = fSampleFCN->GetSampleList(); std::list<MeasurementBase*>::const_iterator iterSam = samchain.begin(); std::map<int, InputHandler*> fInputs = FitBase::EvtManager().GetInputs(); std::map<int, InputHandler*>::const_iterator iterInp = fInputs.begin(); int timestart = time(NULL); for (; iterInp != fInputs.end(); iterInp++) { int input_id = (iterInp->first); InputHandler* cur_input = (iterInp->second); FitEvent* cust_event = cur_input->GetEventPointer(); int fNEvents = cur_input->GetNEvents(); int countwidth = (fNEvents / 10); // MAIN EVENT LOOP for (int i = 0; i < fNEvents; i++) { // Get Event from input list cust_event = FitBase::EvtManager().GetEvent(input_id, i); // Get Weight double Weight = (FitBase::GetRW()->CalcWeight(cust_event) * cust_event->InputWeight); // Skip if dodgy weight if (fabs(cust_event->Mode) > 60 || cust_event->Mode == 0 || Weight > 200.0 || Weight <= 0.0) continue; // Loop over samples and fill histograms iterSam = samchain.begin(); for (; iterSam != samchain.end(); iterSam++) { MeasurementBase* exp = (*iterSam); if (exp->GetInputID() != input_id) continue; exp->FillEventVariables(cust_event); exp->SetMode(cust_event->Mode); exp->SetSignal(cust_event); exp->SetWeight(Weight); exp->FillHistograms(); } // Print Out if (LOG_LEVEL(REC) and i % countwidth == 0) LOG(REC) << "Reconfigured " << i << " total events. W=" << Weight << std::endl; } } // Convert Binned events iterSam = samchain.begin(); for (; iterSam != samchain.end(); iterSam++) { MeasurementBase* exp = (*iterSam); exp->ConvertEventRates(); } LOG(FIT) << "Time Taken = " << time(NULL) - timestart << std::endl; LOG(FIT) << "Finished reconfiguring all events" << std::endl; } else { fSampleFCN->ReconfigureAllEvents(); } } //************************************* void ComparisonRoutines::PrintState() { //************************************* LOG(FIT) << "------------" << std::endl; // Count max size int maxcount = 0; for (UInt_t i = 0; i < fParams.size(); i++) { maxcount = max(int(fParams[i].size()), maxcount); } // Header LOG(FIT) << " # " << left << setw(maxcount) << "Parameter " << " = " << setw(10) << "Value" << " +- " << setw(10) << "Error" << " " << setw(8) << "(Units)" << " " << setw(10) << "Conv. Val" << " +- " << setw(10) << "Conv. Err" << " " << setw(8) << "(Units)" << std::endl; // Parameters for (UInt_t i = 0; i < fParams.size(); i++) { std::string syst = fParams.at(i); std::string typestr = FitBase::ConvDialType(fTypeVals[syst]); std::string curunits = "(sig.)"; double curval = fCurVals[syst]; double curerr = 0.0; if (fStateVals[syst].find("ABS") != std::string::npos) { curval = FitBase::RWSigmaToAbs(typestr, syst, curval); curerr = (FitBase::RWSigmaToAbs(typestr, syst, curerr) - FitBase::RWSigmaToAbs(typestr, syst, 0.0)); curunits = "(Abs.)"; } else if (fStateVals[syst].find("FRAC") != std::string::npos) { curval = FitBase::RWSigmaToFrac(typestr, syst, curval); curerr = (FitBase::RWSigmaToFrac(typestr, syst, curerr) - FitBase::RWSigmaToFrac(typestr, syst, 0.0)); curunits = "(Frac)"; } std::string convunits = "(" + FitBase::GetRWUnits(typestr, syst) + ")"; double convval = FitBase::RWSigmaToAbs(typestr, syst, curval); double converr = (FitBase::RWSigmaToAbs(typestr, syst, curerr) - FitBase::RWSigmaToAbs(typestr, syst, 0.0)); std::ostringstream curparstring; curparstring << " " << setw(3) << left << i << ". " << setw(maxcount) << syst << " = " << setw(10) << curval << " +- " << setw(10) << curerr << " " << setw(8) << curunits << " " << setw(10) << convval << " +- " << setw(10) << converr << " " << setw(8) << convunits; LOG(FIT) << curparstring.str() << endl; } LOG(FIT) << "------------" << std::endl; double like = fSampleFCN->GetLikelihood(); LOG(FIT) << "Likelihood for JointFCN == " << like << endl; LOG(FIT) << "------------" << std::endl; } /* Write Functions */ //************************************* void ComparisonRoutines::SaveCurrentState(std::string subdir) { //************************************* LOG(FIT) << "Saving current full FCN predictions" << std::endl; // Setup DIRS TDirectory* curdir = gDirectory; if (!subdir.empty()) { TDirectory* newdir = (TDirectory*)gDirectory->mkdir(subdir.c_str()); newdir->cd(); } fSampleFCN->Write(); // Change back to current DIR curdir->cd(); return; } //************************************* void ComparisonRoutines::SaveNominal() { //************************************* fOutputRootFile->cd(); LOG(FIT) << "Saving Nominal Predictions (be cautious with this)" << std::endl; FitBase::GetRW()->Reconfigure(); GenerateComparison(); SaveCurrentState("nominal"); }; /* MISC Functions */ //************************************* int ComparisonRoutines::GetStatus() { //************************************* return 0; } diff --git a/src/Routines/MinimizerRoutines.cxx b/src/Routines/MinimizerRoutines.cxx index 13b177f..691545e 100755 --- a/src/Routines/MinimizerRoutines.cxx +++ b/src/Routines/MinimizerRoutines.cxx @@ -1,1566 +1,1571 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "StatusMessage.h" #include "MinimizerRoutines.h" /* Constructor/Destructor */ //************************ void MinimizerRoutines::Init(){ //************************ fInputFile = ""; fInputRootFile = NULL; fOutputFile = ""; fOutputRootFile = NULL; fCovar = NULL; fCovFree = NULL; fCorrel = NULL; fCorFree = NULL; fDecomp = NULL; fDecFree = NULL; fStrategy = "Migrad,FixAtLimBreak,Migrad"; fRoutines.clear(); fCardFile = ""; fFakeDataInput = ""; fSampleFCN = NULL; fMinimizer = NULL; fMinimizerFCN = NULL; fCallFunctor = NULL; fAllowedRoutines = ("Migrad,Simplex,Combined," "Brute,Fumili,ConjugateFR," "ConjugatePR,BFGS,BFGS2," "SteepDesc,GSLSimAn,FixAtLim,FixAtLimBreak" "Chi2Scan1D,Chi2Scan2D,Contours,ErrorBands"); }; //************************************* MinimizerRoutines::~MinimizerRoutines(){ //************************************* }; /* Input Functions */ //************************************* MinimizerRoutines::MinimizerRoutines(int argc, char* argv[]){ //************************************* // Set everything to defaults Init(); std::vector<std::string> configs_cmd; std::string maxevents_flag = ""; int verbosity_flag = 0; int error_flag = 0; // If No Arguments print commands for (int i = 1; i< argc; ++i){ if (i+1 != argc){ // Cardfile if (!std::strcmp(argv[i], "-c")) { fCardFile=argv[i+1]; ++i;} else if (!std::strcmp(argv[i], "-o")) { fOutputFile=argv[i+1]; ++i;} else if (!std::strcmp(argv[i], "-f")) { fStrategy=argv[i+1]; ++i;} else if (!std::strcmp(argv[i], "-q")) { configs_cmd.push_back(argv[i+1]); ++i;} else if (!std::strcmp(argv[i], "-n")) { maxevents_flag=argv[i+1]; ++i;} else if (!std::strcmp(argv[i], "-v")) { verbosity_flag -= 1; } else if (!std::strcmp(argv[i], "+v")) { verbosity_flag += 1; } else if (!std::strcmp(argv[i], "-e")) { error_flag -= 1; } else if (!std::strcmp(argv[i], "+e")) { error_flag += 1; } else { ERR(FTL) << "ERROR: unknown command line option given! - '" <<argv[i]<<" "<<argv[i+1]<<"'"<< std::endl; throw; } } } if (fOutputFile.empty()) { ERR(WRN) << "WARNING: output file not specified." << std::endl; ERR(WRN) << "Using " << fCardFile << ".root" << std::endl; fOutputFile = fCardFile + ".root"; } if (fCardFile == fOutputFile) { ERR(WRN) << "WARNING: output file and card file are the same file, " "writing: " << fCardFile << ".root" << std::endl; fOutputFile = fCardFile + ".root"; } if(fCardFile == fOutputFile){ std::cerr << "WARNING: output file and card file are the same file, " "writing: " << fCardFile << ".root" << std::endl; fOutputFile = fCardFile + ".root"; } // Fill fit routines and check they are good fRoutines = GeneralUtils::ParseToStr(fStrategy,","); for (UInt_t i = 0; i < fRoutines.size(); i++){ if (fAllowedRoutines.find(fRoutines[i]) == std::string::npos){ ERR(FTL) << "Unknown fit routine given! " << "Must be provided as a comma seperated list." << std::endl; ERR(FTL) << "Allowed Routines: " << fAllowedRoutines << std::endl; throw; } } // CONFIG // --------------------------- std::string par_dir = GeneralUtils::GetTopLevelDir()+"/parameters/"; FitPar::Config().ReadParamFile( par_dir + "config.list.dat" ); FitPar::Config().ReadParamFile( fCardFile ); for (UInt_t iter = 0; iter < configs_cmd.size(); iter++){ FitPar::Config().ForceParam(configs_cmd[iter]); } if (!maxevents_flag.empty()){ FitPar::Config().SetParI("input.maxevents", atoi(maxevents_flag.c_str())); } if (verbosity_flag != 0){ int curverb = FitPar::Config().GetParI("VERBOSITY"); FitPar::Config().SetParI("VERBOSITY", curverb + verbosity_flag); } if (error_flag != 0){ int curwarn = FitPar::Config().GetParI("ERROR"); FitPar::Config().SetParI("ERROR", curwarn + error_flag); } LOG_VERB(FitPar::Config().GetParI("VERBOSITY")); ERR_VERB(FitPar::Config().GetParI("ERROR")); // CARD // --------------------------- // Parse Card Options ReadCard(fCardFile); // Outputs // --------------------------- // Save Configs to output file fOutputRootFile = new TFile(fOutputFile.c_str(),"RECREATE"); FitPar::Config().Write(); // Starting Setup // --------------------------- SetupCovariance(); SetupRWEngine(); SetupFCN(); return; }; //************************************* void MinimizerRoutines::ReadCard(std::string cardfile){ //************************************* // Read cardlines into vector std::vector<std::string> cardlines = GeneralUtils::ParseFileToStr(cardfile,"\n"); FitPar::Config().cardLines = cardlines; // Read Samples first (norm params can be overridden) int linecount = 0; for (std::vector<std::string>::iterator iter = cardlines.begin(); iter != cardlines.end(); iter++){ std::string line = (*iter); linecount++; // Skip Comments if (line.empty()) continue; if (line.c_str()[0] == '#') continue; // Read Valid Samples int samstatus = ReadSamples(line); // Show line if bad to help user if (samstatus == kErrorStatus) { ERR(FTL) << "Bad Input in cardfile " << fCardFile << " at line " << linecount << "!" << endl; ERR(FTL) << line << endl; throw; } } // Read Parameters second linecount = 0; for (std::vector<std::string>::iterator iter = cardlines.begin(); iter != cardlines.end(); iter++){ std::string line = (*iter); linecount++; // Skip Comments if (line.empty()) continue; if (line.c_str()[0] == '#') continue; // Try Parameter Reads int parstatus = ReadParameters(line); int fakstatus = ReadFakeDataPars(line); // Show line if bad to help user if (parstatus == kErrorStatus || fakstatus == kErrorStatus ){ ERR(FTL) << "Bad Parameter Input in cardfile " << fCardFile << " at line " << linecount << "!" << endl; ERR(FTL) << line << endl; throw; } } return; }; //***************************************** int MinimizerRoutines::ReadParameters(std::string parstring){ //****************************************** std::string inputspec = "RW Dial Inputs Syntax \n" "free input w/ limits: TYPE NAME START MIN MAX STEP [STATE] \n" "fix input: TYPE NAME VALUE [STATE] \n" "free input w/o limits: TYPE NAME START FREE,[STATE] \n" "Allowed Types: \n" "neut_parameter,niwg_parameter,t2k_parameter," "nuwro_parameter,gibuu_parameter"; // Check sample input if (parstring.find("parameter") == std::string::npos) return kGoodStatus; // Parse inputs std::vector<std::string> strvct = GeneralUtils::ParseToStr(parstring, " "); // Skip if comment or parameter somewhere later in line if (strvct[0].c_str()[0] == '#' || strvct[0].find("parameter") == std::string::npos){ return kGoodStatus; } // Check length if (strvct.size() < 3){ ERR(FTL) << "Input rw dials need to provide at least 3 inputs." << std::endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Setup default inputs std::string partype = strvct[0]; std::string parname = strvct[1]; double parval = GeneralUtils::StrToDbl(strvct[2]); double minval = parval - 1.0; double maxval = parval + 1.0; double stepval = 1.0; std::string state = "FIX"; //[DEFAULT] // Check Type if (FitBase::ConvDialType(partype) == kUNKNOWN){ ERR(FTL) << "Unknown parameter type! " << partype << endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Check Parameter Name if (FitBase::GetDialEnum(partype, parname) == -1){ ERR(FTL) << "Bad RW parameter name! " << partype << " " << parname << endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Option Extra (No Limits) if (strvct.size() == 4){ state = strvct[3]; } // Check for weirder inputs if (strvct.size() > 4 && strvct.size() < 6){ ERR(FTL) << "Provided incomplete limits for " << parname << endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Option Extra (With limits and steps) if (strvct.size() >= 6){ minval = GeneralUtils::StrToDbl(strvct[3]); maxval = GeneralUtils::StrToDbl(strvct[4]); stepval = GeneralUtils::StrToDbl(strvct[5]); } // Option Extra (dial state after limits) if (strvct.size() == 7){ state = strvct[6]; } // Run Parameter Conversion if needed if (state.find("ABS") != std::string::npos){ parval = FitBase::RWAbsToSigma( partype, parname, parval ); minval = FitBase::RWAbsToSigma( partype, parname, minval ); maxval = FitBase::RWAbsToSigma( partype, parname, maxval ); stepval = FitBase::RWAbsToSigma( partype, parname, stepval ); } else if (state.find("FRAC") != std::string::npos){ parval = FitBase::RWFracToSigma( partype, parname, parval ); minval = FitBase::RWFracToSigma( partype, parname, minval ); maxval = FitBase::RWFracToSigma( partype, parname, maxval ); stepval = FitBase::RWFracToSigma( partype, parname, stepval ); } // Check no repeat params if (std::find(fParams.begin(), fParams.end(), parname) != fParams.end()){ ERR(FTL) << "Duplicate parameter names given for " << parname << endl; throw; } // Setup Containers fParams.push_back(parname); fTypeVals[parname] = FitBase::ConvDialType(partype); fStartVals[parname] = parval; fCurVals[parname] = fStartVals[parname]; fErrorVals[parname] = 0.0; fStateVals[parname] = state; bool fixstate = state.find("FIX") != std::string::npos; fFixVals[parname] = fixstate; fStartFixVals[parname] = fFixVals[parname]; fMinVals[parname] = minval; fMaxVals[parname] = maxval; fStepVals[parname] = stepval; // Print the parameter LOG(MIN) << "Read Parameter " << parname << " " << parval << " " << minval << " " << maxval << " " << stepval << " " << state << std::endl; // Tell reader its all good return kGoodStatus; } //******************************************* int MinimizerRoutines::ReadFakeDataPars(std::string parstring){ //****************************************** std::string inputspec = "Fake Data Dial Inputs Syntax \n" "fake value: fake_parameter NAME VALUE \n" "Name should match dialnames given in actual dial specification."; // Check sample input if (parstring.find("fake_parameter") == std::string::npos) return kGoodStatus; // Parse inputs std::vector<std::string> strvct = GeneralUtils::ParseToStr(parstring, " "); // Skip if comment or parameter somewhere later in line if (strvct[0].c_str()[0] == '#' || strvct[0] == "fake_parameter"){ return kGoodStatus; } // Check length if (strvct.size() < 3){ ERR(FTL) << "Fake dials need to provide at least 3 inputs." << std::endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Read Inputs std::string parname = strvct[1]; double parval = GeneralUtils::StrToDbl(strvct[2]); // Setup Container fFakeVals[parname] = parval; // Print the fake parameter LOG(MIN) << "Read Fake Parameter " << parname << " " << parval << std::endl; // Tell reader its all good return kGoodStatus; } //****************************************** int MinimizerRoutines::ReadSamples(std::string samstring){ //****************************************** const static std::string inputspec = "\tsample <sample_name> <input_type>:inputfile.root [OPTS] " "[norm]\nsample_name: Name " "of sample to include. e.g. MiniBooNE_CCQE_XSec_1DQ2_nu\ninput_type: The " "input event format. e.g. NEUT, GENIE, EVSPLN, ...\nOPTS: Additional, " "optional sample options.\nnorm: Additional, optional sample " "normalisation factor."; // Check sample input if (samstring.find("sample") == std::string::npos) return kGoodStatus; // Parse inputs std::vector<std::string> strvct = GeneralUtils::ParseToStr(samstring, " "); // Skip if comment or parameter somewhere later in line if (strvct[0].c_str()[0] == '#' || strvct[0] != "sample"){ return kGoodStatus; } // Check length if (strvct.size() < 3){ ERR(FTL) << "Sample need to provide at least 3 inputs." << std::endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Setup default inputs std::string samname = strvct[1]; std::string samfile = strvct[2]; if (samfile == "FIX") { ERR(FTL) << "Input filename was \"FIX\", this line is probably malformed " "in the input card file. Line:\'" << samstring << "\'" << std::endl; ERR(FTL) << "Expect sample lines to look like:\n\t" << inputspec << std::endl; throw; } std::string samtype = "DEFAULT"; double samnorm = 1.0; // Optional Type if (strvct.size() > 3){ samtype = strvct[3]; + samname += "_"+samtype; + // Also get rid of the / and replace it with underscore because it might not be supported character + while (samname.find("/") != std::string::npos) { + samname.replace(samname.find("/"), 1, std::string("_")); + } } // Optional Norm if (strvct.size() > 4) samnorm = GeneralUtils::StrToDbl(strvct[4]); // Add Sample Names as Norm Dials std::string normname = samname + "_norm"; // Check no repeat params if (std::find(fParams.begin(), fParams.end(), normname) != fParams.end()){ ERR(FTL) << "Duplicate samples given for " << samname << endl; throw; } fParams.push_back(normname); fTypeVals[normname] = kNORM; fStartVals[normname] = samnorm; fCurVals[normname] = fStartVals[normname]; fErrorVals[normname] = 0.0; fMinVals[normname] = 0.1; fMaxVals[normname] = 10.0; fStepVals[normname] = 0.5; bool state = samtype.find("FREE") == std::string::npos; fFixVals[normname] = state; fStartFixVals[normname] = state; // Print read in LOG(MIN) << "Read sample " << samname << " " << samfile << " " << samtype << " " << samnorm << endl; // Tell reader its all good return kGoodStatus; } /* Setup Functions */ //************************************* void MinimizerRoutines::SetupRWEngine(){ //************************************* for (UInt_t i = 0; i < fParams.size(); i++){ std::string name = fParams[i]; FitBase::GetRW() -> IncludeDial(name, fTypeVals.at(name) ); } UpdateRWEngine(fStartVals); return; } //************************************* void MinimizerRoutines::SetupFCN(){ //************************************* LOG(FIT)<<"Making the jointFCN"<<std::endl; if (fSampleFCN) delete fSampleFCN; fSampleFCN = new JointFCN(fCardFile, fOutputRootFile); SetFakeData(); fMinimizerFCN = new MinimizerFCN( fSampleFCN ); fCallFunctor = new ROOT::Math::Functor( *fMinimizerFCN, fParams.size() ); fSampleFCN->CreateIterationTree( "fit_iterations", FitBase::GetRW() ); return; } //****************************************** void MinimizerRoutines::SetupFitter(std::string routine){ //****************************************** // Make the fitter std::string fitclass = ""; std::string fittype = ""; // Get correct types if (!routine.compare("Migrad")) { fitclass = "Minuit2"; fittype = "Migrad"; } else if (!routine.compare("Simplex")) { fitclass = "Minuit2"; fittype = "Simplex"; } else if (!routine.compare("Combined")) { fitclass = "Minuit2"; fittype = "Combined"; } else if (!routine.compare("Brute")) { fitclass = "Minuit2"; fittype = "Scan"; } else if (!routine.compare("Fumili")) { fitclass = "Minuit2"; fittype = "Fumili"; } else if (!routine.compare("ConjugateFR")) { fitclass = "GSLMultiMin"; fittype = "ConjugateFR"; } else if (!routine.compare("ConjugatePR")) { fitclass = "GSLMultiMin"; fittype = "ConjugatePR"; } else if (!routine.compare("BFGS")) { fitclass = "GSLMultiMin"; fittype = "BFGS"; } else if (!routine.compare("BFGS2")) { fitclass = "GSLMultiMin"; fittype = "BFGS2"; } else if (!routine.compare("SteepDesc")) { fitclass = "GSLMultiMin"; fittype = "SteepestDescent"; // } else if (!routine.compare("GSLMulti")) { fitclass = "GSLMultiFit"; fittype = ""; // Doesn't work out of the box } else if (!routine.compare("GSLSimAn")) { fitclass = "GSLSimAn"; fittype = ""; } // make minimizer if (fMinimizer) delete fMinimizer; fMinimizer = ROOT::Math::Factory::CreateMinimizer(fitclass, fittype); fMinimizer->SetMaxFunctionCalls(FitPar::Config().GetParI("minimizer.maxcalls")); if (!routine.compare("Brute")){ fMinimizer->SetMaxFunctionCalls(fParams.size() * fParams.size()*4); fMinimizer->SetMaxIterations(fParams.size() * fParams.size()*4); } fMinimizer->SetMaxIterations(FitPar::Config().GetParI("minimizer.maxiterations")); fMinimizer->SetTolerance(FitPar::Config().GetParD("minimizer.tolerance")); fMinimizer->SetStrategy(FitPar::Config().GetParI("minimizer.strategy")); fMinimizer->SetFunction(*fCallFunctor); int ipar = 0; //Add Fit Parameters for (UInt_t i = 0; i < fParams.size(); i++){ std::string syst = fParams.at(i); bool fixed = true; double vstart, vstep, vlow, vhigh; vstart = vstep = vlow = vhigh = 0.0; if (fCurVals.find(syst) != fCurVals.end() ) vstart = fCurVals.at(syst); if (fMinVals.find(syst) != fMinVals.end() ) vlow = fMinVals.at(syst); if (fMaxVals.find(syst) != fMaxVals.end() ) vhigh = fMaxVals.at(syst); if (fStepVals.find(syst) != fStepVals.end()) vstep = fStepVals.at(syst); if (fFixVals.find(syst) != fFixVals.end() ) fixed = fFixVals.at(syst); // fix for errors if (vhigh == vlow) vhigh += 1.0; fMinimizer->SetVariable(ipar, syst, vstart, vstep); fMinimizer->SetVariableLimits(ipar,vlow,vhigh); if (fixed) { fMinimizer->FixVariable(ipar); LOG(FIT) << "Fixed Param: "<<syst<<std::endl; } else { LOG(FIT) << "Free Param: "<<syst <<" Start:"<<vstart <<" Range:"<<vlow<<" to "<<vhigh <<" Step:"<<vstep<<std::endl; } ipar++; } LOG(FIT) << "Setup Minimizer: "<<fMinimizer->NDim()<<"(NDim) "<<fMinimizer->NFree()<<"(NFree)"<<std::endl; return; } //************************************* void MinimizerRoutines::SetFakeData(){ //************************************* if (fFakeDataInput.empty()) return; if (fFakeDataInput.compare("MC") == 0){ LOG(FIT)<<"Setting fake data from MC starting prediction." <<std::endl; UpdateRWEngine(fFakeVals); FitBase::GetRW()->Reconfigure(); fSampleFCN->ReconfigureAllEvents(); fSampleFCN->SetFakeData("MC"); UpdateRWEngine(fCurVals); LOG(FIT)<<"Set all data to fake MC predictions."<<std::endl; } else { fSampleFCN->SetFakeData(fFakeDataInput); } return; } /* Fitting Functions */ //************************************* void MinimizerRoutines::UpdateRWEngine(std::map<std::string,double>& updateVals){ //************************************* for (UInt_t i = 0; i < fParams.size(); i++){ std::string name = fParams[i]; if (updateVals.find(name) == updateVals.end()) continue; FitBase::GetRW()->SetDialValue(name,updateVals.at(name)); } FitBase::GetRW()->Reconfigure(); return; } //************************************* void MinimizerRoutines::Run(){ //************************************* for (UInt_t i = 0; i < fRoutines.size(); i++){ std::string routine = fRoutines.at(i); int fitstate = kFitUnfinished; LOG(FIT)<<"Running Routine: "<<routine<<std::endl; // Try Routines if (routine.find("LowStat") != std::string::npos) LowStatRoutine(routine); else if (routine == "FixAtLim") FixAtLimit(); else if (routine == "FixAtLimBreak") fitstate = FixAtLimit(); else if (routine.find("ErrorBands") != std::string::npos) GenerateErrorBands(); else if (!routine.compare("Chi2Scan1D")) Create1DScans(); else if (!routine.compare("Chi2Scan2D")) Chi2Scan2D(); else fitstate = RunFitRoutine(routine); // If ending early break here if (fitstate == kFitFinished || fitstate == kNoChange){ LOG(FIT) << "Ending fit routines loop." << endl; break; } } return; } //************************************* int MinimizerRoutines::RunFitRoutine(std::string routine){ //************************************* int endfits = kFitUnfinished; // set fitter at the current start values fOutputRootFile->cd(); SetupFitter(routine); // choose what to do with the minimizer depending on routine. if (!routine.compare("Migrad") or !routine.compare("Simplex") or !routine.compare("Combined") or !routine.compare("Brute") or !routine.compare("Fumili") or !routine.compare("ConjugateFR") or !routine.compare("ConjugatePR") or !routine.compare("BFGS") or !routine.compare("BFGS2") or !routine.compare("SteepDesc") or // !routine.compare("GSLMulti") or !routine.compare("GSLSimAn")) { if (fMinimizer->NFree() > 0){ LOG(FIT) << StatusMessage(fMinimizer->Minimize()) << std::endl; GetMinimizerState(); } } // other otptions else if (!routine.compare("Contour")) { CreateContours(); } return endfits; } //************************************* void MinimizerRoutines::PrintState(){ //************************************* LOG(FIT)<<"------------"<<std::endl; // Count max size int maxcount = 0; for (UInt_t i = 0; i < fParams.size(); i++){ maxcount = max(int(fParams[i].size()), maxcount); } // Header LOG(FIT) << " # " << left << setw(maxcount) << "Parameter " << " = " << setw(10) << "Value" << " +- " << setw(10) << "Error" << " " << setw(8) << "(Units)" << " " << setw(10) << "Conv. Val" << " +- " << setw(10) << "Conv. Err" << " " << setw(8) << "(Units)" << std::endl; // Parameters for (UInt_t i = 0; i < fParams.size(); i++){ std::string syst = fParams.at(i); std::string typestr = FitBase::ConvDialType(fTypeVals[syst]); std::string curunits = "(sig.)"; double curval = fCurVals[syst]; double curerr = fErrorVals[syst]; if (fStateVals[syst].find("ABS") != std::string::npos){ curval = FitBase::RWSigmaToAbs(typestr, syst, curval); curerr = (FitBase::RWSigmaToAbs(typestr, syst, curerr) - FitBase::RWSigmaToAbs(typestr, syst, 0.0)); curunits = "(Abs.)"; } else if (fStateVals[syst].find("FRAC") != std::string::npos){ curval = FitBase::RWSigmaToFrac(typestr, syst, curval); curerr = (FitBase::RWSigmaToFrac(typestr, syst, curerr) - FitBase::RWSigmaToFrac(typestr, syst, 0.0)); curunits = "(Frac)"; } std::string convunits = "(" + FitBase::GetRWUnits(typestr, syst) + ")"; double convval = FitBase::RWSigmaToAbs(typestr, syst, curval); double converr = (FitBase::RWSigmaToAbs(typestr, syst, curerr) - FitBase::RWSigmaToAbs(typestr, syst, 0.0)); std::ostringstream curparstring; curparstring << " " << setw(3) << left << i << ". " << setw(maxcount) << syst << " = " << setw(10) << curval << " +- " << setw(10) << curerr << " " << setw(8) << curunits << " " << setw(10) << convval << " +- " << setw(10) << converr << " " << setw(8) << convunits; LOG(FIT) << curparstring.str() << endl; } LOG(FIT)<<"------------"<<std::endl; double like = fSampleFCN->GetLikelihood(); LOG(FIT)<<"Likelihood for JointFCN == " << like << endl; LOG(FIT)<<"------------"<<std::endl; } //************************************* void MinimizerRoutines::GetMinimizerState(){ //************************************* LOG(FIT) << "Minimizer State: "<<std::endl; // Get X and Err const double *values = fMinimizer->X(); const double *errors = fMinimizer->Errors(); // int ipar = 0; for (UInt_t i = 0; i < fParams.size(); i++){ std::string syst = fParams.at(i); fCurVals[syst] = values[i]; fErrorVals[syst] = errors[i]; } PrintState(); // Covar SetupCovariance(); if (fMinimizer->CovMatrixStatus() > 0){ // Fill Full Covar for (int i = 0; i < fCovar->GetNbinsX(); i++){ for (int j = 0; j < fCovar->GetNbinsY(); j++){ fCovar->SetBinContent(i+1,j+1, fMinimizer->CovMatrix(i,j)); } } int freex = 0; int freey = 0; for (int i = 0; i < fCovar->GetNbinsX(); i++){ if (fMinimizer->IsFixedVariable(i)) continue; freey = 0; for (int j = 0; j < fCovar->GetNbinsY(); j++){ if (fMinimizer->IsFixedVariable(j)) continue; fCovFree->SetBinContent(freex+1,freey+1, fMinimizer->CovMatrix(i,j)); freey++; } freex++; } fCorrel = PlotUtils::GetCorrelationPlot(fCovar,"correlation"); fDecomp = PlotUtils::GetDecompPlot(fCovar,"decomposition"); if (fMinimizer->NFree() > 0){ fCorFree = PlotUtils::GetCorrelationPlot(fCovFree,"correlation_free"); fDecFree = PlotUtils::GetDecompPlot(fCovFree,"decomposition_free"); } } return; }; //************************************* void MinimizerRoutines::LowStatRoutine(std::string routine){ //************************************* LOG(FIT) << "Running Low Statistics Routine: "<<routine<<std::endl; int lowstatsevents = FitPar::Config().GetParI("minimizer.lowstatevents"); int maxevents = FitPar::Config().GetParI("input.maxevents"); int verbosity = FitPar::Config().GetParI("VERBOSITY"); std::string trueroutine = routine; std::string substring = "LowStat"; trueroutine.erase( trueroutine.find(substring), substring.length() ); // Set MAX EVENTS=1000 FitPar::Config().SetParI("input.maxevents",lowstatsevents); FitPar::Config().SetParI("VERBOSITY",3); SetupFCN(); RunFitRoutine(trueroutine); FitPar::Config().SetParI("input.maxevents",maxevents); SetupFCN(); FitPar::Config().SetParI("VERBOSITY",verbosity); return; } //************************************* void MinimizerRoutines::Create1DScans(){ //************************************* // 1D Scan Routine // Steps through all free parameters about nominal using the step size // Creates a graph for each free parameter // At the current point create a 1D Scan for all parametes (Uncorrelated) for (UInt_t i = 0; i < fParams.size(); i++){ if (fFixVals[fParams[i]]) continue; LOG(FIT) << "Running 1D Scan for " << fParams[i] << endl; fSampleFCN->CreateIterationTree(fParams[i] + "_scan1D_iterations", FitBase::GetRW()); double scanmiddlepoint = fCurVals[fParams[i]]; // Determine N points needed double limlow = fMinVals[fParams[i]]; double limhigh = fMaxVals[fParams[i]]; double step = fStepVals[fParams[i]]; int npoints = int( fabs(limhigh - limlow)/(step+0.) ); TH1D* contour = new TH1D(("Chi2Scan1D_" + fParams[i]).c_str(), ("Chi2Scan1D_" + fParams[i] + ";" + fParams[i]).c_str(), npoints, limlow, limhigh); // Fill bins for (int x = 0; x < contour->GetNbinsX(); x++){ // Set X Val fCurVals[fParams[i]] = contour->GetXaxis()->GetBinCenter(x+1); // Run Eval double *vals = FitUtils::GetArrayFromMap( fParams, fCurVals ); double chi2 = fSampleFCN->DoEval( vals ); delete vals; // Fill Contour contour->SetBinContent(x+1, chi2); } // Save contour contour->Write(); // Reset Parameter fCurVals[fParams[i]] = scanmiddlepoint; // Save TTree fSampleFCN->WriteIterationTree(); } return; } //************************************* void MinimizerRoutines::Chi2Scan2D(){ //************************************* // Chi2 Scan 2D // Creates a 2D chi2 scan by stepping through all free parameters // Works for all pairwise combos of free parameters // Scan I for (UInt_t i = 0; i < fParams.size(); i++){ if (fFixVals[fParams[i]]) continue; // Scan J for (UInt_t j = 0; j < i; j++){ if (fFixVals[fParams[j]]) continue; fSampleFCN->CreateIterationTree( fParams[i] + "_" + fParams[j] + "_" + "scan2D_iterations", FitBase::GetRW() ); double scanmid_i = fCurVals[fParams[i]]; double scanmid_j = fCurVals[fParams[j]]; double limlow_i = fMinVals[fParams[i]]; double limhigh_i = fMaxVals[fParams[i]]; double step_i = fStepVals[fParams[i]]; double limlow_j = fMinVals[fParams[j]]; double limhigh_j = fMaxVals[fParams[j]]; double step_j = fStepVals[fParams[j]]; int npoints_i = int( fabs(limhigh_i - limlow_i)/(step_i+0.) ) + 1; int npoints_j = int( fabs(limhigh_j - limlow_j)/(step_j+0.) ) + 1; TH2D* contour = new TH2D(("Chi2Scan2D_" + fParams[i] + "_" + fParams[j]).c_str(), ("Chi2Scan2D_" + fParams[i] + "_" + fParams[j] + ";" + fParams[i] + ";" + fParams[j]).c_str(), npoints_i, limlow_i, limhigh_i, npoints_j, limlow_j, limhigh_j ); // Begin Scan LOG(FIT)<<"Running scan for "<<fParams[i]<<" "<<fParams[j]<<endl; // Fill bins for (int x = 0; x < contour->GetNbinsX(); x++){ // Set X Val fCurVals[fParams[i]] = contour->GetXaxis()->GetBinCenter(x+1); // Loop Y for (int y = 0; y < contour->GetNbinsY(); y++){ // Set Y Val fCurVals[fParams[j]] = contour->GetYaxis()->GetBinCenter(y+1); // Run Eval double *vals = FitUtils::GetArrayFromMap( fParams, fCurVals ); double chi2 = fSampleFCN->DoEval( vals ); delete vals; // Fill Contour contour->SetBinContent(x+1,y+1, chi2); fCurVals[fParams[j]] = scanmid_j; } fCurVals[fParams[i]] = scanmid_i; fCurVals[fParams[j]] = scanmid_j; } // Save contour contour->Write(); // Save Iterations fSampleFCN->WriteIterationTree(); } } return; } //************************************* void MinimizerRoutines::CreateContours(){ //************************************* // Use MINUIT for this if possible ERR(FTL) << " Contours not yet implemented as it is really slow!" << endl; throw; return; } //************************************* int MinimizerRoutines::FixAtLimit(){ //************************************* bool fixedparam = false; for (UInt_t i = 0; i < fParams.size(); i++){ std::string syst = fParams.at(i); if (fFixVals[syst]) continue; double curVal = fCurVals.at(syst); double minVal = fMinVals.at(syst); double maxVal = fMinVals.at(syst); if (fabs(curVal - minVal) < 0.0001){ fCurVals[syst] = minVal; fFixVals[syst] = true; fixedparam = true; } if (fabs(maxVal - curVal) < 0.0001){ fCurVals[syst] = maxVal; fFixVals[syst] = true; fixedparam = true; } } if (!fixedparam){ LOG(FIT) << "No dials needed fixing!" << endl; return kNoChange; }else return kStateChange; } /* Write Functions */ //************************************* void MinimizerRoutines::SaveResults(){ //************************************* fOutputRootFile->cd(); if (fMinimizer){ SetupCovariance(); SaveMinimizerState(); } SaveCurrentState(); } //************************************* void MinimizerRoutines::SaveMinimizerState(){ //************************************* if (!fMinimizer){ ERR(FTL) << "Can't save minimizer state without min object" << endl; throw; } // Save main fit tree fSampleFCN->WriteIterationTree(); // Get Vals and Errors GetMinimizerState(); // Save tree with fit status std::vector<std::string> nameVect; std::vector<double> valVect; std::vector<double> errVect; std::vector<double> minVect; std::vector<double> maxVect; std::vector<double> startVect; std::vector<int> endfixVect; std::vector<int> startfixVect; // int NFREEPARS = fMinimizer->NFree(); int NPARS = fMinimizer->NDim(); int ipar = 0; // Dial Vals for (UInt_t i = 0; i < fParams.size(); i++){ std::string name = fParams.at(i); nameVect .push_back( name ); valVect .push_back( fCurVals.at(name) ); errVect .push_back( fErrorVals.at(name) ); minVect .push_back( fMinVals.at(name) ); maxVect .push_back( fMaxVals.at(name) ); startVect .push_back( fStartVals.at(name) ); endfixVect .push_back( fFixVals.at(name) ); startfixVect.push_back( fStartFixVals.at(name) ); ipar++; } int NFREE = fMinimizer->NFree(); int NDIM = fMinimizer->NDim(); double CHI2 = fSampleFCN->GetLikelihood(); int NBINS = fSampleFCN->GetNDOF(); int NDOF = NBINS - NFREE; // Write fit results TTree* fit_tree = new TTree("fit_result","fit_result"); fit_tree->Branch("parameter_names",&nameVect); fit_tree->Branch("parameter_values",&valVect); fit_tree->Branch("parameter_errors",&errVect); fit_tree->Branch("parameter_min",&minVect); fit_tree->Branch("parameter_max",&maxVect); fit_tree->Branch("parameter_start",&startVect); fit_tree->Branch("parameter_fix",&endfixVect); fit_tree->Branch("parameter_startfix",&startfixVect); fit_tree->Branch("CHI2",&CHI2,"CHI2/D"); fit_tree->Branch("NDOF",&NDOF,"NDOF/I"); fit_tree->Branch("NBINS",&NBINS,"NBINS/I"); fit_tree->Branch("NDIM",&NDIM,"NDIM/I"); fit_tree->Branch("NFREE",&NFREE,"NFREE/I"); fit_tree->Fill(); fit_tree->Write(); // Make dial variables TH1D dialvar = TH1D("fit_dials","fit_dials",NPARS,0,NPARS); TH1D startvar = TH1D("start_dials","start_dials",NPARS,0,NPARS); TH1D minvar = TH1D("min_dials","min_dials",NPARS,0,NPARS); TH1D maxvar = TH1D("max_dials","max_dials",NPARS,0,NPARS); TH1D dialvarfree = TH1D("fit_dials_free","fit_dials_free",NFREE,0,NFREE); TH1D startvarfree = TH1D("start_dials_free","start_dials_free",NFREE,0,NFREE); TH1D minvarfree = TH1D("min_dials_free","min_dials_free",NFREE,0,NFREE); TH1D maxvarfree = TH1D("max_dials_free","max_dials_free",NFREE,0,NFREE); int freecount = 0; for (UInt_t i = 0; i < nameVect.size(); i++){ std::string name = nameVect.at(i); dialvar.SetBinContent(i+1, valVect.at(i)); dialvar.SetBinError(i+1, errVect.at(i)); dialvar.GetXaxis()->SetBinLabel(i+1, name.c_str()); startvar.SetBinContent(i+1, startVect.at(i)); startvar.GetXaxis()->SetBinLabel(i+1, name.c_str()); minvar.SetBinContent(i+1, minVect.at(i)); minvar.GetXaxis()->SetBinLabel(i+1, name.c_str()); maxvar.SetBinContent(i+1, maxVect.at(i)); maxvar.GetXaxis()->SetBinLabel(i+1, name.c_str()); if (NFREE > 0){ if (!startfixVect.at(i)){ freecount++; dialvarfree.SetBinContent(freecount, valVect.at(i)); dialvarfree.SetBinError(freecount, errVect.at(i)); dialvarfree.GetXaxis()->SetBinLabel(freecount, name.c_str()); startvarfree.SetBinContent(freecount, startVect.at(i)); startvarfree.GetXaxis()->SetBinLabel(freecount, name.c_str()); minvarfree.SetBinContent(freecount, minVect.at(i)); minvarfree.GetXaxis()->SetBinLabel(freecount, name.c_str()); maxvarfree.SetBinContent(freecount, maxVect.at(i)); maxvarfree.GetXaxis()->SetBinLabel(freecount, name.c_str()); } } } // Save Dial Plots dialvar.Write(); startvar.Write(); minvar.Write(); maxvar.Write(); if (NFREE > 0){ dialvarfree.Write(); startvarfree.Write(); minvarfree.Write(); maxvarfree.Write(); } // Save fit_status plot TH1D statusplot = TH1D("fit_status","fit_status",8,0,8); std::string fit_labels[8] = {"status", "cov_status", \ "maxiter", "maxfunc", \ "iter", "func", \ "precision", "tolerance"}; double fit_vals[8]; fit_vals[0] = fMinimizer->Status() + 0.; fit_vals[1] = fMinimizer->CovMatrixStatus() + 0.; fit_vals[2] = fMinimizer->MaxIterations() + 0.; fit_vals[3] = fMinimizer->MaxFunctionCalls()+ 0.; fit_vals[4] = fMinimizer->NIterations() + 0.; fit_vals[5] = fMinimizer->NCalls() + 0.; fit_vals[6] = fMinimizer->Precision() + 0.; fit_vals[7] = fMinimizer->Tolerance() + 0.; for (int i = 0; i < 8; i++){ statusplot.SetBinContent(i+1, fit_vals[i]); statusplot.GetXaxis()->SetBinLabel(i+1, fit_labels[i].c_str()); } statusplot.Write(); // Save Covars if (fCovar) fCovar->Write(); if (fCovFree) fCovFree->Write(); if (fCorrel) fCorrel->Write(); if (fCorFree) fCorFree->Write(); if (fDecomp) fDecomp->Write(); if (fDecFree) fDecFree->Write(); return; } //************************************* void MinimizerRoutines::SaveCurrentState(std::string subdir){ //************************************* LOG(FIT)<<"Saving current full FCN predictions" <<std::endl; // Setup DIRS TDirectory* curdir = gDirectory; if (!subdir.empty()){ TDirectory* newdir =(TDirectory*) gDirectory->mkdir(subdir.c_str()); newdir->cd(); } FitBase::GetRW()->Reconfigure(); fSampleFCN->ReconfigureAllEvents(); fSampleFCN->Write(); // Change back to current DIR curdir->cd(); return; } //************************************* void MinimizerRoutines::SaveNominal(){ //************************************* fOutputRootFile->cd(); LOG(FIT)<<"Saving Nominal Predictions (be cautious with this)" <<std::endl; FitBase::GetRW()->Reconfigure(); SaveCurrentState("nominal"); }; //************************************* void MinimizerRoutines::SavePrefit(){ //************************************* fOutputRootFile->cd(); LOG(FIT)<<"Saving Prefit Predictions"<<std::endl; UpdateRWEngine(fStartVals); SaveCurrentState("prefit"); UpdateRWEngine(fCurVals); }; /* MISC Functions */ //************************************* int MinimizerRoutines::GetStatus(){ //************************************* return 0; } //************************************* void MinimizerRoutines::SetupCovariance(){ //************************************* // Remove covares if they exist if (fCovar) delete fCovar; if (fCovFree) delete fCovFree; if (fCorrel) delete fCorrel; if (fCorFree) delete fCorFree; if (fDecomp) delete fDecomp; if (fDecFree) delete fDecFree; LOG(FIT) << "Building covariance matrix.." << endl; int NFREE = 0; int NDIM = 0; // Get NFREE from min or from vals (for cases when doing throws) if (fMinimizer){ NFREE = fMinimizer->NFree(); NDIM = fMinimizer->NDim(); } else { NDIM = fParams.size(); for (UInt_t i = 0; i < fParams.size(); i++){ if (!fFixVals[fParams[i]]) NFREE++; } } if (NDIM == 0) return; LOG(FIT) << "NFREE == " << NFREE << endl; fCovar = new TH2D("covariance","covariance",NDIM,0,NDIM,NDIM,0,NDIM); if (NFREE > 0){ fCovFree = new TH2D("covariance_free", "covariance_free", NFREE,0,NFREE, NFREE,0,NFREE); } else { fCovFree = NULL; } // Set Bin Labels int countall = 0; int countfree = 0; for (UInt_t i = 0; i < fParams.size(); i++){ fCovar->GetXaxis()->SetBinLabel(countall+1,fParams[i].c_str()); fCovar->GetYaxis()->SetBinLabel(countall+1,fParams[i].c_str()); countall++; if (!fFixVals[fParams[i]] and NFREE > 0){ fCovFree->GetXaxis()->SetBinLabel(countfree+1,fParams[i].c_str()); fCovFree->GetYaxis()->SetBinLabel(countfree+1,fParams[i].c_str()); countfree++; } } fCorrel = PlotUtils::GetCorrelationPlot(fCovar,"correlation"); fDecomp = PlotUtils::GetDecompPlot(fCovar,"decomposition"); if (NFREE > 0) { fCorFree = PlotUtils::GetCorrelationPlot(fCovFree, "correlation_free"); fDecFree = PlotUtils::GetDecompPlot(fCovFree,"decomposition_free"); } else { fCorFree = NULL; fDecFree = NULL; } return; }; //************************************* void MinimizerRoutines::ThrowCovariance(bool uniformly){ //************************************* std::vector<double> rands; if (!fDecFree) { ERR(WRN) << "Trying to throw 0 free parameters"<<std::endl; return; } // Generate Random Gaussians for (Int_t i = 0; i < fDecFree->GetNbinsX(); i++){ rands.push_back(gRandom->Gaus(0.0,1.0)); } // Reset Thrown Values for (UInt_t i = 0; i < fParams.size(); i++){ fThrownVals[fParams[i]] = fCurVals[fParams[i]]; } // Loop and get decomp for (Int_t i = 0; i < fDecFree->GetNbinsX(); i++){ std::string parname = std::string(fDecFree->GetXaxis()->GetBinLabel(i+1)); double mod = 0.0; if (!uniformly){ for (Int_t j = 0; j < fDecFree->GetNbinsY(); j++){ mod += rands[j] * fDecFree->GetBinContent(j+1,i+1); } } if (fCurVals.find(parname) != fCurVals.end()) { if (uniformly) fThrownVals[parname] = gRandom->Uniform(fMinVals[parname],fMaxVals[parname]); else { fThrownVals[parname] = fCurVals[parname] + mod; } } } // Check Limits for (UInt_t i = 0; i < fParams.size(); i++){ std::string syst = fParams[i]; if (fFixVals[syst]) continue; if (fThrownVals[syst] < fMinVals[syst]) fThrownVals[syst] = fMinVals[syst]; if (fThrownVals[syst] > fMaxVals[syst]) fThrownVals[syst] = fMaxVals[syst]; } return; }; //************************************* void MinimizerRoutines::GenerateErrorBands(){ //************************************* TDirectory* errorDIR = (TDirectory*) fOutputRootFile->mkdir("error_bands"); errorDIR->cd(); TFile* tempfile = new TFile((fOutputFile + ".throws.root").c_str(),"RECREATE"); tempfile->cd(); int nthrows = FitPar::Config().GetParI("error_throws"); UpdateRWEngine(fCurVals); fSampleFCN->ReconfigureAllEvents(); TDirectory* nominal = (TDirectory*) tempfile->mkdir("nominal"); nominal->cd(); fSampleFCN->Write(); TDirectory* outnominal = (TDirectory*) fOutputRootFile->mkdir("nominal_throw"); outnominal->cd(); fSampleFCN->Write(); errorDIR->cd(); TTree* parameterTree = new TTree("throws","throws"); double chi2; for (UInt_t i = 0; i < fParams.size(); i++) parameterTree->Branch(fParams[i].c_str(), &fThrownVals[fParams[i]], (fParams[i] + "/D").c_str()); parameterTree->Branch("chi2",&chi2,"chi2/D"); bool uniformly = FitPar::Config().GetParB("error_uniform"); // Run Throws and save for (Int_t i = 0; i < nthrows; i++){ TDirectory* throwfolder = (TDirectory*)tempfile->mkdir(Form("throw_%i",i)); throwfolder->cd(); // Generate Random Parameter Throw ThrowCovariance(uniformly); // Run Eval double *vals = FitUtils::GetArrayFromMap( fParams, fThrownVals ); chi2 = fSampleFCN->DoEval( vals ); delete vals; // Save the FCN fSampleFCN->Write(); parameterTree->Fill(); } errorDIR->cd(); fDecFree->Write(); fCovFree->Write(); parameterTree->Write(); delete parameterTree; // Now go through the keys in the temporary file and look for TH1D, and TH2D plots TIter next(nominal->GetListOfKeys()); TKey *key; while ((key = (TKey*)next())) { TClass *cl = gROOT->GetClass(key->GetClassName()); if (!cl->InheritsFrom("TH1D") and !cl->InheritsFrom("TH2D")) continue; TH1D *baseplot = (TH1D*)key->ReadObj(); std::string plotname = std::string(baseplot->GetName()); int nbins = baseplot->GetNbinsX()*baseplot->GetNbinsY(); // Setup TProfile with RMS option TProfile* tprof = new TProfile((plotname + "_prof").c_str(),(plotname + "_prof").c_str(),nbins, 0, nbins, "S"); // Setup The TTREE double* bincontents; bincontents = new double[nbins]; double* binlowest; binlowest = new double[nbins]; double* binhighest; binhighest = new double[nbins]; errorDIR->cd(); TTree* bintree = new TTree((plotname + "_tree").c_str(), (plotname + "_tree").c_str()); for (Int_t i = 0; i < nbins; i++){ bincontents[i] = 0.0; binhighest[i] = 0.0; binlowest[i] = 0.0; bintree->Branch(Form("content_%i",i),&bincontents[i],Form("content_%i/D",i)); } for (Int_t i = 0; i < nthrows; i++){ TH1* newplot = (TH1*)tempfile->Get(Form(("throw_%i/" + plotname).c_str(),i)); for (Int_t j = 0; j < nbins; j++){ tprof->Fill(j+0.5, newplot->GetBinContent(j+1)); bincontents[j] = newplot->GetBinContent(j+1); if (bincontents[j] < binlowest[j] or i == 0) binlowest[j] = bincontents[j]; if (bincontents[j] > binhighest[j] or i == 0) binhighest[j] = bincontents[j]; } errorDIR->cd(); bintree->Fill(); delete newplot; } errorDIR->cd(); for (Int_t j = 0; j < nbins; j++){ if (!uniformly){ baseplot->SetBinError(j+1,tprof->GetBinError(j+1)); } else { baseplot->SetBinContent(j+1, (binlowest[j] + binhighest[j]) / 2.0); baseplot->SetBinError(j+1, (binhighest[j] - binlowest[j])/2.0); } } errorDIR->cd(); baseplot->Write(); tprof->Write(); bintree->Write(); delete baseplot; delete tprof; delete bintree; delete [] bincontents; } return; }; diff --git a/src/Routines/SplineRoutines.cxx b/src/Routines/SplineRoutines.cxx index 851fbf0..aabd204 100755 --- a/src/Routines/SplineRoutines.cxx +++ b/src/Routines/SplineRoutines.cxx @@ -1,913 +1,918 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "StatusMessage.h" #include "SplineRoutines.h" /* Constructor/Destructor */ //************************ void SplineRoutines::Init() { //************************ fStrategy = "SaveEvents"; fRoutines.clear(); fCardFile = ""; fSampleFCN = NULL; fRW = NULL; fAllowedRoutines = ("SaveEvents,SaveSplineEvents"); }; //************************************* SplineRoutines::~SplineRoutines(){ //************************************* }; /* Input Functions */ //************************************* SplineRoutines::SplineRoutines(int argc, char* argv[]) { //************************************* // Set everything to defaults Init(); std::vector<std::string> configs_cmd; std::string maxevents_flag = ""; int verbosity_flag = 0; int error_flag = 0; // If No Arguments print commands for (int i = 1; i < argc; ++i) { if (i + 1 != argc) { // Cardfile if (!std::strcmp(argv[i], "-c")) { fCardFile = argv[i + 1]; ++i; } else if (!std::strcmp(argv[i], "-f")) { fStrategy = argv[i + 1]; ++i; } else if (!std::strcmp(argv[i], "-q")) { configs_cmd.push_back(argv[i + 1]); ++i; } else if (!std::strcmp(argv[i], "-n")) { maxevents_flag = argv[i + 1]; ++i; } else if (!std::strcmp(argv[i], "-v")) { verbosity_flag -= 1; } else if (!std::strcmp(argv[i], "+v")) { verbosity_flag += 1; } else if (!std::strcmp(argv[i], "-e")) { error_flag -= 1; } else if (!std::strcmp(argv[i], "+e")) { error_flag += 1; } else { ERR(FTL) << "ERROR: unknown command line option given! - '" << argv[i] << " " << argv[i + 1] << "'" << std::endl; throw; } } } if (fCardFile.empty()) { ERR(FTL) << "ERROR: card file not specified." << std::endl; ERR(FTL) << "Run with '-h' to see options." << std::endl; throw; } // Fill fit routines and check they are good fRoutines = GeneralUtils::ParseToStr(fStrategy, ","); for (UInt_t i = 0; i < fRoutines.size(); i++) { if (fAllowedRoutines.find(fRoutines[i]) == std::string::npos) { ERR(FTL) << "Unknown fit routine given! " << "Must be provided as a comma seperated list." << std::endl; ERR(FTL) << "Allowed Routines: " << fAllowedRoutines << std::endl; throw; } } // CONFIG // --------------------------- std::string par_dir = GeneralUtils::GetTopLevelDir() + "/parameters/"; FitPar::Config().ReadParamFile(par_dir + "config.list.dat"); FitPar::Config().ReadParamFile(fCardFile); for (UInt_t iter = 0; iter < configs_cmd.size(); iter++) { FitPar::Config().ForceParam(configs_cmd[iter]); } if (!maxevents_flag.empty()) { FitPar::Config().SetParI("input.maxevents", atoi(maxevents_flag.c_str())); } if (verbosity_flag != 0) { int curverb = FitPar::Config().GetParI("VERBOSITY"); FitPar::Config().SetParI("VERBOSITY", curverb + verbosity_flag); } if (error_flag != 0) { int curwarn = FitPar::Config().GetParI("ERROR"); FitPar::Config().SetParI("ERROR", curwarn + error_flag); } LOG_VERB(FitPar::Config().GetParI("VERBOSITY")); ERR_VERB(FitPar::Config().GetParI("ERROR")); // CARD // --------------------------- // Parse Card Options ReadCard(fCardFile); // Outputs // --------------------------- // Save Configs to output file // fOutputRootFile = new TFile(fOutputFile.c_str(),"RECREATE"); FitPar::Config().Write(); // Starting Setup // --------------------------- SetupRWEngine(); SetupSamples(); SetupGenericInputs(); return; }; //************************************* void SplineRoutines::ReadCard(std::string cardfile) { //************************************* // Read cardlines into vector std::vector<std::string> cardlines = GeneralUtils::ParseFileToStr(cardfile, "\n"); FitPar::Config().cardLines = cardlines; // Read Inputs int linecount = 0; for (std::vector<std::string>::iterator iter = cardlines.begin(); iter != cardlines.end(); iter++) { std::string line = (*iter); linecount++; // Skip Comments if (line.empty()) continue; if (line.c_str()[0] == '#') continue; // Read Valid Samples int samstatus = ReadSamples(line); int genstatus = ReadGenericInputs(line); int parstatus = ReadParameters(line); int evtstatus = ReadEventSplines(line); int binstatus = ReadBinSplines(line); // Show line if bad to help user if (samstatus == kErrorStatus || genstatus == kErrorStatus || parstatus == kErrorStatus || evtstatus == kErrorStatus || binstatus == kErrorStatus) { ERR(FTL) << "Bad Input in cardfile " << fCardFile << " at line " << linecount << "!" << endl; ERR(FTL) << line << endl; throw; } } return; }; //***************************************** int SplineRoutines::ReadEventSplines(std::string splstring) { //***************************************** std::string inputspec = "eventspline dialnames type points"; // Check spline input if (splstring.find("eventspline") == std::string::npos) return kGoodStatus; // Parse inputs std::vector<std::string> strvct = GeneralUtils::ParseToStr(splstring, " "); // Skip if comment or parameter somewhere later in line if (strvct[0].c_str()[0] == '#' || strvct[0].find("eventspline") == std::string::npos) { return kGoodStatus; } // Check length if (strvct.size() < 4) { ERR(FTL) << "Input rw dials need to provide at least 4 inputs." << std::endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Read Values std::string parname = strvct[1]; std::string partype = strvct[2]; std::string parpnts = strvct[3]; // Fill Containers fSplineNames.push_back(parname); fSplineTypes[parname] = partype; fSplinePoints[parname] = parpnts; // Return LOG(FIT) << "Read Spline: " << parname << " " << partype << " " << parpnts << endl; return kGoodStatus; } //***************************************** int SplineRoutines::ReadParameters(std::string parstring) { //****************************************** std::string inputspec = "RW Dial Inputs Syntax \n" "free input w/ limits: TYPE NAME START MIN MAX STEP [STATE] \n" "fix input: TYPE NAME VALUE [STATE] \n" "free input w/o limits: TYPE NAME START FREE,[STATE] \n" "Allowed Types: \n" "neut_parameter,niwg_parameter,t2k_parameter," "nuwro_parameter,gibuu_parameter"; // Check sample input if (parstring.find("parameter") == std::string::npos) return kGoodStatus; // Parse inputs std::vector<std::string> strvct = GeneralUtils::ParseToStr(parstring, " "); // Skip if comment or parameter somewhere later in line if (strvct[0].c_str()[0] == '#' || strvct[0].find("parameter") == std::string::npos) { return kGoodStatus; } // Check length if (strvct.size() < 3) { ERR(FTL) << "Input rw dials need to provide at least 3 inputs." << std::endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Setup default inputs std::string partype = strvct[0]; std::string parname = strvct[1]; double parval = GeneralUtils::StrToDbl(strvct[2]); double minval = parval - 1.0; double maxval = parval + 1.0; double stepval = 1.0; std::string state = "FIX"; //[DEFAULT] // Check Type if (FitBase::ConvDialType(partype) == kUNKNOWN) { ERR(FTL) << "Unknown parameter type! " << partype << endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Check Parameter Name if (FitBase::GetDialEnum(partype, parname) == -1) { ERR(FTL) << "Bad RW parameter name! " << partype << " " << parname << endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Option Extra (No Limits) if (strvct.size() == 4) { state = strvct[3]; } // Check for weirder inputs if (strvct.size() > 4 && strvct.size() < 6) { ERR(FTL) << "Provided incomplete limits for " << parname << endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Option Extra (With limits and steps) if (strvct.size() >= 6) { minval = GeneralUtils::StrToDbl(strvct[3]); maxval = GeneralUtils::StrToDbl(strvct[4]); stepval = GeneralUtils::StrToDbl(strvct[5]); } // Option Extra (dial state after limits) if (strvct.size() == 7) { state = strvct[6]; } // Run Parameter Conversion if needed if (state.find("ABS") != std::string::npos) { parval = FitBase::RWAbsToSigma(partype, parname, parval); minval = FitBase::RWAbsToSigma(partype, parname, minval); maxval = FitBase::RWAbsToSigma(partype, parname, maxval); stepval = FitBase::RWAbsToSigma(partype, parname, stepval); } else if (state.find("FRAC") != std::string::npos) { parval = FitBase::RWFracToSigma(partype, parname, parval); minval = FitBase::RWFracToSigma(partype, parname, minval); maxval = FitBase::RWFracToSigma(partype, parname, maxval); stepval = FitBase::RWFracToSigma(partype, parname, stepval); } // Check no repeat params if (std::find(fParams.begin(), fParams.end(), parname) != fParams.end()) { ERR(FTL) << "Duplicate parameter names given for " << parname << endl; throw; } // Setup Containers fParams.push_back(parname); fTypeVals[parname] = FitBase::ConvDialType(partype); fStartVals[parname] = parval; fCurVals[parname] = fStartVals[parname]; fErrorVals[parname] = 0.0; fStateVals[parname] = state; bool fixstate = state.find("FIX") != std::string::npos; fFixVals[parname] = fixstate; fStartFixVals[parname] = fFixVals[parname]; fMinVals[parname] = minval; fMaxVals[parname] = maxval; fStepVals[parname] = stepval; // Print the parameter LOG(MIN) << "Read Parameter " << parname << " " << parval << " " << minval << " " << maxval << " " << stepval << " " << state << std::endl; // Tell reader its all good return kGoodStatus; } //****************************************** int SplineRoutines::ReadGenericInputs(std::string samstring) { //****************************************** std::string inputspec = "genericinput inputfile [outputfile] [type]"; // Check generic input if (samstring.find("genericinput") == std::string::npos) return kGoodStatus; // Parse inputs std::vector<std::string> strvct = GeneralUtils::ParseToStr(samstring, " "); // Skip if comment or input somewhere later in line if (strvct[0].c_str()[0] == '#' || strvct[0] != "genericinput") { return kGoodStatus; } // Check length if (strvct.size() < 3) { ERR(FTL) << "genericinput need to provide at least 2 inputs." << std::endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Setup default inputs std::string inname = strvct[1]; std::string infile = strvct[2]; std::string outfile = infile + ".nuisancefile.root"; std::string type = "FULLSPLINES"; // Optional Specify outputname if (strvct.size() > 3) { outfile = strvct[3]; } // Optional specify type if (strvct.size() > 4) { type = strvct[4]; } // Add to maps fGenericInputNames.push_back(inname); fGenericInputFiles[inname] = infile; fGenericOutputFiles[inname] = outfile; fGenericOutputTypes[inname] = type; // Print out LOG(FIT) << "Read Generic Input: " << inname << " " << infile << " " << outfile << " (" << type << ")" << endl; return kGoodStatus; } //****************************************** int SplineRoutines::ReadSamples(std::string samstring) { //****************************************** const static std::string inputspec = "\tsample <sample_name> <input_type>:inputfile.root [OPTS] " "[norm]\nsample_name: Name " "of sample to include. e.g. MiniBooNE_CCQE_XSec_1DQ2_nu\ninput_type: The " "input event format. e.g. NEUT, GENIE, EVSPLN, ...\nOPTS: Additional, " "optional sample options.\nnorm: Additional, optional sample " "normalisation factor."; // Check sample input if (samstring.find("sample") == std::string::npos) return kGoodStatus; // Parse inputs std::vector<std::string> strvct = GeneralUtils::ParseToStr(samstring, " "); // Skip if comment or sample somewhere later in line if (strvct[0].c_str()[0] == '#' || strvct[0] != "sample") { return kGoodStatus; } // Check length if (strvct.size() < 3) { ERR(FTL) << "Sample need to provide at least 3 inputs." << std::endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Setup default inputs std::string samname = strvct[1]; std::string samfile = strvct[2]; if (samfile == "FIX") { ERR(FTL) << "Input filename was \"FIX\", this line is probably malformed " "in the input card file. Line:\'" << samstring << "\'" << std::endl; ERR(FTL) << "Expect sample lines to look like:\n\t" << inputspec << std::endl; throw; } std::string samtype = "DEFAULT"; double samnorm = 1.0; // Optional Type if (strvct.size() > 3) { samtype = strvct[3]; + samname += "_"+samtype; + // Also get rid of the / and replace it with underscore because it might not be supported character + while (samname.find("/") != std::string::npos) { + samname.replace(samname.find("/"), 1, std::string("_")); + } } // Optional Norm if (strvct.size() > 4) samnorm = GeneralUtils::StrToDbl(strvct[4]); // Add Sample Names as Norm Dials std::string normname = samname + "_norm"; // Check no repeat params if (std::find(fParams.begin(), fParams.end(), normname) != fParams.end()) { ERR(FTL) << "Duplicate samples given for " << samname << endl; throw; } fParams.push_back(normname); fTypeVals[normname] = kNORM; fStartVals[normname] = samnorm; fCurVals[normname] = fStartVals[normname]; fErrorVals[normname] = 0.0; fMinVals[normname] = 0.1; fMaxVals[normname] = 10.0; fStepVals[normname] = 0.5; bool state = samtype.find("FREE") == std::string::npos; fFixVals[normname] = state; fStartFixVals[normname] = state; // Print read in LOG(MIN) << "Read sample " << samname << " " << samfile << " " << samtype << " " << samnorm << endl; // Tell reader its all good return kGoodStatus; } /* Setup Functions */ //************************************* void SplineRoutines::SetupRWEngine() { //************************************* fRW = new FitWeight("splineweight"); for (UInt_t i = 0; i < fParams.size(); i++) { std::string name = fParams[i]; fRW->IncludeDial(name, fTypeVals.at(name)); } UpdateRWEngine(fStartVals); return; } //************************************* void SplineRoutines::SetupGenericInputs() { //************************************* fGenericInputs.clear(); for (unsigned int i = 0; i < fGenericInputNames.size(); i++) { std::string name = fGenericInputNames[i]; std::vector<std::string> file_descriptor = GeneralUtils::ParseToStr(fGenericInputFiles[name], ":"); if (file_descriptor.size() != 2) { ERR(FTL) << "File descriptor had no filetype declaration: \"" << fGenericInputFiles[name] << "\". expected \"FILETYPE:file.root\"" << std::endl; throw; } InputUtils::InputType inpType = InputUtils::ParseInputType(file_descriptor[0]); fGenericInputs[name] = (new InputHandler(name, inpType, file_descriptor[1])); } } //************************************* void SplineRoutines::SetupSamples() { //************************************* /* LOG(FIT)<<"Making the jointFCN"<<std::endl; if (fSampleFCN) delete fSampleFCN; fSampleFCN = new JointFCN(fCardFile, fOutputRootFile); fSamples = fSampleFCN->GetSampleList(); */ return; } /* Fitting Functions */ //************************************* void SplineRoutines::UpdateRWEngine(std::map<std::string, double>& updateVals) { //************************************* for (UInt_t i = 0; i < fParams.size(); i++) { std::string name = fParams[i]; if (updateVals.find(name) == updateVals.end()) continue; fRW->SetDialValue(name, updateVals.at(name)); } fRW->Reconfigure(); return; } //************************************* void SplineRoutines::Run() { //************************************* for (UInt_t i = 0; i < fRoutines.size(); i++) { std::string routine = fRoutines.at(i); int fitstate = kFitUnfinished; LOG(FIT) << "Running Routine: " << routine << std::endl; // Try Routines if (!routine.compare("SaveSplineEvents")) SaveEventSplines(); else if (!routine.compare("SaveEvents")) SaveEvents(); // If ending early break here if (fitstate == kFitFinished || fitstate == kNoChange) { LOG(FIT) << "Ending fit routines loop." << endl; break; } } return; } //************************************* void SplineRoutines::SaveEvents() { //************************************* // Make a new RWm Engine if (fRW) delete fRW; SetupRWEngine(); // Set RW engine to central values UpdateRWEngine(fCurVals); // iterate over generic events std::map<std::string, InputHandler*>::const_iterator iter = fGenericInputs.begin(); // Iterate over all inputs for (; iter != fGenericInputs.end(); iter++) { std::string name = (iter->first); LOG(FIT) << "Creating new nuisance event set in:" << endl; LOG(FIT) << "Name = " << name << endl; LOG(FIT) << "InputFile = " << fGenericInputFiles[name] << endl; LOG(FIT) << "OutputFile = " << fGenericOutputFiles[name] << endl; LOG(FIT) << "Type = " << fGenericOutputTypes[name] << endl; // Create a new TFile TFile* eventfile = new TFile(fGenericOutputFiles[name].c_str(), "RECREATE"); eventfile->cd(); // Get Input InputHandler* curinput = (iter->second); int nevents = curinput->GetNEvents(); // Setup Event FitEvent* custevent = curinput->GetEventPointer(); // Setup TTree eventfile->cd(); TTree* evttree = new TTree("FitEvents", "FitEvents"); custevent->AddBranchesToTree(evttree); int countwidth = (nevents / 50); // Run Loop and Fill Event Tree for (int i = 0; i < nevents; i++) { // Grab new event curinput->ReadEvent(i); // Fill event info custevent->CalcKinematics(); // Fill Spline/Weight Info fRW->CalcWeight(custevent); // Save everything evttree->Fill(); if (i % countwidth == 0) { LOG(REC) << "Filled " << i << "/" << nevents << " nuisance events." << endl; } } // Save TTree alongside flux info eventfile->cd(); evttree->Write(); curinput->GetFluxHistogram()->Write("FitFluxHist"); curinput->GetEventHistogram()->Write("FitEventHist"); // Close file eventfile->Close(); } } //************************************* void SplineRoutines::TestEventSplines() { //************************************* // Make a new RW Engine if (fRW) delete fRW; SetupRWEngine(); // Set RW engine to central values UpdateRWEngine(fCurVals); // Create list of new temp InputHandlers std::map<std::string, InputHandler*> evtsplinehandles; for (UInt_t i = 0; i < fGenericInputNames.size(); i++) { std::string name = fGenericInputNames[i]; evtsplinehandles[name] = (new InputHandler( name + "_splines", InputUtils::kEVSPLN_Input, fGenericOutputFiles[name])); } // Iterate over both inputs/outputs std::map<std::string, InputHandler*>::const_iterator initer = fGenericInputs.begin(); std::map<std::string, InputHandler*>::const_iterator outiter = evtsplinehandles.begin(); // Iterate over all inputs for (; initer != fGenericInputs.end(); initer++, outiter++) { std::string name = (initer->first); LOG(FIT) << "Testing event splines in " << name << endl; // Create a new TFile TFile* splinefile = new TFile(fGenericOutputFiles[name].c_str(), "UPDATE"); splinefile->cd(); // Get Input InputHandler* rawinput = (initer->second); InputHandler* splinput = (outiter->second); int nevents = splinput->GetNEvents(); // Should match... nevents = 100; FitEvent* rawevent = rawinput->GetEventPointer(); FitEvent* splevent = splinput->GetEventPointer(); fRW->ReadSplineHead(splinput->GetSplineHead()); // Small Plots on event-by-event // ------------------------------- // Make folder for graphs TDirectory* graphdir = splinefile->mkdir("testgraphs"); graphdir->cd(); // Create Plot for each event for (int i = 0; i < nevents; i++) { // Grab new event from each sample rawinput->ReadEvent(i); splinput->ReadEvent(i); // Start Loop for each parameter //TODO Make it test ND splines for (unsigned int j = 0; j < fParams.size(); j++) { std::string name = fParams.at(j); if (fFixVals[name]) continue; double startval = fCurVals[name]; // 1D Parameter Loop std::vector<double> xvals; std::vector<double> yvals_raw; std::vector<double> yvals_spl; // Start at min and loop fCurVals[name] = fMinVals[name]; while (fCurVals[name] < fMaxVals[name]) { // Update UpdateRWEngine(fCurVals); fRW->ReadSplineHead(splinput->GetSplineHead()); // Calc Weights xvals.push_back(fCurVals[name]); yvals_raw.push_back(fRW->CalcWeight(rawevent)); yvals_spl.push_back(fRW->CalcWeight(splevent)); // Step fCurVals[name] = fCurVals[name] + fStepVals[name]; } // Reset to normal fCurVals[name] = startval; splinefile->cd(); TGraph* graw = new TGraph(xvals.size(), &xvals[0], &yvals_raw[0]); graw->SetNameTitle( ("evspltest_raw_" + name).c_str(), ("evspltest_raw_" + name + ";" + name + ";weight").c_str()); graw->SetLineColor(kBlue); graw->SetMarkerColor(kBlue); graw->SetLineWidth(2); graw->SetMarkerStyle(0); TGraph* gspl = new TGraph(xvals.size(), &xvals[0], &yvals_spl[0]); gspl->SetNameTitle( ("evspltest_spl_" + name).c_str(), ("evspltest_spl_" + name + ";" + name + ";weight").c_str()); gspl->SetLineColor(kRed); gspl->SetMarkerColor(kRed); gspl->SetLineWidth(2); gspl->SetMarkerStyle(20); TCanvas* c1 = new TCanvas(("evspltest_" + name).c_str(), ("evspltest_" + name).c_str(), 800, 600); TLegend* l1 = new TLegend(0.6, 0.6, 0.9, 0.9); l1->AddEntry(graw, "RAW", "l"); l1->AddEntry(gspl, "SPL", "l"); c1->cd(); graw->Draw("APL"); gspl->Draw("PL SAME"); l1->Draw("SAME"); graphdir->cd(); c1->Write(); delete graw; delete gspl; delete l1; } } // Clean up splinefile->Close(); } // Finish Up evtsplinehandles.clear(); } //************************************* void SplineRoutines::SaveEventSplines() { //************************************* // Make a new RWm Engine if (fRW) delete fRW; SetupRWEngine(); // Set RW engine to central values UpdateRWEngine(fCurVals); // Add Splines to RW Engine for (UInt_t i = 0; i < fSplineNames.size(); i++) { std::string name = fSplineNames.at(i); fRW->SetupSpline(name, fSplineTypes[name], fSplinePoints[name]); } LOG(FIT) << "Starting spline inputs" << endl; // iterate over generic events std::map<std::string, InputHandler*>::const_iterator iter = fGenericInputs.begin(); // Iterate over all inputs for (; iter != fGenericInputs.end(); iter++) { std::string name = (iter->first); LOG(FIT) << "Creating new spline set in:" << endl; LOG(FIT) << "Name = " << name << endl; LOG(FIT) << "InputFile = " << fGenericInputFiles[name] << endl; LOG(FIT) << "OutputFile = " << fGenericOutputFiles[name] << endl; LOG(FIT) << "Type = " << fGenericOutputTypes[name] << endl; // Create a new TFile TFile* splinefile = new TFile(fGenericOutputFiles[name].c_str(), "RECREATE"); splinefile->cd(); // Get Input InputHandler* curinput = (iter->second); int nevents = curinput->GetNEvents(); // Setup Event FitEvent* custevent = curinput->GetEventPointer(); // Setup TTree splinefile->cd(); TTree* evttree = new TTree("FitEvents", "FitEvents"); fRW->SetupEventCoeff(static_cast<BaseFitEvt*>(custevent)); custevent->AddBranchesToTree(evttree); custevent->AddSplineCoeffToTree(evttree); LOG(REC) << "Added events+splines to TTree" << endl; int countwidth = (nevents / 400); // Make folder for graphs TDirectory* graphdir = splinefile->mkdir("gengraphs"); graphdir->cd(); // Run Loop and Fill Event Tree for (int i = 0; i < nevents; i++) { // Grab new event curinput->ReadEvent(i); // Fill event info custevent->CalcKinematics(); bool save = false; if (i % nevents / 20 == 0) save = true; // Fill Spline/Weight Info fRW->GenSplines(custevent, save); fRW->CalcWeight(custevent); // Save everything evttree->Fill(); if (i % countwidth == 0) { LOG(REC) << "Filled " << i << "/" << nevents << " spline events." << endl; } } // Save TTree alongside flux info splinefile->cd(); fRW->GetSplineHeader()->Write("FitSplineHead"); evttree->Write(); curinput->GetFluxHistogram()->Write("FitFluxHist"); curinput->GetEventHistogram()->Write("FitEventHist"); // Close file splinefile->Close(); } TestEventSplines(); } /* MISC Functions */ //************************************* int SplineRoutines::GetStatus() { //************************************* return 0; } diff --git a/src/Routines/SystematicRoutines.cxx b/src/Routines/SystematicRoutines.cxx index f35368a..31a5317 100755 --- a/src/Routines/SystematicRoutines.cxx +++ b/src/Routines/SystematicRoutines.cxx @@ -1,1175 +1,1182 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "StatusMessage.h" #include "SystematicRoutines.h" /* Constructor/Destructor */ //************************ void SystematicRoutines::Init(){ //************************ fInputFile = ""; fInputRootFile = NULL; fOutputFile = ""; fOutputRootFile = NULL; fCovar = fCovarFree = NULL; fCorrel = fCorrelFree = NULL; fDecomp = fDecompFree = NULL; fStrategy = "ErrorBands"; fRoutines.clear(); fCardFile = ""; fFakeDataInput = ""; fSampleFCN = NULL; fAllowedRoutines = ("ErrorBands,PlotLimits"); }; //************************************* SystematicRoutines::~SystematicRoutines(){ //************************************* }; /* Input Functions */ //************************************* SystematicRoutines::SystematicRoutines(int argc, char* argv[]){ //************************************* // Set everything to defaults Init(); std::vector<std::string> configs_cmd; std::string maxevents_flag = ""; int verbosity_flag = 0; int error_flag = 0; // If No Arguments print commands for (int i = 1; i< argc; ++i){ if (i+1 != argc){ // Cardfile if (!std::strcmp(argv[i], "-c")) { fCardFile=argv[i+1]; ++i;} else if (!std::strcmp(argv[i], "-o")) { fOutputFile=argv[i+1]; ++i;} else if (!std::strcmp(argv[i], "-f")) { fStrategy=argv[i+1]; ++i;} else if (!std::strcmp(argv[i], "-q")) { configs_cmd.push_back(argv[i+1]); ++i;} else if (!std::strcmp(argv[i], "-n")) { maxevents_flag=argv[i+1]; ++i;} else if (!std::strcmp(argv[i], "-v")) { verbosity_flag -= 1; } else if (!std::strcmp(argv[i], "+v")) { verbosity_flag += 1; } else if (!std::strcmp(argv[i], "-e")) { error_flag -= 1; } else if (!std::strcmp(argv[i], "+e")) { error_flag += 1; } else { ERR(FTL) << "ERROR: unknown command line option given! - '" <<argv[i]<<" "<<argv[i+1]<<"'"<< std::endl; throw; } } } if (fCardFile.empty()){ ERR(FTL) << "ERROR: card file not specified." << std::endl; ERR(FTL) << "Run with '-h' to see options." << std::endl; throw; } if (fCardFile == fOutputFile) { ERR(WRN) << "WARNING: output file and card file are the same file, " "writing: " << fCardFile << ".root" << std::endl; fOutputFile = fCardFile + ".root"; } if(fCardFile == fOutputFile){ std::cerr << "WARNING: output file and card file are the same file, " "writing: " << fCardFile << ".root" << std::endl; fOutputFile = fCardFile + ".root"; } // Fill fit routines and check they are good fRoutines = GeneralUtils::ParseToStr(fStrategy,","); for (UInt_t i = 0; i < fRoutines.size(); i++){ if (fAllowedRoutines.find(fRoutines[i]) == std::string::npos){ ERR(FTL) << "Unknown fit routine given! " << "Must be provided as a comma seperated list." << std::endl; ERR(FTL) << "Allowed Routines: " << fAllowedRoutines << std::endl; throw; } } // CONFIG // --------------------------- std::string par_dir = GeneralUtils::GetTopLevelDir()+"/parameters/"; FitPar::Config().ReadParamFile( par_dir + "config.list.dat" ); FitPar::Config().ReadParamFile( fCardFile ); for (UInt_t iter = 0; iter < configs_cmd.size(); iter++){ FitPar::Config().ForceParam(configs_cmd[iter]); } if (!maxevents_flag.empty()){ FitPar::Config().SetParI("input.maxevents", atoi(maxevents_flag.c_str())); } if (verbosity_flag != 0){ int curverb = FitPar::Config().GetParI("VERBOSITY"); FitPar::Config().SetParI("VERBOSITY", curverb + verbosity_flag); } if (error_flag != 0){ int curwarn = FitPar::Config().GetParI("ERROR"); FitPar::Config().SetParI("ERROR", curwarn + error_flag); } LOG_VERB(FitPar::Config().GetParI("VERBOSITY")); ERR_VERB(FitPar::Config().GetParI("ERROR")); // CARD // --------------------------- // Parse Card Options ReadCard(fCardFile); // Outputs // --------------------------- // Save Configs to output file fOutputRootFile = new TFile(fOutputFile.c_str(),"RECREATE"); FitPar::Config().Write(); // Starting Setup // --------------------------- SetupCovariance(); SetupFCN(); GetCovarFromFCN(); SetupRWEngine(); return; }; //************************************* void SystematicRoutines::ReadCard(std::string cardfile){ //************************************* // Read cardlines into vector std::vector<std::string> cardlines = GeneralUtils::ParseFileToStr(cardfile,"\n"); FitPar::Config().cardLines = cardlines; // Read Samples first (norm params can be overridden) int linecount = 0; for (std::vector<std::string>::iterator iter = cardlines.begin(); iter != cardlines.end(); iter++){ std::string line = (*iter); linecount++; // Skip Empties if (line.empty()) continue; if (line.c_str()[0] == '#') continue; // Read Valid Samples int samstatus = ReadSamples(line); // Show line if bad to help user if (samstatus == kErrorStatus) { ERR(FTL) << "Bad Input in cardfile " << fCardFile << " at line " << linecount << "!" << std::endl; LOG(FIT) << line << std::endl; throw; } } // Read Parameters second linecount = 0; for (std::vector<std::string>::iterator iter = cardlines.begin(); iter != cardlines.end(); iter++){ std::string line = (*iter); linecount++; // Skip Empties if (line.empty()) continue; if (line.c_str()[0] == '#') continue; // Try Parameter Reads int parstatus = ReadParameters(line); int fakstatus = ReadFakeDataPars(line); // Show line if bad to help user if (parstatus == kErrorStatus || fakstatus == kErrorStatus ){ ERR(FTL) << "Bad Parameter Input in cardfile " << fCardFile << " at line " << linecount << "!" << std::endl; LOG(FIT) << line << std::endl; throw; } } return; }; //***************************************** int SystematicRoutines::ReadParameters(std::string parstring){ //****************************************** std::string inputspec = "RW Dial Inputs Syntax \n" "free input w/ limits: TYPE NAME START MIN MAX STEP [STATE] \n" "fix input: TYPE NAME VALUE [STATE] \n" "free input w/o limits: TYPE NAME START FREE,[STATE] \n" "Allowed Types: \n" "neut_parameter,niwg_parameter,t2k_parameter," "nuwro_parameter,gibuu_parameter"; // Check sample input if (parstring.find("parameter") == std::string::npos) return kGoodStatus; // Parse inputs std::vector<std::string> strvct = GeneralUtils::ParseToStr(parstring, " "); // Skip if comment or parameter somewhere later in line if (strvct[0].c_str()[0] == '#' || strvct[0].find("parameter") == std::string::npos){ return kGoodStatus; } // Check length if (strvct.size() < 3){ ERR(FTL) << "Input rw dials need to provide at least 3 inputs." << std::endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Setup default inputs std::string partype = strvct[0]; std::string parname = strvct[1]; double parval = GeneralUtils::StrToDbl(strvct[2]); double minval = parval - 1.0; double maxval = parval + 1.0; double stepval = 1.0; std::string state = "FIX"; //[DEFAULT] // Check Type if (FitBase::ConvDialType(partype) == kUNKNOWN){ ERR(FTL) << "Unknown parameter type! " << partype << std::endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Check Parameter Name if (FitBase::GetDialEnum(partype, parname) == -1){ ERR(FTL) << "Bad RW parameter name! " << partype << " " << parname << std::endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Option Extra (No Limits) if (strvct.size() == 4){ state = strvct[3]; } // Check for weirder inputs if (strvct.size() > 4 && strvct.size() < 6){ ERR(FTL) << "Provided incomplete limits for " << parname << std::endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Option Extra (With limits and steps) if (strvct.size() >= 6){ minval = GeneralUtils::StrToDbl(strvct[3]); maxval = GeneralUtils::StrToDbl(strvct[4]); stepval = GeneralUtils::StrToDbl(strvct[5]); } // Option Extra (dial state after limits) if (strvct.size() == 7){ state = strvct[6]; } // Run Parameter Conversion if needed if (state.find("ABS") != std::string::npos){ parval = FitBase::RWAbsToSigma( partype, parname, parval ); minval = FitBase::RWAbsToSigma( partype, parname, minval ); maxval = FitBase::RWAbsToSigma( partype, parname, maxval ); stepval = FitBase::RWAbsToSigma( partype, parname, stepval ); } else if (state.find("FRAC") != std::string::npos){ parval = FitBase::RWFracToSigma( partype, parname, parval ); minval = FitBase::RWFracToSigma( partype, parname, minval ); maxval = FitBase::RWFracToSigma( partype, parname, maxval ); stepval = FitBase::RWFracToSigma( partype, parname, stepval ); } // Check no repeat params if (std::find(fParams.begin(), fParams.end(), parname) != fParams.end()){ ERR(FTL) << "Duplicate parameter names given for " << parname << std::endl; throw; } // Setup Containers fParams.push_back(parname); fTypeVals[parname] = FitBase::ConvDialType(partype); fStartVals[parname] = parval; fCurVals[parname] = fStartVals[parname]; fErrorVals[parname] = 0.0; fStateVals[parname] = state; bool fixstate = state.find("FIX") != std::string::npos; fFixVals[parname] = fixstate; fStartFixVals[parname] = fFixVals[parname]; fMinVals[parname] = minval; fMaxVals[parname] = maxval; fStepVals[parname] = stepval; // Print the parameter LOG(MIN) << "Read Parameter " << parname << " " << parval << " " << minval << " " << maxval << " " << stepval << " " << state << std::endl; // Tell reader its all good return kGoodStatus; } //******************************************* int SystematicRoutines::ReadFakeDataPars(std::string parstring){ //****************************************** std::string inputspec = "Fake Data Dial Inputs Syntax \n" "fake value: fake_parameter NAME VALUE \n" "Name should match dialnames given in actual dial specification."; // Check sample input if (parstring.find("fake_parameter") == std::string::npos) return kGoodStatus; // Parse inputs std::vector<std::string> strvct = GeneralUtils::ParseToStr(parstring, " "); // Skip if comment or parameter somewhere later in line if (strvct[0].c_str()[0] == '#' || strvct[0] == "fake_parameter"){ return kGoodStatus; } // Check length if (strvct.size() < 3){ ERR(FTL) << "Fake dials need to provide at least 3 inputs." << std::endl; std::cout << inputspec << std::endl; return kErrorStatus; } // Read Inputs std::string parname = strvct[1]; double parval = GeneralUtils::StrToDbl(strvct[2]); // Setup Container fFakeVals[parname] = parval; // Print the fake parameter LOG(MIN) << "Read Fake Parameter " << parname << " " << parval << std::endl; // Tell reader its all good return kGoodStatus; } //****************************************** int SystematicRoutines::ReadSamples(std::string samstring){ //****************************************** const static std::string inputspec = "\tsample <sample_name> <input_type>:inputfile.root [OPTS] " "[norm]\nsample_name: Name " "of sample to include. e.g. MiniBooNE_CCQE_XSec_1DQ2_nu\ninput_type: The " "input event format. e.g. NEUT, GENIE, EVSPLN, ...\nOPTS: Additional, " "optional sample options.\nnorm: Additional, optional sample " "normalisation factor."; // Check sample input if (samstring.find("sample") == std::string::npos) return kGoodStatus; // Parse inputs std::vector<std::string> strvct = GeneralUtils::ParseToStr(samstring, " "); // Skip if comment or parameter somewhere later in line if (strvct[0].c_str()[0] == '#' || strvct[0] != "sample"){ return kGoodStatus; } // Check length if (strvct.size() < 3){ ERR(FTL) << "Sample need to provide at least 3 inputs." << std::endl; return kErrorStatus; } // Setup default inputs std::string samname = strvct[1]; std::string samfile = strvct[2]; if (samfile == "FIX") { ERR(FTL) << "Input filename was \"FIX\", this line is probably malformed " "in the input card file. Line:\'" << samstring << "\'" << std::endl; ERR(FTL) << "Expect sample lines to look like:\n\t" << inputspec << std::endl; throw; } std::string samtype = "DEFAULT"; double samnorm = 1.0; // Optional Type - if (strvct.size() > 3) samtype = strvct[3]; + if (strvct.size() > 3) { + samtype = strvct[3]; + samname += "_"+samtype; + // Also get rid of the / and replace it with underscore because it might not be supported character + while (samname.find("/") != std::string::npos) { + samname.replace(samname.find("/"), 1, std::string("_")); + } + } // Optional Norm if (strvct.size() > 4) samnorm = GeneralUtils::StrToDbl(strvct[4]); // Add Sample Names as Norm Dials std::string normname = samname + "_norm"; // Check no repeat params if (std::find(fParams.begin(), fParams.end(), normname) != fParams.end()){ ERR(FTL) << "Duplicate samples given for " << samname << std::endl; throw; } fParams.push_back(normname); fTypeVals[normname] = kNORM; fStartVals[normname] = samnorm; fCurVals[normname] = fStartVals[normname]; fErrorVals[normname] = 0.0; fMinVals[normname] = 0.1; fMaxVals[normname] = 10.0; fStepVals[normname] = 0.5; bool state = samtype.find("FREE") == std::string::npos; fFixVals[normname] = state; fStartFixVals[normname] = state; // Print read in LOG(MIN) << "Read sample " << samname << " " << samfile << " " << samtype << " " << samnorm << std::endl; // Tell reader its all good return kGoodStatus; } /* Setup Functions */ //************************************* void SystematicRoutines::SetupRWEngine(){ //************************************* for (UInt_t i = 0; i < fParams.size(); i++){ std::string name = fParams[i]; FitBase::GetRW() -> IncludeDial(name, fTypeVals.at(name) ); } UpdateRWEngine(fStartVals); return; } //************************************* void SystematicRoutines::SetupFCN(){ //************************************* LOG(FIT)<<"Making the jointFCN"<<std::endl; if (fSampleFCN) delete fSampleFCN; fSampleFCN = new JointFCN(fCardFile, fOutputRootFile); SetFakeData(); return; } //************************************* void SystematicRoutines::SetFakeData(){ //************************************* if (fFakeDataInput.empty()) return; if (fFakeDataInput.compare("MC") == 0){ LOG(FIT)<<"Setting fake data from MC starting prediction." <<std::endl; UpdateRWEngine(fFakeVals); FitBase::GetRW()->Reconfigure(); fSampleFCN->ReconfigureAllEvents(); fSampleFCN->SetFakeData("MC"); UpdateRWEngine(fCurVals); LOG(FIT)<<"Set all data to fake MC predictions."<<std::endl; } else { fSampleFCN->SetFakeData(fFakeDataInput); } return; } //***************************************** void SystematicRoutines::GetCovarFromFCN(){ //***************************************** LOG(FIT) << "Loading ParamPull objects from FCN to build covar" << std::endl; // Make helperstring std::ostringstream helperstr; // Keep track of what is being thrown std::map<std::string, std::string> dialthrowhandle; // Get Covariance Objects from FCN std::list<ParamPull*> inputpulls = fSampleFCN->GetPullList(); for (PullListConstIter iter = inputpulls.begin(); iter != inputpulls.end(); iter++){ ParamPull* pull = (*iter); if (pull->GetType().find("THROW")){ fInputThrows.push_back(pull); fInputCovar.push_back(pull->GetFullCovarMatrix()); fInputDials.push_back(pull->GetDataHist()); LOG(FIT) << "Read ParamPull: " << pull->GetName() << " " << pull->GetType() << std::endl; } TH1D dialhist = pull->GetDataHist(); TH1D minhist = pull->GetMinHist(); TH1D maxhist = pull->GetMaxHist(); TH1I typehist = pull->GetDialTypes(); for (int i = 0; i < dialhist.GetNbinsX(); i++){ std::string name = std::string(dialhist.GetXaxis()->GetBinLabel(i+1)); dialthrowhandle[name] = pull->GetName(); if (fCurVals.find(name) == fCurVals.end()){ // Add to Containers fParams.push_back(name); fCurVals[name] = dialhist.GetBinContent(i+1); fStartVals[name] = dialhist.GetBinContent(i+1); fMinVals[name] = minhist.GetBinContent(i+1); fMaxVals[name] = maxhist.GetBinContent(i+1); fStepVals[name] = 1.0; fFixVals[name] = false; fStartFixVals[name] = false; fTypeVals[name] = typehist.GetBinContent(i+1); fStateVals[name] = "FREE" + pull->GetType(); // Maker Helper helperstr << std::string(16, ' ' ) << FitBase::ConvDialType(fTypeVals[name]) << " " << name << " " << fMinVals[name] << " " << fMaxVals[name] << " " << fStepVals[name] << " " << fStateVals[name] << std::endl; } } } // Check if no throws given if (fInputThrows.empty()){ ERR(WRN) << "No covariances given to nuissyst" << std::endl; ERR(WRN) << "Pushing back an uncorrelated gaussian throw error for each free parameter using step size" << std::endl; for (UInt_t i = 0; i < fParams.size(); i++){ std::string syst = fParams[i]; if (fFixVals[syst]) continue; // Make Terms std::string name = syst + "_pull"; std::ostringstream pullterm; pullterm << "DIAL:" << syst << ";" << fStartVals[syst] << ";" << fStepVals[syst]; std::string type = fTypeVals[syst] + "/GAUSTHROW"; // Push Back Pulls ParamPull* pull = new ParamPull( name, pullterm.str(), type ); fInputThrows.push_back(pull); fInputCovar.push_back(pull->GetFullCovarMatrix()); fInputDials.push_back(pull->GetDataHist()); // Print Whats added ERR(WRN) << "Added ParamPull : " << name << " " << pullterm.str() << " " << type << std::endl; // Add helper string for future fits helperstr << std::string(16, ' ' ) << "covar " << name << " " << pullterm.str() << " " << type << std::endl; // Keep Track of Throws dialthrowhandle[syst] = pull->GetName(); } } // Print Helper String if (!helperstr.str().empty()){ LOG(FIT) << "To remove these statements in future studies, add the lines below to your card:" << std::endl; // Can't use the logger properly because this can be multi-line. Use cout and added spaces to look better! std::cout << helperstr.str(); sleep(2); } // Print Throw State for (UInt_t i = 0; i < fParams.size(); i++){ std::string syst = fParams[i]; if (dialthrowhandle.find(syst) != dialthrowhandle.end()){ LOG(FIT) << "Dial " << i << ". " << setw(40) << syst << " = THROWING with " << dialthrowhandle[syst] << std::endl; } else { LOG(FIT) << "Dial " << i << ". " << setw(40) << syst << " = FIXED" << std::endl; } } // Pause anyway sleep(1); return; } /* Fitting Functions */ //************************************* void SystematicRoutines::UpdateRWEngine(std::map<std::string,double>& updateVals){ //************************************* for (UInt_t i = 0; i < fParams.size(); i++){ std::string name = fParams[i]; if (updateVals.find(name) == updateVals.end()) continue; FitBase::GetRW()->SetDialValue(name,updateVals.at(name)); } FitBase::GetRW()->Reconfigure(); return; } //************************************* void SystematicRoutines::Run(){ //************************************* for (UInt_t i = 0; i < fRoutines.size(); i++){ std::string routine = fRoutines.at(i); int fitstate = kFitUnfinished; LOG(FIT)<<"Running Routine: "<<routine<<std::endl; if (routine.find("PlotLimits") != std::string::npos) PlotLimits(); else if (routine.find("ErrorBands") != std::string::npos) GenerateErrorBands(); // If ending early break here if (fitstate == kFitFinished || fitstate == kNoChange){ LOG(FIT) << "Ending fit routines loop." << std::endl; break; } } return; } //************************************* void SystematicRoutines::PrintState(){ //************************************* LOG(FIT)<<"------------"<<std::endl; // Count max size int maxcount = 0; for (UInt_t i = 0; i < fParams.size(); i++){ maxcount = max(int(fParams[i].size()), maxcount); } // Header LOG(FIT) << " # " << left << setw(maxcount) << "Parameter " << " = " << setw(10) << "Value" << " +- " << setw(10) << "Error" << " " << setw(8) << "(Units)" << " " << setw(10) << "Conv. Val" << " +- " << setw(10) << "Conv. Err" << " " << setw(8) << "(Units)" << std::endl; // Parameters for (UInt_t i = 0; i < fParams.size(); i++){ std::string syst = fParams.at(i); std::string typestr = FitBase::ConvDialType(fTypeVals[syst]); std::string curunits = "(sig.)"; double curval = fCurVals[syst]; double curerr = fErrorVals[syst]; if (fStateVals[syst].find("ABS") != std::string::npos){ curval = FitBase::RWSigmaToAbs(typestr, syst, curval); curerr = (FitBase::RWSigmaToAbs(typestr, syst, curerr) - FitBase::RWSigmaToAbs(typestr, syst, 0.0)); curunits = "(Abs.)"; } else if (fStateVals[syst].find("FRAC") != std::string::npos){ curval = FitBase::RWSigmaToFrac(typestr, syst, curval); curerr = (FitBase::RWSigmaToFrac(typestr, syst, curerr) - FitBase::RWSigmaToFrac(typestr, syst, 0.0)); curunits = "(Frac)"; } std::string convunits = "(" + FitBase::GetRWUnits(typestr, syst) + ")"; double convval = FitBase::RWSigmaToAbs(typestr, syst, curval); double converr = (FitBase::RWSigmaToAbs(typestr, syst, curerr) - FitBase::RWSigmaToAbs(typestr, syst, 0.0)); std::ostringstream curparstring; curparstring << " " << setw(3) << left << i << ". " << setw(maxcount) << syst << " = " << setw(10) << curval << " +- " << setw(10) << curerr << " " << setw(8) << curunits << " " << setw(10) << convval << " +- " << setw(10) << converr << " " << setw(8) << convunits; LOG(FIT) << curparstring.str() << std::endl; } LOG(FIT)<<"------------"<<std::endl; double like = fSampleFCN->GetLikelihood(); LOG(FIT)<<"Likelihood for JointFCN == " << like << std::endl; LOG(FIT)<<"------------"<<std::endl; } /* Write Functions */ //************************************* void SystematicRoutines::SaveResults(){ //************************************* fOutputRootFile->cd(); SaveCurrentState(); } //************************************* void SystematicRoutines::SaveCurrentState(std::string subdir){ //************************************* LOG(FIT)<<"Saving current full FCN predictions" <<std::endl; // Setup DIRS TDirectory* curdir = gDirectory; if (!subdir.empty()){ TDirectory* newdir =(TDirectory*) gDirectory->mkdir(subdir.c_str()); newdir->cd(); } FitBase::GetRW()->Reconfigure(); fSampleFCN->ReconfigureAllEvents(); fSampleFCN->Write(); // Change back to current DIR curdir->cd(); return; } //************************************* void SystematicRoutines::SaveNominal(){ //************************************* fOutputRootFile->cd(); LOG(FIT)<<"Saving Nominal Predictions (be cautious with this)" <<std::endl; FitBase::GetRW()->Reconfigure(); SaveCurrentState("nominal"); }; //************************************* void SystematicRoutines::SavePrefit(){ //************************************* fOutputRootFile->cd(); LOG(FIT)<<"Saving Prefit Predictions"<<std::endl; UpdateRWEngine(fStartVals); SaveCurrentState("prefit"); UpdateRWEngine(fCurVals); }; /* MISC Functions */ //************************************* int SystematicRoutines::GetStatus(){ //************************************* return 0; } //************************************* void SystematicRoutines::SetupCovariance(){ //************************************* // Remove covares if they exist if (fCovar) delete fCovar; if (fCovarFree) delete fCovarFree; if (fCorrel) delete fCorrel; if (fCorrelFree) delete fCorrelFree; if (fDecomp) delete fDecomp; if (fDecompFree) delete fDecompFree; int NFREE = 0; int NDIM = 0; // Get NFREE from min or from vals (for cases when doing throws) NDIM = fParams.size(); for (UInt_t i = 0; i < fParams.size(); i++){ if (!fFixVals[fParams[i]]) NFREE++; } if (NDIM == 0) return; fCovar = new TH2D("covariance","covariance",NDIM,0,NDIM,NDIM,0,NDIM); if (NFREE > 0){ fCovarFree = new TH2D("covariance_free", "covariance_free", NFREE,0,NFREE, NFREE,0,NFREE); } // Set Bin Labels int countall = 0; int countfree = 0; for (UInt_t i = 0; i < fParams.size(); i++){ fCovar->GetXaxis()->SetBinLabel(countall+1,fParams[i].c_str()); fCovar->GetYaxis()->SetBinLabel(countall+1,fParams[i].c_str()); countall++; if (!fFixVals[fParams[i]] and NFREE > 0){ fCovarFree->GetXaxis()->SetBinLabel(countfree+1,fParams[i].c_str()); fCovarFree->GetYaxis()->SetBinLabel(countfree+1,fParams[i].c_str()); countfree++; } } fCorrel = PlotUtils::GetCorrelationPlot(fCovar,"correlation"); fDecomp = PlotUtils::GetDecompPlot(fCovar,"decomposition"); if (NFREE > 0)fCorrelFree = PlotUtils::GetCorrelationPlot(fCovarFree, "correlation_free"); if (NFREE > 0)fDecompFree = PlotUtils::GetDecompPlot(fCovarFree,"decomposition_free"); return; }; //************************************* void SystematicRoutines::ThrowCovariance(bool uniformly){ //************************************* // Set fThrownVals to all values in currentVals for (UInt_t i = 0; i < fParams.size(); i++){ std::string name = fParams.at(i); fThrownVals[name] = fCurVals[name]; } for (PullListConstIter iter = fInputThrows.begin(); iter != fInputThrows.end(); iter++){ ParamPull* pull = *iter; pull->ThrowCovariance(); TH1D dialhist = pull->GetDataHist(); for (int i = 0; i < dialhist.GetNbinsX(); i++){ std::string name = std::string(dialhist.GetXaxis()->GetBinLabel(i+1)); if (fCurVals.find(name) != fCurVals.end()){ fThrownVals[name] = dialhist.GetBinContent(i+1); } } // Reset throw incase pulls are calculated. pull->ResetToy(); } return; }; //************************************* void SystematicRoutines::GenerateErrorBands(){ //************************************* TDirectory* errorDIR = (TDirectory*) fOutputRootFile->mkdir("error_bands"); errorDIR->cd(); TFile* tempfile = new TFile((fOutputFile + ".throws.root").c_str(),"RECREATE"); tempfile->cd(); int nthrows = FitPar::Config().GetParI("error_throws"); UpdateRWEngine(fCurVals); fSampleFCN->ReconfigureAllEvents(); TDirectory* nominal = (TDirectory*) tempfile->mkdir("nominal"); nominal->cd(); fSampleFCN->Write(); TDirectory* outnominal = (TDirectory*) fOutputRootFile->mkdir("nominal_throw"); outnominal->cd(); fSampleFCN->Write(); fOutputRootFile->cd(); TTree* parameterTree = new TTree("throws","throws"); double chi2; for (UInt_t i = 0; i < fParams.size(); i++) parameterTree->Branch(fParams[i].c_str(), &fThrownVals[fParams[i]], (fParams[i] + "/D").c_str()); parameterTree->Branch("chi2",&chi2,"chi2/D"); fSampleFCN->CreateIterationTree("error_iterations", FitBase::GetRW()); // Would anybody actually want to do uniform throws of any parameter?? bool uniformly = FitPar::Config().GetParB("error_uniform"); // Run Throws and save for (Int_t i = 0; i < nthrows; i++){ TDirectory* throwfolder = (TDirectory*)tempfile->mkdir(Form("throw_%i",i)); throwfolder->cd(); // Generate Random Parameter Throw ThrowCovariance(uniformly); // Run Eval double *vals = FitUtils::GetArrayFromMap( fParams, fThrownVals ); chi2 = fSampleFCN->DoEval( vals ); delete vals; // Save the FCN fSampleFCN->Write(); parameterTree->Fill(); } fOutputRootFile->cd(); fSampleFCN->WriteIterationTree(); // fDecompFree->Write(); // fCovarFree->Write(); // parameterTree->Write(); // delete parameterTree; // Now go through the keys in the temporary file and look for TH1D, and TH2D plots TIter next(nominal->GetListOfKeys()); TKey *key; while ((key = (TKey*)next())) { TClass *cl = gROOT->GetClass(key->GetClassName()); if (!cl->InheritsFrom("TH1D") and !cl->InheritsFrom("TH2D")) continue; TH1D *baseplot = (TH1D*)key->ReadObj(); std::string plotname = std::string(baseplot->GetName()); LOG(FIT) << "Creating error bands for " << plotname; if (LOG_LEVEL(FIT)){ if (!uniformly) std::cout << " : Using COVARIANCE Throws! " << std::endl; else std::cout << " : Using UNIFORM THROWS!!! " << std::endl; } int nbins = baseplot->GetNbinsX()*baseplot->GetNbinsY(); // Setup TProfile with RMS option TProfile* tprof = new TProfile((plotname + "_prof").c_str(),(plotname + "_prof").c_str(),nbins, 0, nbins, "S"); // Setup The TTREE double* bincontents; bincontents = new double[nbins]; double* binlowest; binlowest = new double[nbins]; double* binhighest; binhighest = new double[nbins]; errorDIR->cd(); TTree* bintree = new TTree((plotname + "_tree").c_str(), (plotname + "_tree").c_str()); for (Int_t i = 0; i < nbins; i++){ bincontents[i] = 0.0; binhighest[i] = 0.0; binlowest[i] = 0.0; bintree->Branch(Form("content_%i",i),&bincontents[i],Form("content_%i/D",i)); } for (Int_t i = 0; i < nthrows; i++){ TH1* newplot = (TH1*)tempfile->Get(Form(("throw_%i/" + plotname).c_str(),i)); for (Int_t j = 0; j < nbins; j++){ tprof->Fill(j+0.5, newplot->GetBinContent(j+1)); bincontents[j] = newplot->GetBinContent(j+1); if (bincontents[j] < binlowest[j] or i == 0) binlowest[j] = bincontents[j]; if (bincontents[j] > binhighest[j] or i == 0) binhighest[j] = bincontents[j]; } errorDIR->cd(); bintree->Fill(); delete newplot; } errorDIR->cd(); if (!uniformly){ LOG(FIT) << "Uniformly Calculating Plot Errors!" << std::endl; } for (Int_t j = 0; j < nbins; j++){ if (!uniformly){ baseplot->SetBinError(j+1,tprof->GetBinError(j+1)); } else { baseplot->SetBinContent(j+1, 0.0);//(binlowest[j] + binhighest[j]) / 2.0); baseplot->SetBinError(j+1, 0.0); //(binhighest[j] - binlowest[j])/2.0); } } errorDIR->cd(); baseplot->Write(); tprof->Write(); bintree->Write(); delete baseplot; delete tprof; delete bintree; delete [] bincontents; } return; }; //************************************* void SystematicRoutines::PlotLimits(){ //************************************* TDirectory* limfolder = (TDirectory*) fOutputRootFile->mkdir("Limits"); limfolder->cd(); // Set all parameters at their starting values for (UInt_t i = 0; i < fParams.size(); i++){ fCurVals[fParams[i]] = fStartVals[fParams[i]]; } TDirectory* nomfolder = (TDirectory*) limfolder->mkdir("nominal"); nomfolder->cd(); UpdateRWEngine(fCurVals); fSampleFCN->ReconfigureAllEvents(); fSampleFCN->Write(); limfolder->cd(); std::vector<std::string> allfolders; // Loop through each parameter for (UInt_t i = 0; i < fParams.size(); i++){ std::string syst = fParams[i]; if (fFixVals[syst]) continue; // Loop Downwards while (fCurVals[syst] > fMinVals[syst]){ fCurVals[syst] = fCurVals[syst] - fStepVals[syst]; // Check Limit if (fCurVals[syst] < fMinVals[syst]) fCurVals[syst] = fMinVals[syst]; // Check folder exists std::string curvalstring = std::string( Form( (syst + "_%f").c_str(), fCurVals[syst] ) ); if (std::find(allfolders.begin(), allfolders.end(), curvalstring) != allfolders.end()) break; // Make new folder for variation TDirectory* minfolder = (TDirectory*) limfolder->mkdir(Form( (syst + "_%f").c_str(), fCurVals[syst] ) ); minfolder->cd(); allfolders.push_back(curvalstring); // Update Iterations double *vals = FitUtils::GetArrayFromMap( fParams, fCurVals ); fSampleFCN->DoEval( vals ); delete vals; // Save to folder fSampleFCN->Write(); } // Reset before next loop fCurVals[syst] = fStartVals[syst]; // Loop Upwards now while (fCurVals[syst] < fMaxVals[syst]){ fCurVals[syst] = fCurVals[syst] + fStepVals[syst]; // Check Limit if (fCurVals[syst] > fMaxVals[syst]) fCurVals[syst] = fMaxVals[syst]; // Check folder exists std::string curvalstring = std::string( Form( (syst + "_%f").c_str(), fCurVals[syst] ) ); if (std::find(allfolders.begin(), allfolders.end(), curvalstring) != allfolders.end()) break; // Make new folder TDirectory* maxfolder = (TDirectory*) limfolder->mkdir(Form( (syst + "_%f").c_str(), fCurVals[syst] ) ); maxfolder->cd(); allfolders.push_back(curvalstring); // Update Iterations double *vals = FitUtils::GetArrayFromMap( fParams, fCurVals ); fSampleFCN->DoEval( vals ); delete vals; // Save to file fSampleFCN->Write(); } // Reset before leaving fCurVals[syst] = fStartVals[syst]; UpdateRWEngine(fCurVals); } return; } diff --git a/src/T2K/CMakeLists.txt b/src/T2K/CMakeLists.txt index 4f5092e..9fed3df 100644 --- a/src/T2K/CMakeLists.txt +++ b/src/T2K/CMakeLists.txt @@ -1,69 +1,83 @@ # Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret ################################################################################ # This file is part of NUISANCE. # # NUISANCE is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # NUISANCE is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. ################################################################################ set(IMPLFILES T2K_CC0pi_XSec_2DPcos_nu.cxx T2K_CC1pip_CH_XSec_1DQ2_nu.cxx T2K_CC1pip_CH_XSec_1DWrec_nu.cxx T2K_CC1pip_CH_XSec_1Dpmu_nu.cxx T2K_CC1pip_CH_XSec_1Dppi_nu.cxx T2K_CC1pip_CH_XSec_1Dq3_nu.cxx T2K_CC1pip_CH_XSec_1Dthmupi_nu.cxx T2K_CC1pip_CH_XSec_1Dthpi_nu.cxx T2K_CC1pip_CH_XSec_1Dthq3pi_nu.cxx +T2K_CC1pip_H2O_XSec_1DEnuDelta_nu.cxx +T2K_CC1pip_H2O_XSec_1DEnuMB_nu.cxx +T2K_CC1pip_H2O_XSec_1Dcosmu_nu.cxx +T2K_CC1pip_H2O_XSec_1Dcosmupi_nu.cxx +T2K_CC1pip_H2O_XSec_1Dcospi_nu.cxx +T2K_CC1pip_H2O_XSec_1Dpmu_nu.cxx +T2K_CC1pip_H2O_XSec_1Dppi_nu.cxx T2K_CC0pinp_STV_XSec_1Ddpt_nu.cxx T2K_SignalDef.cxx ) set(HEADERFILES T2K_CC0pi_XSec_2DPcos_nu.h T2K_CC1pip_CH_XSec_1DQ2_nu.h T2K_CC1pip_CH_XSec_1DWrec_nu.h T2K_CC1pip_CH_XSec_1Dpmu_nu.h T2K_CC1pip_CH_XSec_1Dppi_nu.h T2K_CC1pip_CH_XSec_1Dq3_nu.h T2K_CC1pip_CH_XSec_1Dthmupi_nu.h T2K_CC1pip_CH_XSec_1Dthpi_nu.h T2K_CC1pip_CH_XSec_1Dthq3pi_nu.h +T2K_CC1pip_H2O_XSec_1DEnuDelta_nu.h +T2K_CC1pip_H2O_XSec_1DEnuMB_nu.h +T2K_CC1pip_H2O_XSec_1Dcosmu_nu.h +T2K_CC1pip_H2O_XSec_1Dcosmupi_nu.h +T2K_CC1pip_H2O_XSec_1Dcospi_nu.h +T2K_CC1pip_H2O_XSec_1Dpmu_nu.h +T2K_CC1pip_H2O_XSec_1Dppi_nu.h T2K_CC0pinp_STV_XSec_1Ddpt_nu.h T2K_SignalDef.h ) set(LIBNAME expT2K) if(CMAKE_BUILD_TYPE MATCHES DEBUG) add_library(${LIBNAME} STATIC ${IMPLFILES}) else(CMAKE_BUILD_TYPE MATCHES RELEASE) add_library(${LIBNAME} SHARED ${IMPLFILES}) endif() include_directories(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) include_directories(${CMAKE_SOURCE_DIR}/src/Splines) set_target_properties(${LIBNAME} PROPERTIES VERSION "${ExtFit_VERSION_MAJOR}.${ExtFit_VERSION_MINOR}.${ExtFit_VERSION_REVISION}") set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? #install(FILES ${HEADERFILES} DESTINATION include) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/T2K/T2K_CC0pi_XSec_2DPcos_nu.cxx b/src/T2K/T2K_CC0pi_XSec_2DPcos_nu.cxx index 5a6932f..65da088 100644 --- a/src/T2K/T2K_CC0pi_XSec_2DPcos_nu.cxx +++ b/src/T2K/T2K_CC0pi_XSec_2DPcos_nu.cxx @@ -1,254 +1,254 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "T2K_SignalDef.h" #include "T2K_CC0pi_XSec_2DPcos_nu.h" T2K_CC0pi_XSec_2DPcos_nu::T2K_CC0pi_XSec_2DPcos_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type){ fName = name; if (fName == "T2K_CC0pi_XSec_2DPcos_nu_I") fAnalysis = 1; else fAnalysis = 2; forwardgoing = (type.find("REST") != std::string::npos); EnuMin = 0; EnuMax = 10.0; fBeamDistance = 0.280; fDefaultTypes = "FIX"; fAllowedTypes = "DIAG,FULL/FREE,SHAPE,FIX/SYSTCOV/STATCOV"; fNDataPointsX = 12; fNDataPointsY = 10; Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile); fIsSystCov = type.find("SYSTCOV") != std::string::npos; fIsStatCov = type.find("STATCOV") != std::string::npos; fIsNormCov = type.find("NORMCOV") != std::string::npos; fPlotTitles = "; P_{#mu} (GeV); cos#theta_{#mu}; d^{2}#sigma/dP_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"; SetHistograms(); SetupDefaultHist(); // Diagonal covar setup if (!fIsShape) fAddNormPen = true; fNormError = 0.089; // Set from covar mat instead... // Get Scaling - fScaleFactor = ((fEventHist->Integral("width")/(fNEvents+0.)) * 1E-38 / + fScaleFactor = ((GetEventHistogram()->Integral("width")/(fNEvents+0.)) * 1E-38 / (TotalIntegratedFlux())); }; bool T2K_CC0pi_XSec_2DPcos_nu::isSignal(FitEvent *event){ return SignalDef::isT2K_CC0pi(event, EnuMin, EnuMax, forwardgoing); }; void T2K_CC0pi_XSec_2DPcos_nu::FillEventVariables(FitEvent* event){ if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double pmu = Pmu.Vect().Mag()/1000.; double CosThetaMu = cos(Pnu.Vect().Angle(Pmu.Vect())); fXVar = pmu; fYVar = CosThetaMu; return; }; // Modification is needed after the full reconfigure to move bins around // Otherwise this would need to be replaced by a TH2Poly which is too awkward. void T2K_CC0pi_XSec_2DPcos_nu::ConvertEventRates(){ // Do standard conversion. Measurement2D::ConvertEventRates(); if (fAnalysis == 1){ // Following code handles weird ND280 Binning int nbins = this->fMCHist->GetNbinsX() + 1; double total = 0.0; // Y = 1 total = 0.0; for (int i = 3; i < nbins; i++){ double width = this->fMCHist->GetXaxis()->GetBinWidth(i) * this->fMCHist->GetYaxis()->GetBinWidth(1); total += this->fMCHist->GetBinContent(i, 1) * width; this->fMCHist->SetBinContent(i,1,0); } this->fMCHist->SetBinContent(3, 1, total / (1.0 * 29.6)); // Y = 2 total = 0.0; for (int i = 5; i < nbins; i++){ double width = this->fMCHist->GetXaxis()->GetBinWidth(i) * this->fMCHist->GetYaxis()->GetBinWidth(2); total += this->fMCHist->GetBinContent(i, 2)* width; this->fMCHist->SetBinContent(i,2,0); } this->fMCHist->SetBinContent(5, 2, total / (0.6 *29.4)); // Y = 3 total = 0.0; for (int i = 7; i < nbins; i++){ double width = this->fMCHist->GetXaxis()->GetBinWidth(i) * this->fMCHist->GetYaxis()->GetBinWidth(3); total += this->fMCHist->GetBinContent(i, 3)* width; this->fMCHist->SetBinContent(i, 3,0); } this->fMCHist->SetBinContent(7, 3, total/ (0.1 * 29.2)); // Y = 4 total = 0.0; for (int i = 7; i < nbins; i++){ double width = this->fMCHist->GetXaxis()->GetBinWidth(i) * this->fMCHist->GetYaxis()->GetBinWidth(4); total += this->fMCHist->GetBinContent(i, 4)* width; this->fMCHist->SetBinContent(i, 4,0); } this->fMCHist->SetBinContent(7, 4, total / (0.1 * 29.2)); // Y = 5 total = 0.0; for (int i = 8; i < nbins; i++){ double width = this->fMCHist->GetXaxis()->GetBinWidth(i) * this->fMCHist->GetYaxis()->GetBinWidth(5); total += this->fMCHist->GetBinContent(i, 5)* width; this->fMCHist->SetBinContent(i,5,0); } this->fMCHist->SetBinContent(8, 5, total / (0.05 * 29.0)); // Y = 6 total = 0.0; for (int i = 9; i < nbins; i++){ double width = this->fMCHist->GetXaxis()->GetBinWidth(i) * this->fMCHist->GetYaxis()->GetBinWidth(6); total += this->fMCHist->GetBinContent(i, 6)* width; this->fMCHist->SetBinContent(i, 6,0); } this->fMCHist->SetBinContent(9, 6, total / (0.05 * 28.5)); // Y = 7 total = 0.0; for (int i = 8; i < nbins; i++){ double width = this->fMCHist->GetXaxis()->GetBinWidth(i) * this->fMCHist->GetYaxis()->GetBinWidth(7); total += this->fMCHist->GetBinContent(i, 7)* width; this->fMCHist->SetBinContent(i, 7,0); } this->fMCHist->SetBinContent(8, 7, total/ (0.04 * 28.0)); // Y = 8 total = 0.0; for (int i = 11; i < nbins; i++){ double width = this->fMCHist->GetXaxis()->GetBinWidth(i) * this->fMCHist->GetYaxis()->GetBinWidth(8); total += this->fMCHist->GetBinContent(i, 8)* width; this->fMCHist->SetBinContent(i, 8,0); } this->fMCHist->SetBinContent(11, 8, total / (0.4 * 27.0)); // Y = 9 total = 0.0; for (int i = 9; i < nbins; i++){ double width = this->fMCHist->GetXaxis()->GetBinWidth(i) * this->fMCHist->GetYaxis()->GetBinWidth(9); total += this->fMCHist->GetBinContent(i, 9)* width; this->fMCHist->SetBinContent(i,9,0); } this->fMCHist->SetBinContent(9, 9, total / (0.02 * 25.0)); } return; } void T2K_CC0pi_XSec_2DPcos_nu::SetHistograms(){ // Open file std::string infile = FitPar::GetDataBase()+"/T2K/CC0pi/T2K_CC0PI_2DPmuCosmu_Data.root"; TFile* rootfile = new TFile(infile.c_str(), "READ"); TH2D* tempcov; // ANALYSIS 2 if (fAnalysis == 2){ // Get Data fDataHist = (TH2D*) rootfile->Get("analysis2_data"); fDataHist->SetDirectory(0); fDataHist->SetNameTitle((fName + "_data").c_str(), (fName + "_data" + fPlotTitles).c_str()); // Get Map fMapHist = (TH2I*) rootfile->Get("analysis2_map"); fMapHist->SetDirectory(0); fMapHist->SetNameTitle((fName + "_map").c_str(), (fName + "_map" + fPlotTitles).c_str()); // Get Syst/Stat Covar TH2D* tempsyst = (TH2D*) rootfile->Get("analysis2_systcov"); TH2D* tempstat = (TH2D*) rootfile->Get("analysis2_statcov"); TH2D* tempnorm = (TH2D*) rootfile->Get("analysis2_normcov"); // Create covar [Default is both] tempcov = (TH2D*) tempsyst->Clone(); tempcov->Reset(); if (fIsSystCov) tempcov->Add(tempsyst); if (fIsStatCov) tempcov->Add(tempstat); if (fIsNormCov) tempcov->Add(tempnorm); if (!fIsSystCov && !fIsStatCov && !fIsNormCov){ tempcov->Add(tempsyst); tempcov->Add(tempstat); tempcov->Add(tempnorm); } // SARAS ANALYSIS } else if (fAnalysis == 1){ //TODO (P.Stowell) Add a TH2Poly Measurement class ERR(FTL) << "T2K CC0Pi Analysis 1 is not yet available due to its awkward binning!" << endl; ERR(FTL) << "If you want to use it, add a TH2Poly Class!" << endl; throw; } // Setup Covar int nbins = tempcov->GetNbinsX(); fFullCovar = new TMatrixDSym(nbins); for (int i = 0; i < nbins; i++){ for (int j = 0; j < nbins; j++){ (*fFullCovar)(i,j) = tempcov->GetBinContent(i+1,j+1); } } covar = StatUtils::GetInvert(fFullCovar); fDecomp = StatUtils::GetDecomp(covar); // Set Data Errors StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar, fMapHist, 1E-38); // Remove root file rootfile->Close(); return; }; diff --git a/src/T2K/T2K_CC0pinp_STV_XSec_1Ddpt_nu.cxx b/src/T2K/T2K_CC0pinp_STV_XSec_1Ddpt_nu.cxx index a20d4f6..af433c2 100644 --- a/src/T2K/T2K_CC0pinp_STV_XSec_1Ddpt_nu.cxx +++ b/src/T2K/T2K_CC0pinp_STV_XSec_1Ddpt_nu.cxx @@ -1,63 +1,63 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "T2K_SignalDef.h" #include "T2K_CC0pinp_STV_XSec_1Ddpt_nu.h" //******************************************************************** T2K_CC0pinp_STV_XSec_1Ddpt_nu::T2K_CC0pinp_STV_XSec_1Ddpt_nu( std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) //******************************************************************** { fName = "T2K_CC0pinp_STV_XSec_1Ddpt_nu"; fDefaultTypes = "FIX/DIAG/CHI2"; fPlotTitles = "; #delta#it{p}_{T} (GeV c^{-1}); #frac{d#sigma}{d#delta#it{p}_{T}} " "(cm^{2} neutron^{-1} GeV^{-1} c)"; EnuMin = 0; EnuMax = 50; fIsDiag = true; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); SetDataValues(GeneralUtils::GetTopLevelDir() + "/data/T2K/T2K_CC0pinp_STV_XSec_1Ddpt_nu.dat"); fDataHist->Scale(1E-38); fDataTrue->Scale(1E-38); SetupDefaultHist(); - fScaleFactor = fEventHist->Integral("width") * double(1E-38) * + fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) * (13.0 / 6.0 /*Data is /neutron */) / (double(fNEvents) * TotalIntegratedFlux("width")); }; void T2K_CC0pinp_STV_XSec_1Ddpt_nu::FillEventVariables(FitEvent *event) { fXVar = FitUtils::Get_STV_dpt(event, 14, true) / 1000.0; return; }; //******************************************************************** bool T2K_CC0pinp_STV_XSec_1Ddpt_nu::isSignal(FitEvent *event) //******************************************************************** { return SignalDef::isT2K_CC0pi_STV(event, EnuMin, EnuMax); } diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1DQ2_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1DQ2_nu.cxx index 4bd107c..2764225 100644 --- a/src/T2K/T2K_CC1pip_CH_XSec_1DQ2_nu.cxx +++ b/src/T2K/T2K_CC1pip_CH_XSec_1DQ2_nu.cxx @@ -1,204 +1,204 @@ #include <iomanip> #include "T2K_SignalDef.h" #include "T2K_CC1pip_CH_XSec_1DQ2_nu.h" // The constructor T2K_CC1pip_CH_XSec_1DQ2_nu::T2K_CC1pip_CH_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ EnuMin = 0.; - EnuMax = 10.; + EnuMax = 100.; fIsDiag = false; // Here we can give either MB (kMB), extended MB (keMB) or Delta (kDelta) if (type.find("eMB") != std::string::npos) { fT2KSampleType = keMB; fName = "T2K_CC1pip_CH_XSec_1DQ2eMB_nu"; fPlotTitles = "; Q^{2}_{eMB} (GeV^{2}); d#sigma/dQ^{2}_{eMB} (cm^{2}/GeV^{2}/nucleon)"; } else if (type.find("MB") != std::string::npos) { fT2KSampleType = kMB; fName = "T2K_CC1pip_CH_XSec_1DQ2MB_nu"; fPlotTitles = "; Q^{2}_{MB} (GeV^{2}); d#sigma/dQ^{2}_{MB} (cm^{2}/GeV^{2}/nucleon)"; } else if (type.find("Delta") != std::string::npos) { fT2KSampleType = kDelta; fName = "T2K_CC1pip_CH_XSec_1DQ2delta_nu"; fPlotTitles = "; Q^{2}_{#Delta} (GeV^{2}); d#sigma/dQ^{2}_{#Delta} (cm^{2}/GeV^{2}/nucleon)"; } else { LOG(SAM) << "Found no specified type, using MiniBooNE E_nu/Q2 definition" << std::endl; fT2KSampleType = kMB; fName = "T2K_CC1pip_CH_XSec_1DQ2MB_nu"; fPlotTitles = "; Q^{2}_{MB} (GeV^{2}); d#sigma/dQ^{2}_{MB} (cm^{2}/GeV^{2}/nucleon)"; } Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); //type = keMB; //type = kDelta; if (fT2KSampleType == kMB) { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Q2_MB.root"); this->SetCovarMatrix(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Q2_MB.root"); } else if (fT2KSampleType == keMB) { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Q2_extendedMB.root"); this->SetCovarMatrix(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Q2_extendedMB.root"); } else if (fT2KSampleType == kDelta) { this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Q2_Delta.root"); this->SetCovarMatrix(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Q2_Delta.root"); } else { ERR(FTL) << "No data type set for " << fName << std::endl; ERR(FTL) << __FILE__ << ":" << __LINE__ << std::endl; exit(-1); } this->SetupDefaultHist(); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; // Override this for now // Should really have Measurement1D do this properly though void T2K_CC1pip_CH_XSec_1DQ2_nu::SetDataValues(std::string fileLocation) { LOG(DEB) << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! // Don't want the last bin of dataCopy TH1D *dataCopy = (TH1D*)(dataFile->Get("hResult_sliced_0_1"))->Clone(); const int nPoints = dataCopy->GetNbinsX()-6; LOG(DEB) << nPoints << std::endl; double *binEdges = new double[nPoints+1]; for (int i = 0; i < nPoints+1; i++) { binEdges[i] = dataCopy->GetBinLowEdge(i+1); } for (int i = 0; i < nPoints+1; i++) { LOG(DEB) << "binEdges[" << i << "] = " << binEdges[i] << std::endl; } fDataHist = new TH1D((fName+"_data").c_str(), (fName+"_data"+fPlotTitles).c_str(), nPoints, binEdges); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { fDataHist->SetBinContent(i+1, dataCopy->GetBinContent(i+1)*1E-38); fDataHist->SetBinError(i+1, dataCopy->GetBinError(i+1)*1E-38); LOG(DEB) << fDataHist->GetBinLowEdge(i+1) << " " << fDataHist->GetBinContent(i+1) << " " << fDataHist->GetBinError(i+1) << std::endl; } fDataHist->SetDirectory(0); //should disassociate fDataHist with dataFile fDataHist->SetNameTitle((fName+"_data").c_str(), (fName+"_MC"+fPlotTitles).c_str()); dataFile->Close(); }; // Override this for now // Should really have Measurement1D do this properly though void T2K_CC1pip_CH_XSec_1DQ2_nu::SetCovarMatrix(std::string fileLocation) { LOG(DEB) << "Covariance: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! TH2D *covarMatrix = (TH2D*)(dataFile->Get("TMatrixDBase;1"))->Clone(); int nBinsX = covarMatrix->GetXaxis()->GetNbins(); int nBinsY = covarMatrix->GetYaxis()->GetNbins(); LOG(DEB) << nBinsX << std::endl; LOG(DEB) << fDataHist->GetNbinsX() << std::endl; if ((nBinsX != nBinsY)) ERR(WRN) << "covariance matrix not square!" << std::endl; this->covar = new TMatrixDSym(nBinsX-7); this->fFullCovar = new TMatrixDSym(nBinsX-7); // First two entries are BS // Last entry is BS for (int i = 0; i < nBinsX-7; i++) { for (int j = 0; j < nBinsY-7; j++) { (*this->covar)(i, j) = covarMatrix->GetBinContent(i+3, j+3); //adds syst+stat covariances (*this->fFullCovar)(i, j) = covarMatrix->GetBinContent(i+3, j+3); //adds syst+stat covariances LOG(DEB) << "covar(" << i << ", " << j << ") = " << (*this->covar)(i,j) << std::endl; } } //should now have set covariance, I hope TDecompChol tempMat = TDecompChol(*this->covar); this->covar = new TMatrixDSym(nBinsX, tempMat.Invert().GetMatrixArray(), ""); // *this->covar *= 1E-38*1E-38; return; }; void T2K_CC1pip_CH_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0 || event->NumFSParticle(211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double q2 = -999; switch(fT2KSampleType) { // First int refers to how we reconstruct Enu // 0 uses true neutrino energy (not used here but common for other analyses when they unfold to true Enu from reconstructed Enu) // 1 uses "extended MiniBooNE" method // 2 uses "MiniBooNE reconstructed" method // 3 uses Delta resonance mass for reconstruction // // The last bool refers to if pion directional information was used // // Use MiniBooNE reconstructed Enu; uses Michel tag so no pion direction information case kMB: q2 = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip, 2, false); break; // Use Extended MiniBooNE reconstructed Enu // Needs pion information to reconstruct so bool is true (did not include Michel e tag) case keMB: q2 = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip, 1, true); break; // Use Delta resonance reconstructed Enu // Uses Michel electron so don't have pion directional information case kDelta: q2 = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip, 3, false); break; } fXVar = q2; return; }; //******************************************************************** bool T2K_CC1pip_CH_XSec_1DQ2_nu::isSignal(FitEvent *event) { //******************************************************************** // Warning: The CH analysis has different signal definition to the H2O analysis! // Often to do with the Michel tag switch(fT2KSampleType) { // Using MiniBooNE formula for Enu reconstruction on the Q2 variable // Does have Michel e tag, set bool to true! case kMB: return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, true); break; // Using extended MiniBooNE formula for Enu reconstruction on the Q2 variable // Does not have Michel e tag because we need directional information to reconstruct Q2 case keMB: return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, false); break; // Using Delta resonance for Enu reconstruction on the Q2 variable // Does have Michel e tag, bool to true case kDelta: return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, true); break; } // Default to return false return false; } diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1DWrec_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1DWrec_nu.cxx index 18e8998..0961a84 100644 --- a/src/T2K/T2K_CC1pip_CH_XSec_1DWrec_nu.cxx +++ b/src/T2K/T2K_CC1pip_CH_XSec_1DWrec_nu.cxx @@ -1,118 +1,118 @@ #include <iomanip> #include "T2K_SignalDef.h" #include "T2K_CC1pip_CH_XSec_1DWrec_nu.h" // The constructor T2K_CC1pip_CH_XSec_1DWrec_nu::T2K_CC1pip_CH_XSec_1DWrec_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "T2K_CC1pip_CH_XSec_1DWrec_nu"; fPlotTitles = "; W_{rec} (GeV/c); d#sigma/dW_{rec} (cm^{2}/(GeV/c^{2})/nucleon)"; EnuMin = 0.; - EnuMax = 10.; + EnuMax = 100.; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/W.root"); this->SetCovarMatrix(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/W.root"); this->SetupDefaultHist(); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; // Override this for now // Should really have Measurement1D do this properly though void T2K_CC1pip_CH_XSec_1DWrec_nu::SetDataValues(std::string fileLocation) { LOG(DEB) << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! // Don't want the first and last bin of dataCopy TH1D *dataCopy = (TH1D*)(dataFile->Get("hResult_sliced_0_1"))->Clone(); LOG(DEB) << dataCopy->GetNbinsX() << std::endl; const int dataPoints = dataCopy->GetNbinsX()-2; double *binEdges = new double[dataPoints+1]; // Want to skip the first bin here for (int i = 0; i < dataPoints+1; i++) { binEdges[i] = dataCopy->GetBinLowEdge(i+2); } for (int i = 0; i < dataPoints+1; i++) { LOG(DEB) << "binEdges[" << i << "] = " << binEdges[i] << std::endl; } fDataHist = new TH1D((fName+"_data").c_str(), (fName+"_data"+fPlotTitles).c_str(), dataPoints, binEdges); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { fDataHist->SetBinContent(i+1, dataCopy->GetBinContent(i+2)*1E-38); fDataHist->SetBinError(i+1, dataCopy->GetBinError(i+2)*1E-38); LOG(DEB) << fDataHist->GetBinLowEdge(i+1) << " " << fDataHist->GetBinContent(i+1) << " " << fDataHist->GetBinError(i+1) << std::endl; } fDataHist->SetDirectory(0); //should disassociate fDataHist with dataFile //fDataHist->SetNameTitle((fName+"_data").c_str(), (fName+"_MC"+fPlotTitles).c_str()); dataFile->Close(); }; // Override this for now // Should really have Measurement1D do this properly though void T2K_CC1pip_CH_XSec_1DWrec_nu::SetCovarMatrix(std::string fileLocation) { LOG(DEB) << "Covariance: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! TH2D *covarMatrix = (TH2D*)(dataFile->Get("TMatrixDBase;1"))->Clone(); const int nBinsX = covarMatrix->GetXaxis()->GetNbins(); const int nBinsY = covarMatrix->GetYaxis()->GetNbins(); if ((nBinsX != nBinsY)) ERR(WRN) << "covariance matrix not square!" << std::endl; LOG(DEB) << nBinsX << std::endl; LOG(DEB) << fDataHist->GetNbinsX() << std::endl; this->covar = new TMatrixDSym(nBinsX-3); this->fFullCovar = new TMatrixDSym(nBinsX-3); for (int i = 0; i < nBinsX-3; i++) { for (int j = 0; j < nBinsY-3; j++) { (*this->covar)(i, j) = covarMatrix->GetBinContent(i+4, j+4); //adds syst+stat covariances LOG(DEB) << "covar(" << i << ", " << j << ") = " << (*this->covar)(i,j) << std::endl; } } //should now have set covariance, I hope TDecompChol tempMat = TDecompChol(*this->covar); this->covar = new TMatrixDSym(nBinsX, tempMat.Invert().GetMatrixArray(), ""); // *this->covar *= 1E-38*1E-38; return; }; void T2K_CC1pip_CH_XSec_1DWrec_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0 || event->NumFSParticle(211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double Wrec = FitUtils::WrecCC1pip_T2K_MB(Pnu, Pmu, Ppip); fXVar = Wrec; return; }; //******************************************************************** bool T2K_CC1pip_CH_XSec_1DWrec_nu::isSignal(FitEvent *event) { //******************************************************************** // This sample includes the Michel e tag so do not have to cut into the pion phase space return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, true); } diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1Dpmu_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1Dpmu_nu.cxx index 9a9a5dd..c49baf4 100644 --- a/src/T2K/T2K_CC1pip_CH_XSec_1Dpmu_nu.cxx +++ b/src/T2K/T2K_CC1pip_CH_XSec_1Dpmu_nu.cxx @@ -1,132 +1,134 @@ #include "T2K_CC1pip_CH_XSec_1Dpmu_nu.h" #include <iomanip> // The constructor T2K_CC1pip_CH_XSec_1Dpmu_nu::T2K_CC1pip_CH_XSec_1Dpmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "T2K_CC1pip_CH_XSec_1Dpmu_nu"; fPlotTitles = "; p_{#mu} (GeV/c); d#sigma/dp_{#mu} (cm^{2}/(GeV/c)/nucleon)"; EnuMin = 0.; - EnuMax = 10.; + EnuMax = 100.; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); + // Currently the data is given in individual root files + // This will likely change when results become official this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Pmu.root"); this->SetCovarMatrix(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Pmu.root"); this->SetupDefaultHist(); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; // Override this for now // Should really have Measurement1D do this properly though void T2K_CC1pip_CH_XSec_1Dpmu_nu::SetDataValues(std::string fileLocation) { LOG(DEB) << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! // Don't want the last bin of dataCopy TH1D *dataCopy = (TH1D*)(dataFile->Get("hResult_sliced_0_1"))->Clone(); LOG(DEB) << "nbins = " << dataCopy->GetNbinsX() << std::endl; double *binEdges = new double[dataCopy->GetNbinsX()-1]; for (int i = 0; i < dataCopy->GetNbinsX()-1; i++) { binEdges[i] = dataCopy->GetBinLowEdge(i+1); } binEdges[dataCopy->GetNbinsX()-1] = dataCopy->GetBinLowEdge(dataCopy->GetNbinsX()); for (int i = 0; i < dataCopy->GetNbinsX()+5; i++) { LOG(DEB) << "binEdges[" << i << "] = " << binEdges[i] << std::endl; } fDataHist = new TH1D((fName+"_data").c_str(), (fName+"_data"+fPlotTitles).c_str(), dataCopy->GetNbinsX()-1, binEdges); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { fDataHist->SetBinContent(i+1, dataCopy->GetBinContent(i+1)*1E-38); fDataHist->SetBinError(i+1, dataCopy->GetBinError(i+1)*1E-38); LOG(DEB) << fDataHist->GetBinLowEdge(i+1) << " " << fDataHist->GetBinContent(i+1) << std::endl; } fDataHist->SetDirectory(0); //should disassociate fDataHist with dataFile fDataHist->SetNameTitle((fName+"_data").c_str(), (fName+"_MC"+fPlotTitles).c_str()); dataFile->Close(); }; // Override this for now // Should really have Measurement1D do this properly though void T2K_CC1pip_CH_XSec_1Dpmu_nu::SetCovarMatrix(std::string fileLocation) { LOG(DEB) << "Covariance: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! TH2D *covarMatrix = (TH2D*)(dataFile->Get("TMatrixDBase;1"))->Clone(); int nBinsX = covarMatrix->GetXaxis()->GetNbins(); int nBinsY = covarMatrix->GetYaxis()->GetNbins(); if ((nBinsX != nBinsY)) ERR(WRN) << "covariance matrix not square!" << std::endl; this->covar = new TMatrixDSym(nBinsX-2); this->fFullCovar = new TMatrixDSym(nBinsX-2); // First two entries are BS // Last entry is BS for (int i = 1; i < nBinsX-1; i++) { for (int j = 1; j < nBinsY-1; j++) { (*this->covar)(i-1, j-1) = covarMatrix->GetBinContent(i+1, j+1); //adds syst+stat covariances (*this->fFullCovar)(i-1, j-1) = covarMatrix->GetBinContent(i+1, j+1); //adds syst+stat covariances LOG(DEB) << "covar(" << i-1 << ", " << j-1 << ") = " << (*this->covar)(i-1,j-1) << std::endl; } } //should now have set covariance, I hope TDecompChol tempMat = TDecompChol(*this->covar); this->covar = new TMatrixDSym(nBinsX, tempMat.Invert().GetMatrixArray(), ""); // *this->covar *= 1E-38*1E-38; return; }; void T2K_CC1pip_CH_XSec_1Dpmu_nu::FillEventVariables(FitEvent *event) { - + if (event->NumFSParticle(13) == 0 || event->NumFSParticle(211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double pmu = FitUtils::p(Pmu); fXVar = pmu; return; }; -//******************************************************************** +//******************************************************************** bool T2K_CC1pip_CH_XSec_1Dpmu_nu::isSignal(FitEvent *event) { -//******************************************************************** +//******************************************************************** // Warning: The CH analysis has different signal definition to the H2O analysis! // // If Michel e- is used for pion PID we don't have directional info on pion; set the bool to true // The bool is if we use Michel e- or not // Also, for events binned in muon momentum/angle there's no cut on the pion kinematics // // Additionally, the 2D distribution uses 0.8 > cos th mu > 0 and no pion phase space reduction applied // Also no muon momentum reduction applied // // This uses a slightly custom signal definition where a cut is only placed on the muon angle, not the momentum if (!SignalDef::isCC1pi(event, 14, 211, EnuMin, EnuMax)) return false; TLorentzVector Pnu = event->GetHMISParticle(14)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double cos_th_mu = cos(FitUtils::th(Pnu,Pmu)); if (cos_th_mu >= 0.2) return true; return false; }; diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1Dppi_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1Dppi_nu.cxx index 7ea2a8e..4dfa1ae 100644 --- a/src/T2K/T2K_CC1pip_CH_XSec_1Dppi_nu.cxx +++ b/src/T2K/T2K_CC1pip_CH_XSec_1Dppi_nu.cxx @@ -1,161 +1,161 @@ #include <iomanip> #include "T2K_SignalDef.h" #include "T2K_CC1pip_CH_XSec_1Dppi_nu.h" // The constructor T2K_CC1pip_CH_XSec_1Dppi_nu::T2K_CC1pip_CH_XSec_1Dppi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "T2K_CC1pip_CH_XSec_1Dppi_nu"; fPlotTitles = "; p_{#pi} (GeV/c); d#sigma/dW_{rec} (cm^{2}/(GeV/c)/nucleon)"; EnuMin = 0.; - EnuMax = 10.; + EnuMax = 100.; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); if (type.find("Michel") != std::string::npos) { useMichel = true; fName += "_Michel"; this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Ppi.root"); this->SetCovarMatrix(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Ppi.root"); } else { useMichel = false; fName += "_kin"; this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Ppi_noME.root"); this->SetCovarMatrix(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Ppi_noME.root"); } this->SetupDefaultHist(); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; // Override this for now // Should really have Measurement1D do this properly though void T2K_CC1pip_CH_XSec_1Dppi_nu::SetDataValues(std::string fileLocation) { LOG(DEB) << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! // Don't want the last bin of dataCopy TH1D *dataCopy = (TH1D*)(dataFile->Get("hResult_sliced_0_1"))->Clone(); LOG(DEB) << dataCopy->GetNbinsX() << std::endl; double *binEdges = new double[dataCopy->GetNbinsX()-1]; for (int i = 0; i < dataCopy->GetNbinsX()-1; i++) { binEdges[i] = dataCopy->GetBinLowEdge(i+1); } binEdges[dataCopy->GetNbinsX()-1] = dataCopy->GetBinLowEdge(dataCopy->GetNbinsX()); fDataHist = new TH1D((fName+"_data").c_str(), (fName+"_data"+fPlotTitles).c_str(), dataCopy->GetNbinsX()-2, binEdges); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { fDataHist->SetBinContent(i+1, dataCopy->GetBinContent(i+1)*1E-38); fDataHist->SetBinError(i+1, dataCopy->GetBinError(i+1)*1E-38); LOG(DEB) << fDataHist->GetBinLowEdge(i+1) << " " << fDataHist->GetBinContent(i+1) << std::endl; } fDataHist->SetDirectory(0); //should disassociate fDataHist with dataFile fDataHist->SetNameTitle((fName+"_data").c_str(), (fName+"_MC"+fPlotTitles).c_str()); dataFile->Close(); }; // Override this for now // Should really have Measurement1D do this properly though void T2K_CC1pip_CH_XSec_1Dppi_nu::SetCovarMatrix(std::string fileLocation) { LOG(DEB) << "Covariance: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! TH2D *covarMatrix = (TH2D*)(dataFile->Get("TMatrixDBase;1"))->Clone(); int nBinsX = covarMatrix->GetXaxis()->GetNbins(); int nBinsY = covarMatrix->GetYaxis()->GetNbins(); if ((nBinsX != nBinsY)) ERR(WRN) << "covariance matrix not square!" << std::endl; this->covar = new TMatrixDSym(nBinsX-2); this->fFullCovar = new TMatrixDSym(nBinsX-2); // First two entries are BS // Last entry is BS for (int i = 1; i < nBinsX-1; i++) { for (int j = 1; j < nBinsY-1; j++) { LOG(DEB) << "(" << i << ", " << j << ") = " << covarMatrix->GetBinContent(i+1,j+1) << std::endl; (*this->covar)(i-1, j-1) = covarMatrix->GetBinContent(i, j); //adds syst+stat covariances (*this->fFullCovar)(i-1, j-1) = covarMatrix->GetBinContent(i, j); //adds syst+stat covariances } } //should now have set covariance, I hope TDecompChol tempMat = TDecompChol(*this->covar); this->covar = new TMatrixDSym(nBinsX, tempMat.Invert().GetMatrixArray(), ""); // *this->covar *= 1E-38*1E-38; return; }; void T2K_CC1pip_CH_XSec_1Dppi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0 || event->NumFSParticle(211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double ppip = FitUtils::p(Ppip); fXVar = ppip; return; }; //******************************************************************** bool T2K_CC1pip_CH_XSec_1Dppi_nu::isSignal(FitEvent *event) { //******************************************************************** // This distribution uses a somewhat different signal definition so might as well implement it separately here // If we use Michel tag sample we don't cut into the pion phase space, only the muon phase space // The last bool refers to if we have Michel e or not if (useMichel) { return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, true); } else { // Custom signal definition if we aren't using Michel tag; cut on muon and cut only on pion angle // does the event pass the muon cut? bool muonPass = SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, true); // If the event doesn't pass the muon cut return false if (!muonPass) { return false; } // does the event pass the pion angle cut? // we already know there's just one muon in the event if it passes muonPass so don't need to make an event loop rejection // Need the neutrino four-vector to get the angle between pion and neutrino TLorentzVector Pnu = event->PartInfo(0)->fP; TLorentzVector Ppip; for (unsigned int j = 2; j < event->Npart(); j++) { if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fNEUTStatusCode != 0) continue; //move on if NOT ALIVE and NOT NORMAL int PID = (event->PartInfo(j))->fPID; if (PID == 211) { Ppip = event->PartInfo(j)->fP; // Once the pion is found we can break break; } } double cos_th_pi = cos(FitUtils::th(Pnu, Ppip)); // Now check the angle of the pion if (cos_th_pi <= 0.2) { return false; } else { return true; } } // Unnecessary default to false return false; } diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1Dq3_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1Dq3_nu.cxx index b3f5a29..28f6e7b 100644 --- a/src/T2K/T2K_CC1pip_CH_XSec_1Dq3_nu.cxx +++ b/src/T2K/T2K_CC1pip_CH_XSec_1Dq3_nu.cxx @@ -1,113 +1,113 @@ #include <iomanip> #include "T2K_SignalDef.h" #include "T2K_CC1pip_CH_XSec_1Dq3_nu.h" // The constructor T2K_CC1pip_CH_XSec_1Dq3_nu::T2K_CC1pip_CH_XSec_1Dq3_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "T2K_CC1pip_CH_XSec_1Dq3_nu"; fPlotTitles = "; q_{3} (GeV/c); d#sigma/dq_{3} (cm^{2}/(GeV/c)/nucleon)"; EnuMin = 0.; - EnuMax = 10.; + EnuMax = 100.; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Q3.root"); this->SetCovarMatrix(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Q3.root"); this->SetupDefaultHist(); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; // Override this for now // Should really have Measurement1D do this properly though void T2K_CC1pip_CH_XSec_1Dq3_nu::SetDataValues(std::string fileLocation) { LOG(DEB) << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! // Don't want the last bin of dataCopy TH1D *dataCopy = (TH1D*)(dataFile->Get("hResult_sliced_0_1"))->Clone(); double *binEdges = new double[dataCopy->GetNbinsX()-1]; LOG(DEB) << dataCopy->GetNbinsX() << std::endl; for (int i = 1; i < dataCopy->GetNbinsX(); i++) { binEdges[i-1] = dataCopy->GetBinLowEdge(i+1); LOG(DEB) << i-1 << " " << binEdges[i-1] << " from binLowEdge " << i+1 << std::endl; } fDataHist = new TH1D((fName+"_data").c_str(), (fName+"_data"+fPlotTitles).c_str(), dataCopy->GetNbinsX()-2, binEdges); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { fDataHist->SetBinContent(i+1, dataCopy->GetBinContent(i+2)*1E-38); fDataHist->SetBinError(i+1, dataCopy->GetBinError(i+2)*1E-38); LOG(DEB) << fDataHist->GetBinLowEdge(i+1) << " " << fDataHist->GetBinContent(i+1) << " " << fDataHist->GetBinError(i+1) << std::endl; } fDataHist->SetDirectory(0); //should disassociate fDataHist with dataFile fDataHist->SetNameTitle((fName+"_data").c_str(), (fName+"_MC"+fPlotTitles).c_str()); dataFile->Close(); }; // Override this for now // Should really have Measurement1D do this properly though void T2K_CC1pip_CH_XSec_1Dq3_nu::SetCovarMatrix(std::string fileLocation) { LOG(DEB) << "Covariance: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! TH2D *covarMatrix = (TH2D*)(dataFile->Get("TMatrixDBase;1"))->Clone(); int nBinsX = covarMatrix->GetXaxis()->GetNbins(); int nBinsY = covarMatrix->GetYaxis()->GetNbins(); if ((nBinsX != nBinsY)) ERR(WRN) << "covariance matrix not square!" << std::endl; this->covar = new TMatrixDSym(nBinsX-2); this->fFullCovar = new TMatrixDSym(nBinsX-2); // First two entries are BS // Last entry is BS for (int i = 2; i < nBinsX-1; i++) { for (int j = 2; j < nBinsY-1; j++) { (*this->covar)(i-2, j-2) = covarMatrix->GetBinContent(i+1, j+1); //adds syst+stat covariances (*this->fFullCovar)(i-2, j-2) = covarMatrix->GetBinContent(i+1, j+1); //adds syst+stat covariances LOG(DEB) << "covar(" << i-2 << ", " << j-2 << ") = " << (*this->covar)(i-2,j-2) << std::endl; } } //should now have set covariance, I hope TDecompChol tempMat = TDecompChol(*this->covar); this->covar = new TMatrixDSym(nBinsX, tempMat.Invert().GetMatrixArray(), ""); // *this->covar *= 1E-38*1E-38; return; }; void T2K_CC1pip_CH_XSec_1Dq3_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0 || event->NumFSParticle(211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double q3 = FitUtils::q3_CC1pip_T2K(Pnu, Pmu, Ppip); fXVar = q3; return; }; //******************************************************************** bool T2K_CC1pip_CH_XSec_1Dq3_nu::isSignal(FitEvent *event) { //******************************************************************** // Has a Michel e sample in so no phase space cut on pion required return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, true); } diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1Dthmupi_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1Dthmupi_nu.cxx index 1418c5f..b191482 100644 --- a/src/T2K/T2K_CC1pip_CH_XSec_1Dthmupi_nu.cxx +++ b/src/T2K/T2K_CC1pip_CH_XSec_1Dthmupi_nu.cxx @@ -1,113 +1,113 @@ #include <iomanip> #include "T2K_SignalDef.h" #include "T2K_CC1pip_CH_XSec_1Dthmupi_nu.h" // The constructor T2K_CC1pip_CH_XSec_1Dthmupi_nu::T2K_CC1pip_CH_XSec_1Dthmupi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "T2K_CC1pip_CH_XSec_1Dthmupi_nu"; fPlotTitles = "; #theta_{#pi,#mu} (radians); d#sigma/d#theta_{#pi} (cm^{2}/nucleon)"; EnuMin = 0.; - EnuMax = 10.; + EnuMax = 100.; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Thetapimu.root"); this->SetCovarMatrix(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Thetapimu.root"); this->SetupDefaultHist(); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; // Override this for now // Should really have Measurement1D do this properly though void T2K_CC1pip_CH_XSec_1Dthmupi_nu::SetDataValues(std::string fileLocation) { LOG(DEB) << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! // Don't want the first and last bin of dataCopy TH1D *dataCopy = (TH1D*)(dataFile->Get("hResult_sliced_0_1"))->Clone(); LOG(DEB) << "dataCopy->GetNbinsX() = " << dataCopy->GetNbinsX() << std::endl; double *binEdges = new double[dataCopy->GetNbinsX()]; for (int i = 0; i < dataCopy->GetNbinsX(); i++) { binEdges[i] = dataCopy->GetBinLowEdge(i+1); } binEdges[dataCopy->GetNbinsX()] = dataCopy->GetBinLowEdge(dataCopy->GetNbinsX()+1); for (int i = 0; i < dataCopy->GetNbinsX()+5; i++) { LOG(DEB) << "binEdges[" << i << "] = " << binEdges[i] << std::endl; } fDataHist = new TH1D((fName+"_data").c_str(), (fName+"_data"+fPlotTitles).c_str(), dataCopy->GetNbinsX(), binEdges); for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { fDataHist->SetBinContent(i+1, dataCopy->GetBinContent(i+1)*1E-38); fDataHist->SetBinError(i+1, dataCopy->GetBinError(i+1)*1E-38); LOG(DEB) << fDataHist->GetBinLowEdge(i+1) << " " << fDataHist->GetBinContent(i+1) << " " << fDataHist->GetBinError(i+1) << std::endl; } fDataHist->SetDirectory(0); //should disassociate fDataHist with dataFile dataFile->Close(); }; // Override this for now // Should really have Measurement1D do this properly though void T2K_CC1pip_CH_XSec_1Dthmupi_nu::SetCovarMatrix(std::string fileLocation) { LOG(DEB) << "Covariance: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! TH2D *covarMatrix = (TH2D*)(dataFile->Get("TMatrixDBase;1"))->Clone(); int nBinsX = covarMatrix->GetXaxis()->GetNbins(); int nBinsY = covarMatrix->GetYaxis()->GetNbins(); if ((nBinsX != nBinsY)) ERR(WRN) << "covariance matrix not square!" << std::endl; this->covar = new TMatrixDSym(nBinsX-1); this->fFullCovar = new TMatrixDSym(nBinsX-1); for (int i = 1; i < nBinsX; i++) { for (int j = 1; j < nBinsY; j++) { (*this->covar)(i-1, j-1) = covarMatrix->GetBinContent(i, j); //adds syst+stat covariances (*this->fFullCovar)(i-1, j-1) = covarMatrix->GetBinContent(i, j); //adds syst+stat covariances LOG(DEB) << "covar(" << i-1 << ", " << j-1 << ") = " << (*this->covar)(i-1,j-1) << std::endl; } } //should now have set covariance, I hope TDecompChol tempMat = TDecompChol(*this->covar); this->covar = new TMatrixDSym(nBinsX, tempMat.Invert().GetMatrixArray(), ""); // *this->covar *= 1E-38*1E-38; dataFile->Close(); }; void T2K_CC1pip_CH_XSec_1Dthmupi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0 || event->NumFSParticle(211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double thmupi = FitUtils::th(Pmu, Ppip); fXVar = thmupi; return; }; //******************************************************************** bool T2K_CC1pip_CH_XSec_1Dthmupi_nu::isSignal(FitEvent *event) { //******************************************************************** // This sample requires directional information on the pion so can't use Michel tag sample return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, false); } diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1Dthpi_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1Dthpi_nu.cxx index b33e87a..4324fe6 100644 --- a/src/T2K/T2K_CC1pip_CH_XSec_1Dthpi_nu.cxx +++ b/src/T2K/T2K_CC1pip_CH_XSec_1Dthpi_nu.cxx @@ -1,114 +1,114 @@ #include <iomanip> #include "T2K_SignalDef.h" #include "T2K_CC1pip_CH_XSec_1Dthpi_nu.h" // The constructor T2K_CC1pip_CH_XSec_1Dthpi_nu::T2K_CC1pip_CH_XSec_1Dthpi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "T2K_CC1pip_CH_XSec_1Dthpi_nu"; fPlotTitles = "; #theta_{#pi} (radians); d#sigma/d#theta_{#pi} (cm^{2}/nucleon)"; EnuMin = 0.; - EnuMax = 10.; + EnuMax = 100.; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Thetapi.root"); this->SetCovarMatrix(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/Thetapi.root"); this->SetupDefaultHist(); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; // Override this for now // Should really have Measurement1D do this properly though void T2K_CC1pip_CH_XSec_1Dthpi_nu::SetDataValues(std::string fileLocation) { LOG(DEB) << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! // Don't want the first and last bin of dataCopy TH1D *dataCopy = (TH1D*)(dataFile->Get("hResult_sliced_0_1"))->Clone(); LOG(DEB) << "dataCopy->GetNbinsX() = " << dataCopy->GetNbinsX() << std::endl; double *binEdges = new double[dataCopy->GetNbinsX()-4]; for (int i = 0; i < dataCopy->GetNbinsX()-4; i++) { binEdges[i] = dataCopy->GetBinLowEdge(i+1); } binEdges[dataCopy->GetNbinsX()-4] = dataCopy->GetBinLowEdge(dataCopy->GetNbinsX()-3); for (int i = 0; i < dataCopy->GetNbinsX(); i++) { LOG(DEB) << "binEdges[" << i << "] = " << binEdges[i] << std::endl; } fDataHist = new TH1D((fName+"_data").c_str(), (fName+"_data"+fPlotTitles).c_str(), dataCopy->GetNbinsX()-4, binEdges); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { fDataHist->SetBinContent(i+1, dataCopy->GetBinContent(i+1)*1E-38); fDataHist->SetBinError(i+1, dataCopy->GetBinError(i+1)*1E-38); LOG(DEB) << fDataHist->GetBinLowEdge(i+1) << " " << fDataHist->GetBinContent(i+1) << " " << fDataHist->GetBinError(i+1) << std::endl; } fDataHist->SetDirectory(0); //should disassociate fDataHist with dataFile dataFile->Close(); }; // Override this for now // Should really have Measurement1D do this properly though void T2K_CC1pip_CH_XSec_1Dthpi_nu::SetCovarMatrix(std::string fileLocation) { LOG(DEB) << "Covariance: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! TH2D *covarMatrix = (TH2D*)(dataFile->Get("TMatrixDBase;1"))->Clone(); int nBinsX = covarMatrix->GetXaxis()->GetNbins(); int nBinsY = covarMatrix->GetYaxis()->GetNbins(); if ((nBinsX != nBinsY)) ERR(WRN) << "covariance matrix not square!" << std::endl; this->covar = new TMatrixDSym(nBinsX-5); this->fFullCovar = new TMatrixDSym(nBinsX-5); for (int i = 2; i < nBinsX-3; i++) { for (int j = 2; j < nBinsY-3; j++) { (*this->covar)(i-2, j-2) = covarMatrix->GetBinContent(i, j); //adds syst+stat covariances (*this->fFullCovar)(i-2, j-2) = covarMatrix->GetBinContent(i, j); //adds syst+stat covariances LOG(DEB) << "covar(" << i-2 << ", " << j-2 << ") = " << (*this->covar)(i-2,j-2) << std::endl; } } //should now have set covariance, I hope TDecompChol tempMat = TDecompChol(*this->covar); this->covar = new TMatrixDSym(nBinsX, tempMat.Invert().GetMatrixArray(), ""); // *this->covar *= 1E-38*1E-38; dataFile->Close(); }; void T2K_CC1pip_CH_XSec_1Dthpi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0 || event->NumFSParticle(211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double thpi = FitUtils::th(Pnu, Ppip); fXVar = thpi; return; }; //******************************************************************** bool T2K_CC1pip_CH_XSec_1Dthpi_nu::isSignal(FitEvent *event) { //******************************************************************** // This sample uses directional info on the pion so Michel e tag sample can not be included // i.e. we need reduce the pion variable phase space return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, false); } diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1Dthq3pi_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1Dthq3pi_nu.cxx index 6b385ff..e3a1cbb 100644 --- a/src/T2K/T2K_CC1pip_CH_XSec_1Dthq3pi_nu.cxx +++ b/src/T2K/T2K_CC1pip_CH_XSec_1Dthq3pi_nu.cxx @@ -1,119 +1,119 @@ #include <iomanip> #include "T2K_SignalDef.h" #include "T2K_CC1pip_CH_XSec_1Dthq3pi_nu.h" // The constructor T2K_CC1pip_CH_XSec_1Dthq3pi_nu::T2K_CC1pip_CH_XSec_1Dthq3pi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ fName = "T2K_CC1pip_CH_XSec_1Dthq3pi_nu"; fPlotTitles = "; #theta_{q_{3},#pi} (radians); d#sigma/d#theta_{q_{3},#pi} (cm^{2}/(radian)/nucleon)"; EnuMin = 0.; - EnuMax = 10.; + EnuMax = 100.; fIsDiag = false; Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); this->SetDataValues(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/ThetaQ3Pi.root"); this->SetCovarMatrix(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/CH/ThetaQ3Pi.root"); this->SetupDefaultHist(); - this->fScaleFactor = (this->fEventHist->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); }; // Override this for now // Should really have Measurement1D do this properly though void T2K_CC1pip_CH_XSec_1Dthq3pi_nu::SetDataValues(std::string fileLocation) { LOG(DEB) << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! // Don't want the last bin of dataCopy TH1D *dataCopy = (TH1D*)(dataFile->Get("hResult_sliced_0_1"))->Clone(); double *binEdges = new double[dataCopy->GetNbinsX()-1]; LOG(DEB) << dataCopy->GetNbinsX() << std::endl; for (int i = 1; i < dataCopy->GetNbinsX()+1; i++) { binEdges[i-1] = dataCopy->GetBinLowEdge(i); LOG(DEB) << i-1 << " " << binEdges[i-1] << std::endl; } for (int i = 0; i < dataCopy->GetNbinsX()+5; i++) { LOG(DEB) << "binEdges[" << i << "] = " << binEdges[i] << std::endl; } fDataHist = new TH1D((fName+"_data").c_str(), (fName+"_data"+fPlotTitles).c_str(), dataCopy->GetNbinsX()-1, binEdges); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { fDataHist->SetBinContent(i+1, dataCopy->GetBinContent(i+1)*1E-38); fDataHist->SetBinError(i+1, dataCopy->GetBinError(i+1)*1E-38); LOG(DEB) << fDataHist->GetBinLowEdge(i+1) << " " << fDataHist->GetBinContent(i+1) << " " << fDataHist->GetBinError(i+1) << std::endl; } fDataHist->SetDirectory(0); //should disassociate fDataHist with dataFile fDataHist->SetNameTitle((fName+"_data").c_str(), (fName+"_MC"+fPlotTitles).c_str()); dataFile->Close(); }; // Override this for now // Should really have Measurement1D do this properly though void T2K_CC1pip_CH_XSec_1Dthq3pi_nu::SetCovarMatrix(std::string fileLocation) { LOG(DEB) << "Covariance: " << fileLocation.c_str() << std::endl; TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file! TH2D *covarMatrix = (TH2D*)(dataFile->Get("TMatrixDBase;1"))->Clone(); int nBinsX = covarMatrix->GetXaxis()->GetNbins(); int nBinsY = covarMatrix->GetYaxis()->GetNbins(); if ((nBinsX != nBinsY)) ERR(WRN) << "covariance matrix not square!" << std::endl; // First bin is underflow, last bin is overflow this->covar = new TMatrixDSym(nBinsX-2); this->fFullCovar = new TMatrixDSym(nBinsX-2); // First two entries are BS // Last entry is BS for (int i = 1; i < nBinsX-1; i++) { for (int j = 1; j < nBinsY-1; j++) { (*this->covar)(i-1, j-1) = covarMatrix->GetBinContent(i+1, j+1); //adds syst+stat covariances (*this->fFullCovar)(i-1, j-1) = covarMatrix->GetBinContent(i+1, j+1); //adds syst+stat covariances LOG(DEB) << "covar(" << i-1 << ", " << j-1 << ") = " << (*this->covar)(i-1,j-1) << std::endl; } } //should now have set covariance, I hope TDecompChol tempMat = TDecompChol(*this->covar); this->covar = new TMatrixDSym(nBinsX, tempMat.Invert().GetMatrixArray(), ""); // *this->covar *= 1E-38*1E-38; return; }; void T2K_CC1pip_CH_XSec_1Dthq3pi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0 || event->NumFSParticle(211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double th_q3_pi = FitUtils::thq3pi_CC1pip_T2K(Pnu, Pmu, Ppip); fXVar = th_q3_pi; return; }; //******************************************************************** bool T2K_CC1pip_CH_XSec_1Dthq3pi_nu::isSignal(FitEvent *event) { //******************************************************************** // This sample requires pion directional information so can not include Michel tag sample // i.e. will need to cut the pion phase space return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, false); } diff --git a/src/T2K/T2K_CC1pip_H2O_XSec_1DEnuDelta_nu.cxx b/src/T2K/T2K_CC1pip_H2O_XSec_1DEnuDelta_nu.cxx new file mode 100644 index 0000000..b726e8f --- /dev/null +++ b/src/T2K/T2K_CC1pip_H2O_XSec_1DEnuDelta_nu.cxx @@ -0,0 +1,55 @@ +#include "T2K_CC1pip_H2O_XSec_1DEnuDelta_nu.h" + +// The derived neutrino energy assuming a Delta resonance and a nucleon at rest; so only requires the outgoing muon to derive (and information on the angle between the muon and the neutrino) +// Please beware that this is NOT THE "TRUE" NEUTRINO ENERGY; IT'S A PROXY FOR THE TRUE NEUTRINO ENERGY +// Also, this is flux-integrated cross-section, not flux averaged + +//******************************************************************** +T2K_CC1pip_H2O_XSec_1DEnuDelta_nu::T2K_CC1pip_H2O_XSec_1DEnuDelta_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ +//******************************************************************** + fName = "T2K_CC1pip_H2O_XSec_1DEnuDelta_nu"; + fPlotTitles = "; E^{#Delta}_{#nu} (GeV); #sigma(E^{#Delta}_{#nu}) (cm^{2}/nucleon)"; + EnuMin = 0.; + EnuMax = 100.; + Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); + + // Data comes in ROOT file + // hResultTot is cross-section with all errors + // hResultStat is cross-section with stats-only errors + // hTruthNEUT is the NEUT cross-section given by experimenter + // hTruthGENIE is the GENIE cross-section given by experimenter + SetDataFromFile(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root","EnuRec_Delta/hResultTot"); + SetCovarFromDataFile(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root", "EnuRec_Delta/TotalCovariance", true); + + SetupDefaultHist(); + + fScaleFactor = GetEventHistogram()->Integral("width")*1E-38/double(fNEvents); +}; + + +//******************************************************************** +// Find the muon whows kinematics we use to derive the "neutrino energy" +void T2K_CC1pip_H2O_XSec_1DEnuDelta_nu::FillEventVariables(FitEvent *event) { +//******************************************************************** + + // Need to make sure there's a muon + if (event->NumFSParticle(13) == 0) return; + + // Get the incoming neutrino + TLorentzVector Pnu = event->GetNeutrinoIn()->fP; + // Get the muon + TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; + + double Enu = FitUtils::EnuCC1piprecDelta(Pnu, Pmu); + + fXVar = Enu; + + return; +}; + +//******************************************************************** +// Beware: The H2O analysis has different signal definition to the CH analysis! +bool T2K_CC1pip_H2O_XSec_1DEnuDelta_nu::isSignal(FitEvent *event) { +//******************************************************************** + return SignalDef::isCC1pip_T2K_H2O(event, EnuMin, EnuMax); +} diff --git a/src/T2K/T2K_CC1pip_H2O_XSec_1DEnuDelta_nu.h b/src/T2K/T2K_CC1pip_H2O_XSec_1DEnuDelta_nu.h new file mode 100644 index 0000000..5d1d9f4 --- /dev/null +++ b/src/T2K/T2K_CC1pip_H2O_XSec_1DEnuDelta_nu.h @@ -0,0 +1,18 @@ +#ifndef T2K_CC1PIP_H2O_XSEC_1DENUDELTA_NU_H_SEEN +#define T2K_CC1PIP_H2O_XSEC_1DENUDELTA_NU_H_SEEN + +#include "Measurement1D.h" +#include "T2K_SignalDef.h" + +class T2K_CC1pip_H2O_XSec_1DEnuDelta_nu : public Measurement1D { +public: + T2K_CC1pip_H2O_XSec_1DEnuDelta_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); + virtual ~T2K_CC1pip_H2O_XSec_1DEnuDelta_nu() {}; + + void FillEventVariables(FitEvent *event); + bool isSignal(FitEvent *event); + + private: +}; + +#endif diff --git a/src/T2K/T2K_CC1pip_H2O_XSec_1DEnuMB_nu.cxx b/src/T2K/T2K_CC1pip_H2O_XSec_1DEnuMB_nu.cxx new file mode 100644 index 0000000..8a5a927 --- /dev/null +++ b/src/T2K/T2K_CC1pip_H2O_XSec_1DEnuMB_nu.cxx @@ -0,0 +1,62 @@ +#include "T2K_CC1pip_H2O_XSec_1DEnuMB_nu.h" + +// The derived neutrino energy using the "MiniBooNE formula" (see paper) +// Essentially this is a proxy for the neutrino energy, using the outgoing pion and muon to get the reconstructed neutrino energy, assuming the struck nucleon was at rest +// Again, THIS IS NOT A "TRUE" NEUTRINO ENERGY! + +//******************************************************************** +T2K_CC1pip_H2O_XSec_1DEnuMB_nu::T2K_CC1pip_H2O_XSec_1DEnuMB_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ +//******************************************************************** + + fName = "T2K_CC1pip_H2O_XSec_1DEnuMB_nu"; + fPlotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/nucleon)"; + EnuMin = 0.; + EnuMax = 100.; + Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); + + // Data comes in ROOT file + // hResultTot is cross-section with all errors + // hResultStat is cross-section with stats-only errors + // hTruthNEUT is the NEUT cross-section given by experimenter + // hTruthGENIE is the GENIE cross-section given by experimenter + SetDataFromFile(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root","EnuRec_MB/hResultTot"); + SetCovarFromDataFile(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root", "EnuRec_MB/TotalCovariance", true); + + SetupDefaultHist(); + + fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/double(fNEvents); +}; + +//******************************************************************** +// Find the derived neutrino energy using the "MiniBooNE formula" (see paper) +// Essentially uses the pion and muon kinematics to derive a pseudo-neutrino energy, assuming the struck nucleon is at rest +// We also need the incoming neutrino to get the muon/neutrino and pion/neutrino angles +void T2K_CC1pip_H2O_XSec_1DEnuMB_nu::FillEventVariables(FitEvent *event) { +//******************************************************************** + + // Need to make sure there's a muon + if (event->NumFSParticle(13) == 0) return; + // Need to make sure there's a pion + if (event->NumFSParticle(211) == 0) return; + + // Get the incoming neutrino + TLorentzVector Pnu = event->GetNeutrinoIn()->fP; + // Get the muon + TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; + // Get the pion + TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; + + double Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip); + + fXVar = Enu; + + return; +}; + + +//******************************************************************** +// Beware: The H2O analysis has different signal definition to the CH analysis! +bool T2K_CC1pip_H2O_XSec_1DEnuMB_nu::isSignal(FitEvent *event) { +//******************************************************************** + return SignalDef::isCC1pip_T2K_H2O(event, EnuMin, EnuMax); +} diff --git a/src/T2K/T2K_CC1pip_H2O_XSec_1DEnuMB_nu.h b/src/T2K/T2K_CC1pip_H2O_XSec_1DEnuMB_nu.h new file mode 100644 index 0000000..6d0ab53 --- /dev/null +++ b/src/T2K/T2K_CC1pip_H2O_XSec_1DEnuMB_nu.h @@ -0,0 +1,18 @@ +#ifndef T2K_CC1PIP_XSEC_1DENUMB_NU_H_SEEN +#define T2K_CC1PIP_XSEC_1DENUMB_NU_H_SEEN + +#include "Measurement1D.h" +#include "T2K_SignalDef.h" + +class T2K_CC1pip_H2O_XSec_1DEnuMB_nu : public Measurement1D { +public: + T2K_CC1pip_H2O_XSec_1DEnuMB_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); + virtual ~T2K_CC1pip_H2O_XSec_1DEnuMB_nu() {}; + + void FillEventVariables(FitEvent *event); + bool isSignal(FitEvent *event); + + private: +}; + +#endif diff --git a/src/T2K/T2K_CC1pip_H2O_XSec_1Dcosmu_nu.cxx b/src/T2K/T2K_CC1pip_H2O_XSec_1Dcosmu_nu.cxx new file mode 100644 index 0000000..2bb1ad5 --- /dev/null +++ b/src/T2K/T2K_CC1pip_H2O_XSec_1Dcosmu_nu.cxx @@ -0,0 +1,56 @@ +#include "T2K_CC1pip_H2O_XSec_1Dcosmu_nu.h" + +// The cos of the angle between the neutrino and the muon + +//******************************************************************** +T2K_CC1pip_H2O_XSec_1Dcosmu_nu::T2K_CC1pip_H2O_XSec_1Dcosmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ +//******************************************************************** + + fName = "T2K_CC1pip_H2O_XSec_1Dcosmu_nu"; + fPlotTitles = "; cos#theta_{#mu}; d#sigma/dcos#theta_{#mu} (cm^{2}/nucleon)"; + EnuMin = 0.; + EnuMax = 100.; + Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); + + // Data comes in ROOT file + // hResultTot is cross-section with all errors + // hResultStat is cross-section with stats-only errors + // hTruthNEUT is the NEUT cross-section given by experimenter + // hTruthGENIE is the GENIE cross-section given by experimenter + SetDataFromFile(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root","MuCos/hResultTot"); + SetCovarFromDataFile(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root", "MuCos/TotalCovariance", true); + + SetupDefaultHist(); + + fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); + +}; + +//******************************************************************** +// Find the cos theta of the angle between muon and neutrino +void T2K_CC1pip_H2O_XSec_1Dcosmu_nu::FillEventVariables(FitEvent *event) { +//******************************************************************** + + // Need to make sure there's a muon + if (event->NumFSParticle(13) == 0) return; + + // Get the incoming neutrino + TLorentzVector Pnu = event->GetNeutrinoIn()->fP; + // Get the muon + TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; + + // Do the cos of the angle between the two + double cos_th = cos(FitUtils::th(Pnu, Pmu)); + + fXVar = cos_th; + + return; +}; + +//******************************************************************** +// Beware: The H2O analysis has different signal definition to the CH analysis! +bool T2K_CC1pip_H2O_XSec_1Dcosmu_nu::isSignal(FitEvent *event) { +//******************************************************************** + return SignalDef::isCC1pip_T2K_H2O(event, EnuMin, EnuMax); +} + diff --git a/src/T2K/T2K_CC1pip_H2O_XSec_1Dcosmu_nu.h b/src/T2K/T2K_CC1pip_H2O_XSec_1Dcosmu_nu.h new file mode 100644 index 0000000..a3246ac --- /dev/null +++ b/src/T2K/T2K_CC1pip_H2O_XSec_1Dcosmu_nu.h @@ -0,0 +1,18 @@ +#ifndef T2K_CC1PIP_H2O_XSEC_1DCOSMU_NU_H_SEEN +#define T2K_CC1PIP_H2O_XSEC_1DCOSMU_NU_H_SEEN + +#include "Measurement1D.h" +#include "T2K_SignalDef.h" + +class T2K_CC1pip_H2O_XSec_1Dcosmu_nu : public Measurement1D { +public: + T2K_CC1pip_H2O_XSec_1Dcosmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); + virtual ~T2K_CC1pip_H2O_XSec_1Dcosmu_nu() {}; + + void FillEventVariables(FitEvent *event); + bool isSignal(FitEvent *event); + + private: +}; + +#endif diff --git a/src/T2K/T2K_CC1pip_H2O_XSec_1Dcosmupi_nu.cxx b/src/T2K/T2K_CC1pip_H2O_XSec_1Dcosmupi_nu.cxx new file mode 100644 index 0000000..e969f20 --- /dev/null +++ b/src/T2K/T2K_CC1pip_H2O_XSec_1Dcosmupi_nu.cxx @@ -0,0 +1,55 @@ +#include "T2K_CC1pip_H2O_XSec_1Dcosmupi_nu.h" + +// The cosine of the angle between the muon and pion + +//******************************************************************** +T2K_CC1pip_H2O_XSec_1Dcosmupi_nu::T2K_CC1pip_H2O_XSec_1Dcosmupi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ +//******************************************************************** + + fName = "T2K_CC1pip_H2O_XSec_1Dcosmupi_nu"; + fPlotTitles = "; cos#theta_{#pi,#mu}; d#sigma/dcos#theta_{#pi#mu} (cm^{2}/nucleon)"; + EnuMin = 0.; + EnuMax = 100.; + Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); + + // Data comes in ROOT file + // hResultTot is cross-section with all errors + // hResultStat is cross-section with stats-only errors + // hTruthNEUT is the NEUT cross-section given by experimenter + // hTruthGENIE is the GENIE cross-section given by experimenter + SetDataFromFile(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root","MuPiCos/hResultTot"); + SetCovarFromDataFile(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root", "MuPiCos/TotalCovariance", true); + + SetupDefaultHist(); + + fScaleFactor = GetEventHistogram()->Integral("width")*1E-38/double(fNEvents)/TotalIntegratedFlux("width"); +}; + +//******************************************************************** +// Find the cos theta of the angle between muon and pion +void T2K_CC1pip_H2O_XSec_1Dcosmupi_nu::FillEventVariables(FitEvent *event) { +//******************************************************************** + + // Need to make sure there's a muon + if (event->NumFSParticle(13) == 0) return; + // Need to make sure there's a pion + if (event->NumFSParticle(211) == 0) return; + + // Get the muon + TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; + // Get the pion + TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; + + double cos_th = cos(FitUtils::th(Pmu, Ppip)); + + fXVar = cos_th; + + return; +}; + +//******************************************************************** +// Beware: The H2O analysis has different signal definition to the CH analysis! +bool T2K_CC1pip_H2O_XSec_1Dcosmupi_nu::isSignal(FitEvent *event) { +//******************************************************************** + return SignalDef::isCC1pip_T2K_H2O(event, EnuMin, EnuMax); +} diff --git a/src/T2K/T2K_CC1pip_H2O_XSec_1Dcosmupi_nu.h b/src/T2K/T2K_CC1pip_H2O_XSec_1Dcosmupi_nu.h new file mode 100644 index 0000000..8248a73 --- /dev/null +++ b/src/T2K/T2K_CC1pip_H2O_XSec_1Dcosmupi_nu.h @@ -0,0 +1,18 @@ +#ifndef T2K_CC1PIP_H2O_XSEC_1DCOSMUPI_NU_H_SEEN +#define T2K_CC1PIP_H2O_XSEC_1DCOSMUPI_NU_H_SEEN + +#include "Measurement1D.h" +#include "T2K_SignalDef.h" + +class T2K_CC1pip_H2O_XSec_1Dcosmupi_nu : public Measurement1D { +public: + T2K_CC1pip_H2O_XSec_1Dcosmupi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); + virtual ~T2K_CC1pip_H2O_XSec_1Dcosmupi_nu() {}; + + void FillEventVariables(FitEvent *event); + bool isSignal(FitEvent *event); + + private: +}; + +#endif diff --git a/src/T2K/T2K_CC1pip_H2O_XSec_1Dcospi_nu.cxx b/src/T2K/T2K_CC1pip_H2O_XSec_1Dcospi_nu.cxx new file mode 100644 index 0000000..db6714e --- /dev/null +++ b/src/T2K/T2K_CC1pip_H2O_XSec_1Dcospi_nu.cxx @@ -0,0 +1,53 @@ +#include "T2K_CC1pip_H2O_XSec_1Dcospi_nu.h" + +// The cos of the angle between the pion and the neutrino + +//******************************************************************** +T2K_CC1pip_H2O_XSec_1Dcospi_nu::T2K_CC1pip_H2O_XSec_1Dcospi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ +//******************************************************************** + + fName = "T2K_CC1pip_H2O_XSec_1Dcospi_nu"; + fPlotTitles = "; cos#theta_{#pi}; d#sigma/dcos#theta_{#pi} (cm^{2}/nucleon)"; + EnuMin = 0.; + EnuMax = 100.; + Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); + + // Data comes in ROOT file + // hResultTot is cross-section with all errors + // hResultStat is cross-section with stats-only errors + // hTruthNEUT is the NEUT cross-section given by experimenter + // hTruthGENIE is the GENIE cross-section given by experimenter + SetDataFromFile(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root","PosPionCos/hResultTot"); + SetCovarFromDataFile(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root", "PosPionCos/TotalCovariance", true); + + SetupDefaultHist(); + + fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); +}; + +//******************************************************************** +// Find the cos theta of the angle between pion and neutrino +void T2K_CC1pip_H2O_XSec_1Dcospi_nu::FillEventVariables(FitEvent *event) { +//******************************************************************** + + // Need to make sure there's a pion + if (event->NumFSParticle(211) == 0) return; + + // Get the incoming neutrino + TLorentzVector Pnu = event->GetNeutrinoIn()->fP; + // Get the pion + TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; + + double cos_th = cos(FitUtils::th(Pnu, Ppip)); + + fXVar = cos_th; + + return; +}; + +//******************************************************************** +// Beware: The H2O analysis has different signal definition to the CH analysis! +bool T2K_CC1pip_H2O_XSec_1Dcospi_nu::isSignal(FitEvent *event) { +//******************************************************************** + return SignalDef::isCC1pip_T2K_H2O(event, EnuMin, EnuMax); +} diff --git a/src/T2K/T2K_CC1pip_H2O_XSec_1Dcospi_nu.h b/src/T2K/T2K_CC1pip_H2O_XSec_1Dcospi_nu.h new file mode 100644 index 0000000..3bddbf2 --- /dev/null +++ b/src/T2K/T2K_CC1pip_H2O_XSec_1Dcospi_nu.h @@ -0,0 +1,18 @@ +#ifndef T2K_CC1PIP_H2O_XSEC_1DCOSPI_NU_H_SEEN +#define T2K_CC1PIP_H2O_XSEC_1DCOSPI_NU_H_SEEN + +#include "Measurement1D.h" +#include "T2K_SignalDef.h" + +class T2K_CC1pip_H2O_XSec_1Dcospi_nu : public Measurement1D { +public: + T2K_CC1pip_H2O_XSec_1Dcospi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); + virtual ~T2K_CC1pip_H2O_XSec_1Dcospi_nu() {}; + + void FillEventVariables(FitEvent *event); + bool isSignal(FitEvent *event); + + private: +}; + +#endif diff --git a/src/T2K/T2K_CC1pip_H2O_XSec_1Dpmu_nu.cxx b/src/T2K/T2K_CC1pip_H2O_XSec_1Dpmu_nu.cxx new file mode 100644 index 0000000..9b4cf11 --- /dev/null +++ b/src/T2K/T2K_CC1pip_H2O_XSec_1Dpmu_nu.cxx @@ -0,0 +1,51 @@ +#include "T2K_CC1pip_H2O_XSec_1Dpmu_nu.h" + +// The muon momentum + +//******************************************************************** +T2K_CC1pip_H2O_XSec_1Dpmu_nu::T2K_CC1pip_H2O_XSec_1Dpmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ +//******************************************************************** + + fName = "T2K_CC1pip_H2O_XSec_1Dpmu_nu"; + fPlotTitles = "; p_{#mu} (GeV/c); d#sigma/dp_{#mu} (cm^{2}/(GeV/c)/nucleon)"; + EnuMin = 0.; + EnuMax = 100.; + Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); + + // Data comes in ROOT file + // hResultTot is cross-section with all errors + // hResultStat is cross-section with stats-only errors + // hTruthNEUT is the NEUT cross-section given by experimenter + // hTruthGENIE is the GENIE cross-section given by experimenter + SetDataFromFile(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root","MuMom/hResultTot"); + SetCovarFromDataFile(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root", "MuMom/TotalCovariance", true); + + SetupDefaultHist(); + + fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); +}; + +//******************************************************************** +// Find the momentum of the muon +void T2K_CC1pip_H2O_XSec_1Dpmu_nu::FillEventVariables(FitEvent *event) { +//******************************************************************** + + // Need to make sure there's a muon + if (event->NumFSParticle(13) == 0) return; + + // Get the muon + TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; + + double p_mu = FitUtils::p(Pmu); + + fXVar = p_mu; + + return; +}; + +//******************************************************************** +// Beware: The H2O analysis has different signal definition to the CH analysis! +bool T2K_CC1pip_H2O_XSec_1Dpmu_nu::isSignal(FitEvent *event) { +//******************************************************************** + return SignalDef::isCC1pip_T2K_H2O(event, EnuMin, EnuMax); +} diff --git a/src/T2K/T2K_CC1pip_H2O_XSec_1Dpmu_nu.h b/src/T2K/T2K_CC1pip_H2O_XSec_1Dpmu_nu.h new file mode 100644 index 0000000..5e9dfcf --- /dev/null +++ b/src/T2K/T2K_CC1pip_H2O_XSec_1Dpmu_nu.h @@ -0,0 +1,18 @@ +#ifndef T2K_CC1PIP_H2O_XSEC_1DPMU_NU_H_SEEN +#define T2K_CC1PIP_H2O_XSEC_1DPMU_NU_H_SEEN + +#include "Measurement1D.h" +#include "T2K_SignalDef.h" + +class T2K_CC1pip_H2O_XSec_1Dpmu_nu : public Measurement1D { +public: + T2K_CC1pip_H2O_XSec_1Dpmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); + virtual ~T2K_CC1pip_H2O_XSec_1Dpmu_nu() {}; + + void FillEventVariables(FitEvent *event); + bool isSignal(FitEvent *event); + + private: +}; + +#endif diff --git a/src/T2K/T2K_CC1pip_H2O_XSec_1Dppi_nu.cxx b/src/T2K/T2K_CC1pip_H2O_XSec_1Dppi_nu.cxx new file mode 100644 index 0000000..34fbdbe --- /dev/null +++ b/src/T2K/T2K_CC1pip_H2O_XSec_1Dppi_nu.cxx @@ -0,0 +1,51 @@ +#include "T2K_CC1pip_H2O_XSec_1Dppi_nu.h" + +// The momentum of the (positive) pion + +//******************************************************************** +T2K_CC1pip_H2O_XSec_1Dppi_nu::T2K_CC1pip_H2O_XSec_1Dppi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){ +//******************************************************************** + + fName = "T2K_CC1pip_H2O_XSec_1Dppi_nu"; + fPlotTitles = "; p_{#pi^{+}} (GeV/c); d#sigma/dp_{#pi^{+}} (cm^{2}/(GeV/c)/nucleon)"; + EnuMin = 0.; + EnuMax = 100.; + Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile); + + // Data comes in ROOT file + // hResultTot is cross-section with all errors + // hResultStat is cross-section with stats-only errors + // hTruthNEUT is the NEUT cross-section given by experimenter + // hTruthGENIE is the GENIE cross-section given by experimenter + SetDataFromFile(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root","PosPionMom/hResultTot"); + SetCovarFromDataFile(GeneralUtils::GetTopLevelDir()+"/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root", "PosPionMom/TotalCovariance", true); + + SetupDefaultHist(); + + fScaleFactor = GetEventHistogram()->Integral("width")*1E-38/double(fNEvents)/TotalIntegratedFlux("width"); +}; + +//******************************************************************** +// Find the momentum of the (positively charged) pion +void T2K_CC1pip_H2O_XSec_1Dppi_nu::FillEventVariables(FitEvent *event) { +//******************************************************************** + + // Need to make sure there's a muon + if (event->NumFSParticle(211) == 0) return; + + // Get the pion + TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; + + double p_pi = FitUtils::p(Ppip); + + fXVar = p_pi; + + return; +}; + +//******************************************************************** +// Beware: The H2O analysis has different signal definition to the CH analysis! +bool T2K_CC1pip_H2O_XSec_1Dppi_nu::isSignal(FitEvent *event) { +//******************************************************************** + return SignalDef::isCC1pip_T2K_H2O(event, EnuMin, EnuMax); +} diff --git a/src/T2K/T2K_CC1pip_H2O_XSec_1Dppi_nu.h b/src/T2K/T2K_CC1pip_H2O_XSec_1Dppi_nu.h new file mode 100644 index 0000000..6938c7d --- /dev/null +++ b/src/T2K/T2K_CC1pip_H2O_XSec_1Dppi_nu.h @@ -0,0 +1,18 @@ +#ifndef T2K_CC1PIP_H2O_XSEC_1DPPI_NU_H_SEEN +#define T2K_CC1PIP_H2O_XSEC_1DPPI_NU_H_SEEN + +#include "Measurement1D.h" +#include "T2K_SignalDef.h" + +class T2K_CC1pip_H2O_XSec_1Dppi_nu : public Measurement1D { +public: + T2K_CC1pip_H2O_XSec_1Dppi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); + virtual ~T2K_CC1pip_H2O_XSec_1Dppi_nu() {}; + + void FillEventVariables(FitEvent *event); + bool isSignal(FitEvent *event); + + private: +}; + +#endif diff --git a/src/T2K/T2K_SignalDef.cxx b/src/T2K/T2K_SignalDef.cxx index dbfa0a1..8b4ab65 100644 --- a/src/T2K/T2K_SignalDef.cxx +++ b/src/T2K/T2K_SignalDef.cxx @@ -1,152 +1,153 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "FitUtils.h" - #include "T2K_SignalDef.h" namespace SignalDef { // T2K H2O signal definition bool isCC1pip_T2K_H2O(FitEvent *event, double EnuMin, double EnuMax) { if (!isCC1pi(event, 14, 211, EnuMin, EnuMax)) return false; TLorentzVector Pnu = event->GetHMISParticle(14)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double p_mu = FitUtils::p(Pmu) * 1000; double p_pi = FitUtils::p(Ppip) * 1000; double cos_th_mu = cos(FitUtils::th(Pnu, Pmu)); double cos_th_pi = cos(FitUtils::th(Pnu, Ppip)); - if (p_mu <= 200 || p_pi <= 200 || cos_th_mu <= 0.3 || cos_th_pi <= 0.3) + if (p_mu <= 200 || p_pi <= 200 || cos_th_mu <= 0.3 || cos_th_pi <= 0.3) { return false; + } return true; }; // ****************************************************** // T2K CC1pi+ CH analysis (Raquel's thesis) // Has different phase space cuts depending on if using Michel tag or not // // Essentially consists of two samples: one sample which has Michel e (which we // can't get pion direction from); this covers backwards angles quite well. // Measurements including this sample does not have include pion kinematics cuts // one sample which has PID in FGD and TPC // and no Michel e. These are mostly // forward-going so require a pion // kinematics cut // // Essentially, cuts are: // 1 negative muon // 1 positive pion // Any number of nucleons // No other particles in the final state // // MOVE T2K bool isCC1pip_T2K_CH(FitEvent *event, double EnuMin, double EnuMax, bool MichelElectron) { // ****************************************************** if (!isCC1pi(event, 14, 211, EnuMin, EnuMax)) return false; TLorentzVector Pnu = event->GetHMISParticle(14)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; // If this event passes the criteria on particle counting, enforce the T2K // ND280 phase space constraints // Will be different if Michel tag sample is included or not // Essentially, if there's a Michel tag we don't cut on the pion variables double p_mu = FitUtils::p(Pmu) * 1000; double p_pi = FitUtils::p(Ppip) * 1000; double cos_th_mu = cos(FitUtils::th(Pnu, Pmu)); double cos_th_pi = cos(FitUtils::th(Pnu, Ppip)); // If we're using Michel e- requirement we only care about the muon restricted // phase space and use full pion phase space if (MichelElectron) { // Make the cuts on the muon variables if (p_mu <= 200 || cos_th_mu <= 0.2) { return false; } else { return true; } // If we aren't using Michel e- (i.e. we use directional information from // pion) we need to impose the phase space cuts on the muon AND the pion) } else { // Make the cuts on muon and pion variables if (p_mu <= 200 || p_pi <= 200 || cos_th_mu <= 0.2 || cos_th_pi <= 0.2) { return false; } else { return true; } } // Default to false; should never fire return false; }; bool isT2K_CC0pi(FitEvent *event, double EnuMin, double EnuMax, bool forwardgoing) { // Require a numu CC0pi event if (!isCC0pi(event, 14, EnuMin, EnuMax)) return false; TLorentzVector pnu = event->GetHMISParticle(14)->fP; TLorentzVector pmu = event->GetHMFSParticle(13)->fP; double CosThetaMu = pnu.Vect().Angle(pmu.Vect()); // restricted phase space if (forwardgoing and CosThetaMu < 0.0) return false; return true; } bool isT2K_CC0pi_STV(FitEvent *event, double EnuMin, double EnuMax) { // Require a numu CC0pi event if (!isCC0pi(event, 14, EnuMin, EnuMax)) return false; // Require at least one FS proton if (event->NumFSParticle(2212) == 0) return false; TLorentzVector pnu = event->GetHMISParticle(14)->fP; TLorentzVector pmu = event->GetHMFSParticle(13)->fP; TLorentzVector pp = event->GetHMFSParticle(2212)->fP; // mu phase space - if ((pmu.Vect().Mag() < 250) || (pnu.Vect().Angle(pmu.Vect()) < -0.6)) + if ((pmu.Vect().Mag() < 250) || (pnu.Vect().Angle(pmu.Vect()) < -0.6)) { return false; + } // p phase space if ((pp.Vect().Mag() < 250) || (pp.Vect().Mag() > 1E3) || (pnu.Vect().Angle(pp.Vect()) < 0.4)) { return false; } return true; } } diff --git a/src/Utils/GeneralUtils.h b/src/Utils/GeneralUtils.h index 6e7b3a3..00a9082 100644 --- a/src/Utils/GeneralUtils.h +++ b/src/Utils/GeneralUtils.h @@ -1,139 +1,149 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #ifndef GENERALUTILS_H_SEEN #define GENERALUTILS_H_SEEN #include <math.h> #include <stdlib.h> #include <unistd.h> #include <cstring> #include <fstream> #include <iostream> #include <iostream> #include <numeric> +#include <limits> #include <sstream> #include <string> #include <vector> #include "FitLogger.h" /*! * \addtogroup Utils * @{ */ //! Functions which deal with basic string and file handling. They should have //! no dependence on the other NUISANCE files! namespace GeneralUtils { /*! String handling and file parsing functions */ //! Parse a string into a vector of doubles given a delimiter "del" std::vector<double> ParseToDbl(std::string str, const char* del); //! Parse a string into a vector of ints given a delimiter "del" std::vector<int> ParseToInt(std::string str, const char* del); //! Parse a string into a vector of strings given a delimiter "del" std::vector<std::string> ParseToStr(std::string str, const char* del); //! Parse text file into a vector of strings std::vector<std::string> ParseFileToStr(std::string str, const char* del); //! Convert a string to a double double StrToDbl(std::string str); //! Convert a string to an int int StrToInt(std::string str); //! Convert a string to an bool bool StrToBool(std::string str); //! Return the top level environmental variable for the fitter std::string GetTopLevelDir(); // //! A utility function to return a std::vector from an array // template <typename T, size_t N> // std::vector<T> makeVector(const T (&data)[N]) { // return std::vector<T>(data, data + N); // } template <typename T, size_t N> size_t GetArraySize(const T (&data)[N]) { return N; } template <typename T> size_t GetHammingWeight(T const& d) { T c = d; size_t w = 0; while (bool(c)) { w += c & 1; c = (c >> 1); } return w; } template <typename T> size_t GetFirstOnBit(T const& d) { T c = d; size_t fob = 0; while (bool(c)) { - if(c & 1){ + if (c & 1) { return fob; } else { c = (c >> 1); } fob++; } return fob; } + +template <typename T> +size_t IsSmallNum(T const& d) { + if (std::numeric_limits<T>::is_integer) { + return (d == 0); + } + return (((d > 0) && (d < std::numeric_limits<T>::epsilon())) || + ((d < 0) && (d > -std::numeric_limits<T>::epsilon()))); +} } namespace PhysConst { const double mass_proton = 0.93827203; // Proton mass in GeV const double mass_neutron = 0.93956536; // Neutron mass in GeV const double mass_delta = 1.232; // Delta mass in GeV const double mass_muon = 0.10565837; // Muon mass in GeV const int pdg_neutrinos[] = {12, -12, 14, -14 /*, 16, -16*/}; -const int pdg_muons[] = {13,-13}; +const int pdg_muons[] = {13, -13}; const int pdg_pions[] = {211, -211, 111}; const int pdg_charged_pions[] = {211, -211}; const int pdg_strangemesons[] = { 130, 310, 311, 321, 9000311, 9000321, 10311, 10321, 100311, 100321, 9010311, 9010321, 9020311, 9020321, 313, 323, 10313, 10323, 20313, 20323, 100313, 100323, 9000313, 9000323, 30313, 30323, 315, 325, 9000315, 9000325, 10315, 10325, 20315, 20325, 9010315, 9010325, 9020315, 9020325, 317, 327, 9010317, 9010327}; // Just *-1 to cover possibility const int pdg_kplus = 321; const int pdg_antistrangemesons[] = { -130, -310, -311, -321, -9000311, -9000321, -10311, -10321, -100311, -100321, -9010311, -9010321, -9020311, -9020321, -313, -323, -10313, -10323, -20313, -20323, -100313, -100323, -9000313, -9000323, -30313, -30323, -315, -325, -9000315, -9000325, -10315, -10325, -20315, -20325, -9010315, -9010325, -9020315, -9020325, -317, -327, -9010317, -9010327}; } /*! @} */ #endif diff --git a/src/Utils/StatUtils.cxx b/src/Utils/StatUtils.cxx index 1332a61..58c7ad4 100644 --- a/src/Utils/StatUtils.cxx +++ b/src/Utils/StatUtils.cxx @@ -1,1060 +1,1062 @@ // Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is part of NUISANCE. * * NUISANCE is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * NUISANCE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NUISANCE. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ #include "TH1D.h" #include "StatUtils.h" //******************************************************************* Double_t StatUtils::GetChi2FromDiag(TH1D* data, TH1D* mc, TH1I* mask){ //******************************************************************* Double_t Chi2 = 0.0; TH1D* calc_data = (TH1D*)data->Clone(); TH1D* calc_mc = (TH1D*)mc->Clone(); // Add MC Error to data if required if (FitPar::Config().GetParB("statutils.addmcerror")){ for (int i = 0; i < calc_data->GetNbinsX(); i++){ double dterr = calc_data->GetBinError(i+1); double mcerr = calc_mc->GetBinError(i+1); if (dterr > 0.0) { calc_data->SetBinError(i+1, sqrt(dterr*dterr + mcerr*mcerr)); } } } // Apply masking if required if (mask){ calc_data =ApplyHistogramMasking(data, mask); calc_mc =ApplyHistogramMasking(mc, mask); } // Iterate over bins in X for (int i = 0; i < calc_data->GetNbinsX(); i++) { // Ignore bins with zero data or zero bin error if (calc_data->GetBinError(i+1) <= 0.0 || calc_data->GetBinContent(i+1) == 0.0) continue; // Take mc data difference double diff = calc_data->GetBinContent(i+1) - calc_mc->GetBinContent(i+1); double err = calc_data->GetBinError(i+1); Chi2 += (diff*diff)/(err*err); } // cleanup delete calc_data; delete calc_mc; return Chi2; }; //******************************************************************* Double_t StatUtils::GetChi2FromDiag(TH2D* data, TH2D* mc, TH2I* map, TH2I* mask){ //******************************************************************* // Generate a simple map if (!map) map = GenerateMap(data); // Convert to 1D Histograms TH1D* data_1D = MapToTH1D(data, map); TH1D* mc_1D = MapToTH1D(mc, map); TH1I* mask_1D = MapToMask(mask, map); // Calculate 1D chi2 from 1D Plots Double_t Chi2 = StatUtils:: GetChi2FromDiag(data_1D, mc_1D, mask_1D); // CleanUp delete data_1D; delete mc_1D; delete mask_1D; return Chi2; }; //******************************************************************* Double_t StatUtils::GetChi2FromCov(TH1D* data, TH1D* mc, TMatrixDSym* invcov, TH1I* mask){ //******************************************************************* Double_t Chi2 = 0.0; TMatrixDSym* calc_cov = (TMatrixDSym*) invcov->Clone(); TH1D* calc_data = (TH1D*) data->Clone(); TH1D* calc_mc = (TH1D*) mc->Clone(); // If a mask if applied we need to apply it before the matrix is inverted if (mask) { calc_cov = ApplyInvertedMatrixMasking(invcov, mask); calc_data = ApplyHistogramMasking(data, mask); calc_mc = ApplyHistogramMasking(mc, mask); } // Add MC Error to data if required if (FitPar::Config().GetParB("statutils.addmcerror")){ // Make temp cov TMatrixDSym* newcov = StatUtils::GetInvert(calc_cov); // Add MC err to diag for(int i = 0; i < calc_data->GetNbinsX(); i++){ double mcerr = calc_mc->GetBinError(i+1)*1E38; double oldval = (*newcov)(i,i); (*newcov)(i,i) = oldval + mcerr*mcerr; } // Reset the calc_cov to new invert delete calc_cov; calc_cov = GetInvert(newcov); // Delete the tempcov delete newcov; } // iterate over bins in X (i,j) for (int i = 0; i < calc_data->GetNbinsX(); i++){ for (int j = 0; j < calc_data->GetNbinsX(); j++){ if (calc_data->GetBinContent(i+1) != 0 || calc_mc->GetBinContent(i+1) != 0) { LOG(DEB)<< "i j = "<<i<<" "<<j<<std::endl; LOG(DEB)<<"Calc_data mc i = "<<calc_data->GetBinContent(i+1) <<" "<<calc_mc->GetBinContent(i+1) <<" Dif = " <<( calc_data->GetBinContent(i+1) - calc_mc->GetBinContent(i+1) ) <<std::endl; LOG(DEB)<<"Calc_data mc i = "<<calc_data->GetBinContent(j+1) <<" "<<calc_mc->GetBinContent(j+1) <<" Dif = " <<( calc_data->GetBinContent(j+1) - calc_mc->GetBinContent(j+1) ) <<std::endl; LOG(DEB)<<"Covar = "<< (*calc_cov)(i, j) <<std::endl; LOG(DEB)<<"Cont chi2 = " \ <<( ( calc_data->GetBinContent(i+1) - calc_mc->GetBinContent(i+1) ) \ * (*calc_cov)(i, j) \ * 1E76 \ * ( calc_data->GetBinContent(j+1) - calc_mc->GetBinContent(j+1) ) ) <<" "<<Chi2<<std::endl; Chi2 += ( ( calc_data->GetBinContent(i+1) - calc_mc->GetBinContent(i+1) ) * \ (*calc_cov)(i, j) * 1E76 * \ ( calc_data->GetBinContent(j+1) - calc_mc->GetBinContent(j+1) ) ); } else { LOG(DEB) << "Error on bin (i,j) = (" << i << "," << j << ")" << std::endl; LOG(DEB) << "data->GetBinContent(i+1) = " << calc_data->GetBinContent(i+1) << std::endl; LOG(DEB) << "mc->GetBinContent(i+1) = " << calc_mc->GetBinContent(i+1) << std::endl; LOG(DEB) << "Adding zero to chi2 instead of dying horrifically " << std::endl; Chi2 += 0.; } } } // Cleanup delete calc_cov; delete calc_data; delete calc_mc; return Chi2; } //******************************************************************* Double_t StatUtils::GetChi2FromCov( TH2D* data, TH2D* mc, TMatrixDSym* invcov, TH2I* map, TH2I* mask){ //******************************************************************* // Generate a simple map if (!map) { map = StatUtils::GenerateMap(data); } // Convert to 1D Histograms TH1D* data_1D = MapToTH1D(data, map); TH1D* mc_1D = MapToTH1D(mc, map); TH1I* mask_1D = MapToMask(mask, map); // Calculate 1D chi2 from 1D Plots Double_t Chi2 = StatUtils::GetChi2FromCov(data_1D, mc_1D, invcov, mask_1D); // CleanUp delete data_1D; delete mc_1D; delete mask_1D; return Chi2; } //******************************************************************* Double_t StatUtils::GetChi2FromSVD( TH1D* data, TH1D* mc, TMatrixDSym* cov, TH1I* mask){ //******************************************************************* Double_t Chi2 = 0.0; TMatrixDSym* calc_cov = (TMatrixDSym*) cov->Clone(); TH1D* calc_data = (TH1D*) data->Clone(); TH1D* calc_mc = (TH1D*) mc->Clone(); // If a mask if applied we need to apply it before the matrix is inverted if (mask) { calc_cov = StatUtils::ApplyMatrixMasking(cov, mask); calc_data = StatUtils::ApplyHistogramMasking(data, mask); calc_mc = StatUtils::ApplyHistogramMasking(mc, mask); } // Decompose matrix TDecompSVD LU = TDecompSVD((*calc_cov)); LU.Decompose(); TMatrixDSym* cov_U = new TMatrixDSym(calc_data->GetNbinsX(), LU .GetU().GetMatrixArray(), ""); TVectorD* cov_S = new TVectorD( LU.GetSig() ); // Apply basis rotation before adding up chi2 Double_t rotated_difference = 0.0; for (int i = 0; i < calc_data->GetNbinsX(); i++){ rotated_difference = 0.0; // Rotate basis of Data - MC for (int j = 0; j < calc_data->GetNbinsY(); j++) rotated_difference += ( calc_data->GetBinContent(j+1) - calc_mc ->GetBinContent(j+1) ) * (*cov_U)(j,i) ; // Divide by rotated error cov_S Chi2 += rotated_difference * rotated_difference * 1E76 / (*cov_S)(i); } // Cleanup delete calc_cov; delete calc_data; delete calc_mc; delete cov_U; delete cov_S; return Chi2; } //******************************************************************* Double_t StatUtils::GetChi2FromSVD( TH2D* data, TH2D* mc, TMatrixDSym* cov, TH2I* map, TH2I* mask){ //******************************************************************* // Generate a simple map if (!map) map = StatUtils::GenerateMap(data); // Convert to 1D Histograms TH1D* data_1D = MapToTH1D(data, map); TH1D* mc_1D = MapToTH1D(mc, map); TH1I* mask_1D = MapToMask(mask, map); // Calculate from 1D Double_t Chi2 = StatUtils::GetChi2FromSVD(data_1D, mc_1D, cov, mask_1D); // CleanUp delete data_1D; delete mc_1D; delete mask_1D; return Chi2; } //******************************************************************* double StatUtils::GetChi2FromEventRate(TH1D* data, TH1D* mc, TH1I* mask) { //******************************************************************* // If just an event rate, for chi2 just use Poission Likelihood to calculate the chi2 component double chi2 = 0.0; TH1D* calc_data = (TH1D*)data->Clone(); TH1D* calc_mc = (TH1D*)mc->Clone(); // Apply masking if required if (mask) { calc_data = ApplyHistogramMasking(data, mask); calc_mc = ApplyHistogramMasking(mc, mask); } // Iterate over bins in X for (int i = 0; i < calc_data->GetNbinsX(); i++) { double dt = calc_data->GetBinContent(i+1); double mc = calc_mc->GetBinContent(i+1); - if (dt == 0 or mc == 0) { - LOG(REC) << "Found no MC in bin " << i << " for " << calc_data->GetName() << " (" << calc_data->GetBinLowEdge(i) << " - " << calc_data->GetBinLowEdge(i+1) << ")" << std::endl; - continue; + if (mc == 0) continue; + + if (dt == 0){ + // Only add difference + chi2 += 2 * (mc - dt); + } else { + // Do the chi2 for Poisson distributions + chi2 += 2 * (mc - dt + (dt*log(dt/mc))); } - // Do the chi2 for Poisson distributions - chi2 += 2 * (mc - dt + (dt*log(dt/mc))); - /* LOG(REC)<<"Evt Chi2 cont = "<<i<<" " <<mc<<" "<<dt<<" " <<2 * (mc - dt + (dt+0.) * log((dt+0.) / (mc+0.))) <<" "<<Chi2<<std::endl; */ } // cleanup delete calc_data; delete calc_mc; return chi2; } //******************************************************************* Double_t StatUtils::GetChi2FromEventRate(TH2D* data, TH2D* mc, TH2I* map, TH2I* mask){ //******************************************************************* // Generate a simple map if (!map) map = StatUtils::GenerateMap(data); // Convert to 1D Histograms TH1D* data_1D = MapToTH1D(data, map); TH1D* mc_1D = MapToTH1D(mc, map); TH1I* mask_1D = MapToMask(mask, map); // Calculate from 1D Double_t Chi2 = StatUtils::GetChi2FromEventRate(data_1D, mc_1D, mask_1D); // CleanUp delete data_1D; delete mc_1D; delete mask_1D; return Chi2; } //******************************************************************* Double_t StatUtils::GetLikelihoodFromDiag(TH1D* data, TH1D* mc, TH1I* mask){ //******************************************************************* // Currently just a placeholder! (void) data; (void) mc; (void) mask; return 0.0; }; //******************************************************************* Double_t StatUtils::GetLikelihoodFromDiag(TH2D* data, TH2D* mc, TH2I* map, TH2I* mask){ //******************************************************************* // Generate a simple map if (!map) map = StatUtils::GenerateMap(data); // Convert to 1D Histograms TH1D* data_1D = MapToTH1D(data, map); TH1D* mc_1D = MapToTH1D(mc, map); TH1I* mask_1D = MapToMask(mask, map); // Calculate from 1D Double_t MLE = StatUtils::GetLikelihoodFromDiag(data_1D, mc_1D, mask_1D); // CleanUp delete data_1D; delete mc_1D; delete mask_1D; return MLE; }; //******************************************************************* Double_t StatUtils::GetLikelihoodFromCov( TH1D* data, TH1D* mc, TMatrixDSym* invcov, TH1I* mask){ //******************************************************************* // Currently just a placeholder ! (void) data; (void) mc; (void) invcov; (void) mask; return 0.0; }; //******************************************************************* Double_t StatUtils::GetLikelihoodFromCov( TH2D* data, TH2D* mc, TMatrixDSym* invcov, TH2I* map, TH2I* mask){ //******************************************************************* // Generate a simple map if (!map) map = StatUtils::GenerateMap(data); // Convert to 1D Histograms TH1D* data_1D = MapToTH1D(data, map); TH1D* mc_1D = MapToTH1D(mc, map); TH1I* mask_1D = MapToMask(mask, map); // Calculate from 1D Double_t MLE = StatUtils::GetLikelihoodFromCov(data_1D, mc_1D, invcov, mask_1D); // CleanUp delete data_1D; delete mc_1D; delete mask_1D; return MLE; }; //******************************************************************* Double_t StatUtils::GetLikelihoodFromSVD( TH1D* data, TH1D* mc, TMatrixDSym* cov, TH1I* mask){ //******************************************************************* // Currently just a placeholder! (void) data; (void) mc; (void) cov; (void) mask; return 0.0; }; //******************************************************************* Double_t StatUtils::GetLikelihoodFromSVD( TH2D* data, TH2D* mc, TMatrixDSym* cov, TH2I* map, TH2I* mask){ //******************************************************************* // Generate a simple map if (!map) map = StatUtils::GenerateMap(data); // Convert to 1D Histograms TH1D* data_1D = MapToTH1D(data, map); TH1D* mc_1D = MapToTH1D(mc, map); TH1I* mask_1D = MapToMask(mask, map); // Calculate from 1D Double_t MLE = StatUtils::GetLikelihoodFromSVD(data_1D, mc_1D, cov, mask_1D); // CleanUp delete data_1D; delete mc_1D; delete mask_1D; return MLE; }; //******************************************************************* Double_t StatUtils::GetLikelihoodFromEventRate(TH1D* data, TH1D* mc, TH1I* mask){ //******************************************************************* // Currently just a placeholder! (void) data; (void) mc; (void) mask; return 0.0; }; //******************************************************************* Double_t StatUtils::GetLikelihoodFromEventRate(TH2D* data, TH2D* mc, TH2I* map, TH2I* mask){ //******************************************************************* // Generate a simple map if (!map) map = StatUtils::GenerateMap(data); // Convert to 1D Histograms TH1D* data_1D = MapToTH1D(data, map); TH1D* mc_1D = MapToTH1D(mc, map); TH1I* mask_1D = MapToMask(mask, map); // Calculate from 1D Double_t MLE = StatUtils::GetChi2FromEventRate(data_1D, mc_1D, mask_1D); // CleanUp delete data_1D; delete mc_1D; delete mask_1D; return MLE; }; //******************************************************************* Int_t StatUtils::GetNDOF(TH1D* hist, TH1I* mask){ //******************************************************************* TH1D* calc_hist = (TH1D*)hist->Clone(); // If a mask is provided we need to apply it before getting NDOF if (mask) { calc_hist = StatUtils::ApplyHistogramMasking(hist, mask); } // NDOF is defined as total number of bins with non-zero errors Int_t NDOF = 0; for (int i = 0; i < calc_hist->GetNbinsX(); i++){ if (calc_hist->GetBinError(i+1) > 0.0) NDOF++; } delete calc_hist; return NDOF; }; //******************************************************************* Int_t StatUtils::GetNDOF(TH2D* hist, TH2I* map, TH2I* mask){ //******************************************************************* Int_t NDOF = 0; if (!map) map = StatUtils::GenerateMap(hist); for (int i = 0; i < hist->GetNbinsX(); i++){ for (int j = 0; j < hist->GetNbinsY(); j++){ if (mask->GetBinContent(i+1,j+1)) continue; if (map->GetBinContent(i+1,j+1) <= 0) continue; NDOF++; } } return NDOF; }; //******************************************************************* TH1D* StatUtils::ThrowHistogram(TH1D* hist, TMatrixDSym* cov, bool throwdiag, TH1I* mask){ //******************************************************************* TH1D* calc_hist = (TH1D*) hist->Clone( (std::string(hist->GetName()) + "_THROW" ).c_str() ); TMatrixDSym* calc_cov = (TMatrixDSym*) cov->Clone(); Double_t correl_val = 0.0; // If a mask if applied we need to apply it before the matrix is decomposed if (mask) { calc_cov = ApplyMatrixMasking(cov, mask); calc_hist = ApplyHistogramMasking(calc_hist, mask); } // If a covariance is provided we need a preset random vector and a decomp std::vector<Double_t> rand_val; TMatrixDSym* decomp_cov; if (cov){ for (int i = 0; i < hist->GetNbinsX(); i++){ rand_val.push_back(gRandom->Gaus(0.0,1.0)); } // Decomp the matrix decomp_cov = StatUtils::GetDecomp(calc_cov); } // iterate over bins for (int i = 0; i < hist->GetNbinsX(); i++){ // By Default the errors on the histogram are thrown uncorrelated to the other errors if (throwdiag){ calc_hist->SetBinContent(i+1, (calc_hist->GetBinContent(i+1) + \ gRandom->Gaus(0.0,1.0) * calc_hist->GetBinError(i+1)) ); } // If a covariance is provided that is also thrown if (cov){ correl_val = 0.0; for (int j = 0; j < hist->GetNbinsX(); j++){ correl_val += rand_val[j] * (*decomp_cov)(j,i) ; } calc_hist->SetBinContent(i+1, (calc_hist->GetBinContent(i+1) + \ correl_val) *1E-38); } } delete calc_cov; delete decomp_cov; // return this new thrown data return calc_hist; }; //******************************************************************* TH2D* StatUtils::ThrowHistogram(TH2D* hist, TMatrixDSym* cov, TH2I* map, bool throwdiag, TH2I* mask){ //******************************************************************* // PLACEHOLDER!!!!!!!!! // Currently no support for throwing 2D Histograms from a covariance (void) hist; (void) cov; (void) map; (void) throwdiag; (void) mask; // /todo // Sort maps if required // Throw the covariance for a 1D plot // Unmap back to 2D Histogram return hist; } //******************************************************************* TH1D* StatUtils::ApplyHistogramMasking(TH1D* hist, TH1I* mask){ //******************************************************************* if (!mask) return ( (TH1D*)hist->Clone() ); // This masking is only sufficient for chi2 calculations, and will have dodgy bin edges. // Get New Bin Count Int_t NBins = 0; for (int i = 0; i < hist->GetNbinsX(); i++){ if (mask->GetBinContent(i+1)) continue; NBins++; } // Make new hist std::string newmaskname = std::string(hist->GetName()) + "_MSKD"; TH1D* calc_hist = new TH1D( newmaskname.c_str(), newmaskname.c_str(), NBins, 0, NBins); // fill new hist int binindex = 0; for (int i = 0; i < hist->GetNbinsX(); i++){ if (mask->GetBinContent(i+1)){ LOG(REC)<<"Applying mask to bin "<<i+1<<" "<<hist->GetName()<<std::endl; continue; } calc_hist->SetBinContent(binindex+1, hist->GetBinContent(i+1)); calc_hist->SetBinError(binindex+1, hist->GetBinError(i+1)); binindex++; } return calc_hist; }; //******************************************************************* TH2D* StatUtils::ApplyHistogramMasking(TH2D* hist, TH2I* mask){ //******************************************************************* TH2D* newhist = (TH2D*) hist->Clone(); if (!mask) return newhist; for (int i = 0; i < hist->GetNbinsX(); i++){ for (int j = 0; j < hist->GetNbinsY(); j++){ if (mask->GetBinContent(i+1,j+1) > 0){ newhist->SetBinContent(i+1,j+1, 0.0); newhist->SetBinContent(i+1,j+1, 0.0); } } } return newhist; } //******************************************************************* TMatrixDSym* StatUtils::ApplyMatrixMasking(TMatrixDSym* mat, TH1I* mask){ //******************************************************************* if (!mask) return (TMatrixDSym*)(mat->Clone()); // Get New Bin Count Int_t NBins = 0; for (int i = 0; i < mask->GetNbinsX(); i++){ if (mask->GetBinContent(i+1)) continue; NBins++; } // make new matrix TMatrixDSym* calc_mat = new TMatrixDSym(NBins); int col, row; // Need to mask out bins in the current matrix row = 0; for (int i = 0; i < mask->GetNbinsX(); i++){ col = 0; // skip if masked if (mask->GetBinContent(i+1) > 0.5) continue; for (int j = 0; j < mask->GetNbinsX(); j++){ // skip if masked if (mask->GetBinContent(j+1) > 0.5) continue; (*calc_mat)(row,col) = (*mat)(i,j); col++; } row++; } return calc_mat; }; //******************************************************************* TMatrixDSym* StatUtils::ApplyMatrixMasking(TMatrixDSym* mat, TH2D* data, TH2I* mask, TH2I* map){ //******************************************************************* if (!map) map = StatUtils::GenerateMap(data); TH1I* mask_1D = StatUtils::MapToMask(mask, map); TMatrixDSym* newmat = StatUtils::ApplyMatrixMasking(mat, mask_1D); delete mask_1D; return newmat; } //******************************************************************* TMatrixDSym* StatUtils::ApplyInvertedMatrixMasking(TMatrixDSym* mat, TH1I* mask){ //******************************************************************* TMatrixDSym* new_mat = GetInvert(mat); TMatrixDSym* masked_mat = ApplyMatrixMasking(new_mat, mask); TMatrixDSym* inverted_mat = GetInvert(masked_mat); delete masked_mat; delete new_mat; return inverted_mat; }; //******************************************************************* TMatrixDSym* StatUtils::ApplyInvertedMatrixMasking(TMatrixDSym* mat, TH2D* data, TH2I* mask, TH2I* map){ //******************************************************************* if (!map) map = StatUtils::GenerateMap(data); TH1I* mask_1D = StatUtils::MapToMask(mask, map); TMatrixDSym* newmat = ApplyInvertedMatrixMasking(mat, mask_1D); delete mask_1D; return newmat; } //******************************************************************* TMatrixDSym* StatUtils::GetInvert(TMatrixDSym* mat){ //******************************************************************* TMatrixDSym* new_mat = (TMatrixDSym*)mat->Clone(); // Check for diagonal bool non_diagonal = false; for (int i = 0; i < new_mat->GetNrows(); i++){ for (int j = 0; j < new_mat->GetNrows(); j++){ if (i == j) continue; if ((*new_mat)(i,j) != 0.0) { non_diagonal=true; break; } } } // If diag, just flip the diag if (!non_diagonal or new_mat->GetNrows() == 1){ for(int i = 0; i < new_mat->GetNrows(); i++){ if ((*new_mat)(i,i) != 0.0) (*new_mat)(i,i) = 1.0/(*new_mat)(i,i); else (*new_mat)(i,i) = 0.0; } return new_mat; } // Invert full matrix TDecompSVD LU = TDecompSVD((*new_mat)); new_mat = new TMatrixDSym(new_mat->GetNrows(), LU.Invert().GetMatrixArray(), ""); return new_mat; } //******************************************************************* TMatrixDSym* StatUtils::GetDecomp(TMatrixDSym* mat){ //******************************************************************* TMatrixDSym* new_mat = (TMatrixDSym*)mat->Clone(); int nrows = new_mat->GetNrows(); // Check for diagonal bool diagonal = true; for (int i = 0; i < nrows; i++){ for (int j = 0; j < nrows; j++){ if (i == j) continue; if ((*new_mat)(i,j) != 0.0) { diagonal=false; break; } } } // If diag, just flip the diag if (diagonal or nrows == 1){ for(int i = 0; i < nrows; i++){ if ((*new_mat)(i,i) > 0.0) (*new_mat)(i,i) = sqrt((*new_mat)(i,i)); else (*new_mat)(i,i) = 0.0; } return new_mat; } TDecompChol LU = TDecompChol(*new_mat); LU.Decompose(); delete new_mat; TMatrixDSym* dec_mat = new TMatrixDSym(nrows, LU.GetU().GetMatrixArray(), ""); return dec_mat; } //******************************************************************* void StatUtils::ForceNormIntoCovar(TMatrixDSym* mat, TH1D* hist, double norm){ //******************************************************************* if (!mat) mat = MakeDiagonalCovarMatrix(hist); int nbins = mat->GetNrows(); TMatrixDSym* new_mat = new TMatrixDSym(nbins); for (int i = 0; i < nbins; i++){ for (int j = 0; j < nbins; j++){ double valx = hist->GetBinContent(i+1)*1E38; double valy = hist->GetBinContent(j+1)*1E38; (*new_mat)(i,j) = (*mat)(i,j) + norm*norm*valx*valy; } } // Swap the two delete mat; mat = new_mat; return; }; //******************************************************************* void StatUtils::ForceNormIntoCovar(TMatrixDSym* mat, TH2D* data, double norm, TH2I* map ){ //******************************************************************* if (!map) map = StatUtils::GenerateMap(data); TH1D* data_1D = MapToTH1D(data, map); StatUtils::ForceNormIntoCovar(mat, data_1D, norm); delete data_1D; return; } //******************************************************************* TMatrixDSym* StatUtils::MakeDiagonalCovarMatrix(TH1D* data, double scaleF){ //******************************************************************* TMatrixDSym* newmat = new TMatrixDSym(data->GetNbinsX()); for (int i = 0; i < data->GetNbinsX(); i++){ (*newmat)(i,i) = data->GetBinError(i+1) * data->GetBinError(i+1) * scaleF * scaleF; } return newmat; } //******************************************************************* TMatrixDSym* StatUtils::MakeDiagonalCovarMatrix(TH2D* data, TH2I* map, double scaleF){ //******************************************************************* if (!map) map = StatUtils::GenerateMap(data); TH1D* data_1D = MapToTH1D(data, map); return StatUtils::MakeDiagonalCovarMatrix(data_1D, scaleF); }; //******************************************************************* void StatUtils::SetDataErrorFromCov(TH1D* data, TMatrixDSym* cov, double scale){ //******************************************************************* // Check if (cov->GetNrows() != data->GetNbinsX()){ ERR(WRN) << "Nrows in cov don't match nbins in data for SetDataErrorFromCov" << std::endl; } // Set bin errors form cov diag for (int i = 0; i < data->GetNbinsX(); i++){ data->SetBinError(i+1, sqrt((*cov)(i,i)) * scale ); } return; } //******************************************************************* void StatUtils::SetDataErrorFromCov(TH2D* data, TMatrixDSym* cov, TH2I* map, double scale){ //******************************************************************* // Create map if required if (!map) map = StatUtils::GenerateMap(data); // Set Bin Errors from cov diag int count = 0; for (int i = 0; i < data->GetNbinsX(); i++){ for (int j = 0; j < data->GetNbinsY(); j++){ if (data->GetBinContent(i+1,j+1) == 0.0) continue; count = map->GetBinContent(i+1,j+1)-1; data->SetBinError(i+1,j+1, sqrt((*cov)(count,count)) * scale ); } } return; } //******************************************************************* TH2I* StatUtils::GenerateMap(TH2D* hist){ //******************************************************************* std::string maptitle = std::string(hist->GetName()) + "_MAP"; TH2I* map = new TH2I( maptitle.c_str(), maptitle.c_str(), hist->GetNbinsX(), 0, hist->GetNbinsX(), hist->GetNbinsY(), 0, hist->GetNbinsY()); Int_t index = 1; for (int i = 0; i < hist->GetNbinsX(); i++) { for (int j = 0; j < hist->GetNbinsY(); j++) { if (hist->GetBinContent(i+1,j+1) > 0 && hist->GetBinError(i+1,j+1) > 0){ map->SetBinContent(i+1,j+1, index); index++; } else { map->SetBinContent(i+1, j+1, 0); } } } return map; } //******************************************************************* TH1D* StatUtils::MapToTH1D(TH2D* hist, TH2I* map){ //******************************************************************* if (!hist) return NULL; // Get N bins for 1D plot Int_t Nbins = map->GetMaximum(); std::string name1D = std::string(hist->GetName()) + "_1D"; // Make new 1D Hist TH1D* newhist = new TH1D(name1D.c_str(), name1D.c_str(), Nbins, 0, Nbins); // map bin contents for (int i = 0; i < map->GetNbinsX(); i++){ for (int j = 0; j < map->GetNbinsY(); j++){ if (map->GetBinContent(i+1,j+1) == 0) continue; newhist->SetBinContent(map->GetBinContent(i+1,j+1), hist->GetBinContent(i+1,j+1)); newhist->SetBinError(map->GetBinContent(i+1,j+1), hist->GetBinError(i+1,j+1)); } } // return return newhist; } //******************************************************************* TH1I* StatUtils::MapToMask(TH2I* hist, TH2I* map){ //******************************************************************* TH1I* newhist = NULL; if (!hist) return newhist; // Get N bins for 1D plot Int_t Nbins = map->GetMaximum(); std::string name1D = std::string(hist->GetName()) + "_1D"; // Make new 1D Hist newhist = new TH1I(name1D.c_str(), name1D.c_str(), Nbins, 0, Nbins); // map bin contents for (int i = 0; i < map->GetNbinsX(); i++){ for (int j = 0; j < map->GetNbinsY(); j++){ if (map->GetBinContent(i+1,j+1) == 0) continue; newhist->SetBinContent(map->GetBinContent(i+1,j+1), hist->GetBinContent(i+1,j+1)); } } // return return newhist; } TMatrixDSym* StatUtils::GetCovarFromCorrel(TMatrixDSym* correl, TH1D* data){ int nbins = correl->GetNrows(); TMatrixDSym* covar = new TMatrixDSym(nbins); for (int i = 0; i < nbins; i++){ for (int j = 0; j < nbins; j++){ (*covar)(i,j) = (*correl)(i,j) * data->GetBinError(i+1) * data->GetBinError(j+1); } } return covar; }